You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ace.js 526KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279
  1. // IMPORTANT: the original ace.js file must be encapsulated in
  2. // (function(require,define,requirejs) { ...})(undefined,undefined,undefined);
  3. (function(require,define,requirejs) {
  4. /* ***** BEGIN LICENSE BLOCK *****
  5. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is Ajax.org Code Editor (ACE).
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Ajax.org B.V.
  21. * Portions created by the Initial Developer are Copyright (C) 2010
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Fabian Jakobs <fabian AT ajax DOT org>
  26. *
  27. * Alternatively, the contents of this file may be used under the terms of
  28. * either the GNU General Public License Version 2 or later (the "GPL"), or
  29. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30. * in which case the provisions of the GPL or the LGPL are applicable instead
  31. * of those above. If you wish to allow use of your version of this file only
  32. * under the terms of either the GPL or the LGPL, and not to allow others to
  33. * use your version of this file under the terms of the MPL, indicate your
  34. * decision by deleting the provisions above and replace them with the notice
  35. * and other provisions required by the GPL or the LGPL. If you do not delete
  36. * the provisions above, a recipient may use your version of this file under
  37. * the terms of any one of the MPL, the GPL or the LGPL.
  38. *
  39. * ***** END LICENSE BLOCK ***** */
  40. /**
  41. * Define a module along with a payload
  42. * @param module a name for the payload
  43. * @param payload a function to call with (require, exports, module) params
  44. */
  45. (function() {
  46. var ACE_NAMESPACE = "ace";
  47. var global = (function() {
  48. return this;
  49. })();
  50. var _define = function(module, deps, payload) {
  51. if (typeof module !== 'string') {
  52. if (_define.original)
  53. _define.original.apply(window, arguments);
  54. else {
  55. console.error('dropping module because define wasn\'t a string.');
  56. console.trace();
  57. }
  58. return;
  59. }
  60. if (arguments.length == 2)
  61. payload = deps;
  62. if (!_define.modules)
  63. _define.modules = {};
  64. _define.modules[module] = payload;
  65. };
  66. var _require = function(parentId, module, callback) {
  67. if (Object.prototype.toString.call(module) === "[object Array]") {
  68. var params = [];
  69. for (var i = 0, l = module.length; i < l; ++i) {
  70. var dep = lookup(parentId, module[i]);
  71. if (!dep && _require.original)
  72. return _require.original.apply(window, arguments);
  73. params.push(dep);
  74. }
  75. if (callback) {
  76. callback.apply(null, params);
  77. }
  78. }
  79. else if (typeof module === 'string') {
  80. var payload = lookup(parentId, module);
  81. if (!payload && _require.original)
  82. return _require.original.apply(window, arguments);
  83. if (callback) {
  84. callback();
  85. }
  86. return payload;
  87. }
  88. else {
  89. if (_require.original)
  90. return _require.original.apply(window, arguments);
  91. }
  92. };
  93. var normalizeModule = function(parentId, moduleName) {
  94. // normalize plugin requires
  95. if (moduleName.indexOf("!") !== -1) {
  96. var chunks = moduleName.split("!");
  97. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  98. }
  99. // normalize relative requires
  100. if (moduleName.charAt(0) == ".") {
  101. var base = parentId.split("/").slice(0, -1).join("/");
  102. moduleName = base + "/" + moduleName;
  103. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  104. var previous = moduleName;
  105. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  106. }
  107. }
  108. return moduleName;
  109. };
  110. var lookup = function(parentId, moduleName) {
  111. moduleName = normalizeModule(parentId, moduleName);
  112. var module = _define.modules[moduleName];
  113. if (!module) {
  114. return null;
  115. }
  116. if (typeof module === 'function') {
  117. var exports = {};
  118. var mod = {
  119. id: moduleName,
  120. uri: '',
  121. exports: exports,
  122. packaged: true
  123. };
  124. var req = function(module, callback) {
  125. return _require(moduleName, module, callback);
  126. };
  127. var returnValue = module(req, exports, mod);
  128. exports = returnValue || mod.exports;
  129. // cache the resulting module object for next time
  130. _define.modules[moduleName] = exports;
  131. return exports;
  132. }
  133. return module;
  134. };
  135. function exportAce(ns) {
  136. if (typeof requirejs !== "undefined") {
  137. var define = global.define;
  138. global.define = function(id, deps, callback) {
  139. if (typeof callback !== "function")
  140. return define.apply(this, arguments);
  141. return ace.define(id, deps, function(require, exports, module) {
  142. if (deps[2] == "module")
  143. module.packaged = true;
  144. return callback.apply(this, arguments);
  145. });
  146. };
  147. global.define.packaged = true;
  148. return;
  149. }
  150. var require = function(module, callback) {
  151. return _require("", module, callback);
  152. };
  153. require.packaged = true;
  154. var root = global;
  155. if (ns) {
  156. if (!global[ns])
  157. global[ns] = {};
  158. root = global[ns];
  159. }
  160. if (root.define)
  161. _define.original = root.define;
  162. root.define = _define;
  163. if (root.require)
  164. _require.original = root.require;
  165. root.require = require;
  166. }
  167. exportAce(ACE_NAMESPACE);
  168. })();
  169. /**
  170. * class Ace
  171. *
  172. * The main class required to set up an Ace instance in the browser.
  173. *
  174. *
  175. **/
  176. 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/multi_select', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/keyboard/state_handler', 'ace/placeholder', 'ace/config', 'ace/theme/textmate'], function(require, exports, module) {
  177. require("./lib/fixoldbrowsers");
  178. var Dom = require("./lib/dom");
  179. var Event = require("./lib/event");
  180. var Editor = require("./editor").Editor;
  181. var EditSession = require("./edit_session").EditSession;
  182. var UndoManager = require("./undomanager").UndoManager;
  183. var Renderer = require("./virtual_renderer").VirtualRenderer;
  184. var MultiSelect = require("./multi_select").MultiSelect;
  185. // The following require()s are for inclusion in the built ace file
  186. require("./worker/worker_client");
  187. require("./keyboard/hash_handler");
  188. require("./keyboard/state_handler");
  189. require("./placeholder");
  190. exports.config = require("./config");
  191. exports.edit = function(el) {
  192. if (typeof(el) == "string") {
  193. el = document.getElementById(el);
  194. }
  195. if (el.env && el.env.editor instanceof Editor)
  196. return el.env.editor;
  197. var doc = new EditSession(Dom.getInnerText(el));
  198. doc.setUndoManager(new UndoManager());
  199. el.innerHTML = '';
  200. var editor = new Editor(new Renderer(el, require("./theme/textmate")));
  201. new MultiSelect(editor);
  202. editor.setSession(doc);
  203. var env = {};
  204. env.document = doc;
  205. env.editor = editor;
  206. editor.resize();
  207. Event.addListener(window, "resize", function() {
  208. editor.resize();
  209. });
  210. el.env = env;
  211. // Store env on editor such that it can be accessed later on from
  212. // the returned object.
  213. editor.env = env;
  214. return editor;
  215. };
  216. });
  217. // vim:set ts=4 sts=4 sw=4 st:
  218. // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
  219. // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
  220. // -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified
  221. // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
  222. // -- Irakli Gozalishvili Copyright (C) 2010 MIT License
  223. /*!
  224. Copyright (c) 2009, 280 North Inc. http://280north.com/
  225. MIT License. http://github.com/280north/narwhal/blob/master/README.md
  226. */
  227. ace.define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
  228. require("./regexp");
  229. require("./es5-shim");
  230. });
  231. ace.define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
  232. //---------------------------------
  233. // Private variables
  234. //---------------------------------
  235. var real = {
  236. exec: RegExp.prototype.exec,
  237. test: RegExp.prototype.test,
  238. match: String.prototype.match,
  239. replace: String.prototype.replace,
  240. split: String.prototype.split
  241. },
  242. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  243. compliantLastIndexIncrement = function () {
  244. var x = /^/g;
  245. real.test.call(x, "");
  246. return !x.lastIndex;
  247. }();
  248. if (compliantLastIndexIncrement && compliantExecNpcg)
  249. return;
  250. //---------------------------------
  251. // Overriden native methods
  252. //---------------------------------
  253. // Adds named capture support (with backreferences returned as `result.name`), and fixes two
  254. // cross-browser issues per ES3:
  255. // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
  256. // rather than the empty string.
  257. // - `lastIndex` should not be incremented after zero-length matches.
  258. RegExp.prototype.exec = function (str) {
  259. var match = real.exec.apply(this, arguments),
  260. name, r2;
  261. if ( typeof(str) == 'string' && match) {
  262. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  263. // nonparticipating capturing groups
  264. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  265. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  266. // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
  267. // matching due to characters outside the match
  268. real.replace.call(str.slice(match.index), r2, function () {
  269. for (var i = 1; i < arguments.length - 2; i++) {
  270. if (arguments[i] === undefined)
  271. match[i] = undefined;
  272. }
  273. });
  274. }
  275. // Attach named capture properties
  276. if (this._xregexp && this._xregexp.captureNames) {
  277. for (var i = 1; i < match.length; i++) {
  278. name = this._xregexp.captureNames[i - 1];
  279. if (name)
  280. match[name] = match[i];
  281. }
  282. }
  283. // Fix browsers that increment `lastIndex` after zero-length matches
  284. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  285. this.lastIndex--;
  286. }
  287. return match;
  288. };
  289. // Don't override `test` if it won't change anything
  290. if (!compliantLastIndexIncrement) {
  291. // Fix browser bug in native method
  292. RegExp.prototype.test = function (str) {
  293. // Use the native `exec` to skip some processing overhead, even though the overriden
  294. // `exec` would take care of the `lastIndex` fix
  295. var match = real.exec.call(this, str);
  296. // Fix browsers that increment `lastIndex` after zero-length matches
  297. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  298. this.lastIndex--;
  299. return !!match;
  300. };
  301. }
  302. //---------------------------------
  303. // Private helper functions
  304. //---------------------------------
  305. function getNativeFlags (regex) {
  306. return (regex.global ? "g" : "") +
  307. (regex.ignoreCase ? "i" : "") +
  308. (regex.multiline ? "m" : "") +
  309. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  310. (regex.sticky ? "y" : "");
  311. };
  312. function indexOf (array, item, from) {
  313. if (Array.prototype.indexOf) // Use the native array method if available
  314. return array.indexOf(item, from);
  315. for (var i = from || 0; i < array.length; i++) {
  316. if (array[i] === item)
  317. return i;
  318. }
  319. return -1;
  320. };
  321. });
  322. // vim: ts=4 sts=4 sw=4 expandtab
  323. // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
  324. // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
  325. // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
  326. // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
  327. // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
  328. // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
  329. // -- kossnocorp Sasha Koss XXX TODO License or CLA
  330. // -- bryanforbes Bryan Forbes XXX TODO License or CLA
  331. // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
  332. // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
  333. // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
  334. // -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain)
  335. // -- iwyg XXX TODO License or CLA
  336. // -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License
  337. // -- xavierm02 Montillet Xavier XXX TODO License or CLA
  338. // -- Raynos Raynos XXX TODO License or CLA
  339. // -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License
  340. // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
  341. // -- lexer Alexey Zakharov XXX TODO License or CLA
  342. /*!
  343. Copyright (c) 2009, 280 North Inc. http://280north.com/
  344. MIT License. http://github.com/280north/narwhal/blob/master/README.md
  345. */
  346. ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
  347. /*
  348. * Brings an environment as close to ECMAScript 5 compliance
  349. * as is possible with the facilities of erstwhile engines.
  350. *
  351. * Annotated ES5: http://es5.github.com/ (specific links below)
  352. * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
  353. *
  354. * @module
  355. */
  356. /*whatsupdoc*/
  357. //
  358. // Function
  359. // ========
  360. //
  361. // ES-5 15.3.4.5
  362. // http://es5.github.com/#x15.3.4.5
  363. if (!Function.prototype.bind) {
  364. Function.prototype.bind = function bind(that) { // .length is 1
  365. // 1. Let Target be the this value.
  366. var target = this;
  367. // 2. If IsCallable(Target) is false, throw a TypeError exception.
  368. if (typeof target != "function")
  369. throw new TypeError(); // TODO message
  370. // 3. Let A be a new (possibly empty) internal list of all of the
  371. // argument values provided after thisArg (arg1, arg2 etc), in order.
  372. // XXX slicedArgs will stand in for "A" if used
  373. var args = slice.call(arguments, 1); // for normal call
  374. // 4. Let F be a new native ECMAScript object.
  375. // 11. Set the [[Prototype]] internal property of F to the standard
  376. // built-in Function prototype object as specified in 15.3.3.1.
  377. // 12. Set the [[Call]] internal property of F as described in
  378. // 15.3.4.5.1.
  379. // 13. Set the [[Construct]] internal property of F as described in
  380. // 15.3.4.5.2.
  381. // 14. Set the [[HasInstance]] internal property of F as described in
  382. // 15.3.4.5.3.
  383. var bound = function () {
  384. if (this instanceof bound) {
  385. // 15.3.4.5.2 [[Construct]]
  386. // When the [[Construct]] internal method of a function object,
  387. // F that was created using the bind function is called with a
  388. // list of arguments ExtraArgs, the following steps are taken:
  389. // 1. Let target be the value of F's [[TargetFunction]]
  390. // internal property.
  391. // 2. If target has no [[Construct]] internal method, a
  392. // TypeError exception is thrown.
  393. // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
  394. // property.
  395. // 4. Let args be a new list containing the same values as the
  396. // list boundArgs in the same order followed by the same
  397. // values as the list ExtraArgs in the same order.
  398. // 5. Return the result of calling the [[Construct]] internal
  399. // method of target providing args as the arguments.
  400. var F = function(){};
  401. F.prototype = target.prototype;
  402. var self = new F;
  403. var result = target.apply(
  404. self,
  405. args.concat(slice.call(arguments))
  406. );
  407. if (result !== null && Object(result) === result)
  408. return result;
  409. return self;
  410. } else {
  411. // 15.3.4.5.1 [[Call]]
  412. // When the [[Call]] internal method of a function object, F,
  413. // which was created using the bind function is called with a
  414. // this value and a list of arguments ExtraArgs, the following
  415. // steps are taken:
  416. // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
  417. // property.
  418. // 2. Let boundThis be the value of F's [[BoundThis]] internal
  419. // property.
  420. // 3. Let target be the value of F's [[TargetFunction]] internal
  421. // property.
  422. // 4. Let args be a new list containing the same values as the
  423. // list boundArgs in the same order followed by the same
  424. // values as the list ExtraArgs in the same order.
  425. // 5. Return the result of calling the [[Call]] internal method
  426. // of target providing boundThis as the this value and
  427. // providing args as the arguments.
  428. // equiv: target.call(this, ...boundArgs, ...args)
  429. return target.apply(
  430. that,
  431. args.concat(slice.call(arguments))
  432. );
  433. }
  434. };
  435. // XXX bound.length is never writable, so don't even try
  436. //
  437. // 15. If the [[Class]] internal property of Target is "Function", then
  438. // a. Let L be the length property of Target minus the length of A.
  439. // b. Set the length own property of F to either 0 or L, whichever is
  440. // larger.
  441. // 16. Else set the length own property of F to 0.
  442. // 17. Set the attributes of the length own property of F to the values
  443. // specified in 15.3.5.1.
  444. // TODO
  445. // 18. Set the [[Extensible]] internal property of F to true.
  446. // TODO
  447. // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
  448. // 20. Call the [[DefineOwnProperty]] internal method of F with
  449. // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
  450. // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
  451. // false.
  452. // 21. Call the [[DefineOwnProperty]] internal method of F with
  453. // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
  454. // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
  455. // and false.
  456. // TODO
  457. // NOTE Function objects created using Function.prototype.bind do not
  458. // have a prototype property or the [[Code]], [[FormalParameters]], and
  459. // [[Scope]] internal properties.
  460. // XXX can't delete prototype in pure-js.
  461. // 22. Return F.
  462. return bound;
  463. };
  464. }
  465. // Shortcut to an often accessed properties, in order to avoid multiple
  466. // dereference that costs universally.
  467. // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
  468. // us it in defining shortcuts.
  469. var call = Function.prototype.call;
  470. var prototypeOfArray = Array.prototype;
  471. var prototypeOfObject = Object.prototype;
  472. var slice = prototypeOfArray.slice;
  473. var toString = call.bind(prototypeOfObject.toString);
  474. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  475. // If JS engine supports accessors creating shortcuts.
  476. var defineGetter;
  477. var defineSetter;
  478. var lookupGetter;
  479. var lookupSetter;
  480. var supportsAccessors;
  481. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  482. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  483. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  484. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  485. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  486. }
  487. //
  488. // Array
  489. // =====
  490. //
  491. // ES5 15.4.3.2
  492. // http://es5.github.com/#x15.4.3.2
  493. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
  494. if (!Array.isArray) {
  495. Array.isArray = function isArray(obj) {
  496. return toString(obj) == "[object Array]";
  497. };
  498. }
  499. // The IsCallable() check in the Array functions
  500. // has been replaced with a strict check on the
  501. // internal class of the object to trap cases where
  502. // the provided function was actually a regular
  503. // expression literal, which in V8 and
  504. // JavaScriptCore is a typeof "function". Only in
  505. // V8 are regular expression literals permitted as
  506. // reduce parameters, so it is desirable in the
  507. // general case for the shim to match the more
  508. // strict and common behavior of rejecting regular
  509. // expressions.
  510. // ES5 15.4.4.18
  511. // http://es5.github.com/#x15.4.4.18
  512. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
  513. if (!Array.prototype.forEach) {
  514. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  515. var self = toObject(this),
  516. thisp = arguments[1],
  517. i = 0,
  518. length = self.length >>> 0;
  519. // If no callback function or if callback is not a callable function
  520. if (toString(fun) != "[object Function]") {
  521. throw new TypeError(); // TODO message
  522. }
  523. while (i < length) {
  524. if (i in self) {
  525. // Invoke the callback function with call, passing arguments:
  526. // context, property value, property key, thisArg object context
  527. fun.call(thisp, self[i], i, self);
  528. }
  529. i++;
  530. }
  531. };
  532. }
  533. // ES5 15.4.4.19
  534. // http://es5.github.com/#x15.4.4.19
  535. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
  536. if (!Array.prototype.map) {
  537. Array.prototype.map = function map(fun /*, thisp*/) {
  538. var self = toObject(this),
  539. length = self.length >>> 0,
  540. result = Array(length),
  541. thisp = arguments[1];
  542. // If no callback function or if callback is not a callable function
  543. if (toString(fun) != "[object Function]") {
  544. throw new TypeError(); // TODO message
  545. }
  546. for (var i = 0; i < length; i++) {
  547. if (i in self)
  548. result[i] = fun.call(thisp, self[i], i, self);
  549. }
  550. return result;
  551. };
  552. }
  553. // ES5 15.4.4.20
  554. // http://es5.github.com/#x15.4.4.20
  555. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
  556. if (!Array.prototype.filter) {
  557. Array.prototype.filter = function filter(fun /*, thisp */) {
  558. var self = toObject(this),
  559. length = self.length >>> 0,
  560. result = [],
  561. thisp = arguments[1];
  562. // If no callback function or if callback is not a callable function
  563. if (toString(fun) != "[object Function]") {
  564. throw new TypeError(); // TODO message
  565. }
  566. for (var i = 0; i < length; i++) {
  567. if (i in self && fun.call(thisp, self[i], i, self))
  568. result.push(self[i]);
  569. }
  570. return result;
  571. };
  572. }
  573. // ES5 15.4.4.16
  574. // http://es5.github.com/#x15.4.4.16
  575. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
  576. if (!Array.prototype.every) {
  577. Array.prototype.every = function every(fun /*, thisp */) {
  578. var self = toObject(this),
  579. length = self.length >>> 0,
  580. thisp = arguments[1];
  581. // If no callback function or if callback is not a callable function
  582. if (toString(fun) != "[object Function]") {
  583. throw new TypeError(); // TODO message
  584. }
  585. for (var i = 0; i < length; i++) {
  586. if (i in self && !fun.call(thisp, self[i], i, self))
  587. return false;
  588. }
  589. return true;
  590. };
  591. }
  592. // ES5 15.4.4.17
  593. // http://es5.github.com/#x15.4.4.17
  594. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
  595. if (!Array.prototype.some) {
  596. Array.prototype.some = function some(fun /*, thisp */) {
  597. var self = toObject(this),
  598. length = self.length >>> 0,
  599. thisp = arguments[1];
  600. // If no callback function or if callback is not a callable function
  601. if (toString(fun) != "[object Function]") {
  602. throw new TypeError(); // TODO message
  603. }
  604. for (var i = 0; i < length; i++) {
  605. if (i in self && fun.call(thisp, self[i], i, self))
  606. return true;
  607. }
  608. return false;
  609. };
  610. }
  611. // ES5 15.4.4.21
  612. // http://es5.github.com/#x15.4.4.21
  613. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
  614. if (!Array.prototype.reduce) {
  615. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  616. var self = toObject(this),
  617. length = self.length >>> 0;
  618. // If no callback function or if callback is not a callable function
  619. if (toString(fun) != "[object Function]") {
  620. throw new TypeError(); // TODO message
  621. }
  622. // no value to return if no initial value and an empty array
  623. if (!length && arguments.length == 1)
  624. throw new TypeError(); // TODO message
  625. var i = 0;
  626. var result;
  627. if (arguments.length >= 2) {
  628. result = arguments[1];
  629. } else {
  630. do {
  631. if (i in self) {
  632. result = self[i++];
  633. break;
  634. }
  635. // if array contains no values, no initial value to return
  636. if (++i >= length)
  637. throw new TypeError(); // TODO message
  638. } while (true);
  639. }
  640. for (; i < length; i++) {
  641. if (i in self)
  642. result = fun.call(void 0, result, self[i], i, self);
  643. }
  644. return result;
  645. };
  646. }
  647. // ES5 15.4.4.22
  648. // http://es5.github.com/#x15.4.4.22
  649. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
  650. if (!Array.prototype.reduceRight) {
  651. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  652. var self = toObject(this),
  653. length = self.length >>> 0;
  654. // If no callback function or if callback is not a callable function
  655. if (toString(fun) != "[object Function]") {
  656. throw new TypeError(); // TODO message
  657. }
  658. // no value to return if no initial value, empty array
  659. if (!length && arguments.length == 1)
  660. throw new TypeError(); // TODO message
  661. var result, i = length - 1;
  662. if (arguments.length >= 2) {
  663. result = arguments[1];
  664. } else {
  665. do {
  666. if (i in self) {
  667. result = self[i--];
  668. break;
  669. }
  670. // if array contains no values, no initial value to return
  671. if (--i < 0)
  672. throw new TypeError(); // TODO message
  673. } while (true);
  674. }
  675. do {
  676. if (i in this)
  677. result = fun.call(void 0, result, self[i], i, self);
  678. } while (i--);
  679. return result;
  680. };
  681. }
  682. // ES5 15.4.4.14
  683. // http://es5.github.com/#x15.4.4.14
  684. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
  685. if (!Array.prototype.indexOf) {
  686. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  687. var self = toObject(this),
  688. length = self.length >>> 0;
  689. if (!length)
  690. return -1;
  691. var i = 0;
  692. if (arguments.length > 1)
  693. i = toInteger(arguments[1]);
  694. // handle negative indices
  695. i = i >= 0 ? i : Math.max(0, length + i);
  696. for (; i < length; i++) {
  697. if (i in self && self[i] === sought) {
  698. return i;
  699. }
  700. }
  701. return -1;
  702. };
  703. }
  704. // ES5 15.4.4.15
  705. // http://es5.github.com/#x15.4.4.15
  706. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
  707. if (!Array.prototype.lastIndexOf) {
  708. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  709. var self = toObject(this),
  710. length = self.length >>> 0;
  711. if (!length)
  712. return -1;
  713. var i = length - 1;
  714. if (arguments.length > 1)
  715. i = Math.min(i, toInteger(arguments[1]));
  716. // handle negative indices
  717. i = i >= 0 ? i : length - Math.abs(i);
  718. for (; i >= 0; i--) {
  719. if (i in self && sought === self[i])
  720. return i;
  721. }
  722. return -1;
  723. };
  724. }
  725. //
  726. // Object
  727. // ======
  728. //
  729. // ES5 15.2.3.2
  730. // http://es5.github.com/#x15.2.3.2
  731. if (!Object.getPrototypeOf) {
  732. // https://github.com/kriskowal/es5-shim/issues#issue/2
  733. // http://ejohn.org/blog/objectgetprototypeof/
  734. // recommended by fschaefer on github
  735. Object.getPrototypeOf = function getPrototypeOf(object) {
  736. return object.__proto__ || (
  737. object.constructor ?
  738. object.constructor.prototype :
  739. prototypeOfObject
  740. );
  741. };
  742. }
  743. // ES5 15.2.3.3
  744. // http://es5.github.com/#x15.2.3.3
  745. if (!Object.getOwnPropertyDescriptor) {
  746. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  747. "non-object: ";
  748. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  749. if ((typeof object != "object" && typeof object != "function") || object === null)
  750. throw new TypeError(ERR_NON_OBJECT + object);
  751. // If object does not owns property return undefined immediately.
  752. if (!owns(object, property))
  753. return;
  754. var descriptor, getter, setter;
  755. // If object has a property then it's for sure both `enumerable` and
  756. // `configurable`.
  757. descriptor = { enumerable: true, configurable: true };
  758. // If JS engine supports accessor properties then property may be a
  759. // getter or setter.
  760. if (supportsAccessors) {
  761. // Unfortunately `__lookupGetter__` will return a getter even
  762. // if object has own non getter property along with a same named
  763. // inherited getter. To avoid misbehavior we temporary remove
  764. // `__proto__` so that `__lookupGetter__` will return getter only
  765. // if it's owned by an object.
  766. var prototype = object.__proto__;
  767. object.__proto__ = prototypeOfObject;
  768. var getter = lookupGetter(object, property);
  769. var setter = lookupSetter(object, property);
  770. // Once we have getter and setter we can put values back.
  771. object.__proto__ = prototype;
  772. if (getter || setter) {
  773. if (getter) descriptor.get = getter;
  774. if (setter) descriptor.set = setter;
  775. // If it was accessor property we're done and return here
  776. // in order to avoid adding `value` to the descriptor.
  777. return descriptor;
  778. }
  779. }
  780. // If we got this far we know that object has an own property that is
  781. // not an accessor so we set it as a value and return descriptor.
  782. descriptor.value = object[property];
  783. return descriptor;
  784. };
  785. }
  786. // ES5 15.2.3.4
  787. // http://es5.github.com/#x15.2.3.4
  788. if (!Object.getOwnPropertyNames) {
  789. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  790. return Object.keys(object);
  791. };
  792. }
  793. // ES5 15.2.3.5
  794. // http://es5.github.com/#x15.2.3.5
  795. if (!Object.create) {
  796. Object.create = function create(prototype, properties) {
  797. var object;
  798. if (prototype === null) {
  799. object = { "__proto__": null };
  800. } else {
  801. if (typeof prototype != "object")
  802. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  803. var Type = function () {};
  804. Type.prototype = prototype;
  805. object = new Type();
  806. // IE has no built-in implementation of `Object.getPrototypeOf`
  807. // neither `__proto__`, but this manually setting `__proto__` will
  808. // guarantee that `Object.getPrototypeOf` will work as expected with
  809. // objects created using `Object.create`
  810. object.__proto__ = prototype;
  811. }
  812. if (properties !== void 0)
  813. Object.defineProperties(object, properties);
  814. return object;
  815. };
  816. }
  817. // ES5 15.2.3.6
  818. // http://es5.github.com/#x15.2.3.6
  819. // Patch for WebKit and IE8 standard mode
  820. // Designed by hax <hax.github.com>
  821. // related issue: https://github.com/kriskowal/es5-shim/issues#issue/5
  822. // IE8 Reference:
  823. // http://msdn.microsoft.com/en-us/library/dd282900.aspx
  824. // http://msdn.microsoft.com/en-us/library/dd229916.aspx
  825. // WebKit Bugs:
  826. // https://bugs.webkit.org/show_bug.cgi?id=36423
  827. function doesDefinePropertyWork(object) {
  828. try {
  829. Object.defineProperty(object, "sentinel", {});
  830. return "sentinel" in object;
  831. } catch (exception) {
  832. // returns falsy
  833. }
  834. }
  835. // check whether defineProperty works if it's given. Otherwise,
  836. // shim partially.
  837. if (Object.defineProperty) {
  838. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  839. var definePropertyWorksOnDom = typeof document == "undefined" ||
  840. doesDefinePropertyWork(document.createElement("div"));
  841. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  842. var definePropertyFallback = Object.defineProperty;
  843. }
  844. }
  845. if (!Object.defineProperty || definePropertyFallback) {
  846. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  847. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  848. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  849. "on this javascript engine";
  850. Object.defineProperty = function defineProperty(object, property, descriptor) {
  851. if ((typeof object != "object" && typeof object != "function") || object === null)
  852. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  853. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  854. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  855. // make a valiant attempt to use the real defineProperty
  856. // for I8's DOM elements.
  857. if (definePropertyFallback) {
  858. try {
  859. return definePropertyFallback.call(Object, object, property, descriptor);
  860. } catch (exception) {
  861. // try the shim if the real one doesn't work
  862. }
  863. }
  864. // If it's a data property.
  865. if (owns(descriptor, "value")) {
  866. // fail silently if "writable", "enumerable", or "configurable"
  867. // are requested but not supported
  868. /*
  869. // alternate approach:
  870. if ( // can't implement these features; allow false but not true
  871. !(owns(descriptor, "writable") ? descriptor.writable : true) ||
  872. !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
  873. !(owns(descriptor, "configurable") ? descriptor.configurable : true)
  874. )
  875. throw new RangeError(
  876. "This implementation of Object.defineProperty does not " +
  877. "support configurable, enumerable, or writable."
  878. );
  879. */
  880. if (supportsAccessors && (lookupGetter(object, property) ||
  881. lookupSetter(object, property)))
  882. {
  883. // As accessors are supported only on engines implementing
  884. // `__proto__` we can safely override `__proto__` while defining
  885. // a property to make sure that we don't hit an inherited
  886. // accessor.
  887. var prototype = object.__proto__;
  888. object.__proto__ = prototypeOfObject;
  889. // Deleting a property anyway since getter / setter may be
  890. // defined on object itself.
  891. delete object[property];
  892. object[property] = descriptor.value;
  893. // Setting original `__proto__` back now.
  894. object.__proto__ = prototype;
  895. } else {
  896. object[property] = descriptor.value;
  897. }
  898. } else {
  899. if (!supportsAccessors)
  900. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  901. // If we got that far then getters and setters can be defined !!
  902. if (owns(descriptor, "get"))
  903. defineGetter(object, property, descriptor.get);
  904. if (owns(descriptor, "set"))
  905. defineSetter(object, property, descriptor.set);
  906. }
  907. return object;
  908. };
  909. }
  910. // ES5 15.2.3.7
  911. // http://es5.github.com/#x15.2.3.7
  912. if (!Object.defineProperties) {
  913. Object.defineProperties = function defineProperties(object, properties) {
  914. for (var property in properties) {
  915. if (owns(properties, property))
  916. Object.defineProperty(object, property, properties[property]);
  917. }
  918. return object;
  919. };
  920. }
  921. // ES5 15.2.3.8
  922. // http://es5.github.com/#x15.2.3.8
  923. if (!Object.seal) {
  924. Object.seal = function seal(object) {
  925. // this is misleading and breaks feature-detection, but
  926. // allows "securable" code to "gracefully" degrade to working
  927. // but insecure code.
  928. return object;
  929. };
  930. }
  931. // ES5 15.2.3.9
  932. // http://es5.github.com/#x15.2.3.9
  933. if (!Object.freeze) {
  934. Object.freeze = function freeze(object) {
  935. // this is misleading and breaks feature-detection, but
  936. // allows "securable" code to "gracefully" degrade to working
  937. // but insecure code.
  938. return object;
  939. };
  940. }
  941. // detect a Rhino bug and patch it
  942. try {
  943. Object.freeze(function () {});
  944. } catch (exception) {
  945. Object.freeze = (function freeze(freezeObject) {
  946. return function freeze(object) {
  947. if (typeof object == "function") {
  948. return object;
  949. } else {
  950. return freezeObject(object);
  951. }
  952. };
  953. })(Object.freeze);
  954. }
  955. // ES5 15.2.3.10
  956. // http://es5.github.com/#x15.2.3.10
  957. if (!Object.preventExtensions) {
  958. Object.preventExtensions = function preventExtensions(object) {
  959. // this is misleading and breaks feature-detection, but
  960. // allows "securable" code to "gracefully" degrade to working
  961. // but insecure code.
  962. return object;
  963. };
  964. }
  965. // ES5 15.2.3.11
  966. // http://es5.github.com/#x15.2.3.11
  967. if (!Object.isSealed) {
  968. Object.isSealed = function isSealed(object) {
  969. return false;
  970. };
  971. }
  972. // ES5 15.2.3.12
  973. // http://es5.github.com/#x15.2.3.12
  974. if (!Object.isFrozen) {
  975. Object.isFrozen = function isFrozen(object) {
  976. return false;
  977. };
  978. }
  979. // ES5 15.2.3.13
  980. // http://es5.github.com/#x15.2.3.13
  981. if (!Object.isExtensible) {
  982. Object.isExtensible = function isExtensible(object) {
  983. // 1. If Type(O) is not Object throw a TypeError exception.
  984. if (Object(object) === object) {
  985. throw new TypeError(); // TODO message
  986. }
  987. // 2. Return the Boolean value of the [[Extensible]] internal property of O.
  988. var name = '';
  989. while (owns(object, name)) {
  990. name += '?';
  991. }
  992. object[name] = true;
  993. var returnValue = owns(object, name);
  994. delete object[name];
  995. return returnValue;
  996. };
  997. }
  998. // ES5 15.2.3.14
  999. // http://es5.github.com/#x15.2.3.14
  1000. if (!Object.keys) {
  1001. // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
  1002. var hasDontEnumBug = true,
  1003. dontEnums = [
  1004. "toString",
  1005. "toLocaleString",
  1006. "valueOf",
  1007. "hasOwnProperty",
  1008. "isPrototypeOf",
  1009. "propertyIsEnumerable",
  1010. "constructor"
  1011. ],
  1012. dontEnumsLength = dontEnums.length;
  1013. for (var key in {"toString": null})
  1014. hasDontEnumBug = false;
  1015. Object.keys = function keys(object) {
  1016. if ((typeof object != "object" && typeof object != "function") || object === null)
  1017. throw new TypeError("Object.keys called on a non-object");
  1018. var keys = [];
  1019. for (var name in object) {
  1020. if (owns(object, name)) {
  1021. keys.push(name);
  1022. }
  1023. }
  1024. if (hasDontEnumBug) {
  1025. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  1026. var dontEnum = dontEnums[i];
  1027. if (owns(object, dontEnum)) {
  1028. keys.push(dontEnum);
  1029. }
  1030. }
  1031. }
  1032. return keys;
  1033. };
  1034. }
  1035. //
  1036. // Date
  1037. // ====
  1038. //
  1039. // ES5 15.9.5.43
  1040. // http://es5.github.com/#x15.9.5.43
  1041. // This function returns a String value represent the instance in time
  1042. // represented by this Date object. The format of the String is the Date Time
  1043. // string format defined in 15.9.1.15. All fields are present in the String.
  1044. // The time zone is always UTC, denoted by the suffix Z. If the time value of
  1045. // this object is not a finite Number a RangeError exception is thrown.
  1046. if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) {
  1047. Date.prototype.toISOString = function toISOString() {
  1048. var result, length, value, year;
  1049. if (!isFinite(this))
  1050. throw new RangeError;
  1051. // the date time string format is specified in 15.9.1.15.
  1052. result = [this.getUTCMonth() + 1, this.getUTCDate(),
  1053. this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
  1054. year = this.getUTCFullYear();
  1055. year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6);
  1056. length = result.length;
  1057. while (length--) {
  1058. value = result[length];
  1059. // pad months, days, hours, minutes, and seconds to have two digits.
  1060. if (value < 10)
  1061. result[length] = "0" + value;
  1062. }
  1063. // pad milliseconds to have three digits.
  1064. return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." +
  1065. ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
  1066. }
  1067. }
  1068. // ES5 15.9.4.4
  1069. // http://es5.github.com/#x15.9.4.4
  1070. if (!Date.now) {
  1071. Date.now = function now() {
  1072. return new Date().getTime();
  1073. };
  1074. }
  1075. // ES5 15.9.5.44
  1076. // http://es5.github.com/#x15.9.5.44
  1077. // This function provides a String representation of a Date object for use by
  1078. // JSON.stringify (15.12.3).
  1079. if (!Date.prototype.toJSON) {
  1080. Date.prototype.toJSON = function toJSON(key) {
  1081. // When the toJSON method is called with argument key, the following
  1082. // steps are taken:
  1083. // 1. Let O be the result of calling ToObject, giving it the this
  1084. // value as its argument.
  1085. // 2. Let tv be ToPrimitive(O, hint Number).
  1086. // 3. If tv is a Number and is not finite, return null.
  1087. // XXX
  1088. // 4. Let toISO be the result of calling the [[Get]] internal method of
  1089. // O with argument "toISOString".
  1090. // 5. If IsCallable(toISO) is false, throw a TypeError exception.
  1091. if (typeof this.toISOString != "function")
  1092. throw new TypeError(); // TODO message
  1093. // 6. Return the result of calling the [[Call]] internal method of
  1094. // toISO with O as the this value and an empty argument list.
  1095. return this.toISOString();
  1096. // NOTE 1 The argument is ignored.
  1097. // NOTE 2 The toJSON function is intentionally generic; it does not
  1098. // require that its this value be a Date object. Therefore, it can be
  1099. // transferred to other kinds of objects for use as a method. However,
  1100. // it does require that any such object have a toISOString method. An
  1101. // object is free to use the argument key to filter its
  1102. // stringification.
  1103. };
  1104. }
  1105. // ES5 15.9.4.2
  1106. // http://es5.github.com/#x15.9.4.2
  1107. // based on work shared by Daniel Friesen (dantman)
  1108. // http://gist.github.com/303249
  1109. if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
  1110. // XXX global assignment won't work in embeddings that use
  1111. // an alternate object for the context.
  1112. Date = (function(NativeDate) {
  1113. // Date.length === 7
  1114. var Date = function Date(Y, M, D, h, m, s, ms) {
  1115. var length = arguments.length;
  1116. if (this instanceof NativeDate) {
  1117. var date = length == 1 && String(Y) === Y ? // isString(Y)
  1118. // We explicitly pass it through parse:
  1119. new NativeDate(Date.parse(Y)) :
  1120. // We have to manually make calls depending on argument
  1121. // length here
  1122. length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
  1123. length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
  1124. length >= 5 ? new NativeDate(Y, M, D, h, m) :
  1125. length >= 4 ? new NativeDate(Y, M, D, h) :
  1126. length >= 3 ? new NativeDate(Y, M, D) :
  1127. length >= 2 ? new NativeDate(Y, M) :
  1128. length >= 1 ? new NativeDate(Y) :
  1129. new NativeDate();
  1130. // Prevent mixups with unfixed Date object
  1131. date.constructor = Date;
  1132. return date;
  1133. }
  1134. return NativeDate.apply(this, arguments);
  1135. };
  1136. // 15.9.1.15 Date Time String Format.
  1137. var isoDateExpression = new RegExp("^" +
  1138. "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year
  1139. "(?:-(\\d{2})" + // optional month capture
  1140. "(?:-(\\d{2})" + // optional day capture
  1141. "(?:" + // capture hours:minutes:seconds.milliseconds
  1142. "T(\\d{2})" + // hours capture
  1143. ":(\\d{2})" + // minutes capture
  1144. "(?:" + // optional :seconds.milliseconds
  1145. ":(\\d{2})" + // seconds capture
  1146. "(?:\\.(\\d{3}))?" + // milliseconds capture
  1147. ")?" +
  1148. "(?:" + // capture UTC offset component
  1149. "Z|" + // UTC capture
  1150. "(?:" + // offset specifier +/-hours:minutes
  1151. "([-+])" + // sign capture
  1152. "(\\d{2})" + // hours offset capture
  1153. ":(\\d{2})" + // minutes offset capture
  1154. ")" +
  1155. ")?)?)?)?" +
  1156. "$");
  1157. // Copy any custom methods a 3rd party library may have added
  1158. for (var key in NativeDate)
  1159. Date[key] = NativeDate[key];
  1160. // Copy "native" methods explicitly; they may be non-enumerable
  1161. Date.now = NativeDate.now;
  1162. Date.UTC = NativeDate.UTC;
  1163. Date.prototype = NativeDate.prototype;
  1164. Date.prototype.constructor = Date;
  1165. // Upgrade Date.parse to handle simplified ISO 8601 strings
  1166. Date.parse = function parse(string) {
  1167. var match = isoDateExpression.exec(string);
  1168. if (match) {
  1169. match.shift(); // kill match[0], the full match
  1170. // parse months, days, hours, minutes, seconds, and milliseconds
  1171. for (var i = 1; i < 7; i++) {
  1172. // provide default values if necessary
  1173. match[i] = +(match[i] || (i < 3 ? 1 : 0));
  1174. // match[1] is the month. Months are 0-11 in JavaScript
  1175. // `Date` objects, but 1-12 in ISO notation, so we
  1176. // decrement.
  1177. if (i == 1)
  1178. match[i]--;
  1179. }
  1180. // parse the UTC offset component
  1181. var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop();
  1182. // compute the explicit time zone offset if specified
  1183. var offset = 0;
  1184. if (sign) {
  1185. // detect invalid offsets and return early
  1186. if (hourOffset > 23 || minuteOffset > 59)
  1187. return NaN;
  1188. // express the provided time zone offset in minutes. The offset is
  1189. // negative for time zones west of UTC; positive otherwise.
  1190. offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1);
  1191. }
  1192. // Date.UTC for years between 0 and 99 converts year to 1900 + year
  1193. // The Gregorian calendar has a 400-year cycle, so
  1194. // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...),
  1195. // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years
  1196. var year = +match[0];
  1197. if (0 <= year && year <= 99) {
  1198. match[0] = year + 400;
  1199. return NativeDate.UTC.apply(this, match) + offset - 12622780800000;
  1200. }
  1201. // compute a new UTC date value, accounting for the optional offset
  1202. return NativeDate.UTC.apply(this, match) + offset;
  1203. }
  1204. return NativeDate.parse.apply(this, arguments);
  1205. };
  1206. return Date;
  1207. })(Date);
  1208. }
  1209. //
  1210. // String
  1211. // ======
  1212. //
  1213. // ES5 15.5.4.20
  1214. // http://es5.github.com/#x15.5.4.20
  1215. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  1216. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  1217. "\u2029\uFEFF";
  1218. if (!String.prototype.trim || ws.trim()) {
  1219. // http://blog.stevenlevithan.com/archives/faster-trim-javascript
  1220. // http://perfectionkills.com/whitespace-deviations/
  1221. ws = "[" + ws + "]";
  1222. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  1223. trimEndRegexp = new RegExp(ws + ws + "*$");
  1224. String.prototype.trim = function trim() {
  1225. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  1226. };
  1227. }
  1228. //
  1229. // Util
  1230. // ======
  1231. //
  1232. // ES5 9.4
  1233. // http://es5.github.com/#x9.4
  1234. // http://jsperf.com/to-integer
  1235. var toInteger = function (n) {
  1236. n = +n;
  1237. if (n !== n) // isNaN
  1238. n = 0;
  1239. else if (n !== 0 && n !== (1/0) && n !== -(1/0))
  1240. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  1241. return n;
  1242. };
  1243. var prepareString = "a"[0] != "a",
  1244. // ES5 9.9
  1245. // http://es5.github.com/#x9.9
  1246. toObject = function (o) {
  1247. if (o == null) { // this matches both null and undefined
  1248. throw new TypeError(); // TODO message
  1249. }
  1250. // If the implementation doesn't support by-index access of
  1251. // string characters (ex. IE < 7), split the string
  1252. if (prepareString && typeof o == "string" && o) {
  1253. return o.split("");
  1254. }
  1255. return Object(o);
  1256. };
  1257. });
  1258. ace.define('ace/lib/dom', ['require', 'exports', 'module' ], function(require, exports, module) {
  1259. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  1260. exports.createElement = function(tag, ns) {
  1261. return document.createElementNS ?
  1262. document.createElementNS(ns || XHTML_NS, tag) :
  1263. document.createElement(tag);
  1264. };
  1265. exports.setText = function(elem, text) {
  1266. if (elem.innerText !== undefined) {
  1267. elem.innerText = text;
  1268. }
  1269. if (elem.textContent !== undefined) {
  1270. elem.textContent = text;
  1271. }
  1272. };
  1273. exports.hasCssClass = function(el, name) {
  1274. var classes = el.className.split(/\s+/g);
  1275. return classes.indexOf(name) !== -1;
  1276. };
  1277. exports.addCssClass = function(el, name) {
  1278. if (!exports.hasCssClass(el, name)) {
  1279. el.className += " " + name;
  1280. }
  1281. };
  1282. exports.removeCssClass = function(el, name) {
  1283. var classes = el.className.split(/\s+/g);
  1284. while (true) {
  1285. var index = classes.indexOf(name);
  1286. if (index == -1) {
  1287. break;
  1288. }
  1289. classes.splice(index, 1);
  1290. }
  1291. el.className = classes.join(" ");
  1292. };
  1293. exports.toggleCssClass = function(el, name) {
  1294. var classes = el.className.split(/\s+/g), add = true;
  1295. while (true) {
  1296. var index = classes.indexOf(name);
  1297. if (index == -1) {
  1298. break;
  1299. }
  1300. add = false;
  1301. classes.splice(index, 1);
  1302. }
  1303. if(add)
  1304. classes.push(name);
  1305. el.className = classes.join(" ");
  1306. return add;
  1307. };
  1308. exports.setCssClass = function(node, className, include) {
  1309. if (include) {
  1310. exports.addCssClass(node, className);
  1311. } else {
  1312. exports.removeCssClass(node, className);
  1313. }
  1314. };
  1315. exports.hasCssString = function(id, doc) {
  1316. var index = 0, sheets;
  1317. doc = doc || document;
  1318. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  1319. while (index < sheets.length)
  1320. if (sheets[index++].owningElement.id === id) return true;
  1321. } else if ((sheets = doc.getElementsByTagName("style"))) {
  1322. while (index < sheets.length)
  1323. if (sheets[index++].id === id) return true;
  1324. }
  1325. return false;
  1326. };
  1327. exports.importCssString = function importCssString(cssText, id, doc) {
  1328. doc = doc || document;
  1329. // If style is already imported return immediately.
  1330. if (id && exports.hasCssString(id, doc))
  1331. return null;
  1332. var style;
  1333. if (doc.createStyleSheet) {
  1334. style = doc.createStyleSheet();
  1335. style.cssText = cssText;
  1336. if (id)
  1337. style.owningElement.id = id;
  1338. } else {
  1339. style = doc.createElementNS
  1340. ? doc.createElementNS(XHTML_NS, "style")
  1341. : doc.createElement("style");
  1342. style.appendChild(doc.createTextNode(cssText));
  1343. if (id)
  1344. style.id = id;
  1345. var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
  1346. head.appendChild(style);
  1347. }
  1348. };
  1349. exports.importCssStylsheet = function(uri, doc) {
  1350. if (doc.createStyleSheet) {
  1351. doc.createStyleSheet(uri);
  1352. } else {
  1353. var link = exports.createElement('link');
  1354. link.rel = 'stylesheet';
  1355. link.href = uri;
  1356. var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
  1357. head.appendChild(link);
  1358. }
  1359. };
  1360. exports.getInnerWidth = function(element) {
  1361. return (
  1362. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  1363. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  1364. element.clientWidth
  1365. );
  1366. };
  1367. exports.getInnerHeight = function(element) {
  1368. return (
  1369. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  1370. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  1371. element.clientHeight
  1372. );
  1373. };
  1374. if (window.pageYOffset !== undefined) {
  1375. exports.getPageScrollTop = function() {
  1376. return window.pageYOffset;
  1377. };
  1378. exports.getPageScrollLeft = function() {
  1379. return window.pageXOffset;
  1380. };
  1381. }
  1382. else {
  1383. exports.getPageScrollTop = function() {
  1384. return document.body.scrollTop;
  1385. };
  1386. exports.getPageScrollLeft = function() {
  1387. return document.body.scrollLeft;
  1388. };
  1389. }
  1390. if (window.getComputedStyle)
  1391. exports.computedStyle = function(element, style) {
  1392. if (style)
  1393. return (window.getComputedStyle(element, "") || {})[style] || "";
  1394. return window.getComputedStyle(element, "") || {};
  1395. };
  1396. else
  1397. exports.computedStyle = function(element, style) {
  1398. if (style)
  1399. return element.currentStyle[style];
  1400. return element.currentStyle;
  1401. };
  1402. exports.scrollbarWidth = function(document) {
  1403. var inner = exports.createElement("p");
  1404. inner.style.width = "100%";
  1405. inner.style.minWidth = "0px";
  1406. inner.style.height = "200px";
  1407. var outer = exports.createElement("div");
  1408. var style = outer.style;
  1409. style.position = "absolute";
  1410. style.left = "-10000px";
  1411. style.overflow = "hidden";
  1412. style.width = "200px";
  1413. style.minWidth = "0px";
  1414. style.height = "150px";
  1415. outer.appendChild(inner);
  1416. var body = document.body || document.documentElement;
  1417. body.appendChild(outer);
  1418. var noScrollbar = inner.offsetWidth;
  1419. style.overflow = "scroll";
  1420. var withScrollbar = inner.offsetWidth;
  1421. if (noScrollbar == withScrollbar) {
  1422. withScrollbar = outer.clientWidth;
  1423. }
  1424. body.removeChild(outer);
  1425. return noScrollbar-withScrollbar;
  1426. };
  1427. exports.setInnerHtml = function(el, innerHtml) {
  1428. var element = el.cloneNode(false);//document.createElement("div");
  1429. element.innerHTML = innerHtml;
  1430. el.parentNode.replaceChild(element, el);
  1431. return element;
  1432. };
  1433. exports.setInnerText = function(el, innerText) {
  1434. var document = el.ownerDocument;
  1435. if (document.body && "textContent" in document.body)
  1436. el.textContent = innerText;
  1437. else
  1438. el.innerText = innerText;
  1439. };
  1440. exports.getInnerText = function(el) {
  1441. var document = el.ownerDocument;
  1442. if (document.body && "textContent" in document.body)
  1443. return el.textContent;
  1444. else
  1445. return el.innerText || el.textContent || "";
  1446. };
  1447. exports.getParentWindow = function(document) {
  1448. return document.defaultView || document.parentWindow;
  1449. };
  1450. });
  1451. ace.define('ace/lib/event', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
  1452. var keys = require("./keys");
  1453. var useragent = require("./useragent");
  1454. var dom = require("./dom");
  1455. exports.addListener = function(elem, type, callback) {
  1456. if (elem.addEventListener) {
  1457. return elem.addEventListener(type, callback, false);
  1458. }
  1459. if (elem.attachEvent) {
  1460. var wrapper = function() {
  1461. callback(window.event);
  1462. };
  1463. callback._wrapper = wrapper;
  1464. elem.attachEvent("on" + type, wrapper);
  1465. }
  1466. };
  1467. exports.removeListener = function(elem, type, callback) {
  1468. if (elem.removeEventListener) {
  1469. return elem.removeEventListener(type, callback, false);
  1470. }
  1471. if (elem.detachEvent) {
  1472. elem.detachEvent("on" + type, callback._wrapper || callback);
  1473. }
  1474. };
  1475. exports.stopEvent = function(e) {
  1476. exports.stopPropagation(e);
  1477. exports.preventDefault(e);
  1478. return false;
  1479. };
  1480. exports.stopPropagation = function(e) {
  1481. if (e.stopPropagation)
  1482. e.stopPropagation();
  1483. else
  1484. e.cancelBubble = true;
  1485. };
  1486. exports.preventDefault = function(e) {
  1487. if (e.preventDefault)
  1488. e.preventDefault();
  1489. else
  1490. e.returnValue = false;
  1491. };
  1492. exports.getButton = function(e) {
  1493. if (e.type == "dblclick")
  1494. return 0;
  1495. if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac))
  1496. return 2;
  1497. // DOM Event
  1498. if (e.preventDefault) {
  1499. return e.button;
  1500. }
  1501. // old IE
  1502. else {
  1503. return {1:0, 2:2, 4:1}[e.button];
  1504. }
  1505. };
  1506. if (document.documentElement.setCapture) {
  1507. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1508. function onMouseMove(e) {
  1509. eventHandler(e);
  1510. return exports.stopPropagation(e);
  1511. }
  1512. var called = false;
  1513. function onReleaseCapture(e) {
  1514. eventHandler(e);
  1515. if (!called) {
  1516. called = true;
  1517. releaseCaptureHandler(e);
  1518. }
  1519. exports.removeListener(el, "mousemove", eventHandler);
  1520. exports.removeListener(el, "mouseup", onReleaseCapture);
  1521. exports.removeListener(el, "losecapture", onReleaseCapture);
  1522. el.releaseCapture();
  1523. }
  1524. exports.addListener(el, "mousemove", eventHandler);
  1525. exports.addListener(el, "mouseup", onReleaseCapture);
  1526. exports.addListener(el, "losecapture", onReleaseCapture);
  1527. el.setCapture();
  1528. };
  1529. }
  1530. else {
  1531. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1532. function onMouseMove(e) {
  1533. eventHandler(e);
  1534. e.stopPropagation();
  1535. }
  1536. function onMouseUp(e) {
  1537. eventHandler && eventHandler(e);
  1538. releaseCaptureHandler && releaseCaptureHandler(e);
  1539. document.removeEventListener("mousemove", onMouseMove, true);
  1540. document.removeEventListener("mouseup", onMouseUp, true);
  1541. e.stopPropagation();
  1542. }
  1543. document.addEventListener("mousemove", onMouseMove, true);
  1544. document.addEventListener("mouseup", onMouseUp, true);
  1545. };
  1546. }
  1547. exports.addMouseWheelListener = function(el, callback) {
  1548. var factor = 8;
  1549. var listener = function(e) {
  1550. if (e.wheelDelta !== undefined) {
  1551. if (e.wheelDeltaX !== undefined) {
  1552. e.wheelX = -e.wheelDeltaX / factor;
  1553. e.wheelY = -e.wheelDeltaY / factor;
  1554. } else {
  1555. e.wheelX = 0;
  1556. e.wheelY = -e.wheelDelta / factor;
  1557. }
  1558. }
  1559. else {
  1560. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1561. e.wheelX = (e.detail || 0) * 5;
  1562. e.wheelY = 0;
  1563. } else {
  1564. e.wheelX = 0;
  1565. e.wheelY = (e.detail || 0) * 5;
  1566. }
  1567. }
  1568. callback(e);
  1569. };
  1570. exports.addListener(el, "DOMMouseScroll", listener);
  1571. exports.addListener(el, "mousewheel", listener);
  1572. };
  1573. exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
  1574. var clicks = 0;
  1575. var startX, startY, timer;
  1576. var eventNames = {
  1577. 2: "dblclick",
  1578. 3: "tripleclick",
  1579. 4: "quadclick"
  1580. };
  1581. var listener = function(e) {
  1582. if (exports.getButton(e) != 0) {
  1583. clicks = 0;
  1584. } else {
  1585. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1586. if (!timer || isNewClick)
  1587. clicks = 0;
  1588. clicks += 1;
  1589. if (timer)
  1590. clearTimeout(timer)
  1591. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1592. }
  1593. if (clicks == 1) {
  1594. startX = e.clientX;
  1595. startY = e.clientY;
  1596. }
  1597. eventHandler[callbackName]("mousedown", e);
  1598. if (clicks > 4)
  1599. clicks = 0;
  1600. else if (clicks > 1)
  1601. return eventHandler[callbackName](eventNames[clicks], e);
  1602. };
  1603. exports.addListener(el, "mousedown", listener);
  1604. useragent.isOldIE && exports.addListener(el, "dblclick", listener);
  1605. };
  1606. function normalizeCommandKeys(callback, e, keyCode) {
  1607. var hashId = 0;
  1608. if (useragent.isOpera && useragent.isMac) {
  1609. hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
  1610. | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1611. } else {
  1612. hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0)
  1613. | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1614. }
  1615. if (keyCode in keys.MODIFIER_KEYS) {
  1616. switch (keys.MODIFIER_KEYS[keyCode]) {
  1617. case "Alt":
  1618. hashId = 2;
  1619. break;
  1620. case "Shift":
  1621. hashId = 4;
  1622. break;
  1623. case "Ctrl":
  1624. hashId = 1;
  1625. break;
  1626. default:
  1627. hashId = 8;
  1628. break;
  1629. }
  1630. keyCode = 0;
  1631. }
  1632. if (hashId & 8 && (keyCode == 91 || keyCode == 93)) {
  1633. keyCode = 0;
  1634. }
  1635. // If there is no hashID and the keyCode is not a function key, then
  1636. // we don't call the callback as we don't handle a command key here
  1637. // (it's a normal key/character input).
  1638. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1639. return false;
  1640. }
  1641. return callback(e, hashId, keyCode);
  1642. }
  1643. exports.addCommandKeyListener = function(el, callback) {
  1644. var addListener = exports.addListener;
  1645. if (useragent.isOldGecko || useragent.isOpera) {
  1646. // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
  1647. // event if the user pressed the key for a longer time. Instead, the
  1648. // keydown event was fired once and later on only the keypress event.
  1649. // To emulate the 'right' keydown behavior, the keyCode of the initial
  1650. // keyDown event is stored and in the following keypress events the
  1651. // stores keyCode is used to emulate a keyDown event.
  1652. var lastKeyDownKeyCode = null;
  1653. addListener(el, "keydown", function(e) {
  1654. lastKeyDownKeyCode = e.keyCode;
  1655. });
  1656. addListener(el, "keypress", function(e) {
  1657. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1658. });
  1659. } else {
  1660. var lastDown = null;
  1661. addListener(el, "keydown", function(e) {
  1662. lastDown = e.keyIdentifier || e.keyCode;
  1663. return normalizeCommandKeys(callback, e, e.keyCode);
  1664. });
  1665. }
  1666. };
  1667. if (window.postMessage) {
  1668. var postMessageId = 1;
  1669. exports.nextTick = function(callback, win) {
  1670. win = win || window;
  1671. var messageName = "zero-timeout-message-" + postMessageId;
  1672. exports.addListener(win, "message", function listener(e) {
  1673. if (e.data == messageName) {
  1674. exports.stopPropagation(e);
  1675. exports.removeListener(win, "message", listener);
  1676. callback();
  1677. }
  1678. });
  1679. win.postMessage(messageName, "*");
  1680. };
  1681. }
  1682. else {
  1683. exports.nextTick = function(callback, win) {
  1684. win = win || window;
  1685. window.setTimeout(callback, 0);
  1686. };
  1687. }
  1688. });
  1689. // Most of the following code is taken from SproutCore with a few changes.
  1690. ace.define('ace/lib/keys', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
  1691. var oop = require("./oop");
  1692. var Keys = (function() {
  1693. var ret = {
  1694. MODIFIER_KEYS: {
  1695. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1696. },
  1697. KEY_MODS: {
  1698. "ctrl": 1, "alt": 2, "option" : 2,
  1699. "shift": 4, "meta": 8, "command": 8
  1700. },
  1701. FUNCTION_KEYS : {
  1702. 8 : "Backspace",
  1703. 9 : "Tab",
  1704. 13 : "Return",
  1705. 19 : "Pause",
  1706. 27 : "Esc",
  1707. 32 : "Space",
  1708. 33 : "PageUp",
  1709. 34 : "PageDown",
  1710. 35 : "End",
  1711. 36 : "Home",
  1712. 37 : "Left",
  1713. 38 : "Up",
  1714. 39 : "Right",
  1715. 40 : "Down",
  1716. 44 : "Print",
  1717. 45 : "Insert",
  1718. 46 : "Delete",
  1719. 96 : "Numpad0",
  1720. 97 : "Numpad1",
  1721. 98 : "Numpad2",
  1722. 99 : "Numpad3",
  1723. 100: "Numpad4",
  1724. 101: "Numpad5",
  1725. 102: "Numpad6",
  1726. 103: "Numpad7",
  1727. 104: "Numpad8",
  1728. 105: "Numpad9",
  1729. 112: "F1",
  1730. 113: "F2",
  1731. 114: "F3",
  1732. 115: "F4",
  1733. 116: "F5",
  1734. 117: "F6",
  1735. 118: "F7",
  1736. 119: "F8",
  1737. 120: "F9",
  1738. 121: "F10",
  1739. 122: "F11",
  1740. 123: "F12",
  1741. 144: "Numlock",
  1742. 145: "Scrolllock"
  1743. },
  1744. PRINTABLE_KEYS: {
  1745. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1746. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1747. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1748. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1749. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1750. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1751. 188: ',', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\',
  1752. 221: ']', 222: '\''
  1753. }
  1754. };
  1755. // A reverse map of FUNCTION_KEYS
  1756. for (var i in ret.FUNCTION_KEYS) {
  1757. var name = ret.FUNCTION_KEYS[i].toUpperCase();
  1758. ret[name] = parseInt(i, 10);
  1759. }
  1760. // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY
  1761. // variables as well.
  1762. oop.mixin(ret, ret.MODIFIER_KEYS);
  1763. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1764. oop.mixin(ret, ret.FUNCTION_KEYS);
  1765. return ret;
  1766. })();
  1767. oop.mixin(exports, Keys);
  1768. exports.keyCodeToString = function(keyCode) {
  1769. return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
  1770. }
  1771. });
  1772. ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
  1773. exports.inherits = (function() {
  1774. var tempCtor = function() {};
  1775. return function(ctor, superCtor) {
  1776. tempCtor.prototype = superCtor.prototype;
  1777. ctor.super_ = superCtor.prototype;
  1778. ctor.prototype = new tempCtor();
  1779. ctor.prototype.constructor = ctor;
  1780. };
  1781. }());
  1782. exports.mixin = function(obj, mixin) {
  1783. for (var key in mixin) {
  1784. obj[key] = mixin[key];
  1785. }
  1786. };
  1787. exports.implement = function(proto, mixin) {
  1788. exports.mixin(proto, mixin);
  1789. };
  1790. });
  1791. ace.define('ace/lib/useragent', ['require', 'exports', 'module' ], function(require, exports, module) {
  1792. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1793. var ua = navigator.userAgent;
  1794. // Is the user using a browser that identifies itself as Windows
  1795. exports.isWin = (os == "win");
  1796. // Is the user using a browser that identifies itself as Mac OS
  1797. exports.isMac = (os == "mac");
  1798. // Is the user using a browser that identifies itself as Linux
  1799. exports.isLinux = (os == "linux");
  1800. exports.isIE =
  1801. navigator.appName == "Microsoft Internet Explorer"
  1802. && parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]);
  1803. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1804. // Is this Firefox or related?
  1805. exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
  1806. // oldGecko == rev < 2.0
  1807. exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1808. // Is this Opera
  1809. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1810. // Is the user using a browser that identifies itself as WebKit
  1811. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1812. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1813. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1814. exports.isIPad = ua.indexOf("iPad") >= 0;
  1815. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1816. exports.OS = {
  1817. LINUX: "LINUX",
  1818. MAC: "MAC",
  1819. WINDOWS: "WINDOWS"
  1820. };
  1821. exports.getOS = function() {
  1822. if (exports.isMac) {
  1823. return exports.OS.MAC;
  1824. } else if (exports.isLinux) {
  1825. return exports.OS.LINUX;
  1826. } else {
  1827. return exports.OS.WINDOWS;
  1828. }
  1829. };
  1830. });
  1831. ace.define('ace/editor', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/oop', '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'], function(require, exports, module) {
  1832. require("./lib/fixoldbrowsers");
  1833. var oop = require("./lib/oop");
  1834. var lang = require("./lib/lang");
  1835. var useragent = require("./lib/useragent");
  1836. var TextInput = require("./keyboard/textinput").TextInput;
  1837. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  1838. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  1839. //var TouchHandler = require("./touch_handler").TouchHandler;
  1840. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  1841. var EditSession = require("./edit_session").EditSession;
  1842. var Search = require("./search").Search;
  1843. var Range = require("./range").Range;
  1844. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  1845. var CommandManager = require("./commands/command_manager").CommandManager;
  1846. var defaultCommands = require("./commands/default_commands").commands;
  1847. /**
  1848. * new Editor(renderer, session)
  1849. * - renderer (VirtualRenderer): Associated `VirtualRenderer` that draws everything
  1850. * - session (EditSession): The `EditSession` to refer to
  1851. *
  1852. * Creates a new `Editor` object.
  1853. *
  1854. **/
  1855. var Editor = function(renderer, session) {
  1856. var container = renderer.getContainerElement();
  1857. this.container = container;
  1858. this.renderer = renderer;
  1859. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  1860. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  1861. this.renderer.textarea = this.textInput.getElement();
  1862. this.keyBinding = new KeyBinding(this);
  1863. // TODO detect touch event support
  1864. if (useragent.isIPad) {
  1865. //this.$mouseHandler = new TouchHandler(this);
  1866. } else {
  1867. this.$mouseHandler = new MouseHandler(this);
  1868. new FoldHandler(this);
  1869. }
  1870. this.$blockScrolling = 0;
  1871. this.$search = new Search().set({
  1872. wrap: true
  1873. });
  1874. this.setSession(session || new EditSession(""));
  1875. };
  1876. (function(){
  1877. oop.implement(this, EventEmitter);
  1878. this.setKeyboardHandler = function(keyboardHandler) {
  1879. this.keyBinding.setKeyboardHandler(keyboardHandler);
  1880. };
  1881. this.getKeyboardHandler = function() {
  1882. return this.keyBinding.getKeyboardHandler();
  1883. };
  1884. this.setSession = function(session) {
  1885. if (this.session == session)
  1886. return;
  1887. if (this.session) {
  1888. var oldSession = this.session;
  1889. this.session.removeEventListener("change", this.$onDocumentChange);
  1890. this.session.removeEventListener("changeMode", this.$onChangeMode);
  1891. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  1892. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  1893. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  1894. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  1895. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  1896. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  1897. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  1898. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  1899. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  1900. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  1901. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  1902. this.session.removeEventListener("changeLeftTop", this.$onScrollLeftChange);
  1903. var selection = this.session.getSelection();
  1904. selection.removeEventListener("changeCursor", this.$onCursorChange);
  1905. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  1906. }
  1907. this.session = session;
  1908. this.$onDocumentChange = this.onDocumentChange.bind(this);
  1909. session.addEventListener("change", this.$onDocumentChange);
  1910. this.renderer.setSession(session);
  1911. this.$onChangeMode = this.onChangeMode.bind(this);
  1912. session.addEventListener("changeMode", this.$onChangeMode);
  1913. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  1914. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  1915. this.$onChangeTabSize = this.renderer.updateText.bind(this.renderer);
  1916. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  1917. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  1918. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  1919. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  1920. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  1921. this.$onChangeFold = this.onChangeFold.bind(this);
  1922. session.addEventListener("changeFold", this.$onChangeFold);
  1923. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  1924. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  1925. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  1926. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  1927. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  1928. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  1929. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  1930. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  1931. this.$onCursorChange = this.onCursorChange.bind(this);
  1932. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  1933. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  1934. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  1935. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  1936. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  1937. this.selection = session.getSelection();
  1938. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  1939. this.$onSelectionChange = this.onSelectionChange.bind(this);
  1940. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  1941. this.onChangeMode();
  1942. this.$blockScrolling += 1;
  1943. this.onCursorChange();
  1944. this.$blockScrolling -= 1;
  1945. this.onScrollTopChange();
  1946. this.onScrollLeftChange();
  1947. this.onSelectionChange();
  1948. this.onChangeFrontMarker();
  1949. this.onChangeBackMarker();
  1950. this.onChangeBreakpoint();
  1951. this.onChangeAnnotation();
  1952. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  1953. this.renderer.updateFull();
  1954. this._emit("changeSession", {
  1955. session: session,
  1956. oldSession: oldSession
  1957. });
  1958. };
  1959. this.getSession = function() {
  1960. return this.session;
  1961. };
  1962. this.setValue = function(val, cursorPos) {
  1963. this.session.doc.setValue(val);
  1964. if (!cursorPos)
  1965. this.selectAll();
  1966. else if (cursorPos == 1)
  1967. this.navigateFileEnd();
  1968. else if (cursorPos == -1)
  1969. this.navigateFileStart();
  1970. return val;
  1971. };
  1972. this.getValue = function() {
  1973. return this.session.getValue();
  1974. };
  1975. this.getSelection = function() {
  1976. return this.selection;
  1977. };
  1978. this.resize = function(force) {
  1979. this.renderer.onResize(force);
  1980. };
  1981. this.setTheme = function(theme) {
  1982. this.renderer.setTheme(theme);
  1983. };
  1984. this.getTheme = function() {
  1985. return this.renderer.getTheme();
  1986. };
  1987. this.setStyle = function(style) {
  1988. this.renderer.setStyle(style);
  1989. };
  1990. this.unsetStyle = function(style) {
  1991. this.renderer.unsetStyle(style);
  1992. };
  1993. this.setFontSize = function(size) {
  1994. this.container.style.fontSize = size;
  1995. this.renderer.updateFontSize();
  1996. };
  1997. this.$highlightBrackets = function() {
  1998. if (this.session.$bracketHighlight) {
  1999. this.session.removeMarker(this.session.$bracketHighlight);
  2000. this.session.$bracketHighlight = null;
  2001. }
  2002. if (this.$highlightPending) {
  2003. return;
  2004. }
  2005. // perform highlight async to not block the browser during navigation
  2006. var self = this;
  2007. this.$highlightPending = true;
  2008. setTimeout(function() {
  2009. self.$highlightPending = false;
  2010. var pos = self.session.findMatchingBracket(self.getCursorPosition());
  2011. if (pos) {
  2012. var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
  2013. self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
  2014. }
  2015. }, 10);
  2016. };
  2017. this.focus = function() {
  2018. // Safari needs the timeout
  2019. // iOS and Firefox need it called immediately
  2020. // to be on the save side we do both
  2021. var _self = this;
  2022. setTimeout(function() {
  2023. _self.textInput.focus();
  2024. });
  2025. this.textInput.focus();
  2026. };
  2027. this.isFocused = function() {
  2028. return this.textInput.isFocused();
  2029. };
  2030. this.blur = function() {
  2031. this.textInput.blur();
  2032. };
  2033. this.onFocus = function() {
  2034. if (this.$isFocused)
  2035. return;
  2036. this.$isFocused = true;
  2037. this.renderer.showCursor();
  2038. this.renderer.visualizeFocus();
  2039. this._emit("focus");
  2040. };
  2041. this.onBlur = function() {
  2042. if (!this.$isFocused)
  2043. return;
  2044. this.$isFocused = false;
  2045. this.renderer.hideCursor();
  2046. this.renderer.visualizeBlur();
  2047. this._emit("blur");
  2048. };
  2049. this.$cursorChange = function() {
  2050. this.renderer.updateCursor();
  2051. };
  2052. this.onDocumentChange = function(e) {
  2053. var delta = e.data;
  2054. var range = delta.range;
  2055. var lastRow;
  2056. if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
  2057. lastRow = range.end.row;
  2058. else
  2059. lastRow = Infinity;
  2060. this.renderer.updateLines(range.start.row, lastRow);
  2061. this._emit("change", e);
  2062. // update cursor because tab characters can influence the cursor position
  2063. this.$cursorChange();
  2064. };
  2065. this.onTokenizerUpdate = function(e) {
  2066. var rows = e.data;
  2067. this.renderer.updateLines(rows.first, rows.last);
  2068. };
  2069. this.onScrollTopChange = function() {
  2070. this.renderer.scrollToY(this.session.getScrollTop());
  2071. };
  2072. this.onScrollLeftChange = function() {
  2073. this.renderer.scrollToX(this.session.getScrollLeft());
  2074. };
  2075. this.onCursorChange = function() {
  2076. this.$cursorChange();
  2077. if (!this.$blockScrolling) {
  2078. this.renderer.scrollCursorIntoView();
  2079. }
  2080. this.$highlightBrackets();
  2081. this.$updateHighlightActiveLine();
  2082. };
  2083. this.$updateHighlightActiveLine = function() {
  2084. var session = this.getSession();
  2085. if (session.$highlightLineMarker)
  2086. session.removeMarker(session.$highlightLineMarker);
  2087. session.$highlightLineMarker = null;
  2088. if (this.$highlightActiveLine) {
  2089. var cursor = this.getCursorPosition();
  2090. var foldLine = this.session.getFoldLine(cursor.row);
  2091. if ((this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) {
  2092. var range;
  2093. if (foldLine) {
  2094. range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0);
  2095. } else {
  2096. range = new Range(cursor.row, 0, cursor.row+1, 0);
  2097. }
  2098. session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background");
  2099. }
  2100. }
  2101. };
  2102. this.onSelectionChange = function(e) {
  2103. var session = this.session;
  2104. if (session.$selectionMarker) {
  2105. session.removeMarker(session.$selectionMarker);
  2106. }
  2107. session.$selectionMarker = null;
  2108. if (!this.selection.isEmpty()) {
  2109. var range = this.selection.getRange();
  2110. var style = this.getSelectionStyle();
  2111. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  2112. } else {
  2113. this.$updateHighlightActiveLine();
  2114. }
  2115. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()
  2116. this.session.highlight(re);
  2117. };
  2118. this.$getSelectionHighLightRegexp = function() {
  2119. var session = this.session;
  2120. var selection = this.getSelectionRange();
  2121. if (selection.isEmpty() || selection.isMultiLine())
  2122. return;
  2123. var startOuter = selection.start.column - 1;
  2124. var endOuter = selection.end.column + 1;
  2125. var line = session.getLine(selection.start.row);
  2126. var lineCols = line.length;
  2127. var needle = line.substring(Math.max(startOuter, 0),
  2128. Math.min(endOuter, lineCols));
  2129. // Make sure the outer characters are not part of the word.
  2130. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  2131. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  2132. return;
  2133. needle = line.substring(selection.start.column, selection.end.column);
  2134. if (!/^[\w\d]+$/.test(needle))
  2135. return;
  2136. var re = this.$search.$assembleRegExp({
  2137. wholeWord: true,
  2138. caseSensitive: true,
  2139. needle: needle
  2140. });
  2141. return re;
  2142. };
  2143. this.onChangeFrontMarker = function() {
  2144. this.renderer.updateFrontMarkers();
  2145. };
  2146. this.onChangeBackMarker = function() {
  2147. this.renderer.updateBackMarkers();
  2148. };
  2149. this.onChangeBreakpoint = function() {
  2150. this.renderer.updateBreakpoints();
  2151. };
  2152. this.onChangeAnnotation = function() {
  2153. this.renderer.setAnnotations(this.session.getAnnotations());
  2154. };
  2155. this.onChangeMode = function() {
  2156. this.renderer.updateText();
  2157. };
  2158. this.onChangeWrapLimit = function() {
  2159. this.renderer.updateFull();
  2160. };
  2161. this.onChangeWrapMode = function() {
  2162. this.renderer.onResize(true);
  2163. };
  2164. this.onChangeFold = function() {
  2165. // Update the active line marker as due to folding changes the current
  2166. // line range on the screen might have changed.
  2167. this.$updateHighlightActiveLine();
  2168. // TODO: This might be too much updating. Okay for now.
  2169. this.renderer.updateFull();
  2170. };
  2171. this.getCopyText = function() {
  2172. var text = "";
  2173. if (!this.selection.isEmpty())
  2174. text = this.session.getTextRange(this.getSelectionRange());
  2175. this._emit("copy", text);
  2176. return text;
  2177. };
  2178. this.onCopy = function() {
  2179. this.commands.exec("copy", this);
  2180. };
  2181. this.onCut = function() {
  2182. this.commands.exec("cut", this);
  2183. };
  2184. this.onPaste = function(text) {
  2185. this._emit("paste", text);
  2186. this.insert(text);
  2187. };
  2188. this.insert = function(text) {
  2189. var session = this.session;
  2190. var mode = session.getMode();
  2191. var cursor = this.getCursorPosition();
  2192. if (this.getBehavioursEnabled()) {
  2193. // Get a transform if the current mode wants one.
  2194. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  2195. if (transform)
  2196. text = transform.text;
  2197. }
  2198. text = text.replace("\t", this.session.getTabString());
  2199. // remove selected text
  2200. if (!this.selection.isEmpty()) {
  2201. cursor = this.session.remove(this.getSelectionRange());
  2202. this.clearSelection();
  2203. }
  2204. else if (this.session.getOverwrite()) {
  2205. var range = new Range.fromPoints(cursor, cursor);
  2206. range.end.column += text.length;
  2207. this.session.remove(range);
  2208. }
  2209. this.clearSelection();
  2210. var start = cursor.column;
  2211. var lineState = session.getState(cursor.row);
  2212. var shouldOutdent = mode.checkOutdent(lineState, session.getLine(cursor.row), text);
  2213. var line = session.getLine(cursor.row);
  2214. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  2215. var end = session.insert(cursor, text);
  2216. if (transform && transform.selection) {
  2217. if (transform.selection.length == 2) { // Transform relative to the current column
  2218. this.selection.setSelectionRange(
  2219. new Range(cursor.row, start + transform.selection[0],
  2220. cursor.row, start + transform.selection[1]));
  2221. } else { // Transform relative to the current row.
  2222. this.selection.setSelectionRange(
  2223. new Range(cursor.row + transform.selection[0],
  2224. transform.selection[1],
  2225. cursor.row + transform.selection[2],
  2226. transform.selection[3]));
  2227. }
  2228. }
  2229. var lineState = session.getState(cursor.row);
  2230. // TODO disabled multiline auto indent
  2231. // possibly doing the indent before inserting the text
  2232. // if (cursor.row !== end.row) {
  2233. if (session.getDocument().isNewLine(text)) {
  2234. this.moveCursorTo(cursor.row+1, 0);
  2235. var size = session.getTabSize();
  2236. var minIndent = Number.MAX_VALUE;
  2237. for (var row = cursor.row + 1; row <= end.row; ++row) {
  2238. var indent = 0;
  2239. line = session.getLine(row);
  2240. for (var i = 0; i < line.length; ++i)
  2241. if (line.charAt(i) == '\t')
  2242. indent += size;
  2243. else if (line.charAt(i) == ' ')
  2244. indent += 1;
  2245. else
  2246. break;
  2247. if (/[^\s]/.test(line))
  2248. minIndent = Math.min(indent, minIndent);
  2249. }
  2250. for (var row = cursor.row + 1; row <= end.row; ++row) {
  2251. var outdent = minIndent;
  2252. line = session.getLine(row);
  2253. for (var i = 0; i < line.length && outdent > 0; ++i)
  2254. if (line.charAt(i) == '\t')
  2255. outdent -= size;
  2256. else if (line.charAt(i) == ' ')
  2257. outdent -= 1;
  2258. session.remove(new Range(row, 0, row, i));
  2259. }
  2260. session.indentRows(cursor.row + 1, end.row, lineIndent);
  2261. }
  2262. if (shouldOutdent)
  2263. mode.autoOutdent(lineState, session, cursor.row);
  2264. };
  2265. this.onTextInput = function(text) {
  2266. this.keyBinding.onTextInput(text);
  2267. };
  2268. this.onCommandKey = function(e, hashId, keyCode) {
  2269. this.keyBinding.onCommandKey(e, hashId, keyCode);
  2270. };
  2271. this.setOverwrite = function(overwrite) {
  2272. this.session.setOverwrite(overwrite);
  2273. };
  2274. this.getOverwrite = function() {
  2275. return this.session.getOverwrite();
  2276. };
  2277. this.toggleOverwrite = function() {
  2278. this.session.toggleOverwrite();
  2279. };
  2280. this.setScrollSpeed = function(speed) {
  2281. this.$mouseHandler.setScrollSpeed(speed);
  2282. };
  2283. this.getScrollSpeed = function() {
  2284. return this.$mouseHandler.getScrollSpeed();
  2285. };
  2286. this.setDragDelay = function(dragDelay) {
  2287. this.$mouseHandler.setDragDelay(dragDelay);
  2288. };
  2289. this.getDragDelay = function() {
  2290. return this.$mouseHandler.getDragDelay();
  2291. };
  2292. this.$selectionStyle = "line";
  2293. this.setSelectionStyle = function(style) {
  2294. if (this.$selectionStyle == style) return;
  2295. this.$selectionStyle = style;
  2296. this.onSelectionChange();
  2297. this._emit("changeSelectionStyle", {data: style});
  2298. };
  2299. this.getSelectionStyle = function() {
  2300. return this.$selectionStyle;
  2301. };
  2302. this.$highlightActiveLine = true;
  2303. this.setHighlightActiveLine = function(shouldHighlight) {
  2304. if (this.$highlightActiveLine == shouldHighlight)
  2305. return;
  2306. this.$highlightActiveLine = shouldHighlight;
  2307. this.$updateHighlightActiveLine();
  2308. };
  2309. this.getHighlightActiveLine = function() {
  2310. return this.$highlightActiveLine;
  2311. };
  2312. this.$highlightGutterLine = true;
  2313. this.setHighlightGutterLine = function(shouldHighlight) {
  2314. if (this.$highlightGutterLine == shouldHighlight)
  2315. return;
  2316. this.renderer.setHighlightGutterLine(shouldHighlight);
  2317. this.$highlightGutterLine = shouldHighlight;
  2318. };
  2319. this.getHighlightGutterLine = function() {
  2320. return this.$highlightGutterLine;
  2321. };
  2322. this.$highlightSelectedWord = true;
  2323. this.setHighlightSelectedWord = function(shouldHighlight) {
  2324. if (this.$highlightSelectedWord == shouldHighlight)
  2325. return;
  2326. this.$highlightSelectedWord = shouldHighlight;
  2327. this.$onSelectionChange();
  2328. };
  2329. this.getHighlightSelectedWord = function() {
  2330. return this.$highlightSelectedWord;
  2331. };
  2332. this.setAnimatedScroll = function(shouldAnimate){
  2333. this.renderer.setAnimatedScroll(shouldAnimate);
  2334. };
  2335. this.getAnimatedScroll = function(){
  2336. return this.renderer.getAnimatedScroll();
  2337. };
  2338. this.setShowInvisibles = function(showInvisibles) {
  2339. if (this.getShowInvisibles() == showInvisibles)
  2340. return;
  2341. this.renderer.setShowInvisibles(showInvisibles);
  2342. };
  2343. this.getShowInvisibles = function() {
  2344. return this.renderer.getShowInvisibles();
  2345. };
  2346. this.setShowPrintMargin = function(showPrintMargin) {
  2347. this.renderer.setShowPrintMargin(showPrintMargin);
  2348. };
  2349. this.getShowPrintMargin = function() {
  2350. return this.renderer.getShowPrintMargin();
  2351. };
  2352. this.setPrintMarginColumn = function(showPrintMargin) {
  2353. this.renderer.setPrintMarginColumn(showPrintMargin);
  2354. };
  2355. this.getPrintMarginColumn = function() {
  2356. return this.renderer.getPrintMarginColumn();
  2357. };
  2358. this.$readOnly = false;
  2359. this.setReadOnly = function(readOnly) {
  2360. this.$readOnly = readOnly;
  2361. };
  2362. this.getReadOnly = function() {
  2363. return this.$readOnly;
  2364. };
  2365. this.$modeBehaviours = true;
  2366. this.setBehavioursEnabled = function (enabled) {
  2367. this.$modeBehaviours = enabled;
  2368. };
  2369. this.getBehavioursEnabled = function () {
  2370. return this.$modeBehaviours;
  2371. };
  2372. this.setShowFoldWidgets = function(show) {
  2373. var gutter = this.renderer.$gutterLayer;
  2374. if (gutter.getShowFoldWidgets() == show)
  2375. return;
  2376. this.renderer.$gutterLayer.setShowFoldWidgets(show);
  2377. this.$showFoldWidgets = show;
  2378. this.renderer.updateFull();
  2379. };
  2380. this.getShowFoldWidgets = function() {
  2381. return this.renderer.$gutterLayer.getShowFoldWidgets();
  2382. };
  2383. this.setFadeFoldWidgets = function(show) {
  2384. this.renderer.setFadeFoldWidgets(show);
  2385. };
  2386. this.getFadeFoldWidgets = function() {
  2387. return this.renderer.getFadeFoldWidgets();
  2388. };
  2389. this.remove = function(dir) {
  2390. if (this.selection.isEmpty()){
  2391. if (dir == "left")
  2392. this.selection.selectLeft();
  2393. else
  2394. this.selection.selectRight();
  2395. }
  2396. var range = this.getSelectionRange();
  2397. if (this.getBehavioursEnabled()) {
  2398. var session = this.session;
  2399. var state = session.getState(range.start.row);
  2400. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  2401. if (new_range)
  2402. range = new_range;
  2403. }
  2404. this.session.remove(range);
  2405. this.clearSelection();
  2406. };
  2407. this.removeWordRight = function() {
  2408. if (this.selection.isEmpty())
  2409. this.selection.selectWordRight();
  2410. this.session.remove(this.getSelectionRange());
  2411. this.clearSelection();
  2412. };
  2413. this.removeWordLeft = function() {
  2414. if (this.selection.isEmpty())
  2415. this.selection.selectWordLeft();
  2416. this.session.remove(this.getSelectionRange());
  2417. this.clearSelection();
  2418. };
  2419. this.removeToLineStart = function() {
  2420. if (this.selection.isEmpty())
  2421. this.selection.selectLineStart();
  2422. this.session.remove(this.getSelectionRange());
  2423. this.clearSelection();
  2424. };
  2425. this.removeToLineEnd = function() {
  2426. if (this.selection.isEmpty())
  2427. this.selection.selectLineEnd();
  2428. var range = this.getSelectionRange();
  2429. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  2430. range.end.column = 0;
  2431. range.end.row++;
  2432. }
  2433. this.session.remove(range);
  2434. this.clearSelection();
  2435. };
  2436. this.splitLine = function() {
  2437. if (!this.selection.isEmpty()) {
  2438. this.session.remove(this.getSelectionRange());
  2439. this.clearSelection();
  2440. }
  2441. var cursor = this.getCursorPosition();
  2442. this.insert("\n");
  2443. this.moveCursorToPosition(cursor);
  2444. };
  2445. this.transposeLetters = function() {
  2446. if (!this.selection.isEmpty()) {
  2447. return;
  2448. }
  2449. var cursor = this.getCursorPosition();
  2450. var column = cursor.column;
  2451. if (column === 0)
  2452. return;
  2453. var line = this.session.getLine(cursor.row);
  2454. var swap, range;
  2455. if (column < line.length) {
  2456. swap = line.charAt(column) + line.charAt(column-1);
  2457. range = new Range(cursor.row, column-1, cursor.row, column+1);
  2458. }
  2459. else {
  2460. swap = line.charAt(column-1) + line.charAt(column-2);
  2461. range = new Range(cursor.row, column-2, cursor.row, column);
  2462. }
  2463. this.session.replace(range, swap);
  2464. };
  2465. this.toLowerCase = function() {
  2466. var originalRange = this.getSelectionRange();
  2467. if (this.selection.isEmpty()) {
  2468. this.selection.selectWord();
  2469. }
  2470. var range = this.getSelectionRange();
  2471. var text = this.session.getTextRange(range);
  2472. this.session.replace(range, text.toLowerCase());
  2473. this.selection.setSelectionRange(originalRange);
  2474. };
  2475. this.toUpperCase = function() {
  2476. var originalRange = this.getSelectionRange();
  2477. if (this.selection.isEmpty()) {
  2478. this.selection.selectWord();
  2479. }
  2480. var range = this.getSelectionRange();
  2481. var text = this.session.getTextRange(range);
  2482. this.session.replace(range, text.toUpperCase());
  2483. this.selection.setSelectionRange(originalRange);
  2484. };
  2485. this.indent = function() {
  2486. var session = this.session;
  2487. var range = this.getSelectionRange();
  2488. if (range.start.row < range.end.row || range.start.column < range.end.column) {
  2489. var rows = this.$getSelectedRows();
  2490. session.indentRows(rows.first, rows.last, "\t");
  2491. } else {
  2492. var indentString;
  2493. if (this.session.getUseSoftTabs()) {
  2494. var size = session.getTabSize(),
  2495. position = this.getCursorPosition(),
  2496. column = session.documentToScreenColumn(position.row, position.column),
  2497. count = (size - column % size);
  2498. indentString = lang.stringRepeat(" ", count);
  2499. } else
  2500. indentString = "\t";
  2501. return this.insert(indentString);
  2502. }
  2503. };
  2504. this.blockOutdent = function() {
  2505. var selection = this.session.getSelection();
  2506. this.session.outdentRows(selection.getRange());
  2507. };
  2508. this.toggleCommentLines = function() {
  2509. var state = this.session.getState(this.getCursorPosition().row);
  2510. var rows = this.$getSelectedRows();
  2511. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  2512. };
  2513. this.removeLines = function() {
  2514. var rows = this.$getSelectedRows();
  2515. var range;
  2516. if (rows.first === 0 || rows.last+1 < this.session.getLength())
  2517. range = new Range(rows.first, 0, rows.last+1, 0);
  2518. else
  2519. range = new Range(
  2520. rows.first-1, this.session.getLine(rows.first-1).length,
  2521. rows.last, this.session.getLine(rows.last).length
  2522. );
  2523. this.session.remove(range);
  2524. this.clearSelection();
  2525. };
  2526. this.duplicateSelection = function() {
  2527. var sel = this.selection;
  2528. var doc = this.session;
  2529. var range = sel.getRange();
  2530. if (range.isEmpty()) {
  2531. var row = range.start.row;
  2532. doc.duplicateLines(row, row);
  2533. } else {
  2534. var reverse = sel.isBackwards()
  2535. var point = sel.isBackwards() ? range.start : range.end;
  2536. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  2537. range.start = point;
  2538. range.end = endPoint;
  2539. sel.setSelectionRange(range, reverse)
  2540. }
  2541. };
  2542. this.moveLinesDown = function() {
  2543. this.$moveLines(function(firstRow, lastRow) {
  2544. return this.session.moveLinesDown(firstRow, lastRow);
  2545. });
  2546. };
  2547. this.moveLinesUp = function() {
  2548. this.$moveLines(function(firstRow, lastRow) {
  2549. return this.session.moveLinesUp(firstRow, lastRow);
  2550. });
  2551. };
  2552. this.moveText = function(range, toPosition) {
  2553. if (this.$readOnly)
  2554. return null;
  2555. return this.session.moveText(range, toPosition);
  2556. };
  2557. this.copyLinesUp = function() {
  2558. this.$moveLines(function(firstRow, lastRow) {
  2559. this.session.duplicateLines(firstRow, lastRow);
  2560. return 0;
  2561. });
  2562. };
  2563. this.copyLinesDown = function() {
  2564. this.$moveLines(function(firstRow, lastRow) {
  2565. return this.session.duplicateLines(firstRow, lastRow);
  2566. });
  2567. };
  2568. this.$moveLines = function(mover) {
  2569. var rows = this.$getSelectedRows();
  2570. var selection = this.selection;
  2571. if (!selection.isMultiLine()) {
  2572. var range = selection.getRange();
  2573. var reverse = selection.isBackwards();
  2574. }
  2575. var linesMoved = mover.call(this, rows.first, rows.last);
  2576. if (range) {
  2577. range.start.row += linesMoved;
  2578. range.end.row += linesMoved;
  2579. selection.setSelectionRange(range, reverse);
  2580. }
  2581. else {
  2582. selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
  2583. selection.$moveSelection(function() {
  2584. selection.moveCursorTo(rows.first+linesMoved, 0);
  2585. });
  2586. }
  2587. };
  2588. this.$getSelectedRows = function() {
  2589. var range = this.getSelectionRange().collapseRows();
  2590. return {
  2591. first: range.start.row,
  2592. last: range.end.row
  2593. };
  2594. };
  2595. this.onCompositionStart = function(text) {
  2596. this.renderer.showComposition(this.getCursorPosition());
  2597. };
  2598. this.onCompositionUpdate = function(text) {
  2599. this.renderer.setCompositionText(text);
  2600. };
  2601. this.onCompositionEnd = function() {
  2602. this.renderer.hideComposition();
  2603. };
  2604. this.getFirstVisibleRow = function() {
  2605. return this.renderer.getFirstVisibleRow();
  2606. };
  2607. this.getLastVisibleRow = function() {
  2608. return this.renderer.getLastVisibleRow();
  2609. };
  2610. this.isRowVisible = function(row) {
  2611. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  2612. };
  2613. this.isRowFullyVisible = function(row) {
  2614. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  2615. };
  2616. this.$getVisibleRowCount = function() {
  2617. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  2618. };
  2619. this.$moveByPage = function(dir, select) {
  2620. var renderer = this.renderer;
  2621. var config = this.renderer.layerConfig;
  2622. var rows = dir * Math.floor(config.height / config.lineHeight);
  2623. this.$blockScrolling++;
  2624. if (select == true) {
  2625. this.selection.$moveSelection(function(){
  2626. this.moveCursorBy(rows, 0);
  2627. });
  2628. } else if (select == false) {
  2629. this.selection.moveCursorBy(rows, 0);
  2630. this.selection.clearSelection();
  2631. }
  2632. this.$blockScrolling--;
  2633. var scrollTop = renderer.scrollTop;
  2634. renderer.scrollBy(0, rows * config.lineHeight);
  2635. if (select != null)
  2636. renderer.scrollCursorIntoView(null, 0.5);
  2637. renderer.animateScrolling(scrollTop);
  2638. };
  2639. this.selectPageDown = function() {
  2640. this.$moveByPage(1, true);
  2641. };
  2642. this.selectPageUp = function() {
  2643. this.$moveByPage(-1, true);
  2644. };
  2645. this.gotoPageDown = function() {
  2646. this.$moveByPage(1, false);
  2647. };
  2648. this.gotoPageUp = function() {
  2649. this.$moveByPage(-1, false);
  2650. };
  2651. this.scrollPageDown = function() {
  2652. this.$moveByPage(1);
  2653. };
  2654. this.scrollPageUp = function() {
  2655. this.$moveByPage(-1);
  2656. };
  2657. this.scrollToRow = function(row) {
  2658. this.renderer.scrollToRow(row);
  2659. };
  2660. this.scrollToLine = function(line, center, animate, callback) {
  2661. this.renderer.scrollToLine(line, center, animate, callback);
  2662. };
  2663. this.centerSelection = function() {
  2664. var range = this.getSelectionRange();
  2665. var pos = {
  2666. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  2667. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  2668. }
  2669. this.renderer.alignCursor(pos, 0.5);
  2670. };
  2671. this.getCursorPosition = function() {
  2672. return this.selection.getCursor();
  2673. };
  2674. this.getCursorPositionScreen = function() {
  2675. return this.session.documentToScreenPosition(this.getCursorPosition());
  2676. };
  2677. this.getSelectionRange = function() {
  2678. return this.selection.getRange();
  2679. };
  2680. this.selectAll = function() {
  2681. this.$blockScrolling += 1;
  2682. this.selection.selectAll();
  2683. this.$blockScrolling -= 1;
  2684. };
  2685. this.clearSelection = function() {
  2686. this.selection.clearSelection();
  2687. };
  2688. this.moveCursorTo = function(row, column) {
  2689. this.selection.moveCursorTo(row, column);
  2690. };
  2691. this.moveCursorToPosition = function(pos) {
  2692. this.selection.moveCursorToPosition(pos);
  2693. };
  2694. this.jumpToMatching = function(select) {
  2695. var cursor = this.getCursorPosition();
  2696. var range = this.session.getBracketRange(cursor);
  2697. if (!range) {
  2698. range = editor.find({
  2699. needle: /[{}()\[\]]/g,
  2700. preventScroll:true,
  2701. start: {row: cursor.row, column: cursor.column - 1}
  2702. });
  2703. if (!range)
  2704. return;
  2705. var pos = range.start;
  2706. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  2707. range = this.session.getBracketRange(pos);
  2708. }
  2709. pos = range && range.cursor || pos;
  2710. if (pos) {
  2711. if (select) {
  2712. if (range && range.isEqual(editor.getSelectionRange()))
  2713. this.clearSelection();
  2714. else
  2715. this.selection.selectTo(pos.row, pos.column);
  2716. } else {
  2717. this.clearSelection();
  2718. this.moveCursorTo(pos.row, pos.column);
  2719. }
  2720. }
  2721. };
  2722. this.gotoLine = function(lineNumber, column, animate) {
  2723. this.selection.clearSelection();
  2724. this.session.unfold({row: lineNumber - 1, column: column || 0});
  2725. this.$blockScrolling += 1;
  2726. this.moveCursorTo(lineNumber - 1, column || 0);
  2727. this.$blockScrolling -= 1;
  2728. if (!this.isRowFullyVisible(lineNumber - 1))
  2729. this.scrollToLine(lineNumber - 1, true, animate);
  2730. };
  2731. this.navigateTo = function(row, column) {
  2732. this.clearSelection();
  2733. this.moveCursorTo(row, column);
  2734. };
  2735. this.navigateUp = function(times) {
  2736. this.selection.clearSelection();
  2737. times = times || 1;
  2738. this.selection.moveCursorBy(-times, 0);
  2739. };
  2740. this.navigateDown = function(times) {
  2741. this.selection.clearSelection();
  2742. times = times || 1;
  2743. this.selection.moveCursorBy(times, 0);
  2744. };
  2745. this.navigateLeft = function(times) {
  2746. if (!this.selection.isEmpty()) {
  2747. var selectionStart = this.getSelectionRange().start;
  2748. this.moveCursorToPosition(selectionStart);
  2749. }
  2750. else {
  2751. times = times || 1;
  2752. while (times--) {
  2753. this.selection.moveCursorLeft();
  2754. }
  2755. }
  2756. this.clearSelection();
  2757. };
  2758. this.navigateRight = function(times) {
  2759. if (!this.selection.isEmpty()) {
  2760. var selectionEnd = this.getSelectionRange().end;
  2761. this.moveCursorToPosition(selectionEnd);
  2762. }
  2763. else {
  2764. times = times || 1;
  2765. while (times--) {
  2766. this.selection.moveCursorRight();
  2767. }
  2768. }
  2769. this.clearSelection();
  2770. };
  2771. this.navigateLineStart = function() {
  2772. this.selection.moveCursorLineStart();
  2773. this.clearSelection();
  2774. };
  2775. this.navigateLineEnd = function() {
  2776. this.selection.moveCursorLineEnd();
  2777. this.clearSelection();
  2778. };
  2779. this.navigateFileEnd = function() {
  2780. var scrollTop = this.renderer.scrollTop;
  2781. this.selection.moveCursorFileEnd();
  2782. this.clearSelection();
  2783. this.renderer.animateScrolling(scrollTop);
  2784. };
  2785. this.navigateFileStart = function() {
  2786. var scrollTop = this.renderer.scrollTop;
  2787. this.selection.moveCursorFileStart();
  2788. this.clearSelection();
  2789. this.renderer.animateScrolling(scrollTop);
  2790. };
  2791. this.navigateWordRight = function() {
  2792. this.selection.moveCursorWordRight();
  2793. this.clearSelection();
  2794. };
  2795. this.navigateWordLeft = function() {
  2796. this.selection.moveCursorWordLeft();
  2797. this.clearSelection();
  2798. };
  2799. this.replace = function(replacement, options) {
  2800. if (options)
  2801. this.$search.set(options);
  2802. var range = this.$search.find(this.session);
  2803. var replaced = 0;
  2804. if (!range)
  2805. return replaced;
  2806. if (this.$tryReplace(range, replacement)) {
  2807. replaced = 1;
  2808. }
  2809. if (range !== null) {
  2810. this.selection.setSelectionRange(range);
  2811. this.renderer.scrollSelectionIntoView(range.start, range.end);
  2812. }
  2813. return replaced;
  2814. };
  2815. this.replaceAll = function(replacement, options) {
  2816. if (options) {
  2817. this.$search.set(options);
  2818. }
  2819. var ranges = this.$search.findAll(this.session);
  2820. var replaced = 0;
  2821. if (!ranges.length)
  2822. return replaced;
  2823. this.$blockScrolling += 1;
  2824. var selection = this.getSelectionRange();
  2825. this.clearSelection();
  2826. this.selection.moveCursorTo(0, 0);
  2827. for (var i = ranges.length - 1; i >= 0; --i) {
  2828. if(this.$tryReplace(ranges[i], replacement)) {
  2829. replaced++;
  2830. }
  2831. }
  2832. this.selection.setSelectionRange(selection);
  2833. this.$blockScrolling -= 1;
  2834. return replaced;
  2835. };
  2836. this.$tryReplace = function(range, replacement) {
  2837. var input = this.session.getTextRange(range);
  2838. replacement = this.$search.replace(input, replacement);
  2839. if (replacement !== null) {
  2840. range.end = this.session.replace(range, replacement);
  2841. return range;
  2842. } else {
  2843. return null;
  2844. }
  2845. };
  2846. this.getLastSearchOptions = function() {
  2847. return this.$search.getOptions();
  2848. };
  2849. this.find = function(needle, options, animate) {
  2850. if (!options)
  2851. options = {};
  2852. if (typeof needle == "string" || needle instanceof RegExp)
  2853. options.needle = needle;
  2854. else if (typeof needle == "object")
  2855. oop.mixin(options, needle);
  2856. var range = this.selection.getRange();
  2857. if (options.needle == null) {
  2858. needle = this.session.getTextRange(range)
  2859. || this.$search.$options.needle;
  2860. if (!needle) {
  2861. range = this.session.getWordRange(range.start.row, range.start.column);
  2862. needle = this.session.getTextRange(range);
  2863. }
  2864. this.$search.set({needle: needle});
  2865. }
  2866. this.$search.set(options);
  2867. if (!options.start)
  2868. this.$search.set({start: range});
  2869. var newRange = this.$search.find(this.session);
  2870. if (options.preventScroll)
  2871. return newRange;
  2872. if (newRange) {
  2873. this.revealRange(newRange, animate);
  2874. return newRange;
  2875. }
  2876. // clear selection if nothing is found
  2877. if (options.backwards)
  2878. range.start = range.end;
  2879. else
  2880. range.end = range.start;
  2881. this.selection.setRange(range);
  2882. };
  2883. this.findNext = function(options, animate) {
  2884. this.find({skipCurrent: true, backwards: false}, options, animate);
  2885. };
  2886. this.findPrevious = function(options, animate) {
  2887. this.find(options, {skipCurrent: true, backwards: true}, animate);
  2888. };
  2889. this.revealRange = function(range, animate) {
  2890. this.$blockScrolling += 1;
  2891. this.session.unfold(range);
  2892. this.selection.setSelectionRange(range);
  2893. this.$blockScrolling -= 1;
  2894. var scrollTop = this.renderer.scrollTop;
  2895. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  2896. if (animate != false)
  2897. this.renderer.animateScrolling(scrollTop);
  2898. };
  2899. this.undo = function() {
  2900. this.$blockScrolling++;
  2901. this.session.getUndoManager().undo();
  2902. this.$blockScrolling--;
  2903. this.renderer.scrollCursorIntoView(null, 0.5);
  2904. };
  2905. this.redo = function() {
  2906. this.$blockScrolling++;
  2907. this.session.getUndoManager().redo();
  2908. this.$blockScrolling--;
  2909. this.renderer.scrollCursorIntoView(null, 0.5);
  2910. };
  2911. this.destroy = function() {
  2912. this.renderer.destroy();
  2913. };
  2914. }).call(Editor.prototype);
  2915. exports.Editor = Editor;
  2916. });
  2917. ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
  2918. exports.stringReverse = function(string) {
  2919. return string.split("").reverse().join("");
  2920. };
  2921. exports.stringRepeat = function (string, count) {
  2922. return new Array(count + 1).join(string);
  2923. };
  2924. var trimBeginRegexp = /^\s\s*/;
  2925. var trimEndRegexp = /\s\s*$/;
  2926. exports.stringTrimLeft = function (string) {
  2927. return string.replace(trimBeginRegexp, '');
  2928. };
  2929. exports.stringTrimRight = function (string) {
  2930. return string.replace(trimEndRegexp, '');
  2931. };
  2932. exports.copyObject = function(obj) {
  2933. var copy = {};
  2934. for (var key in obj) {
  2935. copy[key] = obj[key];
  2936. }
  2937. return copy;
  2938. };
  2939. exports.copyArray = function(array){
  2940. var copy = [];
  2941. for (var i=0, l=array.length; i<l; i++) {
  2942. if (array[i] && typeof array[i] == "object")
  2943. copy[i] = this.copyObject( array[i] );
  2944. else
  2945. copy[i] = array[i];
  2946. }
  2947. return copy;
  2948. };
  2949. exports.deepCopy = function (obj) {
  2950. if (typeof obj != "object") {
  2951. return obj;
  2952. }
  2953. var copy = obj.constructor();
  2954. for (var key in obj) {
  2955. if (typeof obj[key] == "object") {
  2956. copy[key] = this.deepCopy(obj[key]);
  2957. } else {
  2958. copy[key] = obj[key];
  2959. }
  2960. }
  2961. return copy;
  2962. };
  2963. exports.arrayToMap = function(arr) {
  2964. var map = {};
  2965. for (var i=0; i<arr.length; i++) {
  2966. map[arr[i]] = 1;
  2967. }
  2968. return map;
  2969. };
  2970. exports.arrayRemove = function(array, value) {
  2971. for (var i = 0; i <= array.length; i++) {
  2972. if (value === array[i]) {
  2973. array.splice(i, 1);
  2974. }
  2975. }
  2976. };
  2977. exports.escapeRegExp = function(str) {
  2978. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  2979. };
  2980. exports.getMatchOffsets = function(string, regExp) {
  2981. var matches = [];
  2982. string.replace(regExp, function(str) {
  2983. matches.push({
  2984. offset: arguments[arguments.length-2],
  2985. length: str.length
  2986. });
  2987. });
  2988. return matches;
  2989. };
  2990. exports.deferredCall = function(fcn) {
  2991. var timer = null;
  2992. var callback = function() {
  2993. timer = null;
  2994. fcn();
  2995. };
  2996. var deferred = function(timeout) {
  2997. deferred.cancel();
  2998. timer = setTimeout(callback, timeout || 0);
  2999. return deferred;
  3000. };
  3001. deferred.schedule = deferred;
  3002. deferred.call = function() {
  3003. this.cancel();
  3004. fcn();
  3005. return deferred;
  3006. };
  3007. deferred.cancel = function() {
  3008. clearTimeout(timer);
  3009. timer = null;
  3010. return deferred;
  3011. };
  3012. return deferred;
  3013. };
  3014. });
  3015. ace.define('ace/keyboard/textinput', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
  3016. var event = require("../lib/event");
  3017. var useragent = require("../lib/useragent");
  3018. var dom = require("../lib/dom");
  3019. var TextInput = function(parentNode, host) {
  3020. var text = dom.createElement("textarea");
  3021. if (useragent.isTouchPad)
  3022. text.setAttribute("x-palm-disable-auto-cap", true);
  3023. text.setAttribute("wrap", "off");
  3024. text.style.top = "-2em";
  3025. parentNode.insertBefore(text, parentNode.firstChild);
  3026. var PLACEHOLDER = useragent.isIE ? "\x01" : "\x01";
  3027. sendText();
  3028. var inCompostion = false;
  3029. var copied = false;
  3030. var pasted = false;
  3031. var tempStyle = '';
  3032. function reset(full) {
  3033. try {
  3034. if (full) {
  3035. text.value = PLACEHOLDER;
  3036. text.selectionStart = 0;
  3037. text.selectionEnd = 1;
  3038. } else
  3039. text.select();
  3040. } catch (e) {}
  3041. }
  3042. function sendText(valueToSend) {
  3043. if (!copied) {
  3044. var value = valueToSend || text.value;
  3045. if (value) {
  3046. if (value.length > 1) {
  3047. if (value.charAt(0) == PLACEHOLDER)
  3048. value = value.substr(1);
  3049. else if (value.charAt(value.length - 1) == PLACEHOLDER)
  3050. value = value.slice(0, -1);
  3051. }
  3052. if (value && value != PLACEHOLDER) {
  3053. if (pasted)
  3054. host.onPaste(value);
  3055. else
  3056. host.onTextInput(value);
  3057. }
  3058. }
  3059. }
  3060. copied = false;
  3061. pasted = false;
  3062. // Safari doesn't fire copy events if no text is selected
  3063. reset(true);
  3064. }
  3065. var onTextInput = function(e) {
  3066. if (!inCompostion)
  3067. sendText(e.data);
  3068. setTimeout(function () {
  3069. if (!inCompostion)
  3070. reset(true);
  3071. }, 0);
  3072. };
  3073. var onPropertyChange = function(e) {
  3074. setTimeout(function() {
  3075. if (!inCompostion)
  3076. sendText();
  3077. }, 0);
  3078. };
  3079. var onCompositionStart = function(e) {
  3080. inCompostion = true;
  3081. host.onCompositionStart();
  3082. setTimeout(onCompositionUpdate, 0);
  3083. };
  3084. var onCompositionUpdate = function() {
  3085. if (!inCompostion) return;
  3086. host.onCompositionUpdate(text.value);
  3087. };
  3088. var onCompositionEnd = function(e) {
  3089. inCompostion = false;
  3090. host.onCompositionEnd();
  3091. };
  3092. var onCopy = function(e) {
  3093. copied = true;
  3094. var copyText = host.getCopyText();
  3095. if(copyText)
  3096. text.value = copyText;
  3097. else
  3098. e.preventDefault();
  3099. reset();
  3100. setTimeout(function () {
  3101. sendText();
  3102. }, 0);
  3103. };
  3104. var onCut = function(e) {
  3105. copied = true;
  3106. var copyText = host.getCopyText();
  3107. if(copyText) {
  3108. text.value = copyText;
  3109. host.onCut();
  3110. } else
  3111. e.preventDefault();
  3112. reset();
  3113. setTimeout(function () {
  3114. sendText();
  3115. }, 0);
  3116. };
  3117. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  3118. event.addListener(text, "input", useragent.isIE ? onPropertyChange : onTextInput);
  3119. event.addListener(text, "paste", function(e) {
  3120. // Mark that the next input text comes from past.
  3121. pasted = true;
  3122. // Some browsers support the event.clipboardData API. Use this to get
  3123. // the pasted content which increases speed if pasting a lot of lines.
  3124. if (e.clipboardData && e.clipboardData.getData) {
  3125. sendText(e.clipboardData.getData("text/plain"));
  3126. e.preventDefault();
  3127. }
  3128. else {
  3129. // If a browser doesn't support any of the things above, use the regular
  3130. // method to detect the pasted input.
  3131. onPropertyChange();
  3132. }
  3133. });
  3134. if ("onbeforecopy" in text && typeof clipboardData !== "undefined") {
  3135. event.addListener(text, "beforecopy", function(e) {
  3136. if (tempStyle)
  3137. return; // without this text is copied when contextmenu is shown
  3138. var copyText = host.getCopyText();
  3139. if (copyText)
  3140. clipboardData.setData("Text", copyText);
  3141. else
  3142. e.preventDefault();
  3143. });
  3144. event.addListener(parentNode, "keydown", function(e) {
  3145. if (e.ctrlKey && e.keyCode == 88) {
  3146. var copyText = host.getCopyText();
  3147. if (copyText) {
  3148. clipboardData.setData("Text", copyText);
  3149. host.onCut();
  3150. }
  3151. event.preventDefault(e);
  3152. }
  3153. });
  3154. event.addListener(text, "cut", onCut); // for ie9 context menu
  3155. }
  3156. else if (useragent.isOpera) {
  3157. event.addListener(parentNode, "keydown", function(e) {
  3158. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  3159. return;
  3160. if ((e.keyCode == 88 || e.keyCode == 67)) {
  3161. var copyText = host.getCopyText();
  3162. if (copyText) {
  3163. text.value = copyText;
  3164. text.select();
  3165. if (e.keyCode == 88)
  3166. host.onCut();
  3167. }
  3168. }
  3169. });
  3170. }
  3171. else {
  3172. event.addListener(text, "copy", onCopy);
  3173. event.addListener(text, "cut", onCut);
  3174. }
  3175. event.addListener(text, "compositionstart", onCompositionStart);
  3176. if (useragent.isGecko) {
  3177. event.addListener(text, "text", onCompositionUpdate);
  3178. }
  3179. if (useragent.isWebKit) {
  3180. event.addListener(text, "keyup", onCompositionUpdate);
  3181. }
  3182. event.addListener(text, "compositionend", onCompositionEnd);
  3183. event.addListener(text, "blur", function() {
  3184. host.onBlur();
  3185. });
  3186. event.addListener(text, "focus", function() {
  3187. host.onFocus();
  3188. reset();
  3189. });
  3190. this.focus = function() {
  3191. reset();
  3192. text.focus();
  3193. };
  3194. this.blur = function() {
  3195. text.blur();
  3196. };
  3197. function isFocused() {
  3198. return document.activeElement === text;
  3199. }
  3200. this.isFocused = isFocused;
  3201. this.getElement = function() {
  3202. return text;
  3203. };
  3204. this.onContextMenu = function(e) {
  3205. if (!tempStyle)
  3206. tempStyle = text.style.cssText;
  3207. text.style.cssText =
  3208. "position:fixed; z-index:100000;" + //"background:rgba(250, 0, 0, 0.3); opacity:1;" +
  3209. "left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;";
  3210. if (host.selection.isEmpty())
  3211. text.value = "";
  3212. if (e.type != "mousedown")
  3213. return;
  3214. if (host.renderer.$keepTextAreaAtCursor)
  3215. host.renderer.$keepTextAreaAtCursor = null;
  3216. // on windows context menu is opened after mouseup
  3217. if (useragent.isGecko && useragent.isWin)
  3218. event.capture(host.container, function(e) {
  3219. text.style.left = e.clientX - 2 + "px";
  3220. text.style.top = e.clientY - 2 + "px";
  3221. }, onContextMenuClose);
  3222. };
  3223. function onContextMenuClose() {
  3224. setTimeout(function () {
  3225. if (tempStyle) {
  3226. text.style.cssText = tempStyle;
  3227. tempStyle = '';
  3228. }
  3229. sendText();
  3230. if (host.renderer.$keepTextAreaAtCursor == null) {
  3231. host.renderer.$keepTextAreaAtCursor = true;
  3232. host.renderer.$moveTextAreaToCursor();
  3233. }
  3234. }, 0);
  3235. };
  3236. this.onContextMenuClose = onContextMenuClose;
  3237. // firefox fires contextmenu event after opening it
  3238. if (!useragent.isGecko)
  3239. event.addListener(text, "contextmenu", function(e) {
  3240. host.textInput.onContextMenu(e);
  3241. onContextMenuClose()
  3242. });
  3243. };
  3244. exports.TextInput = TextInput;
  3245. });
  3246. ace.define('ace/mouse/mouse_handler', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/mouse/default_handlers', 'ace/mouse/default_gutter_handler', 'ace/mouse/mouse_event', 'ace/mouse/dragdrop'], function(require, exports, module) {
  3247. var event = require("../lib/event");
  3248. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3249. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3250. var MouseEvent = require("./mouse_event").MouseEvent;
  3251. var DragdropHandler = require("./dragdrop").DragdropHandler;
  3252. var MouseHandler = function(editor) {
  3253. this.editor = editor;
  3254. new DefaultHandlers(this);
  3255. new DefaultGutterHandler(this);
  3256. new DragdropHandler(this);
  3257. event.addListener(editor.container, "mousedown", function(e) {
  3258. editor.focus();
  3259. return event.preventDefault(e);
  3260. });
  3261. var mouseTarget = editor.renderer.getMouseEventTarget();
  3262. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3263. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3264. event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent");
  3265. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3266. var gutterEl = editor.renderer.$gutter;
  3267. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3268. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3269. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3270. event.addListener(gutterEl, "mousemove", this.onMouseMove.bind(this, "gutter"));
  3271. };
  3272. (function() {
  3273. this.$scrollSpeed = 1;
  3274. this.setScrollSpeed = function(speed) {
  3275. this.$scrollSpeed = speed;
  3276. };
  3277. this.getScrollSpeed = function() {
  3278. return this.$scrollSpeed;
  3279. };
  3280. this.onMouseEvent = function(name, e) {
  3281. this.editor._emit(name, new MouseEvent(e, this.editor));
  3282. };
  3283. this.$dragDelay = 250;
  3284. this.setDragDelay = function(dragDelay) {
  3285. this.$dragDelay = dragDelay;
  3286. };
  3287. this.getDragDelay = function() {
  3288. return this.$dragDelay;
  3289. };
  3290. this.onMouseMove = function(name, e) {
  3291. // optimization, because mousemove doesn't have a default handler.
  3292. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3293. if (!listeners || !listeners.length)
  3294. return;
  3295. this.editor._emit(name, new MouseEvent(e, this.editor));
  3296. };
  3297. this.onMouseWheel = function(name, e) {
  3298. var mouseEvent = new MouseEvent(e, this.editor);
  3299. mouseEvent.speed = this.$scrollSpeed * 2;
  3300. mouseEvent.wheelX = e.wheelX;
  3301. mouseEvent.wheelY = e.wheelY;
  3302. this.editor._emit(name, mouseEvent);
  3303. };
  3304. this.setState = function(state) {
  3305. this.state = state;
  3306. };
  3307. this.captureMouse = function(ev, state) {
  3308. if (state)
  3309. this.setState(state);
  3310. this.x = ev.x;
  3311. this.y = ev.y;
  3312. // do not move textarea during selection
  3313. var renderer = this.editor.renderer;
  3314. if (renderer.$keepTextAreaAtCursor)
  3315. renderer.$keepTextAreaAtCursor = null;
  3316. var self = this;
  3317. var onMouseMove = function(e) {
  3318. self.x = e.clientX;
  3319. self.y = e.clientY;
  3320. };
  3321. var onCaptureEnd = function(e) {
  3322. clearInterval(timerId);
  3323. self[self.state + "End"] && self[self.state + "End"](e);
  3324. self.$clickSelection = null;
  3325. if (renderer.$keepTextAreaAtCursor == null) {
  3326. renderer.$keepTextAreaAtCursor = true;
  3327. renderer.$moveTextAreaToCursor();
  3328. }
  3329. };
  3330. var onCaptureInterval = function() {
  3331. self[self.state] && self[self.state]();
  3332. }
  3333. event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3334. var timerId = setInterval(onCaptureInterval, 20);
  3335. };
  3336. }).call(MouseHandler.prototype);
  3337. exports.MouseHandler = MouseHandler;
  3338. });
  3339. ace.define('ace/mouse/default_handlers', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/useragent'], function(require, exports, module) {
  3340. var dom = require("../lib/dom");
  3341. var useragent = require("../lib/useragent");
  3342. var DRAG_OFFSET = 5; // pixels
  3343. function DefaultHandlers(mouseHandler) {
  3344. mouseHandler.$clickSelection = null;
  3345. var editor = mouseHandler.editor;
  3346. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  3347. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  3348. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  3349. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  3350. editor.setDefaultHandler("mousewheel", this.onScroll.bind(mouseHandler));
  3351. var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
  3352. "dragWaitEnd", "startDrag", "focusWait"];
  3353. exports.forEach(function(x) {
  3354. mouseHandler[x] = this[x];
  3355. }, this);
  3356. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  3357. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  3358. mouseHandler.$focusWaitTimout = 250;
  3359. }
  3360. (function() {
  3361. this.onMouseDown = function(ev) {
  3362. var inSelection = ev.inSelection();
  3363. var pos = ev.getDocumentPosition();
  3364. this.mousedownEvent = ev;
  3365. var editor = this.editor;
  3366. var _self = this;
  3367. var button = ev.getButton();
  3368. if (button !== 0) {
  3369. var selectionRange = editor.getSelectionRange();
  3370. var selectionEmpty = selectionRange.isEmpty();
  3371. if (selectionEmpty) {
  3372. editor.moveCursorToPosition(pos);
  3373. editor.selection.clearSelection();
  3374. }
  3375. // 2: contextmenu, 1: linux paste
  3376. editor.textInput.onContextMenu(ev.domEvent);
  3377. return; // stopping event here breaks contextmenu on ff mac
  3378. }
  3379. // if this click caused the editor to be focused should not clear the
  3380. // selection
  3381. if (inSelection && !editor.isFocused()) {
  3382. editor.focus();
  3383. if (this.$focusWaitTimout && !this.$clickSelection) {
  3384. this.setState("focusWait");
  3385. this.captureMouse(ev);
  3386. return ev.preventDefault();
  3387. }
  3388. }
  3389. if (!inSelection || this.$clickSelection || ev.getShiftKey()) {
  3390. // Directly pick STATE_SELECT, since the user is not clicking inside
  3391. // a selection.
  3392. this.startSelect(pos);
  3393. } else if (inSelection) {
  3394. this.mousedownEvent.time = (new Date()).getTime();
  3395. this.setState("dragWait");
  3396. }
  3397. this.captureMouse(ev);
  3398. return ev.preventDefault();
  3399. };
  3400. this.startSelect = function(pos) {
  3401. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  3402. if (this.mousedownEvent.getShiftKey()) {
  3403. this.editor.selection.selectToPosition(pos);
  3404. }
  3405. else if (!this.$clickSelection) {
  3406. this.editor.moveCursorToPosition(pos);
  3407. this.editor.selection.clearSelection();
  3408. }
  3409. this.setState("select");
  3410. }
  3411. this.select = function() {
  3412. var anchor, editor = this.editor;
  3413. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  3414. if (this.$clickSelection) {
  3415. var cmp = this.$clickSelection.comparePoint(cursor);
  3416. if (cmp == -1) {
  3417. anchor = this.$clickSelection.end;
  3418. } else if (cmp == 1) {
  3419. anchor = this.$clickSelection.start;
  3420. } else {
  3421. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  3422. cursor = orientedRange.cursor;
  3423. anchor = orientedRange.anchor;
  3424. }
  3425. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  3426. }
  3427. editor.selection.selectToPosition(cursor);
  3428. editor.renderer.scrollCursorIntoView();
  3429. };
  3430. this.extendSelectionBy = function(unitName) {
  3431. var anchor, editor = this.editor;
  3432. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  3433. var range = editor.selection[unitName](cursor.row, cursor.column);
  3434. if (this.$clickSelection) {
  3435. var cmpStart = this.$clickSelection.comparePoint(range.start);
  3436. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  3437. if (cmpStart == -1 && cmpEnd <= 0) {
  3438. anchor = this.$clickSelection.end;
  3439. cursor = range.start;
  3440. } else if (cmpEnd == 1 && cmpStart >= 0) {
  3441. anchor = this.$clickSelection.start;
  3442. cursor = range.end;
  3443. } else if (cmpStart == -1 && cmpEnd == 1) {
  3444. cursor = range.end;
  3445. anchor = range.start;
  3446. } else {
  3447. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  3448. cursor = orientedRange.cursor;
  3449. anchor = orientedRange.anchor;
  3450. }
  3451. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  3452. }
  3453. editor.selection.selectToPosition(cursor);
  3454. editor.renderer.scrollCursorIntoView();
  3455. };
  3456. this.startDrag = function() {
  3457. var editor = this.editor;
  3458. this.setState("drag");
  3459. this.dragRange = editor.getSelectionRange();
  3460. var style = editor.getSelectionStyle();
  3461. this.dragSelectionMarker = editor.session.addMarker(this.dragRange, "ace_selection", style);
  3462. editor.clearSelection();
  3463. dom.addCssClass(editor.container, "ace_dragging");
  3464. if (!this.$dragKeybinding) {
  3465. this.$dragKeybinding = {
  3466. handleKeyboard: function(data, hashId, keyString, keyCode) {
  3467. if (keyString == "esc")
  3468. return {command: this.command};
  3469. },
  3470. command: {
  3471. exec: function(editor) {
  3472. var self = editor.$mouseHandler;
  3473. self.dragCursor = null
  3474. self.dragEnd();
  3475. self.startSelect();
  3476. }
  3477. }
  3478. }
  3479. }
  3480. editor.keyBinding.addKeyboardHandler(this.$dragKeybinding);
  3481. };
  3482. this.focusWait = function() {
  3483. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  3484. var time = (new Date()).getTime();
  3485. if (distance > DRAG_OFFSET ||time - this.mousedownEvent.time > this.$focusWaitTimout)
  3486. this.startSelect();
  3487. };
  3488. this.dragWait = function(e) {
  3489. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  3490. var time = (new Date()).getTime();
  3491. var editor = this.editor;
  3492. if (distance > DRAG_OFFSET) {
  3493. this.startSelect();
  3494. } else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
  3495. this.startDrag();
  3496. }
  3497. };
  3498. this.dragWaitEnd = function(e) {
  3499. this.mousedownEvent.domEvent = e;
  3500. this.startSelect();
  3501. };
  3502. this.drag = function() {
  3503. var editor = this.editor;
  3504. this.dragCursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  3505. editor.moveCursorToPosition(this.dragCursor);
  3506. editor.renderer.scrollCursorIntoView();
  3507. };
  3508. this.dragEnd = function(e) {
  3509. var editor = this.editor;
  3510. var dragCursor = this.dragCursor;
  3511. var dragRange = this.dragRange;
  3512. dom.removeCssClass(editor.container, "ace_dragging");
  3513. editor.session.removeMarker(this.dragSelectionMarker);
  3514. editor.keyBinding.removeKeyboardHandler(this.$dragKeybinding);
  3515. if (!dragCursor)
  3516. return;
  3517. editor.clearSelection();
  3518. if (e && (e.ctrlKey || e.altKey)) {
  3519. var session = editor.session;
  3520. var newRange = dragRange;
  3521. newRange.end = session.insert(dragCursor, session.getTextRange(dragRange));
  3522. newRange.start = dragCursor;
  3523. } else if (dragRange.contains(dragCursor.row, dragCursor.column)) {
  3524. return;
  3525. } else {
  3526. var newRange = editor.moveText(dragRange, dragCursor);
  3527. }
  3528. if (!newRange)
  3529. return;
  3530. editor.selection.setSelectionRange(newRange);
  3531. };
  3532. this.onDoubleClick = function(ev) {
  3533. var pos = ev.getDocumentPosition();
  3534. var editor = this.editor;
  3535. var session = editor.session
  3536. var range = session.getBracketRange(pos);
  3537. if (range) {
  3538. if (range.isEmpty()) {
  3539. range.start.column--;
  3540. range.end.column++;
  3541. }
  3542. this.$clickSelection = range;
  3543. this.setState("select");
  3544. return;
  3545. }
  3546. this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column);
  3547. this.setState("selectByWords");
  3548. };
  3549. this.onTripleClick = function(ev) {
  3550. var pos = ev.getDocumentPosition();
  3551. var editor = this.editor;
  3552. this.setState("selectByLines");
  3553. editor.moveCursorToPosition(pos);
  3554. editor.selection.selectLine();
  3555. this.$clickSelection = editor.getSelectionRange();
  3556. };
  3557. this.onQuadClick = function(ev) {
  3558. var editor = this.editor;
  3559. editor.selectAll();
  3560. this.$clickSelection = editor.getSelectionRange();
  3561. this.setState("null");
  3562. };
  3563. this.onScroll = function(ev) {
  3564. var editor = this.editor;
  3565. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  3566. if (isScrolable) {
  3567. this.$passScrollEvent = false;
  3568. } else {
  3569. if (this.$passScrollEvent)
  3570. return;
  3571. if (!this.$scrollStopTimeout) {
  3572. var self = this;
  3573. this.$scrollStopTimeout = setTimeout(function() {
  3574. self.$passScrollEvent = true;
  3575. self.$scrollStopTimeout = null;
  3576. }, 200);
  3577. }
  3578. }
  3579. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  3580. return ev.preventDefault();
  3581. };
  3582. }).call(DefaultHandlers.prototype);
  3583. exports.DefaultHandlers = DefaultHandlers;
  3584. function calcDistance(ax, ay, bx, by) {
  3585. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  3586. }
  3587. function calcRangeOrientation(range, cursor) {
  3588. if (range.start.row == range.end.row)
  3589. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  3590. else
  3591. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  3592. if (cmp < 0)
  3593. return {cursor: range.start, anchor: range.end};
  3594. else
  3595. return {cursor: range.end, anchor: range.start};
  3596. }
  3597. });
  3598. ace.define('ace/mouse/default_gutter_handler', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
  3599. var dom = require("../lib/dom");
  3600. function GutterHandler(mouseHandler) {
  3601. var editor = mouseHandler.editor;
  3602. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  3603. var target = e.domEvent.target;
  3604. if (target.className.indexOf("ace_gutter-cell") == -1)
  3605. return;
  3606. if (!editor.isFocused())
  3607. return;
  3608. var padding = parseInt(dom.computedStyle(target).paddingLeft);
  3609. if (e.x < padding + target.getBoundingClientRect().left + 1)
  3610. return;
  3611. var row = e.getDocumentPosition().row;
  3612. var selection = editor.session.selection;
  3613. if (e.getShiftKey()) {
  3614. selection.selectTo(row, 0);
  3615. } else {
  3616. selection.moveCursorTo(row, 0);
  3617. selection.selectLine();
  3618. mouseHandler.$clickSelection = selection.getRange();
  3619. }
  3620. mouseHandler.captureMouse(e, "selectByLines");
  3621. return e.preventDefault();
  3622. });
  3623. }
  3624. exports.GutterHandler = GutterHandler;
  3625. });
  3626. ace.define('ace/mouse/mouse_event', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent'], function(require, exports, module) {
  3627. var event = require("../lib/event");
  3628. var useragent = require("../lib/useragent");
  3629. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  3630. this.domEvent = domEvent;
  3631. this.editor = editor;
  3632. this.x = this.clientX = domEvent.clientX;
  3633. this.y = this.clientY = domEvent.clientY;
  3634. this.$pos = null;
  3635. this.$inSelection = null;
  3636. this.propagationStopped = false;
  3637. this.defaultPrevented = false;
  3638. };
  3639. (function() {
  3640. this.stopPropagation = function() {
  3641. event.stopPropagation(this.domEvent);
  3642. this.propagationStopped = true;
  3643. };
  3644. this.preventDefault = function() {
  3645. event.preventDefault(this.domEvent);
  3646. this.defaultPrevented = true;
  3647. };
  3648. this.stop = function() {
  3649. this.stopPropagation();
  3650. this.preventDefault();
  3651. };
  3652. this.getDocumentPosition = function() {
  3653. if (this.$pos)
  3654. return this.$pos;
  3655. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  3656. return this.$pos;
  3657. };
  3658. this.inSelection = function() {
  3659. if (this.$inSelection !== null)
  3660. return this.$inSelection;
  3661. var editor = this.editor;
  3662. if (editor.getReadOnly()) {
  3663. this.$inSelection = false;
  3664. }
  3665. else {
  3666. var selectionRange = editor.getSelectionRange();
  3667. if (selectionRange.isEmpty())
  3668. this.$inSelection = false;
  3669. else {
  3670. var pos = this.getDocumentPosition();
  3671. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  3672. }
  3673. }
  3674. return this.$inSelection;
  3675. };
  3676. this.getButton = function() {
  3677. return event.getButton(this.domEvent);
  3678. };
  3679. this.getShiftKey = function() {
  3680. return this.domEvent.shiftKey;
  3681. };
  3682. this.getAccelKey = useragent.isMac
  3683. ? function() { return this.domEvent.metaKey; }
  3684. : function() { return this.domEvent.ctrlKey; };
  3685. }).call(MouseEvent.prototype);
  3686. });
  3687. ace.define('ace/mouse/dragdrop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
  3688. var event = require("../lib/event");
  3689. var DragdropHandler = function(mouseHandler) {
  3690. var editor = mouseHandler.editor;
  3691. var dragSelectionMarker, x, y;
  3692. var timerId, range, isBackwards;
  3693. var dragCursor, counter = 0;
  3694. var mouseTarget = editor.container;
  3695. event.addListener(mouseTarget, "dragenter", function(e) {console.log(e.type, counter,e.target);
  3696. counter++;
  3697. if (!dragSelectionMarker) {
  3698. range = editor.getSelectionRange();
  3699. isBackwards = editor.selection.isBackwards();
  3700. var style = editor.getSelectionStyle();
  3701. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", style);
  3702. editor.clearSelection();
  3703. clearInterval(timerId);
  3704. timerId = setInterval(onDragInterval, 20);
  3705. }
  3706. return event.preventDefault(e);
  3707. });
  3708. event.addListener(mouseTarget, "dragover", function(e) {
  3709. x = e.clientX;
  3710. y = e.clientY;
  3711. return event.preventDefault(e);
  3712. });
  3713. var onDragInterval = function() {
  3714. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  3715. editor.moveCursorToPosition(dragCursor);
  3716. editor.renderer.scrollCursorIntoView();
  3717. };
  3718. event.addListener(mouseTarget, "dragleave", function(e) {console.log(e.type, counter,e.target);
  3719. counter--;
  3720. if (counter > 0)
  3721. return;
  3722. console.log(e.type, counter,e.target);
  3723. clearInterval(timerId);
  3724. editor.session.removeMarker(dragSelectionMarker);
  3725. dragSelectionMarker = null;
  3726. editor.selection.setSelectionRange(range, isBackwards);
  3727. return event.preventDefault(e);
  3728. });
  3729. event.addListener(mouseTarget, "drop", function(e) {
  3730. console.log(e.type, counter,e.target);
  3731. counter = 0;
  3732. clearInterval(timerId);
  3733. editor.session.removeMarker(dragSelectionMarker);
  3734. dragSelectionMarker = null;
  3735. range.end = editor.session.insert(dragCursor, e.dataTransfer.getData('Text'));
  3736. range.start = dragCursor;
  3737. editor.focus();
  3738. editor.selection.setSelectionRange(range);
  3739. return event.preventDefault(e);
  3740. });
  3741. };
  3742. exports.DragdropHandler = DragdropHandler;
  3743. });
  3744. ace.define('ace/mouse/fold_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
  3745. function FoldHandler(editor) {
  3746. editor.on("click", function(e) {
  3747. var position = e.getDocumentPosition();
  3748. var session = editor.session;
  3749. // If the user clicked on a fold, then expand it.
  3750. var fold = session.getFoldAt(position.row, position.column, 1);
  3751. if (fold) {
  3752. if (e.getAccelKey())
  3753. session.removeFold(fold);
  3754. else
  3755. session.expandFold(fold);
  3756. e.stop();
  3757. }
  3758. });
  3759. editor.on("gutterclick", function(e) {
  3760. if (e.domEvent.target.className.indexOf("ace_fold-widget") != -1) {
  3761. var row = e.getDocumentPosition().row;
  3762. editor.session.onFoldWidgetClick(row, e.domEvent);
  3763. e.stop();
  3764. }
  3765. });
  3766. }
  3767. exports.FoldHandler = FoldHandler;
  3768. });
  3769. ace.define('ace/keyboard/keybinding', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/event'], function(require, exports, module) {
  3770. var keyUtil = require("../lib/keys");
  3771. var event = require("../lib/event");
  3772. var KeyBinding = function(editor) {
  3773. this.$editor = editor;
  3774. this.$data = { };
  3775. this.$handlers = [];
  3776. this.setDefaultHandler(editor.commands);
  3777. };
  3778. (function() {
  3779. this.setDefaultHandler = function(kb) {
  3780. this.removeKeyboardHandler(this.$defaultHandler);
  3781. this.$defaultHandler = kb;
  3782. this.addKeyboardHandler(kb, 0);
  3783. this.$data = {editor: this.$editor};
  3784. };
  3785. this.setKeyboardHandler = function(kb) {
  3786. if (this.$handlers[this.$handlers.length - 1] == kb)
  3787. return;
  3788. while (this.$handlers[1])
  3789. this.removeKeyboardHandler(this.$handlers[1]);
  3790. this.addKeyboardHandler(kb, 1);
  3791. };
  3792. this.addKeyboardHandler = function(kb, pos) {
  3793. if (!kb)
  3794. return;
  3795. var i = this.$handlers.indexOf(kb);
  3796. if (i != -1)
  3797. this.$handlers.splice(i, 1);
  3798. if (pos == undefined)
  3799. this.$handlers.push(kb);
  3800. else
  3801. this.$handlers.splice(pos, 0, kb);
  3802. if (i == -1 && kb.attach)
  3803. kb.attach(this.$editor);
  3804. };
  3805. this.removeKeyboardHandler = function(kb) {
  3806. var i = this.$handlers.indexOf(kb);
  3807. if (i == -1)
  3808. return false;
  3809. this.$handlers.splice(i, 1);
  3810. kb.detach && kb.detach(this.$editor);
  3811. return true;
  3812. };
  3813. this.getKeyboardHandler = function() {
  3814. return this.$handlers[this.$handlers.length - 1];
  3815. };
  3816. this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
  3817. var toExecute;
  3818. for (var i = this.$handlers.length; i--;) {
  3819. toExecute = this.$handlers[i].handleKeyboard(
  3820. this.$data, hashId, keyString, keyCode, e
  3821. );
  3822. if (toExecute && toExecute.command)
  3823. break;
  3824. }
  3825. if (!toExecute || !toExecute.command)
  3826. return false;
  3827. var success = false;
  3828. var commands = this.$editor.commands;
  3829. // allow keyboardHandler to consume keys
  3830. if (toExecute.command != "null")
  3831. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3832. else
  3833. success = toExecute.passEvent != true;
  3834. // do not stop input events to not break repeating
  3835. if (success && e && hashId != -1)
  3836. event.stopEvent(e);
  3837. return success;
  3838. };
  3839. this.onCommandKey = function(e, hashId, keyCode) {
  3840. var keyString = keyUtil.keyCodeToString(keyCode);
  3841. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3842. };
  3843. this.onTextInput = function(text) {
  3844. var success = this.$callKeyboardHandlers(-1, text);
  3845. if (!success)
  3846. this.$editor.commands.exec("insertstring", this.$editor, text);
  3847. };
  3848. }).call(KeyBinding.prototype);
  3849. exports.KeyBinding = KeyBinding;
  3850. });
  3851. ace.define('ace/edit_session', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/net', '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) {
  3852. var config = require("./config");
  3853. var oop = require("./lib/oop");
  3854. var lang = require("./lib/lang");
  3855. var net = require("./lib/net");
  3856. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3857. var Selection = require("./selection").Selection;
  3858. var TextMode = require("./mode/text").Mode;
  3859. var Range = require("./range").Range;
  3860. var Document = require("./document").Document;
  3861. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  3862. var SearchHighlight = require("./search_highlight").SearchHighlight;
  3863. /**
  3864. * new EditSession(text, mode)
  3865. * - text (Document | String): If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text
  3866. * - mode (TextMode): The inital language mode to use for the document
  3867. *
  3868. * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`.
  3869. *
  3870. **/
  3871. var EditSession = function(text, mode) {
  3872. this.$modified = true;
  3873. this.$breakpoints = [];
  3874. this.$frontMarkers = {};
  3875. this.$backMarkers = {};
  3876. this.$markerId = 1;
  3877. this.$resetRowCache(0);
  3878. this.$wrapData = [];
  3879. this.$foldData = [];
  3880. this.$rowLengthCache = [];
  3881. this.$undoSelect = true;
  3882. this.$foldData.toString = function() {
  3883. var str = "";
  3884. this.forEach(function(foldLine) {
  3885. str += "\n" + foldLine.toString();
  3886. });
  3887. return str;
  3888. }
  3889. if (typeof text == "object" && text.getLine) {
  3890. this.setDocument(text);
  3891. } else {
  3892. this.setDocument(new Document(text));
  3893. }
  3894. this.selection = new Selection(this);
  3895. this.setMode(mode);
  3896. };
  3897. (function() {
  3898. oop.implement(this, EventEmitter);
  3899. this.setDocument = function(doc) {
  3900. if (this.doc)
  3901. throw new Error("Document is already set");
  3902. this.doc = doc;
  3903. doc.on("change", this.onChange.bind(this));
  3904. this.on("changeFold", this.onChangeFold.bind(this));
  3905. if (this.bgTokenizer) {
  3906. this.bgTokenizer.setDocument(this.getDocument());
  3907. this.bgTokenizer.start(0);
  3908. }
  3909. };
  3910. this.getDocument = function() {
  3911. return this.doc;
  3912. };
  3913. this.$resetRowCache = function(docRrow) {
  3914. if (!docRrow) {
  3915. this.$docRowCache = [];
  3916. this.$screenRowCache = [];
  3917. return;
  3918. }
  3919. var i = this.$getRowCacheIndex(this.$docRowCache, docRrow) + 1;
  3920. var l = this.$docRowCache.length;
  3921. this.$docRowCache.splice(i, l);
  3922. this.$screenRowCache.splice(i, l);
  3923. };
  3924. this.$getRowCacheIndex = function(cacheArray, val) {
  3925. var low = 0;
  3926. var hi = cacheArray.length - 1;
  3927. while (low <= hi) {
  3928. var mid = (low + hi) >> 1;
  3929. var c = cacheArray[mid];
  3930. if (val > c)
  3931. low = mid + 1;
  3932. else if (val < c)
  3933. hi = mid - 1;
  3934. else
  3935. return mid;
  3936. }
  3937. return low && low -1;
  3938. };
  3939. this.onChangeFold = function(e) {
  3940. var fold = e.data;
  3941. this.$resetRowCache(fold.start.row);
  3942. };
  3943. this.onChange = function(e) {
  3944. var delta = e.data;
  3945. this.$modified = true;
  3946. this.$resetRowCache(delta.range.start.row);
  3947. var removedFolds = this.$updateInternalDataOnChange(e);
  3948. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  3949. this.$deltasDoc.push(delta);
  3950. if (removedFolds && removedFolds.length != 0) {
  3951. this.$deltasFold.push({
  3952. action: "removeFolds",
  3953. folds: removedFolds
  3954. });
  3955. }
  3956. this.$informUndoManager.schedule();
  3957. }
  3958. this.bgTokenizer.$updateOnChange(delta);
  3959. this._emit("change", e);
  3960. };
  3961. this.setValue = function(text) {
  3962. this.doc.setValue(text);
  3963. this.selection.moveCursorTo(0, 0);
  3964. this.selection.clearSelection();
  3965. this.$resetRowCache(0);
  3966. this.$deltas = [];
  3967. this.$deltasDoc = [];
  3968. this.$deltasFold = [];
  3969. this.getUndoManager().reset();
  3970. };
  3971. /** alias of: EditSession.getValue
  3972. * EditSession.toString() -> String
  3973. *
  3974. * Returns the current [[Document `Document`]] as a string.
  3975. *
  3976. **/
  3977. this.getValue =
  3978. this.toString = function() {
  3979. return this.doc.getValue();
  3980. };
  3981. this.getSelection = function() {
  3982. return this.selection;
  3983. };
  3984. this.getState = function(row) {
  3985. return this.bgTokenizer.getState(row);
  3986. };
  3987. this.getTokens = function(row) {
  3988. return this.bgTokenizer.getTokens(row);
  3989. };
  3990. this.getTokenAt = function(row, column) {
  3991. var tokens = this.bgTokenizer.getTokens(row);
  3992. var token, c = 0;
  3993. if (column == null) {
  3994. i = tokens.length - 1;
  3995. c = this.getLine(row).length;
  3996. } else {
  3997. for (var i = 0; i < tokens.length; i++) {
  3998. c += tokens[i].value.length;
  3999. if (c >= column)
  4000. break;
  4001. }
  4002. }
  4003. token = tokens[i];
  4004. if (!token)
  4005. return null;
  4006. token.index = i;
  4007. token.start = c - token.value.length;
  4008. return token;
  4009. };
  4010. this.highlight = function(re) {
  4011. if (!this.$searchHighlight) {
  4012. var highlight = new SearchHighlight(null, "ace_selected_word", "text");
  4013. this.$searchHighlight = this.addDynamicMarker(highlight);
  4014. }
  4015. this.$searchHighlight.setRegexp(re);
  4016. }
  4017. /**
  4018. * EditSession.setUndoManager(undoManager)
  4019. * - undoManager (UndoManager): The new undo manager
  4020. *
  4021. * Sets the undo manager.
  4022. **/
  4023. this.setUndoManager = function(undoManager) {
  4024. this.$undoManager = undoManager;
  4025. this.$deltas = [];
  4026. this.$deltasDoc = [];
  4027. this.$deltasFold = [];
  4028. if (this.$informUndoManager)
  4029. this.$informUndoManager.cancel();
  4030. if (undoManager) {
  4031. var self = this;
  4032. this.$syncInformUndoManager = function() {
  4033. self.$informUndoManager.cancel();
  4034. if (self.$deltasFold.length) {
  4035. self.$deltas.push({
  4036. group: "fold",
  4037. deltas: self.$deltasFold
  4038. });
  4039. self.$deltasFold = [];
  4040. }
  4041. if (self.$deltasDoc.length) {
  4042. self.$deltas.push({
  4043. group: "doc",
  4044. deltas: self.$deltasDoc
  4045. });
  4046. self.$deltasDoc = [];
  4047. }
  4048. if (self.$deltas.length > 0) {
  4049. undoManager.execute({
  4050. action: "aceupdate",
  4051. args: [self.$deltas, self]
  4052. });
  4053. }
  4054. self.$deltas = [];
  4055. }
  4056. this.$informUndoManager =
  4057. lang.deferredCall(this.$syncInformUndoManager);
  4058. }
  4059. };
  4060. this.$defaultUndoManager = {
  4061. undo: function() {},
  4062. redo: function() {},
  4063. reset: function() {}
  4064. };
  4065. this.getUndoManager = function() {
  4066. return this.$undoManager || this.$defaultUndoManager;
  4067. },
  4068. /**
  4069. * EditSession.getTabString() -> String
  4070. *
  4071. * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]); otherwise it's simply `'\t'`.
  4072. **/
  4073. this.getTabString = function() {
  4074. if (this.getUseSoftTabs()) {
  4075. return lang.stringRepeat(" ", this.getTabSize());
  4076. } else {
  4077. return "\t";
  4078. }
  4079. };
  4080. this.$useSoftTabs = true;
  4081. this.setUseSoftTabs = function(useSoftTabs) {
  4082. if (this.$useSoftTabs === useSoftTabs) return;
  4083. this.$useSoftTabs = useSoftTabs;
  4084. };
  4085. this.getUseSoftTabs = function() {
  4086. return this.$useSoftTabs;
  4087. };
  4088. this.$tabSize = 4;
  4089. this.setTabSize = function(tabSize) {
  4090. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  4091. this.$modified = true;
  4092. this.$rowLengthCache = [];
  4093. this.$tabSize = tabSize;
  4094. this._emit("changeTabSize");
  4095. };
  4096. this.getTabSize = function() {
  4097. return this.$tabSize;
  4098. };
  4099. this.isTabStop = function(position) {
  4100. return this.$useSoftTabs && (position.column % this.$tabSize == 0);
  4101. };
  4102. this.$overwrite = false;
  4103. this.setOverwrite = function(overwrite) {
  4104. if (this.$overwrite == overwrite) return;
  4105. this.$overwrite = overwrite;
  4106. this._emit("changeOverwrite");
  4107. };
  4108. this.getOverwrite = function() {
  4109. return this.$overwrite;
  4110. };
  4111. this.toggleOverwrite = function() {
  4112. this.setOverwrite(!this.$overwrite);
  4113. };
  4114. this.getBreakpoints = function() {
  4115. return this.$breakpoints;
  4116. };
  4117. this.setBreakpoints = function(rows) {
  4118. this.$breakpoints = [];
  4119. for (var i=0; i<rows.length; i++) {
  4120. this.$breakpoints[rows[i]] = true;
  4121. }
  4122. this._emit("changeBreakpoint", {});
  4123. };
  4124. this.clearBreakpoints = function() {
  4125. this.$breakpoints = [];
  4126. this._emit("changeBreakpoint", {});
  4127. };
  4128. this.setBreakpoint = function(row) {
  4129. this.$breakpoints[row] = true;
  4130. this._emit("changeBreakpoint", {});
  4131. };
  4132. this.clearBreakpoint = function(row) {
  4133. delete this.$breakpoints[row];
  4134. this._emit("changeBreakpoint", {});
  4135. };
  4136. this.addMarker = function(range, clazz, type, inFront) {
  4137. var id = this.$markerId++;
  4138. var marker = {
  4139. range : range,
  4140. type : type || "line",
  4141. renderer: typeof type == "function" ? type : null,
  4142. clazz : clazz,
  4143. inFront: !!inFront,
  4144. id: id
  4145. }
  4146. if (inFront) {
  4147. this.$frontMarkers[id] = marker;
  4148. this._emit("changeFrontMarker")
  4149. } else {
  4150. this.$backMarkers[id] = marker;
  4151. this._emit("changeBackMarker")
  4152. }
  4153. return id;
  4154. };
  4155. this.addDynamicMarker = function(marker, inFront) {
  4156. if (!marker.update)
  4157. return;
  4158. var id = this.$markerId++;
  4159. marker.id = id;
  4160. marker.inFront = !!inFront;
  4161. if (inFront) {
  4162. this.$frontMarkers[id] = marker;
  4163. this._emit("changeFrontMarker")
  4164. } else {
  4165. this.$backMarkers[id] = marker;
  4166. this._emit("changeBackMarker")
  4167. }
  4168. return marker;
  4169. };
  4170. this.removeMarker = function(markerId) {
  4171. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  4172. if (!marker)
  4173. return;
  4174. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  4175. if (marker) {
  4176. delete (markers[markerId]);
  4177. this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  4178. }
  4179. };
  4180. this.getMarkers = function(inFront) {
  4181. return inFront ? this.$frontMarkers : this.$backMarkers;
  4182. };
  4183. /**
  4184. * EditSession.setAnnotations(annotations)
  4185. * - annotations (Array): A list of annotations
  4186. *
  4187. * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
  4188. **/
  4189. this.setAnnotations = function(annotations) {
  4190. this.$annotations = {};
  4191. for (var i=0; i<annotations.length; i++) {
  4192. var annotation = annotations[i];
  4193. var row = annotation.row;
  4194. if (this.$annotations[row])
  4195. this.$annotations[row].push(annotation);
  4196. else
  4197. this.$annotations[row] = [annotation];
  4198. }
  4199. this._emit("changeAnnotation", {});
  4200. };
  4201. this.getAnnotations = function() {
  4202. return this.$annotations || {};
  4203. };
  4204. this.clearAnnotations = function() {
  4205. this.$annotations = {};
  4206. this._emit("changeAnnotation", {});
  4207. };
  4208. this.$detectNewLine = function(text) {
  4209. var match = text.match(/^.*?(\r?\n)/m);
  4210. if (match) {
  4211. this.$autoNewLine = match[1];
  4212. } else {
  4213. this.$autoNewLine = "\n";
  4214. }
  4215. };
  4216. this.getWordRange = function(row, column) {
  4217. var line = this.getLine(row);
  4218. var inToken = false;
  4219. if (column > 0)
  4220. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  4221. if (!inToken)
  4222. inToken = !!line.charAt(column).match(this.tokenRe);
  4223. if (inToken)
  4224. var re = this.tokenRe;
  4225. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  4226. var re = /\s/;
  4227. else
  4228. var re = this.nonTokenRe;
  4229. var start = column;
  4230. if (start > 0) {
  4231. do {
  4232. start--;
  4233. }
  4234. while (start >= 0 && line.charAt(start).match(re));
  4235. start++;
  4236. }
  4237. var end = column;
  4238. while (end < line.length && line.charAt(end).match(re)) {
  4239. end++;
  4240. }
  4241. return new Range(row, start, row, end);
  4242. };
  4243. this.getAWordRange = function(row, column) {
  4244. var wordRange = this.getWordRange(row, column);
  4245. var line = this.getLine(wordRange.end.row);
  4246. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  4247. wordRange.end.column += 1;
  4248. }
  4249. return wordRange;
  4250. };
  4251. this.setNewLineMode = function(newLineMode) {
  4252. this.doc.setNewLineMode(newLineMode);
  4253. };
  4254. this.getNewLineMode = function() {
  4255. return this.doc.getNewLineMode();
  4256. };
  4257. this.$useWorker = true;
  4258. this.setUseWorker = function(useWorker) {
  4259. if (this.$useWorker == useWorker)
  4260. return;
  4261. this.$useWorker = useWorker;
  4262. this.$stopWorker();
  4263. if (useWorker)
  4264. this.$startWorker();
  4265. };
  4266. this.getUseWorker = function() {
  4267. return this.$useWorker;
  4268. };
  4269. this.onReloadTokenizer = function(e) {
  4270. var rows = e.data;
  4271. this.bgTokenizer.start(rows.first);
  4272. this._emit("tokenizerUpdate", e);
  4273. };
  4274. this.$modes = {};
  4275. this._loadMode = function(mode, callback) {
  4276. if (!this.$modes["null"])
  4277. this.$modes["null"] = this.$modes["ace/mode/text"] = new TextMode();
  4278. if (this.$modes[mode])
  4279. return callback(this.$modes[mode]);
  4280. var _self = this;
  4281. var module;
  4282. try {
  4283. module = require(mode);
  4284. } catch (e) {};
  4285. // sometimes require returns empty object (this bug is present in requirejs 2 as well)
  4286. if (module && module.Mode)
  4287. return done(module);
  4288. // set mode to text until loading is finished
  4289. if (!this.$mode)
  4290. this.$setModePlaceholder();
  4291. fetch(function() {
  4292. require([mode], done);
  4293. });
  4294. function done(module) {
  4295. if (_self.$modes[mode])
  4296. return callback(_self.$modes[mode]);
  4297. _self.$modes[mode] = new module.Mode();
  4298. _self.$modes[mode].$id = mode;
  4299. _self._emit("loadmode", {
  4300. name: mode,
  4301. mode: _self.$modes[mode]
  4302. });
  4303. callback(_self.$modes[mode]);
  4304. }
  4305. function fetch(callback) {
  4306. if (!config.get("packaged"))
  4307. return callback();
  4308. var base = mode.split("/").pop();
  4309. var filename = config.get("modePath") + "/mode-" + base + ".js";
  4310. net.loadScript(filename, callback);
  4311. }
  4312. };
  4313. this.$setModePlaceholder = function() {
  4314. this.$mode = this.$modes["null"];
  4315. var tokenizer = this.$mode.getTokenizer();
  4316. if (!this.bgTokenizer) {
  4317. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  4318. var _self = this;
  4319. this.bgTokenizer.addEventListener("update", function(e) {
  4320. _self._emit("tokenizerUpdate", e);
  4321. });
  4322. } else {
  4323. this.bgTokenizer.setTokenizer(tokenizer);
  4324. }
  4325. this.bgTokenizer.setDocument(this.getDocument());
  4326. this.tokenRe = this.$mode.tokenRe;
  4327. this.nonTokenRe = this.$mode.nonTokenRe;
  4328. };
  4329. this.$mode = null;
  4330. this.$modeId = null;
  4331. this.setMode = function(mode) {
  4332. mode = mode || "null";
  4333. // load on demand
  4334. if (typeof mode === "string") {
  4335. if (this.$modeId == mode)
  4336. return;
  4337. this.$modeId = mode;
  4338. var _self = this;
  4339. this._loadMode(mode, function(module) {
  4340. if (_self.$modeId !== mode)
  4341. return;
  4342. _self.setMode(module);
  4343. });
  4344. return;
  4345. }
  4346. if (this.$mode === mode) return;
  4347. this.$mode = mode;
  4348. this.$modeId = mode.$id;
  4349. this.$stopWorker();
  4350. if (this.$useWorker)
  4351. this.$startWorker();
  4352. var tokenizer = mode.getTokenizer();
  4353. if(tokenizer.addEventListener !== undefined) {
  4354. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  4355. tokenizer.addEventListener("update", onReloadTokenizer);
  4356. }
  4357. if (!this.bgTokenizer) {
  4358. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  4359. var _self = this;
  4360. this.bgTokenizer.addEventListener("update", function(e) {
  4361. _self._emit("tokenizerUpdate", e);
  4362. });
  4363. } else {
  4364. this.bgTokenizer.setTokenizer(tokenizer);
  4365. }
  4366. this.bgTokenizer.setDocument(this.getDocument());
  4367. this.bgTokenizer.start(0);
  4368. this.tokenRe = mode.tokenRe;
  4369. this.nonTokenRe = mode.nonTokenRe;
  4370. this.$setFolding(mode.foldingRules);
  4371. this._emit("changeMode");
  4372. };
  4373. this.$stopWorker = function() {
  4374. if (this.$worker)
  4375. this.$worker.terminate();
  4376. this.$worker = null;
  4377. };
  4378. this.$startWorker = function() {
  4379. if (typeof Worker !== "undefined" && !require.noWorker) {
  4380. try {
  4381. this.$worker = this.$mode.createWorker(this);
  4382. } catch (e) {
  4383. console.log("Could not load worker");
  4384. console.log(e);
  4385. this.$worker = null;
  4386. }
  4387. }
  4388. else
  4389. this.$worker = null;
  4390. };
  4391. this.getMode = function() {
  4392. return this.$mode;
  4393. };
  4394. this.$scrollTop = 0;
  4395. this.setScrollTop = function(scrollTop) {
  4396. scrollTop = Math.round(Math.max(0, scrollTop));
  4397. if (this.$scrollTop === scrollTop)
  4398. return;
  4399. this.$scrollTop = scrollTop;
  4400. this._emit("changeScrollTop", scrollTop);
  4401. };
  4402. this.getScrollTop = function() {
  4403. return this.$scrollTop;
  4404. };
  4405. this.$scrollLeft = 0;
  4406. this.setScrollLeft = function(scrollLeft) {
  4407. scrollLeft = Math.round(Math.max(0, scrollLeft));
  4408. if (this.$scrollLeft === scrollLeft)
  4409. return;
  4410. this.$scrollLeft = scrollLeft;
  4411. this._emit("changeScrollLeft", scrollLeft);
  4412. };
  4413. this.getScrollLeft = function() {
  4414. return this.$scrollLeft;
  4415. };
  4416. this.getScreenWidth = function() {
  4417. this.$computeWidth();
  4418. return this.screenWidth;
  4419. };
  4420. this.$computeWidth = function(force) {
  4421. if (this.$modified || force) {
  4422. this.$modified = false;
  4423. if (this.$useWrapMode)
  4424. return this.screenWidth = this.$wrapLimit;
  4425. var lines = this.doc.getAllLines();
  4426. var cache = this.$rowLengthCache;
  4427. var longestScreenLine = 0;
  4428. var foldIndex = 0;
  4429. var foldLine = this.$foldData[foldIndex];
  4430. var foldStart = foldLine ? foldLine.start.row : Infinity;
  4431. var len = lines.length;
  4432. for (var i = 0; i < len; i++) {
  4433. if (i > foldStart) {
  4434. i = foldLine.end.row + 1;
  4435. if (i >= len)
  4436. break
  4437. foldLine = this.$foldData[foldIndex++];
  4438. foldStart = foldLine ? foldLine.start.row : Infinity;
  4439. }
  4440. if (cache[i] == null)
  4441. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  4442. if (cache[i] > longestScreenLine)
  4443. longestScreenLine = cache[i];
  4444. }
  4445. this.screenWidth = longestScreenLine;
  4446. }
  4447. };
  4448. this.getLine = function(row) {
  4449. return this.doc.getLine(row);
  4450. };
  4451. this.getLines = function(firstRow, lastRow) {
  4452. return this.doc.getLines(firstRow, lastRow);
  4453. };
  4454. this.getLength = function() {
  4455. return this.doc.getLength();
  4456. };
  4457. this.getTextRange = function(range) {
  4458. return this.doc.getTextRange(range || this.selection.getRange());
  4459. };
  4460. this.insert = function(position, text) {
  4461. return this.doc.insert(position, text);
  4462. };
  4463. this.remove = function(range) {
  4464. return this.doc.remove(range);
  4465. };
  4466. this.undoChanges = function(deltas, dontSelect) {
  4467. if (!deltas.length)
  4468. return;
  4469. this.$fromUndo = true;
  4470. var lastUndoRange = null;
  4471. for (var i = deltas.length - 1; i != -1; i--) {
  4472. var delta = deltas[i];
  4473. if (delta.group == "doc") {
  4474. this.doc.revertDeltas(delta.deltas);
  4475. lastUndoRange =
  4476. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  4477. } else {
  4478. delta.deltas.forEach(function(foldDelta) {
  4479. this.addFolds(foldDelta.folds);
  4480. }, this);
  4481. }
  4482. }
  4483. this.$fromUndo = false;
  4484. lastUndoRange &&
  4485. this.$undoSelect &&
  4486. !dontSelect &&
  4487. this.selection.setSelectionRange(lastUndoRange);
  4488. return lastUndoRange;
  4489. };
  4490. this.redoChanges = function(deltas, dontSelect) {
  4491. if (!deltas.length)
  4492. return;
  4493. this.$fromUndo = true;
  4494. var lastUndoRange = null;
  4495. for (var i = 0; i < deltas.length; i++) {
  4496. var delta = deltas[i];
  4497. if (delta.group == "doc") {
  4498. this.doc.applyDeltas(delta.deltas);
  4499. lastUndoRange =
  4500. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  4501. }
  4502. }
  4503. this.$fromUndo = false;
  4504. lastUndoRange &&
  4505. this.$undoSelect &&
  4506. !dontSelect &&
  4507. this.selection.setSelectionRange(lastUndoRange);
  4508. return lastUndoRange;
  4509. };
  4510. this.setUndoSelect = function(enable) {
  4511. this.$undoSelect = enable;
  4512. };
  4513. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  4514. function isInsert(delta) {
  4515. var insert =
  4516. delta.action == "insertText" || delta.action == "insertLines";
  4517. return isUndo ? !insert : insert;
  4518. }
  4519. var delta = deltas[0];
  4520. var range, point;
  4521. var lastDeltaIsInsert = false;
  4522. if (isInsert(delta)) {
  4523. range = delta.range.clone();
  4524. lastDeltaIsInsert = true;
  4525. } else {
  4526. range = Range.fromPoints(delta.range.start, delta.range.start);
  4527. lastDeltaIsInsert = false;
  4528. }
  4529. for (var i = 1; i < deltas.length; i++) {
  4530. delta = deltas[i];
  4531. if (isInsert(delta)) {
  4532. point = delta.range.start;
  4533. if (range.compare(point.row, point.column) == -1) {
  4534. range.setStart(delta.range.start);
  4535. }
  4536. point = delta.range.end;
  4537. if (range.compare(point.row, point.column) == 1) {
  4538. range.setEnd(delta.range.end);
  4539. }
  4540. lastDeltaIsInsert = true;
  4541. } else {
  4542. point = delta.range.start;
  4543. if (range.compare(point.row, point.column) == -1) {
  4544. range =
  4545. Range.fromPoints(delta.range.start, delta.range.start);
  4546. }
  4547. lastDeltaIsInsert = false;
  4548. }
  4549. }
  4550. // Check if this range and the last undo range has something in common.
  4551. // If true, merge the ranges.
  4552. if (lastUndoRange != null) {
  4553. var cmp = lastUndoRange.compareRange(range);
  4554. if (cmp == 1) {
  4555. range.setStart(lastUndoRange.start);
  4556. } else if (cmp == -1) {
  4557. range.setEnd(lastUndoRange.end);
  4558. }
  4559. }
  4560. return range;
  4561. },
  4562. /** related to: Document.replace
  4563. * EditSession.replace(range, text) -> Object
  4564. * - range (Range): A specified Range to replace
  4565. * - text (String): The new text to use as a replacement
  4566. * + (Object): Returns an object containing the final row and column, like this:<br/>
  4567. * ```{row: endRow, column: 0}```<br/>
  4568. * If the text and range are empty, this function returns an object containing the current `range.start` value.<br/>
  4569. * If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value.
  4570. *
  4571. * Replaces a range in the document with the new `text`.
  4572. *
  4573. *
  4574. *
  4575. **/
  4576. this.replace = function(range, text) {
  4577. return this.doc.replace(range, text);
  4578. };
  4579. this.moveText = function(fromRange, toPosition) {
  4580. var text = this.getTextRange(fromRange);
  4581. this.remove(fromRange);
  4582. var toRow = toPosition.row;
  4583. var toColumn = toPosition.column;
  4584. // Make sure to update the insert location, when text is removed in
  4585. // front of the chosen point of insertion.
  4586. if (!fromRange.isMultiLine() && fromRange.start.row == toRow &&
  4587. fromRange.end.column < toColumn)
  4588. toColumn -= text.length;
  4589. if (fromRange.isMultiLine() && fromRange.end.row < toRow) {
  4590. var lines = this.doc.$split(text);
  4591. toRow -= lines.length - 1;
  4592. }
  4593. var endRow = toRow + fromRange.end.row - fromRange.start.row;
  4594. var endColumn = fromRange.isMultiLine() ?
  4595. fromRange.end.column :
  4596. toColumn + fromRange.end.column - fromRange.start.column;
  4597. var toRange = new Range(toRow, toColumn, endRow, endColumn);
  4598. this.insert(toRange.start, text);
  4599. return toRange;
  4600. };
  4601. this.indentRows = function(startRow, endRow, indentString) {
  4602. indentString = indentString.replace(/\t/g, this.getTabString());
  4603. for (var row=startRow; row<=endRow; row++)
  4604. this.insert({row: row, column:0}, indentString);
  4605. };
  4606. this.outdentRows = function (range) {
  4607. var rowRange = range.collapseRows();
  4608. var deleteRange = new Range(0, 0, 0, 0);
  4609. var size = this.getTabSize();
  4610. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  4611. var line = this.getLine(i);
  4612. deleteRange.start.row = i;
  4613. deleteRange.end.row = i;
  4614. for (var j = 0; j < size; ++j)
  4615. if (line.charAt(j) != ' ')
  4616. break;
  4617. if (j < size && line.charAt(j) == '\t') {
  4618. deleteRange.start.column = j;
  4619. deleteRange.end.column = j + 1;
  4620. } else {
  4621. deleteRange.start.column = 0;
  4622. deleteRange.end.column = j;
  4623. }
  4624. this.remove(deleteRange);
  4625. }
  4626. };
  4627. this.moveLinesUp = function(firstRow, lastRow) {
  4628. if (firstRow <= 0) return 0;
  4629. var removed = this.doc.removeLines(firstRow, lastRow);
  4630. this.doc.insertLines(firstRow - 1, removed);
  4631. return -1;
  4632. };
  4633. this.moveLinesDown = function(firstRow, lastRow) {
  4634. if (lastRow >= this.doc.getLength()-1) return 0;
  4635. var removed = this.doc.removeLines(firstRow, lastRow);
  4636. this.doc.insertLines(firstRow+1, removed);
  4637. return 1;
  4638. };
  4639. this.duplicateLines = function(firstRow, lastRow) {
  4640. var firstRow = this.$clipRowToDocument(firstRow);
  4641. var lastRow = this.$clipRowToDocument(lastRow);
  4642. var lines = this.getLines(firstRow, lastRow);
  4643. this.doc.insertLines(firstRow, lines);
  4644. var addedRows = lastRow - firstRow + 1;
  4645. return addedRows;
  4646. };
  4647. this.$clipRowToDocument = function(row) {
  4648. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  4649. };
  4650. this.$clipColumnToRow = function(row, column) {
  4651. if (column < 0)
  4652. return 0;
  4653. return Math.min(this.doc.getLine(row).length, column);
  4654. };
  4655. this.$clipPositionToDocument = function(row, column) {
  4656. column = Math.max(0, column);
  4657. if (row < 0) {
  4658. row = 0;
  4659. column = 0;
  4660. } else {
  4661. var len = this.doc.getLength();
  4662. if (row >= len) {
  4663. row = len - 1;
  4664. column = this.doc.getLine(len-1).length;
  4665. } else {
  4666. column = Math.min(this.doc.getLine(row).length, column);
  4667. }
  4668. }
  4669. return {
  4670. row: row,
  4671. column: column
  4672. };
  4673. };
  4674. this.$clipRangeToDocument = function(range) {
  4675. if (range.start.row < 0) {
  4676. range.start.row = 0;
  4677. range.start.column = 0
  4678. } else {
  4679. range.start.column = this.$clipColumnToRow(
  4680. range.start.row,
  4681. range.start.column
  4682. );
  4683. }
  4684. var len = this.doc.getLength() - 1;
  4685. if (range.end.row > len) {
  4686. range.end.row = len;
  4687. range.end.column = this.doc.getLine(len).length;
  4688. } else {
  4689. range.end.column = this.$clipColumnToRow(
  4690. range.end.row,
  4691. range.end.column
  4692. );
  4693. }
  4694. return range;
  4695. };
  4696. // WRAPMODE
  4697. this.$wrapLimit = 80;
  4698. this.$useWrapMode = false;
  4699. this.$wrapLimitRange = {
  4700. min : null,
  4701. max : null
  4702. };
  4703. this.setUseWrapMode = function(useWrapMode) {
  4704. if (useWrapMode != this.$useWrapMode) {
  4705. this.$useWrapMode = useWrapMode;
  4706. this.$modified = true;
  4707. this.$resetRowCache(0);
  4708. // If wrapMode is activaed, the wrapData array has to be initialized.
  4709. if (useWrapMode) {
  4710. var len = this.getLength();
  4711. this.$wrapData = [];
  4712. for (var i = 0; i < len; i++) {
  4713. this.$wrapData.push([]);
  4714. }
  4715. this.$updateWrapData(0, len - 1);
  4716. }
  4717. this._emit("changeWrapMode");
  4718. }
  4719. };
  4720. this.getUseWrapMode = function() {
  4721. return this.$useWrapMode;
  4722. };
  4723. // Allow the wrap limit to move freely between min and max. Either
  4724. // parameter can be null to allow the wrap limit to be unconstrained
  4725. // in that direction. Or set both parameters to the same number to pin
  4726. // the limit to that value.
  4727. /**
  4728. * EditSession.setWrapLimitRange(min, max)
  4729. * - min (Number): The minimum wrap value (the left side wrap)
  4730. * - max (Number): The maximum wrap value (the right side wrap)
  4731. *
  4732. * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event.
  4733. **/
  4734. this.setWrapLimitRange = function(min, max) {
  4735. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  4736. this.$wrapLimitRange.min = min;
  4737. this.$wrapLimitRange.max = max;
  4738. this.$modified = true;
  4739. // This will force a recalculation of the wrap limit
  4740. this._emit("changeWrapMode");
  4741. }
  4742. };
  4743. this.adjustWrapLimit = function(desiredLimit) {
  4744. var wrapLimit = this.$constrainWrapLimit(desiredLimit);
  4745. if (wrapLimit != this.$wrapLimit && wrapLimit > 0) {
  4746. this.$wrapLimit = wrapLimit;
  4747. this.$modified = true;
  4748. if (this.$useWrapMode) {
  4749. this.$updateWrapData(0, this.getLength() - 1);
  4750. this.$resetRowCache(0)
  4751. this._emit("changeWrapLimit");
  4752. }
  4753. return true;
  4754. }
  4755. return false;
  4756. };
  4757. this.$constrainWrapLimit = function(wrapLimit) {
  4758. var min = this.$wrapLimitRange.min;
  4759. if (min)
  4760. wrapLimit = Math.max(min, wrapLimit);
  4761. var max = this.$wrapLimitRange.max;
  4762. if (max)
  4763. wrapLimit = Math.min(max, wrapLimit);
  4764. // What would a limit of 0 even mean?
  4765. return Math.max(1, wrapLimit);
  4766. };
  4767. this.getWrapLimit = function() {
  4768. return this.$wrapLimit;
  4769. };
  4770. this.getWrapLimitRange = function() {
  4771. // Avoid unexpected mutation by returning a copy
  4772. return {
  4773. min : this.$wrapLimitRange.min,
  4774. max : this.$wrapLimitRange.max
  4775. };
  4776. };
  4777. this.$updateInternalDataOnChange = function(e) {
  4778. var useWrapMode = this.$useWrapMode;
  4779. var len;
  4780. var action = e.data.action;
  4781. var firstRow = e.data.range.start.row;
  4782. var lastRow = e.data.range.end.row;
  4783. var start = e.data.range.start;
  4784. var end = e.data.range.end;
  4785. var removedFolds = null;
  4786. if (action.indexOf("Lines") != -1) {
  4787. if (action == "insertLines") {
  4788. lastRow = firstRow + (e.data.lines.length);
  4789. } else {
  4790. lastRow = firstRow;
  4791. }
  4792. len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
  4793. } else {
  4794. len = lastRow - firstRow;
  4795. }
  4796. if (len != 0) {
  4797. if (action.indexOf("remove") != -1) {
  4798. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  4799. var foldLines = this.$foldData;
  4800. removedFolds = this.getFoldsInRange(e.data.range);
  4801. this.removeFolds(removedFolds);
  4802. var foldLine = this.getFoldLine(end.row);
  4803. var idx = 0;
  4804. if (foldLine) {
  4805. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  4806. foldLine.shiftRow(-len);
  4807. var foldLineBefore = this.getFoldLine(firstRow);
  4808. if (foldLineBefore && foldLineBefore !== foldLine) {
  4809. foldLineBefore.merge(foldLine);
  4810. foldLine = foldLineBefore;
  4811. }
  4812. idx = foldLines.indexOf(foldLine) + 1;
  4813. }
  4814. for (idx; idx < foldLines.length; idx++) {
  4815. var foldLine = foldLines[idx];
  4816. if (foldLine.start.row >= end.row) {
  4817. foldLine.shiftRow(-len);
  4818. }
  4819. }
  4820. lastRow = firstRow;
  4821. } else {
  4822. var args;
  4823. if (useWrapMode) {
  4824. args = [firstRow, 0];
  4825. for (var i = 0; i < len; i++) args.push([]);
  4826. this.$wrapData.splice.apply(this.$wrapData, args);
  4827. } else {
  4828. args = Array(len);
  4829. args.unshift(firstRow, 0);
  4830. this.$rowLengthCache.splice.apply(this.$rowLengthCache, args);
  4831. }
  4832. // If some new line is added inside of a foldLine, then split
  4833. // the fold line up.
  4834. var foldLines = this.$foldData;
  4835. var foldLine = this.getFoldLine(firstRow);
  4836. var idx = 0;
  4837. if (foldLine) {
  4838. var cmp = foldLine.range.compareInside(start.row, start.column)
  4839. // Inside of the foldLine range. Need to split stuff up.
  4840. if (cmp == 0) {
  4841. foldLine = foldLine.split(start.row, start.column);
  4842. foldLine.shiftRow(len);
  4843. foldLine.addRemoveChars(
  4844. lastRow, 0, end.column - start.column);
  4845. } else
  4846. // Infront of the foldLine but same row. Need to shift column.
  4847. if (cmp == -1) {
  4848. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  4849. foldLine.shiftRow(len);
  4850. }
  4851. // Nothing to do if the insert is after the foldLine.
  4852. idx = foldLines.indexOf(foldLine) + 1;
  4853. }
  4854. for (idx; idx < foldLines.length; idx++) {
  4855. var foldLine = foldLines[idx];
  4856. if (foldLine.start.row >= firstRow) {
  4857. foldLine.shiftRow(len);
  4858. }
  4859. }
  4860. }
  4861. } else {
  4862. // Realign folds. E.g. if you add some new chars before a fold, the
  4863. // fold should "move" to the right.
  4864. len = Math.abs(e.data.range.start.column - e.data.range.end.column);
  4865. if (action.indexOf("remove") != -1) {
  4866. // Get all the folds in the change range and remove them.
  4867. removedFolds = this.getFoldsInRange(e.data.range);
  4868. this.removeFolds(removedFolds);
  4869. len = -len;
  4870. }
  4871. var foldLine = this.getFoldLine(firstRow);
  4872. if (foldLine) {
  4873. foldLine.addRemoveChars(firstRow, start.column, len);
  4874. }
  4875. }
  4876. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  4877. console.error("doc.getLength() and $wrapData.length have to be the same!");
  4878. }
  4879. if (useWrapMode)
  4880. this.$updateWrapData(firstRow, lastRow);
  4881. else
  4882. this.$updateRowLengthCache(firstRow, lastRow);
  4883. return removedFolds;
  4884. };
  4885. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  4886. //console.log(firstRow, lastRow, b)
  4887. this.$rowLengthCache[firstRow] = null;
  4888. this.$rowLengthCache[lastRow] = null;
  4889. //console.log(this.$rowLengthCache)
  4890. };
  4891. this.$updateWrapData = function(firstRow, lastRow) {
  4892. var lines = this.doc.getAllLines();
  4893. var tabSize = this.getTabSize();
  4894. var wrapData = this.$wrapData;
  4895. var wrapLimit = this.$wrapLimit;
  4896. var tokens;
  4897. var foldLine;
  4898. var row = firstRow;
  4899. lastRow = Math.min(lastRow, lines.length - 1);
  4900. while (row <= lastRow) {
  4901. foldLine = this.getFoldLine(row, foldLine);
  4902. if (!foldLine) {
  4903. tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row]));
  4904. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  4905. row ++;
  4906. } else {
  4907. tokens = [];
  4908. foldLine.walk(
  4909. function(placeholder, row, column, lastColumn) {
  4910. var walkTokens;
  4911. if (placeholder) {
  4912. walkTokens = this.$getDisplayTokens(
  4913. placeholder, tokens.length);
  4914. walkTokens[0] = PLACEHOLDER_START;
  4915. for (var i = 1; i < walkTokens.length; i++) {
  4916. walkTokens[i] = PLACEHOLDER_BODY;
  4917. }
  4918. } else {
  4919. walkTokens = this.$getDisplayTokens(
  4920. lines[row].substring(lastColumn, column),
  4921. tokens.length);
  4922. }
  4923. tokens = tokens.concat(walkTokens);
  4924. }.bind(this),
  4925. foldLine.end.row,
  4926. lines[foldLine.end.row].length + 1
  4927. );
  4928. // Remove spaces/tabs from the back of the token array.
  4929. while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE)
  4930. tokens.pop();
  4931. wrapData[foldLine.start.row]
  4932. = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  4933. row = foldLine.end.row + 1;
  4934. }
  4935. }
  4936. };
  4937. // "Tokens"
  4938. var CHAR = 1,
  4939. CHAR_EXT = 2,
  4940. PLACEHOLDER_START = 3,
  4941. PLACEHOLDER_BODY = 4,
  4942. PUNCTUATION = 9,
  4943. SPACE = 10,
  4944. TAB = 11,
  4945. TAB_SPACE = 12;
  4946. this.$computeWrapSplits = function(tokens, wrapLimit) {
  4947. if (tokens.length == 0) {
  4948. return [];
  4949. }
  4950. var splits = [];
  4951. var displayLength = tokens.length;
  4952. var lastSplit = 0, lastDocSplit = 0;
  4953. function addSplit(screenPos) {
  4954. var displayed = tokens.slice(lastSplit, screenPos);
  4955. // The document size is the current size - the extra width for tabs
  4956. // and multipleWidth characters.
  4957. var len = displayed.length;
  4958. displayed.join("").
  4959. // Get all the TAB_SPACEs.
  4960. replace(/12/g, function() {
  4961. len -= 1;
  4962. }).
  4963. // Get all the CHAR_EXT/multipleWidth characters.
  4964. replace(/2/g, function() {
  4965. len -= 1;
  4966. });
  4967. lastDocSplit += len;
  4968. splits.push(lastDocSplit);
  4969. lastSplit = screenPos;
  4970. }
  4971. while (displayLength - lastSplit > wrapLimit) {
  4972. // This is, where the split should be.
  4973. var split = lastSplit + wrapLimit;
  4974. // If there is a space or tab at this split position, then making
  4975. // a split is simple.
  4976. if (tokens[split] >= SPACE) {
  4977. // Include all following spaces + tabs in this split as well.
  4978. while (tokens[split] >= SPACE) {
  4979. split ++;
  4980. }
  4981. addSplit(split);
  4982. continue;
  4983. }
  4984. // === ELSE ===
  4985. // Check if split is inside of a placeholder. Placeholder are
  4986. // not splitable. Therefore, seek the beginning of the placeholder
  4987. // and try to place the split beofre the placeholder's start.
  4988. if (tokens[split] == PLACEHOLDER_START
  4989. || tokens[split] == PLACEHOLDER_BODY)
  4990. {
  4991. // Seek the start of the placeholder and do the split
  4992. // before the placeholder. By definition there always
  4993. // a PLACEHOLDER_START between split and lastSplit.
  4994. for (split; split != lastSplit - 1; split--) {
  4995. if (tokens[split] == PLACEHOLDER_START) {
  4996. // split++; << No incremental here as we want to
  4997. // have the position before the Placeholder.
  4998. break;
  4999. }
  5000. }
  5001. // If the PLACEHOLDER_START is not the index of the
  5002. // last split, then we can do the split
  5003. if (split > lastSplit) {
  5004. addSplit(split);
  5005. continue;
  5006. }
  5007. // If the PLACEHOLDER_START IS the index of the last
  5008. // split, then we have to place the split after the
  5009. // placeholder. So, let's seek for the end of the placeholder.
  5010. split = lastSplit + wrapLimit;
  5011. for (split; split < tokens.length; split++) {
  5012. if (tokens[split] != PLACEHOLDER_BODY)
  5013. {
  5014. break;
  5015. }
  5016. }
  5017. // If spilt == tokens.length, then the placeholder is the last
  5018. // thing in the line and adding a new split doesn't make sense.
  5019. if (split == tokens.length) {
  5020. break; // Breaks the while-loop.
  5021. }
  5022. // Finally, add the split...
  5023. addSplit(split);
  5024. continue;
  5025. }
  5026. // === ELSE ===
  5027. // Search for the first non space/tab/placeholder/punctuation token backwards.
  5028. var minSplit = Math.max(split - 10, lastSplit - 1);
  5029. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  5030. split --;
  5031. }
  5032. while (split > minSplit && tokens[split] == PUNCTUATION) {
  5033. split --;
  5034. }
  5035. // If we found one, then add the split.
  5036. if (split > minSplit) {
  5037. addSplit(++split);
  5038. continue;
  5039. }
  5040. // === ELSE ===
  5041. split = lastSplit + wrapLimit;
  5042. // The split is inside of a CHAR or CHAR_EXT token and no space
  5043. // around -> force a split.
  5044. addSplit(split);
  5045. }
  5046. return splits;
  5047. }
  5048. /** internal, hide
  5049. * EditSession.$getDisplayTokens(str, offset) -> Array
  5050. * - str (String): The string to check
  5051. * - offset (Number): The value to start at
  5052. *
  5053. * Given a string, returns an array of the display characters, including tabs and spaces.
  5054. **/
  5055. this.$getDisplayTokens = function(str, offset) {
  5056. var arr = [];
  5057. var tabSize;
  5058. offset = offset || 0;
  5059. for (var i = 0; i < str.length; i++) {
  5060. var c = str.charCodeAt(i);
  5061. // Tab
  5062. if (c == 9) {
  5063. tabSize = this.getScreenTabSize(arr.length + offset);
  5064. arr.push(TAB);
  5065. for (var n = 1; n < tabSize; n++) {
  5066. arr.push(TAB_SPACE);
  5067. }
  5068. }
  5069. // Space
  5070. else if (c == 32) {
  5071. arr.push(SPACE);
  5072. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  5073. arr.push(PUNCTUATION);
  5074. }
  5075. // full width characters
  5076. else if (c >= 0x1100 && isFullWidth(c)) {
  5077. arr.push(CHAR, CHAR_EXT);
  5078. } else {
  5079. arr.push(CHAR);
  5080. }
  5081. }
  5082. return arr;
  5083. }
  5084. /** internal, hide
  5085. * EditSession.$getStringScreenWidth(str, maxScreenColumn, screenColumn) -> [Number]
  5086. * - str (String): The string to calculate the screen width of
  5087. * - maxScreenColumn (Number):
  5088. * - screenColumn (Number):
  5089. * + ([Number]): Returns an `int[]` array with two elements:<br/>
  5090. * The first position indicates the number of columns for `str` on screen.<br/>
  5091. * The second value contains the position of the document column that this function read until.
  5092. *
  5093. * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen.
  5094. *
  5095. *
  5096. **/
  5097. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  5098. if (maxScreenColumn == 0)
  5099. return [0, 0];
  5100. if (maxScreenColumn == null)
  5101. maxScreenColumn = Infinity;
  5102. screenColumn = screenColumn || 0;
  5103. var c, column;
  5104. for (column = 0; column < str.length; column++) {
  5105. c = str.charCodeAt(column);
  5106. // tab
  5107. if (c == 9) {
  5108. screenColumn += this.getScreenTabSize(screenColumn);
  5109. }
  5110. // full width characters
  5111. else if (c >= 0x1100 && isFullWidth(c)) {
  5112. screenColumn += 2;
  5113. } else {
  5114. screenColumn += 1;
  5115. }
  5116. if (screenColumn > maxScreenColumn) {
  5117. break
  5118. }
  5119. }
  5120. return [screenColumn, column];
  5121. }
  5122. /**
  5123. * EditSession.getRowLength(row) -> Number
  5124. * - row (Number): The row number to check
  5125. *
  5126. *
  5127. * Returns the length of the indicated row.
  5128. **/
  5129. this.getRowLength = function(row) {
  5130. if (!this.$useWrapMode || !this.$wrapData[row]) {
  5131. return 1;
  5132. } else {
  5133. return this.$wrapData[row].length + 1;
  5134. }
  5135. }
  5136. /**
  5137. * EditSession.getRowHeight(config, row) -> Number
  5138. * - config (Object): An object containing a parameter indicating the `lineHeight`.
  5139. * - row (Number): The row number to check
  5140. *
  5141. * Returns the height of the indicated row. This is mostly relevant for situations where wrapping occurs, and a single line spans across multiple rows.
  5142. *
  5143. **/
  5144. this.getRowHeight = function(config, row) {
  5145. return this.getRowLength(row) * config.lineHeight;
  5146. }
  5147. /** internal, hide, related to: EditSession.documentToScreenColumn
  5148. * EditSession.getScreenLastRowColumn(screenRow) -> Number
  5149. * - screenRow (Number): The screen row to check
  5150. *
  5151. * Returns the column position (on screen) for the last character in the provided row.
  5152. **/
  5153. this.getScreenLastRowColumn = function(screenRow) {
  5154. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE)
  5155. return this.documentToScreenColumn(pos.row, pos.column);
  5156. };
  5157. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  5158. var screenRow = this.documentToScreenRow(docRow, docColumn);
  5159. return this.getScreenLastRowColumn(screenRow);
  5160. };
  5161. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  5162. var screenRow = this.documentToScreenRow(docRow, docColumn);
  5163. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  5164. };
  5165. this.getRowSplitData = function(row) {
  5166. if (!this.$useWrapMode) {
  5167. return undefined;
  5168. } else {
  5169. return this.$wrapData[row];
  5170. }
  5171. };
  5172. this.getScreenTabSize = function(screenColumn) {
  5173. return this.$tabSize - screenColumn % this.$tabSize;
  5174. };
  5175. this.screenToDocumentRow = function(screenRow, screenColumn) {
  5176. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  5177. };
  5178. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  5179. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  5180. };
  5181. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  5182. if (screenRow < 0)
  5183. return {row: 0, column: 0};
  5184. var line;
  5185. var docRow = 0;
  5186. var docColumn = 0;
  5187. var column;
  5188. var row = 0;
  5189. var rowLength = 0;
  5190. var rowCache = this.$screenRowCache;
  5191. var i = this.$getRowCacheIndex(rowCache, screenRow);
  5192. var row1 = rowCache[i];
  5193. var docRow1 = this.$docRowCache[i];
  5194. if (0 < i && i < rowCache.length) {
  5195. var row = rowCache[i];
  5196. var docRow = this.$docRowCache[i];
  5197. var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1);
  5198. } else {
  5199. var doCache = true;
  5200. }
  5201. var maxRow = this.getLength() - 1;
  5202. var foldLine = this.getNextFoldLine(docRow);
  5203. var foldStart = foldLine ? foldLine.start.row : Infinity;
  5204. while (row <= screenRow) {
  5205. rowLength = this.getRowLength(docRow);
  5206. if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
  5207. break;
  5208. } else {
  5209. row += rowLength;
  5210. docRow++;
  5211. if (docRow > foldStart) {
  5212. docRow = foldLine.end.row+1;
  5213. foldLine = this.getNextFoldLine(docRow, foldLine);
  5214. foldStart = foldLine ? foldLine.start.row : Infinity;
  5215. }
  5216. }
  5217. if (doCache) {
  5218. this.$docRowCache.push(docRow);
  5219. this.$screenRowCache.push(row);
  5220. }
  5221. }
  5222. if (foldLine && foldLine.start.row <= docRow) {
  5223. line = this.getFoldDisplayLine(foldLine);
  5224. docRow = foldLine.start.row;
  5225. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  5226. // clip at the end of the document
  5227. return {
  5228. row: maxRow,
  5229. column: this.getLine(maxRow).length
  5230. }
  5231. } else {
  5232. line = this.getLine(docRow);
  5233. foldLine = null;
  5234. }
  5235. if (this.$useWrapMode) {
  5236. var splits = this.$wrapData[docRow];
  5237. if (splits) {
  5238. column = splits[screenRow - row];
  5239. if(screenRow > row && splits.length) {
  5240. docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
  5241. line = line.substring(docColumn);
  5242. }
  5243. }
  5244. }
  5245. docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
  5246. // We remove one character at the end so that the docColumn
  5247. // position returned is not associated to the next row on the screen.
  5248. if (this.$useWrapMode && docColumn >= column)
  5249. docColumn = column - 1;
  5250. if (foldLine)
  5251. return foldLine.idxToPosition(docColumn);
  5252. return {row: docRow, column: docColumn};
  5253. };
  5254. this.documentToScreenPosition = function(docRow, docColumn) {
  5255. // Normalize the passed in arguments.
  5256. if (typeof docColumn === "undefined")
  5257. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  5258. else
  5259. pos = this.$clipPositionToDocument(docRow, docColumn);
  5260. docRow = pos.row;
  5261. docColumn = pos.column;
  5262. var screenRow = 0;
  5263. var foldStartRow = null;
  5264. var fold = null;
  5265. // Clamp the docRow position in case it's inside of a folded block.
  5266. fold = this.getFoldAt(docRow, docColumn, 1);
  5267. if (fold) {
  5268. docRow = fold.start.row;
  5269. docColumn = fold.start.column;
  5270. }
  5271. var rowEnd, row = 0;
  5272. var rowCache = this.$docRowCache;
  5273. var i = this.$getRowCacheIndex(rowCache, docRow);
  5274. if (0 < i && i < rowCache.length) {
  5275. var row = rowCache[i];
  5276. var screenRow = this.$screenRowCache[i];
  5277. var doCache = docRow > row || (docRow == row && i == rowCache.length - 1);
  5278. } else {
  5279. var doCache = true;
  5280. }
  5281. var foldLine = this.getNextFoldLine(row);
  5282. var foldStart = foldLine ?foldLine.start.row :Infinity;
  5283. while (row < docRow) {
  5284. if (row >= foldStart) {
  5285. rowEnd = foldLine.end.row + 1;
  5286. if (rowEnd > docRow)
  5287. break;
  5288. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  5289. foldStart = foldLine ?foldLine.start.row :Infinity;
  5290. }
  5291. else {
  5292. rowEnd = row + 1;
  5293. }
  5294. screenRow += this.getRowLength(row);
  5295. row = rowEnd;
  5296. if (doCache) {
  5297. this.$docRowCache.push(row);
  5298. this.$screenRowCache.push(screenRow);
  5299. }
  5300. }
  5301. // Calculate the text line that is displayed in docRow on the screen.
  5302. var textLine = "";
  5303. // Check if the final row we want to reach is inside of a fold.
  5304. if (foldLine && row >= foldStart) {
  5305. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  5306. foldStartRow = foldLine.start.row;
  5307. } else {
  5308. textLine = this.getLine(docRow).substring(0, docColumn);
  5309. foldStartRow = docRow;
  5310. }
  5311. // Clamp textLine if in wrapMode.
  5312. if (this.$useWrapMode) {
  5313. var wrapRow = this.$wrapData[foldStartRow];
  5314. var screenRowOffset = 0;
  5315. while (textLine.length >= wrapRow[screenRowOffset]) {
  5316. screenRow ++;
  5317. screenRowOffset++;
  5318. }
  5319. textLine = textLine.substring(
  5320. wrapRow[screenRowOffset - 1] || 0, textLine.length
  5321. );
  5322. }
  5323. return {
  5324. row: screenRow,
  5325. column: this.$getStringScreenWidth(textLine)[0]
  5326. };
  5327. };
  5328. this.documentToScreenColumn = function(row, docColumn) {
  5329. return this.documentToScreenPosition(row, docColumn).column;
  5330. };
  5331. this.documentToScreenRow = function(docRow, docColumn) {
  5332. return this.documentToScreenPosition(docRow, docColumn).row;
  5333. };
  5334. this.getScreenLength = function() {
  5335. var screenRows = 0;
  5336. var fold = null;
  5337. if (!this.$useWrapMode) {
  5338. screenRows = this.getLength();
  5339. // Remove the folded lines again.
  5340. var foldData = this.$foldData;
  5341. for (var i = 0; i < foldData.length; i++) {
  5342. fold = foldData[i];
  5343. screenRows -= fold.end.row - fold.start.row;
  5344. }
  5345. } else {
  5346. var lastRow = this.$wrapData.length;
  5347. var row = 0, i = 0;
  5348. var fold = this.$foldData[i++];
  5349. var foldStart = fold ? fold.start.row :Infinity;
  5350. while (row < lastRow) {
  5351. screenRows += this.$wrapData[row].length + 1;
  5352. row ++;
  5353. if (row > foldStart) {
  5354. row = fold.end.row+1;
  5355. fold = this.$foldData[i++];
  5356. foldStart = fold ?fold.start.row :Infinity;
  5357. }
  5358. }
  5359. }
  5360. return screenRows;
  5361. }
  5362. // For every keystroke this gets called once per char in the whole doc!!
  5363. // Wouldn't hurt to make it a bit faster for c >= 0x1100
  5364. function isFullWidth(c) {
  5365. if (c < 0x1100)
  5366. return false;
  5367. return c >= 0x1100 && c <= 0x115F ||
  5368. c >= 0x11A3 && c <= 0x11A7 ||
  5369. c >= 0x11FA && c <= 0x11FF ||
  5370. c >= 0x2329 && c <= 0x232A ||
  5371. c >= 0x2E80 && c <= 0x2E99 ||
  5372. c >= 0x2E9B && c <= 0x2EF3 ||
  5373. c >= 0x2F00 && c <= 0x2FD5 ||
  5374. c >= 0x2FF0 && c <= 0x2FFB ||
  5375. c >= 0x3000 && c <= 0x303E ||
  5376. c >= 0x3041 && c <= 0x3096 ||
  5377. c >= 0x3099 && c <= 0x30FF ||
  5378. c >= 0x3105 && c <= 0x312D ||
  5379. c >= 0x3131 && c <= 0x318E ||
  5380. c >= 0x3190 && c <= 0x31BA ||
  5381. c >= 0x31C0 && c <= 0x31E3 ||
  5382. c >= 0x31F0 && c <= 0x321E ||
  5383. c >= 0x3220 && c <= 0x3247 ||
  5384. c >= 0x3250 && c <= 0x32FE ||
  5385. c >= 0x3300 && c <= 0x4DBF ||
  5386. c >= 0x4E00 && c <= 0xA48C ||
  5387. c >= 0xA490 && c <= 0xA4C6 ||
  5388. c >= 0xA960 && c <= 0xA97C ||
  5389. c >= 0xAC00 && c <= 0xD7A3 ||
  5390. c >= 0xD7B0 && c <= 0xD7C6 ||
  5391. c >= 0xD7CB && c <= 0xD7FB ||
  5392. c >= 0xF900 && c <= 0xFAFF ||
  5393. c >= 0xFE10 && c <= 0xFE19 ||
  5394. c >= 0xFE30 && c <= 0xFE52 ||
  5395. c >= 0xFE54 && c <= 0xFE66 ||
  5396. c >= 0xFE68 && c <= 0xFE6B ||
  5397. c >= 0xFF01 && c <= 0xFF60 ||
  5398. c >= 0xFFE0 && c <= 0xFFE6;
  5399. };
  5400. }).call(EditSession.prototype);
  5401. require("./edit_session/folding").Folding.call(EditSession.prototype);
  5402. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  5403. exports.EditSession = EditSession;
  5404. });
  5405. ace.define('ace/config', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
  5406. "no use strict";
  5407. var lang = require("./lib/lang");
  5408. var global = (function() {
  5409. return this;
  5410. })();
  5411. var options = {
  5412. packaged: false,
  5413. workerPath: "",
  5414. modePath: "",
  5415. themePath: "",
  5416. suffix: ".js"
  5417. };
  5418. exports.get = function(key) {
  5419. if (!options.hasOwnProperty(key))
  5420. throw new Error("Unknown config key: " + key);
  5421. return options[key];
  5422. };
  5423. exports.set = function(key, value) {
  5424. if (!options.hasOwnProperty(key))
  5425. throw new Error("Unknown config key: " + key);
  5426. options[key] = value;
  5427. };
  5428. exports.all = function() {
  5429. return lang.copyObject(options);
  5430. };
  5431. exports.init = function() {
  5432. options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
  5433. if (!global.document)
  5434. return "";
  5435. var scriptOptions = {};
  5436. var scriptUrl = "";
  5437. var scripts = document.getElementsByTagName("script");
  5438. for (var i=0; i<scripts.length; i++) {
  5439. var script = scripts[i];
  5440. var src = script.src || script.getAttribute("src");
  5441. if (!src) {
  5442. continue;
  5443. }
  5444. var attributes = script.attributes;
  5445. for (var j=0, l=attributes.length; j < l; j++) {
  5446. var attr = attributes[j];
  5447. if (attr.name.indexOf("data-ace-") === 0) {
  5448. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  5449. }
  5450. }
  5451. var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/);
  5452. if (m) {
  5453. scriptUrl = m[1] || m[2];
  5454. }
  5455. }
  5456. if (scriptUrl) {
  5457. scriptOptions.base = scriptOptions.base || scriptUrl;
  5458. scriptOptions.packaged = true;
  5459. }
  5460. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  5461. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  5462. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  5463. delete scriptOptions.base;
  5464. for (var key in scriptOptions)
  5465. if (typeof scriptOptions[key] !== "undefined")
  5466. exports.set(key, scriptOptions[key]);
  5467. };
  5468. function deHyphenate(str) {
  5469. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  5470. }
  5471. });
  5472. ace.define('ace/lib/net', ['require', 'exports', 'module' ], function(require, exports, module) {
  5473. exports.get = function (url, callback) {
  5474. var xhr = exports.createXhr();
  5475. xhr.open('GET', url, true);
  5476. xhr.onreadystatechange = function (evt) {
  5477. //Do not explicitly handle errors, those should be
  5478. //visible via console output in the browser.
  5479. if (xhr.readyState === 4) {
  5480. callback(xhr.responseText);
  5481. }
  5482. };
  5483. xhr.send(null);
  5484. };
  5485. var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
  5486. exports.createXhr = function() {
  5487. //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
  5488. var xhr, i, progId;
  5489. if (typeof XMLHttpRequest !== "undefined") {
  5490. return new XMLHttpRequest();
  5491. } else {
  5492. for (i = 0; i < 3; i++) {
  5493. progId = progIds[i];
  5494. try {
  5495. xhr = new ActiveXObject(progId);
  5496. } catch (e) {}
  5497. if (xhr) {
  5498. progIds = [progId]; // so faster next time
  5499. break;
  5500. }
  5501. }
  5502. }
  5503. if (!xhr) {
  5504. throw new Error("createXhr(): XMLHttpRequest not available");
  5505. }
  5506. return xhr;
  5507. };
  5508. exports.loadScript = function(path, callback) {
  5509. var head = document.getElementsByTagName('head')[0];
  5510. var s = document.createElement('script');
  5511. s.src = path;
  5512. head.appendChild(s);
  5513. s.onload = callback;
  5514. };
  5515. });
  5516. ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
  5517. var EventEmitter = {};
  5518. EventEmitter._emit =
  5519. EventEmitter._dispatchEvent = function(eventName, e) {
  5520. this._eventRegistry = this._eventRegistry || {};
  5521. this._defaultHandlers = this._defaultHandlers || {};
  5522. var listeners = this._eventRegistry[eventName] || [];
  5523. var defaultHandler = this._defaultHandlers[eventName];
  5524. if (!listeners.length && !defaultHandler)
  5525. return;
  5526. e = e || {};
  5527. e.type = eventName;
  5528. if (!e.stopPropagation) {
  5529. e.stopPropagation = function() {
  5530. this.propagationStopped = true;
  5531. };
  5532. }
  5533. if (!e.preventDefault) {
  5534. e.preventDefault = function() {
  5535. this.defaultPrevented = true;
  5536. };
  5537. }
  5538. for (var i=0; i<listeners.length; i++) {
  5539. listeners[i](e);
  5540. if (e.propagationStopped)
  5541. break;
  5542. }
  5543. if (defaultHandler && !e.defaultPrevented)
  5544. return defaultHandler(e);
  5545. };
  5546. EventEmitter.setDefaultHandler = function(eventName, callback) {
  5547. this._defaultHandlers = this._defaultHandlers || {};
  5548. if (this._defaultHandlers[eventName])
  5549. throw new Error("The default handler for '" + eventName + "' is already set");
  5550. this._defaultHandlers[eventName] = callback;
  5551. };
  5552. EventEmitter.on =
  5553. EventEmitter.addEventListener = function(eventName, callback) {
  5554. this._eventRegistry = this._eventRegistry || {};
  5555. var listeners = this._eventRegistry[eventName];
  5556. if (!listeners)
  5557. var listeners = this._eventRegistry[eventName] = [];
  5558. if (listeners.indexOf(callback) == -1)
  5559. listeners.push(callback);
  5560. };
  5561. EventEmitter.removeListener =
  5562. EventEmitter.removeEventListener = function(eventName, callback) {
  5563. this._eventRegistry = this._eventRegistry || {};
  5564. var listeners = this._eventRegistry[eventName];
  5565. if (!listeners)
  5566. return;
  5567. var index = listeners.indexOf(callback);
  5568. if (index !== -1)
  5569. listeners.splice(index, 1);
  5570. };
  5571. EventEmitter.removeAllListeners = function(eventName) {
  5572. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  5573. };
  5574. exports.EventEmitter = EventEmitter;
  5575. });
  5576. ace.define('ace/selection', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter', 'ace/range'], function(require, exports, module) {
  5577. var oop = require("./lib/oop");
  5578. var lang = require("./lib/lang");
  5579. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5580. var Range = require("./range").Range;
  5581. /**
  5582. * new Selection(session)
  5583. * - session (EditSession): The session to use
  5584. *
  5585. * Creates a new `Selection` object.
  5586. *
  5587. **/
  5588. var Selection = function(session) {
  5589. this.session = session;
  5590. this.doc = session.getDocument();
  5591. this.clearSelection();
  5592. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  5593. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  5594. var self = this;
  5595. this.lead.on("change", function(e) {
  5596. self._emit("changeCursor");
  5597. if (!self.$isEmpty)
  5598. self._emit("changeSelection");
  5599. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  5600. self.$desiredColumn = null;
  5601. });
  5602. this.selectionAnchor.on("change", function() {
  5603. if (!self.$isEmpty)
  5604. self._emit("changeSelection");
  5605. });
  5606. };
  5607. (function() {
  5608. oop.implement(this, EventEmitter);
  5609. this.isEmpty = function() {
  5610. return (this.$isEmpty || (
  5611. this.anchor.row == this.lead.row &&
  5612. this.anchor.column == this.lead.column
  5613. ));
  5614. };
  5615. this.isMultiLine = function() {
  5616. if (this.isEmpty()) {
  5617. return false;
  5618. }
  5619. return this.getRange().isMultiLine();
  5620. };
  5621. this.getCursor = function() {
  5622. return this.lead.getPosition();
  5623. };
  5624. this.setSelectionAnchor = function(row, column) {
  5625. this.anchor.setPosition(row, column);
  5626. if (this.$isEmpty) {
  5627. this.$isEmpty = false;
  5628. this._emit("changeSelection");
  5629. }
  5630. };
  5631. this.getSelectionAnchor = function() {
  5632. if (this.$isEmpty)
  5633. return this.getSelectionLead()
  5634. else
  5635. return this.anchor.getPosition();
  5636. };
  5637. this.getSelectionLead = function() {
  5638. return this.lead.getPosition();
  5639. };
  5640. this.shiftSelection = function(columns) {
  5641. if (this.$isEmpty) {
  5642. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  5643. return;
  5644. };
  5645. var anchor = this.getSelectionAnchor();
  5646. var lead = this.getSelectionLead();
  5647. var isBackwards = this.isBackwards();
  5648. if (!isBackwards || anchor.column !== 0)
  5649. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  5650. if (isBackwards || lead.column !== 0) {
  5651. this.$moveSelection(function() {
  5652. this.moveCursorTo(lead.row, lead.column + columns);
  5653. });
  5654. }
  5655. };
  5656. this.isBackwards = function() {
  5657. var anchor = this.anchor;
  5658. var lead = this.lead;
  5659. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  5660. };
  5661. this.getRange = function() {
  5662. var anchor = this.anchor;
  5663. var lead = this.lead;
  5664. if (this.isEmpty())
  5665. return Range.fromPoints(lead, lead);
  5666. if (this.isBackwards()) {
  5667. return Range.fromPoints(lead, anchor);
  5668. }
  5669. else {
  5670. return Range.fromPoints(anchor, lead);
  5671. }
  5672. };
  5673. this.clearSelection = function() {
  5674. if (!this.$isEmpty) {
  5675. this.$isEmpty = true;
  5676. this._emit("changeSelection");
  5677. }
  5678. };
  5679. this.selectAll = function() {
  5680. var lastRow = this.doc.getLength() - 1;
  5681. this.setSelectionAnchor(0, 0);
  5682. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  5683. };
  5684. this.setRange =
  5685. this.setSelectionRange = function(range, reverse) {
  5686. if (reverse) {
  5687. this.setSelectionAnchor(range.end.row, range.end.column);
  5688. this.selectTo(range.start.row, range.start.column);
  5689. } else {
  5690. this.setSelectionAnchor(range.start.row, range.start.column);
  5691. this.selectTo(range.end.row, range.end.column);
  5692. }
  5693. this.$desiredColumn = null;
  5694. };
  5695. this.$moveSelection = function(mover) {
  5696. var lead = this.lead;
  5697. if (this.$isEmpty)
  5698. this.setSelectionAnchor(lead.row, lead.column);
  5699. mover.call(this);
  5700. };
  5701. this.selectTo = function(row, column) {
  5702. this.$moveSelection(function() {
  5703. this.moveCursorTo(row, column);
  5704. });
  5705. };
  5706. this.selectToPosition = function(pos) {
  5707. this.$moveSelection(function() {
  5708. this.moveCursorToPosition(pos);
  5709. });
  5710. };
  5711. this.selectUp = function() {
  5712. this.$moveSelection(this.moveCursorUp);
  5713. };
  5714. this.selectDown = function() {
  5715. this.$moveSelection(this.moveCursorDown);
  5716. };
  5717. this.selectRight = function() {
  5718. this.$moveSelection(this.moveCursorRight);
  5719. };
  5720. this.selectLeft = function() {
  5721. this.$moveSelection(this.moveCursorLeft);
  5722. };
  5723. this.selectLineStart = function() {
  5724. this.$moveSelection(this.moveCursorLineStart);
  5725. };
  5726. this.selectLineEnd = function() {
  5727. this.$moveSelection(this.moveCursorLineEnd);
  5728. };
  5729. this.selectFileEnd = function() {
  5730. this.$moveSelection(this.moveCursorFileEnd);
  5731. };
  5732. this.selectFileStart = function() {
  5733. this.$moveSelection(this.moveCursorFileStart);
  5734. };
  5735. this.selectWordRight = function() {
  5736. this.$moveSelection(this.moveCursorWordRight);
  5737. };
  5738. this.selectWordLeft = function() {
  5739. this.$moveSelection(this.moveCursorWordLeft);
  5740. };
  5741. this.getWordRange = function(row, column) {
  5742. if (typeof column == "undefined") {
  5743. var cursor = row || this.lead;
  5744. row = cursor.row;
  5745. column = cursor.column;
  5746. }
  5747. return this.session.getWordRange(row, column);
  5748. };
  5749. this.selectWord = function() {
  5750. this.setSelectionRange(this.getWordRange());
  5751. };
  5752. this.selectAWord = function() {
  5753. var cursor = this.getCursor();
  5754. var range = this.session.getAWordRange(cursor.row, cursor.column);
  5755. this.setSelectionRange(range);
  5756. };
  5757. this.getLineRange = function(row, excludeLastChar) {
  5758. var rowStart = typeof row == "number" ? row : this.lead.row;
  5759. var rowEnd;
  5760. var foldLine = this.session.getFoldLine(rowStart);
  5761. if (foldLine) {
  5762. rowStart = foldLine.start.row;
  5763. rowEnd = foldLine.end.row;
  5764. } else {
  5765. rowEnd = rowStart;
  5766. }
  5767. if (excludeLastChar)
  5768. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  5769. else
  5770. return new Range(rowStart, 0, rowEnd + 1, 0);
  5771. };
  5772. this.selectLine = function() {
  5773. this.setSelectionRange(this.getLineRange());
  5774. };
  5775. this.moveCursorUp = function() {
  5776. this.moveCursorBy(-1, 0);
  5777. };
  5778. this.moveCursorDown = function() {
  5779. this.moveCursorBy(1, 0);
  5780. };
  5781. this.moveCursorLeft = function() {
  5782. var cursor = this.lead.getPosition(),
  5783. fold;
  5784. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  5785. this.moveCursorTo(fold.start.row, fold.start.column);
  5786. } else if (cursor.column == 0) {
  5787. // cursor is a line (start
  5788. if (cursor.row > 0) {
  5789. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  5790. }
  5791. }
  5792. else {
  5793. var tabSize = this.session.getTabSize();
  5794. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  5795. this.moveCursorBy(0, -tabSize);
  5796. else
  5797. this.moveCursorBy(0, -1);
  5798. }
  5799. };
  5800. this.moveCursorRight = function() {
  5801. var cursor = this.lead.getPosition(),
  5802. fold;
  5803. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  5804. this.moveCursorTo(fold.end.row, fold.end.column);
  5805. }
  5806. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  5807. if (this.lead.row < this.doc.getLength() - 1) {
  5808. this.moveCursorTo(this.lead.row + 1, 0);
  5809. }
  5810. }
  5811. else {
  5812. var tabSize = this.session.getTabSize();
  5813. var cursor = this.lead;
  5814. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  5815. this.moveCursorBy(0, tabSize);
  5816. else
  5817. this.moveCursorBy(0, 1);
  5818. }
  5819. };
  5820. this.moveCursorLineStart = function() {
  5821. var row = this.lead.row;
  5822. var column = this.lead.column;
  5823. var screenRow = this.session.documentToScreenRow(row, column);
  5824. // Determ the doc-position of the first character at the screen line.
  5825. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  5826. // Determ the line
  5827. var beforeCursor = this.session.getDisplayLine(
  5828. row, null,
  5829. firstColumnPosition.row, firstColumnPosition.column
  5830. );
  5831. var leadingSpace = beforeCursor.match(/^\s*/);
  5832. if (leadingSpace[0].length == column) {
  5833. this.moveCursorTo(
  5834. firstColumnPosition.row, firstColumnPosition.column
  5835. );
  5836. }
  5837. else {
  5838. this.moveCursorTo(
  5839. firstColumnPosition.row,
  5840. firstColumnPosition.column + leadingSpace[0].length
  5841. );
  5842. }
  5843. };
  5844. this.moveCursorLineEnd = function() {
  5845. var lead = this.lead;
  5846. var lastRowColumnPosition =
  5847. this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  5848. this.moveCursorTo(
  5849. lastRowColumnPosition.row,
  5850. lastRowColumnPosition.column
  5851. );
  5852. };
  5853. this.moveCursorFileEnd = function() {
  5854. var row = this.doc.getLength() - 1;
  5855. var column = this.doc.getLine(row).length;
  5856. this.moveCursorTo(row, column);
  5857. };
  5858. this.moveCursorFileStart = function() {
  5859. this.moveCursorTo(0, 0);
  5860. };
  5861. this.moveCursorLongWordRight = function() {
  5862. var row = this.lead.row;
  5863. var column = this.lead.column;
  5864. var line = this.doc.getLine(row);
  5865. var rightOfCursor = line.substring(column);
  5866. var match;
  5867. this.session.nonTokenRe.lastIndex = 0;
  5868. this.session.tokenRe.lastIndex = 0;
  5869. // skip folds
  5870. var fold = this.session.getFoldAt(row, column, 1);
  5871. if (fold) {
  5872. this.moveCursorTo(fold.end.row, fold.end.column);
  5873. return;
  5874. }
  5875. // first skip space
  5876. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  5877. column += this.session.nonTokenRe.lastIndex;
  5878. this.session.nonTokenRe.lastIndex = 0;
  5879. rightOfCursor = line.substring(column);
  5880. }
  5881. // if at line end proceed with next line
  5882. if (column >= line.length) {
  5883. this.moveCursorTo(row, line.length);
  5884. this.moveCursorRight();
  5885. if (row < this.doc.getLength() - 1)
  5886. this.moveCursorWordRight();
  5887. return;
  5888. }
  5889. // advance to the end of the next token
  5890. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  5891. column += this.session.tokenRe.lastIndex;
  5892. this.session.tokenRe.lastIndex = 0;
  5893. }
  5894. this.moveCursorTo(row, column);
  5895. };
  5896. this.moveCursorLongWordLeft = function() {
  5897. var row = this.lead.row;
  5898. var column = this.lead.column;
  5899. // skip folds
  5900. var fold;
  5901. if (fold = this.session.getFoldAt(row, column, -1)) {
  5902. this.moveCursorTo(fold.start.row, fold.start.column);
  5903. return;
  5904. }
  5905. var str = this.session.getFoldStringAt(row, column, -1);
  5906. if (str == null) {
  5907. str = this.doc.getLine(row).substring(0, column)
  5908. }
  5909. var leftOfCursor = lang.stringReverse(str);
  5910. var match;
  5911. this.session.nonTokenRe.lastIndex = 0;
  5912. this.session.tokenRe.lastIndex = 0;
  5913. // skip whitespace
  5914. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  5915. column -= this.session.nonTokenRe.lastIndex;
  5916. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  5917. this.session.nonTokenRe.lastIndex = 0;
  5918. }
  5919. // if at begin of the line proceed in line above
  5920. if (column <= 0) {
  5921. this.moveCursorTo(row, 0);
  5922. this.moveCursorLeft();
  5923. if (row > 0)
  5924. this.moveCursorWordLeft();
  5925. return;
  5926. }
  5927. // move to the begin of the word
  5928. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  5929. column -= this.session.tokenRe.lastIndex;
  5930. this.session.tokenRe.lastIndex = 0;
  5931. }
  5932. this.moveCursorTo(row, column);
  5933. };
  5934. this.$shortWordEndIndex = function(rightOfCursor) {
  5935. var match, index = 0, ch;
  5936. var whitespaceRe = /\s/;
  5937. var tokenRe = this.session.tokenRe;
  5938. tokenRe.lastIndex = 0;
  5939. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  5940. index = this.session.tokenRe.lastIndex;
  5941. } else {
  5942. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  5943. index ++;
  5944. if (index <= 1) {
  5945. tokenRe.lastIndex = 0;
  5946. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  5947. tokenRe.lastIndex = 0;
  5948. index ++;
  5949. if (whitespaceRe.test(ch)) {
  5950. if (index > 2) {
  5951. index--
  5952. break;
  5953. } else {
  5954. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  5955. index ++;
  5956. if (index > 2)
  5957. break
  5958. }
  5959. }
  5960. }
  5961. }
  5962. }
  5963. tokenRe.lastIndex = 0;
  5964. return index;
  5965. };
  5966. this.moveCursorShortWordRight = function() {
  5967. var row = this.lead.row;
  5968. var column = this.lead.column;
  5969. var line = this.doc.getLine(row);
  5970. var rightOfCursor = line.substring(column);
  5971. var fold = this.session.getFoldAt(row, column, 1);
  5972. if (fold)
  5973. return this.moveCursorTo(fold.end.row, fold.end.column);
  5974. if (column == line.length) {
  5975. var l = this.doc.getLength();
  5976. do {
  5977. row++;
  5978. rightOfCursor = this.doc.getLine(row)
  5979. } while (row < l && /^\s*$/.test(rightOfCursor))
  5980. if (!/^\s+/.test(rightOfCursor))
  5981. rightOfCursor = ""
  5982. column = 0;
  5983. }
  5984. var index = this.$shortWordEndIndex(rightOfCursor);
  5985. this.moveCursorTo(row, column + index);
  5986. };
  5987. this.moveCursorShortWordLeft = function() {
  5988. var row = this.lead.row;
  5989. var column = this.lead.column;
  5990. var fold;
  5991. if (fold = this.session.getFoldAt(row, column, -1))
  5992. return this.moveCursorTo(fold.start.row, fold.start.column);
  5993. var line = this.session.getLine(row).substring(0, column);
  5994. if (column == 0) {
  5995. do {
  5996. row--;
  5997. line = this.doc.getLine(row);
  5998. } while (row > 0 && /^\s*$/.test(line))
  5999. column = line.length;
  6000. if (!/\s+$/.test(line))
  6001. line = ""
  6002. }
  6003. var leftOfCursor = lang.stringReverse(line);
  6004. var index = this.$shortWordEndIndex(leftOfCursor);
  6005. return this.moveCursorTo(row, column - index);
  6006. };
  6007. this.moveCursorWordRight = function() {
  6008. if (this.session.$selectLongWords)
  6009. this.moveCursorLongWordRight();
  6010. else
  6011. this.moveCursorShortWordRight();
  6012. };
  6013. this.moveCursorWordLeft = function() {
  6014. if (this.session.$selectLongWords)
  6015. this.moveCursorLongWordLeft();
  6016. else
  6017. this.moveCursorShortWordLeft();
  6018. };
  6019. this.moveCursorBy = function(rows, chars) {
  6020. var screenPos = this.session.documentToScreenPosition(
  6021. this.lead.row,
  6022. this.lead.column
  6023. );
  6024. if (chars === 0) {
  6025. if (this.$desiredColumn)
  6026. screenPos.column = this.$desiredColumn;
  6027. else
  6028. this.$desiredColumn = screenPos.column;
  6029. }
  6030. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  6031. // move the cursor and update the desired column
  6032. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  6033. };
  6034. this.moveCursorToPosition = function(position) {
  6035. this.moveCursorTo(position.row, position.column);
  6036. };
  6037. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  6038. // Ensure the row/column is not inside of a fold.
  6039. var fold = this.session.getFoldAt(row, column, 1);
  6040. if (fold) {
  6041. row = fold.start.row;
  6042. column = fold.start.column;
  6043. }
  6044. this.$keepDesiredColumnOnChange = true;
  6045. this.lead.setPosition(row, column);
  6046. this.$keepDesiredColumnOnChange = false;
  6047. if (!keepDesiredColumn)
  6048. this.$desiredColumn = null;
  6049. };
  6050. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  6051. var pos = this.session.screenToDocumentPosition(row, column);
  6052. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  6053. };
  6054. // remove listeners from document
  6055. this.detach = function() {
  6056. this.lead.detach();
  6057. this.anchor.detach();
  6058. this.session = this.doc = null;
  6059. }
  6060. this.fromOrientedRange = function(range) {
  6061. this.setSelectionRange(range, range.cursor == range.start);
  6062. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  6063. }
  6064. this.toOrientedRange = function(range) {
  6065. var r = this.getRange();
  6066. if (range) {
  6067. range.start.column = r.start.column;
  6068. range.start.row = r.start.row;
  6069. range.end.column = r.end.column;
  6070. range.end.row = r.end.row;
  6071. } else {
  6072. range = r;
  6073. }
  6074. range.cursor = this.isBackwards() ? range.start : range.end;
  6075. range.desiredColumn = this.$desiredColumn;
  6076. return range;
  6077. }
  6078. }).call(Selection.prototype);
  6079. exports.Selection = Selection;
  6080. });
  6081. ace.define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
  6082. /**
  6083. * class Range
  6084. *
  6085. * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column.
  6086. *
  6087. **/
  6088. /**
  6089. * new Range(startRow, startColumn, endRow, endColumn)
  6090. * - startRow (Number): The starting row
  6091. * - startColumn (Number): The starting column
  6092. * - endRow (Number): The ending row
  6093. * - endColumn (Number): The ending column
  6094. *
  6095. * Creates a new `Range` object with the given starting and ending row and column points.
  6096. *
  6097. **/
  6098. var Range = function(startRow, startColumn, endRow, endColumn) {
  6099. this.start = {
  6100. row: startRow,
  6101. column: startColumn
  6102. };
  6103. this.end = {
  6104. row: endRow,
  6105. column: endColumn
  6106. };
  6107. };
  6108. (function() {
  6109. /**
  6110. * Range.isEqual(range) -> Boolean
  6111. * - range (Range): A range to check against
  6112. *
  6113. * Returns `true` if and only if the starting row and column, and ending tow and column, are equivalent to those given by `range`.
  6114. *
  6115. **/
  6116. this.isEqual = function(range) {
  6117. return this.start.row == range.start.row &&
  6118. this.end.row == range.end.row &&
  6119. this.start.column == range.start.column &&
  6120. this.end.column == range.end.column
  6121. };
  6122. this.toString = function() {
  6123. return ("Range: [" + this.start.row + "/" + this.start.column +
  6124. "] -> [" + this.end.row + "/" + this.end.column + "]");
  6125. };
  6126. this.contains = function(row, column) {
  6127. return this.compare(row, column) == 0;
  6128. };
  6129. this.compareRange = function(range) {
  6130. var cmp,
  6131. end = range.end,
  6132. start = range.start;
  6133. cmp = this.compare(end.row, end.column);
  6134. if (cmp == 1) {
  6135. cmp = this.compare(start.row, start.column);
  6136. if (cmp == 1) {
  6137. return 2;
  6138. } else if (cmp == 0) {
  6139. return 1;
  6140. } else {
  6141. return 0;
  6142. }
  6143. } else if (cmp == -1) {
  6144. return -2;
  6145. } else {
  6146. cmp = this.compare(start.row, start.column);
  6147. if (cmp == -1) {
  6148. return -1;
  6149. } else if (cmp == 1) {
  6150. return 42;
  6151. } else {
  6152. return 0;
  6153. }
  6154. }
  6155. }
  6156. /** related to: Range.compare
  6157. * Range.comparePoint(p) -> Number
  6158. * - p (Range): A point to compare with
  6159. * + (Number): This method returns one of the following numbers:<br/>
  6160. * * `0` if the two points are exactly equal<br/>
  6161. * * `-1` if `p.row` is less then the calling range<br/>
  6162. * * `1` if `p.row` is greater than the calling range<br/>
  6163. * <br/>
  6164. * If the starting row of the calling range is equal to `p.row`, and:<br/>
  6165. * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`<br/>
  6166. * * Otherwise, it returns -1<br/>
  6167. *<br/>
  6168. * If the ending row of the calling range is equal to `p.row`, and:<br/>
  6169. * * `p.column` is less than or equal to the calling range's ending column, this returns `0`<br/>
  6170. * * Otherwise, it returns 1<br/>
  6171. *
  6172. * Checks the row and column points of `p` with the row and column points of the calling range.
  6173. *
  6174. *
  6175. *
  6176. **/
  6177. this.comparePoint = function(p) {
  6178. return this.compare(p.row, p.column);
  6179. }
  6180. /** related to: Range.comparePoint
  6181. * Range.containsRange(range) -> Boolean
  6182. * - range (Range): A range to compare with
  6183. *
  6184. * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.
  6185. *
  6186. **/
  6187. this.containsRange = function(range) {
  6188. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  6189. }
  6190. /**
  6191. * Range.intersects(range) -> Boolean
  6192. * - range (Range): A range to compare with
  6193. *
  6194. * Returns `true` if passed in `range` intersects with the one calling this method.
  6195. *
  6196. **/
  6197. this.intersects = function(range) {
  6198. var cmp = this.compareRange(range);
  6199. return (cmp == -1 || cmp == 0 || cmp == 1);
  6200. }
  6201. /**
  6202. * Range.isEnd(row, column) -> Boolean
  6203. * - row (Number): A row point to compare with
  6204. * - column (Number): A column point to compare with
  6205. *
  6206. * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.
  6207. *
  6208. **/
  6209. this.isEnd = function(row, column) {
  6210. return this.end.row == row && this.end.column == column;
  6211. }
  6212. /**
  6213. * Range.isStart(row, column) -> Boolean
  6214. * - row (Number): A row point to compare with
  6215. * - column (Number): A column point to compare with
  6216. *
  6217. * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.
  6218. *
  6219. **/
  6220. this.isStart = function(row, column) {
  6221. return this.start.row == row && this.start.column == column;
  6222. }
  6223. /**
  6224. * Range.setStart(row, column)
  6225. * - row (Number): A row point to set
  6226. * - column (Number): A column point to set
  6227. *
  6228. * Sets the starting row and column for the range.
  6229. *
  6230. **/
  6231. this.setStart = function(row, column) {
  6232. if (typeof row == "object") {
  6233. this.start.column = row.column;
  6234. this.start.row = row.row;
  6235. } else {
  6236. this.start.row = row;
  6237. this.start.column = column;
  6238. }
  6239. }
  6240. /**
  6241. * Range.setEnd(row, column)
  6242. * - row (Number): A row point to set
  6243. * - column (Number): A column point to set
  6244. *
  6245. * Sets the starting row and column for the range.
  6246. *
  6247. **/
  6248. this.setEnd = function(row, column) {
  6249. if (typeof row == "object") {
  6250. this.end.column = row.column;
  6251. this.end.row = row.row;
  6252. } else {
  6253. this.end.row = row;
  6254. this.end.column = column;
  6255. }
  6256. }
  6257. /** related to: Range.compare
  6258. * Range.inside(row, column) -> Boolean
  6259. * - row (Number): A row point to compare with
  6260. * - column (Number): A column point to compare with
  6261. *
  6262. * Returns `true` if the `row` and `column` are within the given range.
  6263. *
  6264. **/
  6265. this.inside = function(row, column) {
  6266. if (this.compare(row, column) == 0) {
  6267. if (this.isEnd(row, column) || this.isStart(row, column)) {
  6268. return false;
  6269. } else {
  6270. return true;
  6271. }
  6272. }
  6273. return false;
  6274. }
  6275. /** related to: Range.compare
  6276. * Range.insideStart(row, column) -> Boolean
  6277. * - row (Number): A row point to compare with
  6278. * - column (Number): A column point to compare with
  6279. *
  6280. * Returns `true` if the `row` and `column` are within the given range's starting points.
  6281. *
  6282. **/
  6283. this.insideStart = function(row, column) {
  6284. if (this.compare(row, column) == 0) {
  6285. if (this.isEnd(row, column)) {
  6286. return false;
  6287. } else {
  6288. return true;
  6289. }
  6290. }
  6291. return false;
  6292. }
  6293. /** related to: Range.compare
  6294. * Range.insideEnd(row, column) -> Boolean
  6295. * - row (Number): A row point to compare with
  6296. * - column (Number): A column point to compare with
  6297. *
  6298. * Returns `true` if the `row` and `column` are within the given range's ending points.
  6299. *
  6300. **/
  6301. this.insideEnd = function(row, column) {
  6302. if (this.compare(row, column) == 0) {
  6303. if (this.isStart(row, column)) {
  6304. return false;
  6305. } else {
  6306. return true;
  6307. }
  6308. }
  6309. return false;
  6310. }
  6311. /**
  6312. * Range.compare(row, column) -> Number
  6313. * - row (Number): A row point to compare with
  6314. * - column (Number): A column point to compare with
  6315. * + (Number): This method returns one of the following numbers:<br/>
  6316. * * `0` if the two points are exactly equal <br/>
  6317. * * `-1` if `p.row` is less then the calling range <br/>
  6318. * * `1` if `p.row` is greater than the calling range <br/>
  6319. * <br/>
  6320. * If the starting row of the calling range is equal to `p.row`, and: <br/>
  6321. * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`<br/>
  6322. * * Otherwise, it returns -1<br/>
  6323. * <br/>
  6324. * If the ending row of the calling range is equal to `p.row`, and: <br/>
  6325. * * `p.column` is less than or equal to the calling range's ending column, this returns `0` <br/>
  6326. * * Otherwise, it returns 1
  6327. *
  6328. * Checks the row and column points with the row and column points of the calling range.
  6329. *
  6330. *
  6331. **/
  6332. this.compare = function(row, column) {
  6333. if (!this.isMultiLine()) {
  6334. if (row === this.start.row) {
  6335. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  6336. };
  6337. }
  6338. if (row < this.start.row)
  6339. return -1;
  6340. if (row > this.end.row)
  6341. return 1;
  6342. if (this.start.row === row)
  6343. return column >= this.start.column ? 0 : -1;
  6344. if (this.end.row === row)
  6345. return column <= this.end.column ? 0 : 1;
  6346. return 0;
  6347. };
  6348. this.compareStart = function(row, column) {
  6349. if (this.start.row == row && this.start.column == column) {
  6350. return -1;
  6351. } else {
  6352. return this.compare(row, column);
  6353. }
  6354. }
  6355. /**
  6356. * Range.compareEnd(row, column) -> Number
  6357. * - row (Number): A row point to compare with
  6358. * - column (Number): A column point to compare with
  6359. * + (Number): This method returns one of the following numbers:<br/>
  6360. * * `0` if the two points are exactly equal<br/>
  6361. * * `-1` if `p.row` is less then the calling range<br/>
  6362. * * `1` if `p.row` is greater than the calling range, or if `isEnd` is `true.<br/>
  6363. * <br/>
  6364. * If the starting row of the calling range is equal to `p.row`, and:<br/>
  6365. * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`<br/>
  6366. * * Otherwise, it returns -1<br/>
  6367. *<br/>
  6368. * If the ending row of the calling range is equal to `p.row`, and:<br/>
  6369. * * `p.column` is less than or equal to the calling range's ending column, this returns `0`<br/>
  6370. * * Otherwise, it returns 1
  6371. *
  6372. * Checks the row and column points with the row and column points of the calling range.
  6373. *
  6374. *
  6375. **/
  6376. this.compareEnd = function(row, column) {
  6377. if (this.end.row == row && this.end.column == column) {
  6378. return 1;
  6379. } else {
  6380. return this.compare(row, column);
  6381. }
  6382. }
  6383. /**
  6384. * Range.compareInside(row, column) -> Number
  6385. * - row (Number): A row point to compare with
  6386. * - column (Number): A column point to compare with
  6387. * + (Number): This method returns one of the following numbers:<br/>
  6388. * * `1` if the ending row of the calling range is equal to `row`, and the ending column of the calling range is equal to `column`<br/>
  6389. * * `-1` if the starting row of the calling range is equal to `row`, and the starting column of the calling range is equal to `column`<br/>
  6390. * <br/>
  6391. * Otherwise, it returns the value after calling [[Range.compare `compare()`]].
  6392. *
  6393. * Checks the row and column points with the row and column points of the calling range.
  6394. *
  6395. *
  6396. *
  6397. **/
  6398. this.compareInside = function(row, column) {
  6399. if (this.end.row == row && this.end.column == column) {
  6400. return 1;
  6401. } else if (this.start.row == row && this.start.column == column) {
  6402. return -1;
  6403. } else {
  6404. return this.compare(row, column);
  6405. }
  6406. }
  6407. /**
  6408. * Range.clipRows(firstRow, lastRow) -> Range
  6409. * - firstRow (Number): The starting row
  6410. * - lastRow (Number): The ending row
  6411. *
  6412. * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.
  6413. *
  6414. **/
  6415. this.clipRows = function(firstRow, lastRow) {
  6416. if (this.end.row > lastRow) {
  6417. var end = {
  6418. row: lastRow+1,
  6419. column: 0
  6420. };
  6421. }
  6422. if (this.start.row > lastRow) {
  6423. var start = {
  6424. row: lastRow+1,
  6425. column: 0
  6426. };
  6427. }
  6428. if (this.start.row < firstRow) {
  6429. var start = {
  6430. row: firstRow,
  6431. column: 0
  6432. };
  6433. }
  6434. if (this.end.row < firstRow) {
  6435. var end = {
  6436. row: firstRow,
  6437. column: 0
  6438. };
  6439. }
  6440. return Range.fromPoints(start || this.start, end || this.end);
  6441. };
  6442. this.extend = function(row, column) {
  6443. var cmp = this.compare(row, column);
  6444. if (cmp == 0)
  6445. return this;
  6446. else if (cmp == -1)
  6447. var start = {row: row, column: column};
  6448. else
  6449. var end = {row: row, column: column};
  6450. return Range.fromPoints(start || this.start, end || this.end);
  6451. };
  6452. this.isEmpty = function() {
  6453. return (this.start.row == this.end.row && this.start.column == this.end.column);
  6454. };
  6455. this.isMultiLine = function() {
  6456. return (this.start.row !== this.end.row);
  6457. };
  6458. this.clone = function() {
  6459. return Range.fromPoints(this.start, this.end);
  6460. };
  6461. this.collapseRows = function() {
  6462. if (this.end.column == 0)
  6463. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  6464. else
  6465. return new Range(this.start.row, 0, this.end.row, 0)
  6466. };
  6467. this.toScreenRange = function(session) {
  6468. var screenPosStart =
  6469. session.documentToScreenPosition(this.start);
  6470. var screenPosEnd =
  6471. session.documentToScreenPosition(this.end);
  6472. return new Range(
  6473. screenPosStart.row, screenPosStart.column,
  6474. screenPosEnd.row, screenPosEnd.column
  6475. );
  6476. };
  6477. }).call(Range.prototype);
  6478. Range.fromPoints = function(start, end) {
  6479. return new Range(start.row, start.column, end.row, end.column);
  6480. };
  6481. exports.Range = Range;
  6482. });
  6483. ace.define('ace/mode/text', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/behaviour', 'ace/unicode'], function(require, exports, module) {
  6484. var Tokenizer = require("../tokenizer").Tokenizer;
  6485. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  6486. var Behaviour = require("./behaviour").Behaviour;
  6487. var unicode = require("../unicode");
  6488. var Mode = function() {
  6489. this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
  6490. this.$behaviour = new Behaviour();
  6491. };
  6492. (function() {
  6493. this.tokenRe = new RegExp("^["
  6494. + unicode.packages.L
  6495. + unicode.packages.Mn + unicode.packages.Mc
  6496. + unicode.packages.Nd
  6497. + unicode.packages.Pc + "\\$_]+", "g"
  6498. );
  6499. this.nonTokenRe = new RegExp("^(?:[^"
  6500. + unicode.packages.L
  6501. + unicode.packages.Mn + unicode.packages.Mc
  6502. + unicode.packages.Nd
  6503. + unicode.packages.Pc + "\\$_]|\s])+", "g"
  6504. );
  6505. this.getTokenizer = function() {
  6506. return this.$tokenizer;
  6507. };
  6508. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  6509. };
  6510. this.getNextLineIndent = function(state, line, tab) {
  6511. return "";
  6512. };
  6513. this.checkOutdent = function(state, line, input) {
  6514. return false;
  6515. };
  6516. this.autoOutdent = function(state, doc, row) {
  6517. };
  6518. this.$getIndent = function(line) {
  6519. var match = line.match(/^(\s+)/);
  6520. if (match) {
  6521. return match[1];
  6522. }
  6523. return "";
  6524. };
  6525. this.createWorker = function(session) {
  6526. return null;
  6527. };
  6528. this.createModeDelegates = function (mapping) {
  6529. if (!this.$embeds) {
  6530. return;
  6531. }
  6532. this.$modes = {};
  6533. for (var i = 0; i < this.$embeds.length; i++) {
  6534. if (mapping[this.$embeds[i]]) {
  6535. this.$modes[this.$embeds[i]] = new mapping[this.$embeds[i]]();
  6536. }
  6537. }
  6538. var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction'];
  6539. for (var i = 0; i < delegations.length; i++) {
  6540. (function(scope) {
  6541. var functionName = delegations[i];
  6542. var defaultHandler = scope[functionName];
  6543. scope[delegations[i]] = function() {
  6544. return this.$delegator(functionName, arguments, defaultHandler);
  6545. }
  6546. } (this));
  6547. }
  6548. }
  6549. this.$delegator = function(method, args, defaultHandler) {
  6550. var state = args[0];
  6551. for (var i = 0; i < this.$embeds.length; i++) {
  6552. if (!this.$modes[this.$embeds[i]]) continue;
  6553. var split = state.split(this.$embeds[i]);
  6554. if (!split[0] && split[1]) {
  6555. args[0] = split[1];
  6556. var mode = this.$modes[this.$embeds[i]];
  6557. return mode[method].apply(mode, args);
  6558. }
  6559. }
  6560. var ret = defaultHandler.apply(this, args);
  6561. return defaultHandler ? ret : undefined;
  6562. };
  6563. this.transformAction = function(state, action, editor, session, param) {
  6564. if (this.$behaviour) {
  6565. var behaviours = this.$behaviour.getBehaviours();
  6566. for (var key in behaviours) {
  6567. if (behaviours[key][action]) {
  6568. var ret = behaviours[key][action].apply(this, arguments);
  6569. if (ret) {
  6570. return ret;
  6571. }
  6572. }
  6573. }
  6574. }
  6575. }
  6576. }).call(Mode.prototype);
  6577. exports.Mode = Mode;
  6578. });
  6579. ace.define('ace/tokenizer', ['require', 'exports', 'module' ], function(require, exports, module) {
  6580. /**
  6581. * class Tokenizer
  6582. *
  6583. * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
  6584. *
  6585. **/
  6586. /**
  6587. * new Tokenizer(rules, flag)
  6588. * - rules (Object): The highlighting rules
  6589. * - flag (String): Any additional regular expression flags to pass (like "i" for case insensitive)
  6590. *
  6591. * Constructs a new tokenizer based on the given rules and flags.
  6592. *
  6593. **/
  6594. var Tokenizer = function(rules, flag) {
  6595. flag = flag ? "g" + flag : "g";
  6596. this.rules = rules;
  6597. this.regExps = {};
  6598. this.matchMappings = {};
  6599. for ( var key in this.rules) {
  6600. var rule = this.rules[key];
  6601. var state = rule;
  6602. var ruleRegExps = [];
  6603. var matchTotal = 0;
  6604. var mapping = this.matchMappings[key] = {};
  6605. for ( var i = 0; i < state.length; i++) {
  6606. if (state[i].regex instanceof RegExp)
  6607. state[i].regex = state[i].regex.toString().slice(1, -1);
  6608. // Count number of matching groups. 2 extra groups from the full match
  6609. // And the catch-all on the end (used to force a match);
  6610. var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
  6611. // Replace any backreferences and offset appropriately.
  6612. var adjustedregex = state[i].regex.replace(/\\([0-9]+)/g, function (match, digit) {
  6613. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  6614. });
  6615. if (matchcount > 1 && state[i].token.length !== matchcount-1)
  6616. throw new Error("Matching groups and length of the token array don't match in rule #" + i + " of state " + key);
  6617. mapping[matchTotal] = {
  6618. rule: i,
  6619. len: matchcount
  6620. };
  6621. matchTotal += matchcount;
  6622. ruleRegExps.push(adjustedregex);
  6623. }
  6624. this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", flag);
  6625. }
  6626. };
  6627. (function() {
  6628. /**
  6629. * Tokenizer.getLineTokens() -> Object
  6630. *
  6631. * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state.
  6632. **/
  6633. this.getLineTokens = function(line, startState) {
  6634. var currentState = startState || "start";
  6635. var state = this.rules[currentState];
  6636. var mapping = this.matchMappings[currentState];
  6637. var re = this.regExps[currentState];
  6638. re.lastIndex = 0;
  6639. var match, tokens = [];
  6640. var lastIndex = 0;
  6641. var token = {
  6642. type: null,
  6643. value: ""
  6644. };
  6645. while (match = re.exec(line)) {
  6646. var type = "text";
  6647. var rule = null;
  6648. var value = [match[0]];
  6649. for (var i = 0; i < match.length-2; i++) {
  6650. if (match[i + 1] === undefined)
  6651. continue;
  6652. rule = state[mapping[i].rule];
  6653. if (mapping[i].len > 1)
  6654. value = match.slice(i+2, i+1+mapping[i].len);
  6655. // compute token type
  6656. if (typeof rule.token == "function")
  6657. type = rule.token.apply(this, value);
  6658. else
  6659. type = rule.token;
  6660. if (rule.next) {
  6661. currentState = rule.next;
  6662. state = this.rules[currentState];
  6663. mapping = this.matchMappings[currentState];
  6664. lastIndex = re.lastIndex;
  6665. re = this.regExps[currentState];
  6666. re.lastIndex = lastIndex;
  6667. }
  6668. break;
  6669. }
  6670. if (value[0]) {
  6671. if (typeof type == "string") {
  6672. value = [value.join("")];
  6673. type = [type];
  6674. }
  6675. for (var i = 0; i < value.length; i++) {
  6676. if (!value[i])
  6677. continue;
  6678. if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
  6679. token.value += value[i];
  6680. } else {
  6681. if (token.type)
  6682. tokens.push(token);
  6683. token = {
  6684. type: type[i],
  6685. value: value[i]
  6686. };
  6687. }
  6688. }
  6689. }
  6690. if (lastIndex == line.length)
  6691. break;
  6692. lastIndex = re.lastIndex;
  6693. }
  6694. if (token.type)
  6695. tokens.push(token);
  6696. return {
  6697. tokens : tokens,
  6698. state : currentState
  6699. };
  6700. };
  6701. }).call(Tokenizer.prototype);
  6702. exports.Tokenizer = Tokenizer;
  6703. });
  6704. ace.define('ace/mode/text_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
  6705. var lang = require("../lib/lang");
  6706. var TextHighlightRules = function() {
  6707. // regexp must not have capturing parentheses
  6708. // regexps are ordered -> the first match is used
  6709. this.$rules = {
  6710. "start" : [{
  6711. token : "empty_line",
  6712. regex : '^$'
  6713. }, {
  6714. token : "text",
  6715. regex : ".+"
  6716. }]
  6717. };
  6718. };
  6719. (function() {
  6720. this.addRules = function(rules, prefix) {
  6721. for (var key in rules) {
  6722. var state = rules[key];
  6723. for (var i=0; i<state.length; i++) {
  6724. var rule = state[i];
  6725. if (rule.next) {
  6726. rule.next = prefix + rule.next;
  6727. }
  6728. }
  6729. this.$rules[prefix + key] = state;
  6730. }
  6731. };
  6732. this.getRules = function() {
  6733. return this.$rules;
  6734. };
  6735. this.embedRules = function (HighlightRules, prefix, escapeRules, states) {
  6736. var embedRules = new HighlightRules().getRules();
  6737. if (states) {
  6738. for (var i = 0; i < states.length; i++) {
  6739. states[i] = prefix + states[i];
  6740. }
  6741. } else {
  6742. states = [];
  6743. for (var key in embedRules) {
  6744. states.push(prefix + key);
  6745. }
  6746. }
  6747. this.addRules(embedRules, prefix);
  6748. for (var i = 0; i < states.length; i++) {
  6749. Array.prototype.unshift.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  6750. }
  6751. if (!this.$embeds) {
  6752. this.$embeds = [];
  6753. }
  6754. this.$embeds.push(prefix);
  6755. }
  6756. this.getEmbeds = function() {
  6757. return this.$embeds;
  6758. }
  6759. }).call(TextHighlightRules.prototype);
  6760. exports.TextHighlightRules = TextHighlightRules;
  6761. });
  6762. ace.define('ace/mode/behaviour', ['require', 'exports', 'module' ], function(require, exports, module) {
  6763. var Behaviour = function() {
  6764. this.$behaviours = {};
  6765. };
  6766. (function () {
  6767. this.add = function (name, action, callback) {
  6768. switch (undefined) {
  6769. case this.$behaviours:
  6770. this.$behaviours = {};
  6771. case this.$behaviours[name]:
  6772. this.$behaviours[name] = {};
  6773. }
  6774. this.$behaviours[name][action] = callback;
  6775. }
  6776. this.addBehaviours = function (behaviours) {
  6777. for (var key in behaviours) {
  6778. for (var action in behaviours[key]) {
  6779. this.add(key, action, behaviours[key][action]);
  6780. }
  6781. }
  6782. }
  6783. this.remove = function (name) {
  6784. if (this.$behaviours && this.$behaviours[name]) {
  6785. delete this.$behaviours[name];
  6786. }
  6787. }
  6788. this.inherit = function (mode, filter) {
  6789. if (typeof mode === "function") {
  6790. var behaviours = new mode().getBehaviours(filter);
  6791. } else {
  6792. var behaviours = mode.getBehaviours(filter);
  6793. }
  6794. this.addBehaviours(behaviours);
  6795. }
  6796. this.getBehaviours = function (filter) {
  6797. if (!filter) {
  6798. return this.$behaviours;
  6799. } else {
  6800. var ret = {}
  6801. for (var i = 0; i < filter.length; i++) {
  6802. if (this.$behaviours[filter[i]]) {
  6803. ret[filter[i]] = this.$behaviours[filter[i]];
  6804. }
  6805. }
  6806. return ret;
  6807. }
  6808. }
  6809. }).call(Behaviour.prototype);
  6810. exports.Behaviour = Behaviour;
  6811. });
  6812. ace.define('ace/unicode', ['require', 'exports', 'module' ], function(require, exports, module) {
  6813. /*
  6814. XRegExp Unicode plugin pack: Categories 1.0
  6815. (c) 2010 Steven Levithan
  6816. MIT License
  6817. <http://xregexp.com>
  6818. Uses the Unicode 5.2 character database
  6819. This package for the XRegExp Unicode plugin enables the following Unicode categories (aka properties):
  6820. L - Letter (the top-level Letter category is included in the Unicode plugin base script)
  6821. Ll - Lowercase letter
  6822. Lu - Uppercase letter
  6823. Lt - Titlecase letter
  6824. Lm - Modifier letter
  6825. Lo - Letter without case
  6826. M - Mark
  6827. Mn - Non-spacing mark
  6828. Mc - Spacing combining mark
  6829. Me - Enclosing mark
  6830. N - Number
  6831. Nd - Decimal digit
  6832. Nl - Letter number
  6833. No - Other number
  6834. P - Punctuation
  6835. Pd - Dash punctuation
  6836. Ps - Open punctuation
  6837. Pe - Close punctuation
  6838. Pi - Initial punctuation
  6839. Pf - Final punctuation
  6840. Pc - Connector punctuation
  6841. Po - Other punctuation
  6842. S - Symbol
  6843. Sm - Math symbol
  6844. Sc - Currency symbol
  6845. Sk - Modifier symbol
  6846. So - Other symbol
  6847. Z - Separator
  6848. Zs - Space separator
  6849. Zl - Line separator
  6850. Zp - Paragraph separator
  6851. C - Other
  6852. Cc - Control
  6853. Cf - Format
  6854. Co - Private use
  6855. Cs - Surrogate
  6856. Cn - Unassigned
  6857. Example usage:
  6858. \p{N}
  6859. \p{Cn}
  6860. */
  6861. // will be populated by addUnicodePackage
  6862. exports.packages = {};
  6863. addUnicodePackage({
  6864. 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",
  6865. 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",
  6866. 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",
  6867. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  6868. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  6869. 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",
  6870. 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",
  6871. 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",
  6872. 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",
  6873. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  6874. 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",
  6875. 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",
  6876. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  6877. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  6878. 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",
  6879. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  6880. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  6881. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  6882. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  6883. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  6884. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  6885. 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",
  6886. 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",
  6887. 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",
  6888. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  6889. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  6890. 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",
  6891. Z: "002000A01680180E2000-200A20282029202F205F3000",
  6892. Zs: "002000A01680180E2000-200A202F205F3000",
  6893. Zl: "2028",
  6894. Zp: "2029",
  6895. 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",
  6896. Cc: "0000-001F007F-009F",
  6897. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  6898. Co: "E000-F8FF",
  6899. Cs: "D800-DFFF",
  6900. 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"
  6901. });
  6902. function addUnicodePackage (pack) {
  6903. var codePoint = /\w{4}/g;
  6904. for (var name in pack)
  6905. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  6906. };
  6907. });
  6908. ace.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
  6909. var oop = require("./lib/oop");
  6910. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  6911. var Range = require("./range").Range;
  6912. var Anchor = require("./anchor").Anchor;
  6913. /**
  6914. * new Document([text])
  6915. * - text (String | Array): The starting text
  6916. *
  6917. * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
  6918. *
  6919. **/
  6920. var Document = function(text) {
  6921. this.$lines = [];
  6922. // There has to be one line at least in the document. If you pass an empty
  6923. // string to the insert function, nothing will happen. Workaround.
  6924. if (text.length == 0) {
  6925. this.$lines = [""];
  6926. } else if (Array.isArray(text)) {
  6927. this.insertLines(0, text);
  6928. } else {
  6929. this.insert({row: 0, column:0}, text);
  6930. }
  6931. };
  6932. (function() {
  6933. oop.implement(this, EventEmitter);
  6934. this.setValue = function(text) {
  6935. var len = this.getLength();
  6936. this.remove(new Range(0, 0, len, this.getLine(len-1).length));
  6937. this.insert({row: 0, column:0}, text);
  6938. };
  6939. this.getValue = function() {
  6940. return this.getAllLines().join(this.getNewLineCharacter());
  6941. };
  6942. this.createAnchor = function(row, column) {
  6943. return new Anchor(this, row, column);
  6944. };
  6945. // check for IE split bug
  6946. if ("aaa".split(/a/).length == 0)
  6947. this.$split = function(text) {
  6948. return text.replace(/\r\n|\r/g, "\n").split("\n");
  6949. }
  6950. else
  6951. this.$split = function(text) {
  6952. return text.split(/\r\n|\r|\n/);
  6953. };
  6954. this.$detectNewLine = function(text) {
  6955. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  6956. if (match) {
  6957. this.$autoNewLine = match[1];
  6958. } else {
  6959. this.$autoNewLine = "\n";
  6960. }
  6961. };
  6962. this.getNewLineCharacter = function() {
  6963. switch (this.$newLineMode) {
  6964. case "windows":
  6965. return "\r\n";
  6966. case "unix":
  6967. return "\n";
  6968. case "auto":
  6969. return this.$autoNewLine;
  6970. }
  6971. };
  6972. this.$autoNewLine = "\n";
  6973. this.$newLineMode = "auto";
  6974. this.setNewLineMode = function(newLineMode) {
  6975. if (this.$newLineMode === newLineMode)
  6976. return;
  6977. this.$newLineMode = newLineMode;
  6978. };
  6979. this.getNewLineMode = function() {
  6980. return this.$newLineMode;
  6981. };
  6982. this.isNewLine = function(text) {
  6983. return (text == "\r\n" || text == "\r" || text == "\n");
  6984. };
  6985. this.getLine = function(row) {
  6986. return this.$lines[row] || "";
  6987. };
  6988. this.getLines = function(firstRow, lastRow) {
  6989. return this.$lines.slice(firstRow, lastRow + 1);
  6990. };
  6991. this.getAllLines = function() {
  6992. return this.getLines(0, this.getLength());
  6993. };
  6994. this.getLength = function() {
  6995. return this.$lines.length;
  6996. };
  6997. this.getTextRange = function(range) {
  6998. if (range.start.row == range.end.row) {
  6999. return this.$lines[range.start.row].substring(range.start.column,
  7000. range.end.column);
  7001. }
  7002. else {
  7003. var lines = this.getLines(range.start.row+1, range.end.row-1);
  7004. lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
  7005. lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
  7006. return lines.join(this.getNewLineCharacter());
  7007. }
  7008. };
  7009. this.$clipPosition = function(position) {
  7010. var length = this.getLength();
  7011. if (position.row >= length) {
  7012. position.row = Math.max(0, length - 1);
  7013. position.column = this.getLine(length-1).length;
  7014. }
  7015. return position;
  7016. };
  7017. this.insert = function(position, text) {
  7018. if (!text || text.length === 0)
  7019. return position;
  7020. position = this.$clipPosition(position);
  7021. // only detect new lines if the document has no line break yet
  7022. if (this.getLength() <= 1)
  7023. this.$detectNewLine(text);
  7024. var lines = this.$split(text);
  7025. var firstLine = lines.splice(0, 1)[0];
  7026. var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
  7027. position = this.insertInLine(position, firstLine);
  7028. if (lastLine !== null) {
  7029. position = this.insertNewLine(position); // terminate first line
  7030. position = this.insertLines(position.row, lines);
  7031. position = this.insertInLine(position, lastLine || "");
  7032. }
  7033. return position;
  7034. };
  7035. this.insertLines = function(row, lines) {
  7036. if (lines.length == 0)
  7037. return {row: row, column: 0};
  7038. // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF)
  7039. // to circumvent that we have to break huge inserts into smaller chunks here
  7040. if (lines.length > 0xFFFF) {
  7041. var end = this.insertLines(row, lines.slice(0xFFFF));
  7042. lines = lines.slice(0, 0xFFFF);
  7043. }
  7044. var args = [row, 0];
  7045. args.push.apply(args, lines);
  7046. this.$lines.splice.apply(this.$lines, args);
  7047. var range = new Range(row, 0, row + lines.length, 0);
  7048. var delta = {
  7049. action: "insertLines",
  7050. range: range,
  7051. lines: lines
  7052. };
  7053. this._emit("change", { data: delta });
  7054. return end || range.end;
  7055. };
  7056. this.insertNewLine = function(position) {
  7057. position = this.$clipPosition(position);
  7058. var line = this.$lines[position.row] || "";
  7059. this.$lines[position.row] = line.substring(0, position.column);
  7060. this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
  7061. var end = {
  7062. row : position.row + 1,
  7063. column : 0
  7064. };
  7065. var delta = {
  7066. action: "insertText",
  7067. range: Range.fromPoints(position, end),
  7068. text: this.getNewLineCharacter()
  7069. };
  7070. this._emit("change", { data: delta });
  7071. return end;
  7072. };
  7073. this.insertInLine = function(position, text) {
  7074. if (text.length == 0)
  7075. return position;
  7076. var line = this.$lines[position.row] || "";
  7077. this.$lines[position.row] = line.substring(0, position.column) + text
  7078. + line.substring(position.column);
  7079. var end = {
  7080. row : position.row,
  7081. column : position.column + text.length
  7082. };
  7083. var delta = {
  7084. action: "insertText",
  7085. range: Range.fromPoints(position, end),
  7086. text: text
  7087. };
  7088. this._emit("change", { data: delta });
  7089. return end;
  7090. };
  7091. this.remove = function(range) {
  7092. // clip to document
  7093. range.start = this.$clipPosition(range.start);
  7094. range.end = this.$clipPosition(range.end);
  7095. if (range.isEmpty())
  7096. return range.start;
  7097. var firstRow = range.start.row;
  7098. var lastRow = range.end.row;
  7099. if (range.isMultiLine()) {
  7100. var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
  7101. var lastFullRow = lastRow - 1;
  7102. if (range.end.column > 0)
  7103. this.removeInLine(lastRow, 0, range.end.column);
  7104. if (lastFullRow >= firstFullRow)
  7105. this.removeLines(firstFullRow, lastFullRow);
  7106. if (firstFullRow != firstRow) {
  7107. this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
  7108. this.removeNewLine(range.start.row);
  7109. }
  7110. }
  7111. else {
  7112. this.removeInLine(firstRow, range.start.column, range.end.column);
  7113. }
  7114. return range.start;
  7115. };
  7116. this.removeInLine = function(row, startColumn, endColumn) {
  7117. if (startColumn == endColumn)
  7118. return;
  7119. var range = new Range(row, startColumn, row, endColumn);
  7120. var line = this.getLine(row);
  7121. var removed = line.substring(startColumn, endColumn);
  7122. var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
  7123. this.$lines.splice(row, 1, newLine);
  7124. var delta = {
  7125. action: "removeText",
  7126. range: range,
  7127. text: removed
  7128. };
  7129. this._emit("change", { data: delta });
  7130. return range.start;
  7131. };
  7132. this.removeLines = function(firstRow, lastRow) {
  7133. var range = new Range(firstRow, 0, lastRow + 1, 0);
  7134. var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
  7135. var delta = {
  7136. action: "removeLines",
  7137. range: range,
  7138. nl: this.getNewLineCharacter(),
  7139. lines: removed
  7140. };
  7141. this._emit("change", { data: delta });
  7142. return removed;
  7143. };
  7144. this.removeNewLine = function(row) {
  7145. var firstLine = this.getLine(row);
  7146. var secondLine = this.getLine(row+1);
  7147. var range = new Range(row, firstLine.length, row+1, 0);
  7148. var line = firstLine + secondLine;
  7149. this.$lines.splice(row, 2, line);
  7150. var delta = {
  7151. action: "removeText",
  7152. range: range,
  7153. text: this.getNewLineCharacter()
  7154. };
  7155. this._emit("change", { data: delta });
  7156. };
  7157. this.replace = function(range, text) {
  7158. if (text.length == 0 && range.isEmpty())
  7159. return range.start;
  7160. // Shortcut: If the text we want to insert is the same as it is already
  7161. // in the document, we don't have to replace anything.
  7162. if (text == this.getTextRange(range))
  7163. return range.end;
  7164. this.remove(range);
  7165. if (text) {
  7166. var end = this.insert(range.start, text);
  7167. }
  7168. else {
  7169. end = range.start;
  7170. }
  7171. return end;
  7172. };
  7173. this.applyDeltas = function(deltas) {
  7174. for (var i=0; i<deltas.length; i++) {
  7175. var delta = deltas[i];
  7176. var range = Range.fromPoints(delta.range.start, delta.range.end);
  7177. if (delta.action == "insertLines")
  7178. this.insertLines(range.start.row, delta.lines);
  7179. else if (delta.action == "insertText")
  7180. this.insert(range.start, delta.text);
  7181. else if (delta.action == "removeLines")
  7182. this.removeLines(range.start.row, range.end.row - 1);
  7183. else if (delta.action == "removeText")
  7184. this.remove(range);
  7185. }
  7186. };
  7187. this.revertDeltas = function(deltas) {
  7188. for (var i=deltas.length-1; i>=0; i--) {
  7189. var delta = deltas[i];
  7190. var range = Range.fromPoints(delta.range.start, delta.range.end);
  7191. if (delta.action == "insertLines")
  7192. this.removeLines(range.start.row, range.end.row - 1);
  7193. else if (delta.action == "insertText")
  7194. this.remove(range);
  7195. else if (delta.action == "removeLines")
  7196. this.insertLines(range.start.row, delta.lines);
  7197. else if (delta.action == "removeText")
  7198. this.insert(range.start, delta.text);
  7199. }
  7200. };
  7201. }).call(Document.prototype);
  7202. exports.Document = Document;
  7203. });
  7204. ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
  7205. var oop = require("./lib/oop");
  7206. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7207. /**
  7208. * new Anchor(doc, row, column)
  7209. * - doc (Document): The document to associate with the anchor
  7210. * - row (Number): The starting row position
  7211. * - column (Number): The starting column position
  7212. *
  7213. * Creates a new `Anchor` and associates it with a document.
  7214. *
  7215. **/
  7216. var Anchor = exports.Anchor = function(doc, row, column) {
  7217. this.document = doc;
  7218. if (typeof column == "undefined")
  7219. this.setPosition(row.row, row.column);
  7220. else
  7221. this.setPosition(row, column);
  7222. this.$onChange = this.onChange.bind(this);
  7223. doc.on("change", this.$onChange);
  7224. };
  7225. (function() {
  7226. oop.implement(this, EventEmitter);
  7227. this.getPosition = function() {
  7228. return this.$clipPositionToDocument(this.row, this.column);
  7229. };
  7230. this.getDocument = function() {
  7231. return this.document;
  7232. };
  7233. this.onChange = function(e) {
  7234. var delta = e.data;
  7235. var range = delta.range;
  7236. if (range.start.row == range.end.row && range.start.row != this.row)
  7237. return;
  7238. if (range.start.row > this.row)
  7239. return;
  7240. if (range.start.row == this.row && range.start.column > this.column)
  7241. return;
  7242. var row = this.row;
  7243. var column = this.column;
  7244. if (delta.action === "insertText") {
  7245. if (range.start.row === row && range.start.column <= column) {
  7246. if (range.start.row === range.end.row) {
  7247. column += range.end.column - range.start.column;
  7248. }
  7249. else {
  7250. column -= range.start.column;
  7251. row += range.end.row - range.start.row;
  7252. }
  7253. }
  7254. else if (range.start.row !== range.end.row && range.start.row < row) {
  7255. row += range.end.row - range.start.row;
  7256. }
  7257. } else if (delta.action === "insertLines") {
  7258. if (range.start.row <= row) {
  7259. row += range.end.row - range.start.row;
  7260. }
  7261. }
  7262. else if (delta.action == "removeText") {
  7263. if (range.start.row == row && range.start.column < column) {
  7264. if (range.end.column >= column)
  7265. column = range.start.column;
  7266. else
  7267. column = Math.max(0, column - (range.end.column - range.start.column));
  7268. } else if (range.start.row !== range.end.row && range.start.row < row) {
  7269. if (range.end.row == row) {
  7270. column = Math.max(0, column - range.end.column) + range.start.column;
  7271. }
  7272. row -= (range.end.row - range.start.row);
  7273. }
  7274. else if (range.end.row == row) {
  7275. row -= range.end.row - range.start.row;
  7276. column = Math.max(0, column - range.end.column) + range.start.column;
  7277. }
  7278. } else if (delta.action == "removeLines") {
  7279. if (range.start.row <= row) {
  7280. if (range.end.row <= row)
  7281. row -= range.end.row - range.start.row;
  7282. else {
  7283. row = range.start.row;
  7284. column = 0;
  7285. }
  7286. }
  7287. }
  7288. this.setPosition(row, column, true);
  7289. };
  7290. this.setPosition = function(row, column, noClip) {
  7291. var pos;
  7292. if (noClip) {
  7293. pos = {
  7294. row: row,
  7295. column: column
  7296. };
  7297. }
  7298. else {
  7299. pos = this.$clipPositionToDocument(row, column);
  7300. }
  7301. if (this.row == pos.row && this.column == pos.column)
  7302. return;
  7303. var old = {
  7304. row: this.row,
  7305. column: this.column
  7306. };
  7307. this.row = pos.row;
  7308. this.column = pos.column;
  7309. this._emit("change", {
  7310. old: old,
  7311. value: pos
  7312. });
  7313. };
  7314. this.detach = function() {
  7315. this.document.removeEventListener("change", this.$onChange);
  7316. };
  7317. this.$clipPositionToDocument = function(row, column) {
  7318. var pos = {};
  7319. if (row >= this.document.getLength()) {
  7320. pos.row = Math.max(0, this.document.getLength() - 1);
  7321. pos.column = this.document.getLine(pos.row).length;
  7322. }
  7323. else if (row < 0) {
  7324. pos.row = 0;
  7325. pos.column = 0;
  7326. }
  7327. else {
  7328. pos.row = row;
  7329. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  7330. }
  7331. if (column < 0)
  7332. pos.column = 0;
  7333. return pos;
  7334. };
  7335. }).call(Anchor.prototype);
  7336. });
  7337. ace.define('ace/background_tokenizer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
  7338. var oop = require("./lib/oop");
  7339. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7340. // tokenizing lines longer than this makes editor very slow
  7341. var MAX_LINE_LENGTH = 5000;
  7342. /**
  7343. * new BackgroundTokenizer(tokenizer, editor)
  7344. * - tokenizer (Tokenizer): The tokenizer to use
  7345. * - editor (Editor): The editor to associate with
  7346. *
  7347. * Creates a new `BackgroundTokenizer` object.
  7348. *
  7349. *
  7350. **/
  7351. var BackgroundTokenizer = function(tokenizer, editor) {
  7352. this.running = false;
  7353. this.lines = [];
  7354. this.states = [];
  7355. this.currentLine = 0;
  7356. this.tokenizer = tokenizer;
  7357. var self = this;
  7358. this.$worker = function() {
  7359. if (!self.running) { return; }
  7360. var workerStart = new Date();
  7361. var startLine = self.currentLine;
  7362. var doc = self.doc;
  7363. var processedLines = 0;
  7364. var len = doc.getLength();
  7365. while (self.currentLine < len) {
  7366. self.$tokenizeRow(self.currentLine);
  7367. while (self.lines[self.currentLine])
  7368. self.currentLine++;
  7369. // only check every 5 lines
  7370. processedLines ++;
  7371. if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
  7372. self.fireUpdateEvent(startLine, self.currentLine-1);
  7373. self.running = setTimeout(self.$worker, 20);
  7374. return;
  7375. }
  7376. }
  7377. self.running = false;
  7378. self.fireUpdateEvent(startLine, len - 1);
  7379. };
  7380. };
  7381. (function(){
  7382. oop.implement(this, EventEmitter);
  7383. this.setTokenizer = function(tokenizer) {
  7384. this.tokenizer = tokenizer;
  7385. this.lines = [];
  7386. this.states = [];
  7387. this.start(0);
  7388. };
  7389. this.setDocument = function(doc) {
  7390. this.doc = doc;
  7391. this.lines = [];
  7392. this.states = [];
  7393. this.stop();
  7394. };
  7395. this.fireUpdateEvent = function(firstRow, lastRow) {
  7396. var data = {
  7397. first: firstRow,
  7398. last: lastRow
  7399. };
  7400. this._emit("update", {data: data});
  7401. };
  7402. this.start = function(startRow) {
  7403. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  7404. // remove all cached items below this line
  7405. this.lines.splice(this.currentLine, this.lines.length);
  7406. this.states.splice(this.currentLine, this.states.length);
  7407. this.stop();
  7408. // pretty long delay to prevent the tokenizer from interfering with the user
  7409. this.running = setTimeout(this.$worker, 700);
  7410. };
  7411. this.$updateOnChange = function(delta) {
  7412. var range = delta.range;
  7413. var startRow = range.start.row;
  7414. var len = range.end.row - startRow;
  7415. if (len === 0) {
  7416. this.lines[startRow] = null;
  7417. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  7418. this.lines.splice(startRow, len + 1, null);
  7419. this.states.splice(startRow, len + 1, null);
  7420. } else {
  7421. var args = Array(len + 1);
  7422. args.unshift(startRow, 1);
  7423. this.lines.splice.apply(this.lines, args);
  7424. this.states.splice.apply(this.states, args);
  7425. }
  7426. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  7427. this.stop();
  7428. // pretty long delay to prevent the tokenizer from interfering with the user
  7429. this.running = setTimeout(this.$worker, 700);
  7430. };
  7431. this.stop = function() {
  7432. if (this.running)
  7433. clearTimeout(this.running);
  7434. this.running = false;
  7435. };
  7436. this.getTokens = function(row) {
  7437. return this.lines[row] || this.$tokenizeRow(row);
  7438. };
  7439. this.getState = function(row) {
  7440. if (this.currentLine == row)
  7441. this.$tokenizeRow(row);
  7442. return this.states[row] || "start";
  7443. };
  7444. this.$tokenizeRow = function(row) {
  7445. var line = this.doc.getLine(row);
  7446. var state = this.states[row - 1];
  7447. if (line.length > MAX_LINE_LENGTH) {
  7448. var overflow = {value: line.substr(MAX_LINE_LENGTH), type: "text"};
  7449. line = line.slice(0, MAX_LINE_LENGTH);
  7450. }
  7451. var data = this.tokenizer.getLineTokens(line, state);
  7452. if (overflow) {
  7453. data.tokens.push(overflow);
  7454. data.state = "start";
  7455. }
  7456. if (this.states[row] !== data.state) {
  7457. this.states[row] = data.state;
  7458. this.lines[row + 1] = null;
  7459. if (this.currentLine > row + 1)
  7460. this.currentLine = row + 1;
  7461. } else if (this.currentLine == row) {
  7462. this.currentLine = row + 1;
  7463. }
  7464. return this.lines[row] = data.tokens;
  7465. };
  7466. }).call(BackgroundTokenizer.prototype);
  7467. exports.BackgroundTokenizer = BackgroundTokenizer;
  7468. });
  7469. ace.define('ace/search_highlight', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
  7470. var lang = require("./lib/lang");
  7471. var oop = require("./lib/oop");
  7472. var Range = require("./range").Range;
  7473. var SearchHighlight = function(regExp, clazz, type) {
  7474. this.setRegexp(regExp);
  7475. this.clazz = clazz;
  7476. this.type = type || "text";
  7477. };
  7478. (function() {
  7479. this.setRegexp = function(regExp) {
  7480. if (this.regExp+"" == regExp+"")
  7481. return;
  7482. this.regExp = regExp;
  7483. this.cache = [];
  7484. };
  7485. this.update = function(html, markerLayer, session, config) {
  7486. if (!this.regExp)
  7487. return;
  7488. var start = config.firstRow, end = config.lastRow;
  7489. for (var i = start; i <= end; i++) {
  7490. var ranges = this.cache[i];
  7491. if (ranges == null) {
  7492. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  7493. ranges = ranges.map(function(match) {
  7494. return new Range(i, match.offset, i, match.offset + match.length);
  7495. });
  7496. this.cache[i] = ranges.length ? ranges : "";
  7497. }
  7498. for (var j = ranges.length; j --; ) {
  7499. markerLayer.drawSingleLineMarker(
  7500. html, ranges[j].toScreenRange(session), this.clazz, config,
  7501. null, this.type
  7502. );
  7503. }
  7504. }
  7505. };
  7506. }).call(SearchHighlight.prototype);
  7507. exports.SearchHighlight = SearchHighlight;
  7508. });
  7509. 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) {
  7510. var Range = require("../range").Range;
  7511. var FoldLine = require("./fold_line").FoldLine;
  7512. var Fold = require("./fold").Fold;
  7513. var TokenIterator = require("../token_iterator").TokenIterator;
  7514. function Folding() {
  7515. /*
  7516. * Looks up a fold at a given row/column. Possible values for side:
  7517. * -1: ignore a fold if fold.start = row/column
  7518. * +1: ignore a fold if fold.end = row/column
  7519. */
  7520. this.getFoldAt = function(row, column, side) {
  7521. var foldLine = this.getFoldLine(row);
  7522. if (!foldLine)
  7523. return null;
  7524. var folds = foldLine.folds;
  7525. for (var i = 0; i < folds.length; i++) {
  7526. var fold = folds[i];
  7527. if (fold.range.contains(row, column)) {
  7528. if (side == 1 && fold.range.isEnd(row, column)) {
  7529. continue;
  7530. } else if (side == -1 && fold.range.isStart(row, column)) {
  7531. continue;
  7532. }
  7533. return fold;
  7534. }
  7535. }
  7536. };
  7537. this.getFoldsInRange = function(range) {
  7538. range = range.clone();
  7539. var start = range.start;
  7540. var end = range.end;
  7541. var foldLines = this.$foldData;
  7542. var foundFolds = [];
  7543. start.column += 1;
  7544. end.column -= 1;
  7545. for (var i = 0; i < foldLines.length; i++) {
  7546. var cmp = foldLines[i].range.compareRange(range);
  7547. if (cmp == 2) {
  7548. // Range is before foldLine. No intersection. This means,
  7549. // there might be other foldLines that intersect.
  7550. continue;
  7551. }
  7552. else if (cmp == -2) {
  7553. // Range is after foldLine. There can't be any other foldLines then,
  7554. // so let's give up.
  7555. break;
  7556. }
  7557. var folds = foldLines[i].folds;
  7558. for (var j = 0; j < folds.length; j++) {
  7559. var fold = folds[j];
  7560. cmp = fold.range.compareRange(range);
  7561. if (cmp == -2) {
  7562. break;
  7563. } else if (cmp == 2) {
  7564. continue;
  7565. } else
  7566. // WTF-state: Can happen due to -1/+1 to start/end column.
  7567. if (cmp == 42) {
  7568. break;
  7569. }
  7570. foundFolds.push(fold);
  7571. }
  7572. }
  7573. return foundFolds;
  7574. };
  7575. this.getAllFolds = function() {
  7576. var folds = [];
  7577. var foldLines = this.$foldData;
  7578. function addFold(fold) {
  7579. folds.push(fold);
  7580. if (!fold.subFolds)
  7581. return;
  7582. for (var i = 0; i < fold.subFolds.length; i++)
  7583. addFold(fold.subFolds[i]);
  7584. }
  7585. for (var i = 0; i < foldLines.length; i++)
  7586. for (var j = 0; j < foldLines[i].folds.length; j++)
  7587. addFold(foldLines[i].folds[j]);
  7588. return folds;
  7589. };
  7590. this.getFoldStringAt = function(row, column, trim, foldLine) {
  7591. foldLine = foldLine || this.getFoldLine(row);
  7592. if (!foldLine)
  7593. return null;
  7594. var lastFold = {
  7595. end: { column: 0 }
  7596. };
  7597. // TODO: Refactor to use getNextFoldTo function.
  7598. var str, fold;
  7599. for (var i = 0; i < foldLine.folds.length; i++) {
  7600. fold = foldLine.folds[i];
  7601. var cmp = fold.range.compareEnd(row, column);
  7602. if (cmp == -1) {
  7603. str = this
  7604. .getLine(fold.start.row)
  7605. .substring(lastFold.end.column, fold.start.column);
  7606. break;
  7607. }
  7608. else if (cmp === 0) {
  7609. return null;
  7610. }
  7611. lastFold = fold;
  7612. }
  7613. if (!str)
  7614. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  7615. if (trim == -1)
  7616. return str.substring(0, column - lastFold.end.column);
  7617. else if (trim == 1)
  7618. return str.substring(column - lastFold.end.column);
  7619. else
  7620. return str;
  7621. };
  7622. this.getFoldLine = function(docRow, startFoldLine) {
  7623. var foldData = this.$foldData;
  7624. var i = 0;
  7625. if (startFoldLine)
  7626. i = foldData.indexOf(startFoldLine);
  7627. if (i == -1)
  7628. i = 0;
  7629. for (i; i < foldData.length; i++) {
  7630. var foldLine = foldData[i];
  7631. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  7632. return foldLine;
  7633. } else if (foldLine.end.row > docRow) {
  7634. return null;
  7635. }
  7636. }
  7637. return null;
  7638. };
  7639. // returns the fold which starts after or contains docRow
  7640. this.getNextFoldLine = function(docRow, startFoldLine) {
  7641. var foldData = this.$foldData;
  7642. var i = 0;
  7643. if (startFoldLine)
  7644. i = foldData.indexOf(startFoldLine);
  7645. if (i == -1)
  7646. i = 0;
  7647. for (i; i < foldData.length; i++) {
  7648. var foldLine = foldData[i];
  7649. if (foldLine.end.row >= docRow) {
  7650. return foldLine;
  7651. }
  7652. }
  7653. return null;
  7654. };
  7655. this.getFoldedRowCount = function(first, last) {
  7656. var foldData = this.$foldData, rowCount = last-first+1;
  7657. for (var i = 0; i < foldData.length; i++) {
  7658. var foldLine = foldData[i],
  7659. end = foldLine.end.row,
  7660. start = foldLine.start.row;
  7661. if (end >= last) {
  7662. if(start < last) {
  7663. if(start >= first)
  7664. rowCount -= last-start;
  7665. else
  7666. rowCount = 0;//in one fold
  7667. }
  7668. break;
  7669. } else if(end >= first){
  7670. if (start >= first) //fold inside range
  7671. rowCount -= end-start;
  7672. else
  7673. rowCount -= end-first+1;
  7674. }
  7675. }
  7676. return rowCount;
  7677. };
  7678. this.$addFoldLine = function(foldLine) {
  7679. this.$foldData.push(foldLine);
  7680. this.$foldData.sort(function(a, b) {
  7681. return a.start.row - b.start.row;
  7682. });
  7683. return foldLine;
  7684. };
  7685. this.addFold = function(placeholder, range) {
  7686. var foldData = this.$foldData;
  7687. var added = false;
  7688. var fold;
  7689. if (placeholder instanceof Fold)
  7690. fold = placeholder;
  7691. else
  7692. fold = new Fold(range, placeholder);
  7693. this.$clipRangeToDocument(fold.range);
  7694. var startRow = fold.start.row;
  7695. var startColumn = fold.start.column;
  7696. var endRow = fold.end.row;
  7697. var endColumn = fold.end.column;
  7698. // --- Some checking ---
  7699. if (fold.placeholder.length < 2)
  7700. throw "Placeholder has to be at least 2 characters";
  7701. if (startRow == endRow && endColumn - startColumn < 2)
  7702. throw "The range has to be at least 2 characters width";
  7703. var startFold = this.getFoldAt(startRow, startColumn, 1);
  7704. var endFold = this.getFoldAt(endRow, endColumn, -1);
  7705. if (startFold && endFold == startFold)
  7706. return startFold.addSubFold(fold);
  7707. if (
  7708. (startFold && !startFold.range.isStart(startRow, startColumn))
  7709. || (endFold && !endFold.range.isEnd(endRow, endColumn))
  7710. ) {
  7711. throw "A fold can't intersect already existing fold" + fold.range + startFold.range;
  7712. }
  7713. // Check if there are folds in the range we create the new fold for.
  7714. var folds = this.getFoldsInRange(fold.range);
  7715. if (folds.length > 0) {
  7716. // Remove the folds from fold data.
  7717. this.removeFolds(folds);
  7718. // Add the removed folds as subfolds on the new fold.
  7719. fold.subFolds = folds;
  7720. }
  7721. for (var i = 0; i < foldData.length; i++) {
  7722. var foldLine = foldData[i];
  7723. if (endRow == foldLine.start.row) {
  7724. foldLine.addFold(fold);
  7725. added = true;
  7726. break;
  7727. }
  7728. else if (startRow == foldLine.end.row) {
  7729. foldLine.addFold(fold);
  7730. added = true;
  7731. if (!fold.sameRow) {
  7732. // Check if we might have to merge two FoldLines.
  7733. var foldLineNext = foldData[i + 1];
  7734. if (foldLineNext && foldLineNext.start.row == endRow) {
  7735. // We need to merge!
  7736. foldLine.merge(foldLineNext);
  7737. break;
  7738. }
  7739. }
  7740. break;
  7741. }
  7742. else if (endRow <= foldLine.start.row) {
  7743. break;
  7744. }
  7745. }
  7746. if (!added)
  7747. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  7748. if (this.$useWrapMode)
  7749. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  7750. else
  7751. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  7752. // Notify that fold data has changed.
  7753. this.$modified = true;
  7754. this._emit("changeFold", { data: fold });
  7755. return fold;
  7756. };
  7757. this.addFolds = function(folds) {
  7758. folds.forEach(function(fold) {
  7759. this.addFold(fold);
  7760. }, this);
  7761. };
  7762. this.removeFold = function(fold) {
  7763. var foldLine = fold.foldLine;
  7764. var startRow = foldLine.start.row;
  7765. var endRow = foldLine.end.row;
  7766. var foldLines = this.$foldData;
  7767. var folds = foldLine.folds;
  7768. // Simple case where there is only one fold in the FoldLine such that
  7769. // the entire fold line can get removed directly.
  7770. if (folds.length == 1) {
  7771. foldLines.splice(foldLines.indexOf(foldLine), 1);
  7772. } else
  7773. // If the fold is the last fold of the foldLine, just remove it.
  7774. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  7775. folds.pop();
  7776. foldLine.end.row = folds[folds.length - 1].end.row;
  7777. foldLine.end.column = folds[folds.length - 1].end.column;
  7778. } else
  7779. // If the fold is the first fold of the foldLine, just remove it.
  7780. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  7781. folds.shift();
  7782. foldLine.start.row = folds[0].start.row;
  7783. foldLine.start.column = folds[0].start.column;
  7784. } else
  7785. // We know there are more then 2 folds and the fold is not at the edge.
  7786. // This means, the fold is somewhere in between.
  7787. //
  7788. // If the fold is in one row, we just can remove it.
  7789. if (fold.sameRow) {
  7790. folds.splice(folds.indexOf(fold), 1);
  7791. } else
  7792. // The fold goes over more then one row. This means remvoing this fold
  7793. // will cause the fold line to get splitted up. newFoldLine is the second part
  7794. {
  7795. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  7796. folds = newFoldLine.folds;
  7797. folds.shift();
  7798. newFoldLine.start.row = folds[0].start.row;
  7799. newFoldLine.start.column = folds[0].start.column;
  7800. }
  7801. if (this.$useWrapMode)
  7802. this.$updateWrapData(startRow, endRow);
  7803. else
  7804. this.$updateRowLengthCache(startRow, endRow);
  7805. // Notify that fold data has changed.
  7806. this.$modified = true;
  7807. this._emit("changeFold", { data: fold });
  7808. };
  7809. this.removeFolds = function(folds) {
  7810. // We need to clone the folds array passed in as it might be the folds
  7811. // array of a fold line and as we call this.removeFold(fold), folds
  7812. // are removed from folds and changes the current index.
  7813. var cloneFolds = [];
  7814. for (var i = 0; i < folds.length; i++) {
  7815. cloneFolds.push(folds[i]);
  7816. }
  7817. cloneFolds.forEach(function(fold) {
  7818. this.removeFold(fold);
  7819. }, this);
  7820. this.$modified = true;
  7821. };
  7822. this.expandFold = function(fold) {
  7823. this.removeFold(fold);
  7824. fold.subFolds.forEach(function(fold) {
  7825. this.addFold(fold);
  7826. }, this);
  7827. fold.subFolds = [];
  7828. };
  7829. this.expandFolds = function(folds) {
  7830. folds.forEach(function(fold) {
  7831. this.expandFold(fold);
  7832. }, this);
  7833. };
  7834. this.unfold = function(location, expandInner) {
  7835. var range, folds;
  7836. if (location == null)
  7837. range = new Range(0, 0, this.getLength(), 0);
  7838. else if (typeof location == "number")
  7839. range = new Range(location, 0, location, this.getLine(location).length);
  7840. else if ("row" in location)
  7841. range = Range.fromPoints(location, location);
  7842. else
  7843. range = location;
  7844. folds = this.getFoldsInRange(range);
  7845. if (expandInner) {
  7846. this.removeFolds(folds);
  7847. } else {
  7848. // TODO: might need to remove and add folds in one go instead of using
  7849. // expandFolds several times.
  7850. while (folds.length) {
  7851. this.expandFolds(folds);
  7852. folds = this.getFoldsInRange(range);
  7853. }
  7854. }
  7855. };
  7856. this.isRowFolded = function(docRow, startFoldRow) {
  7857. return !!this.getFoldLine(docRow, startFoldRow);
  7858. };
  7859. this.getRowFoldEnd = function(docRow, startFoldRow) {
  7860. var foldLine = this.getFoldLine(docRow, startFoldRow);
  7861. return (foldLine
  7862. ? foldLine.end.row
  7863. : docRow);
  7864. };
  7865. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  7866. if (startRow == null) {
  7867. startRow = foldLine.start.row;
  7868. startColumn = 0;
  7869. }
  7870. if (endRow == null) {
  7871. endRow = foldLine.end.row;
  7872. endColumn = this.getLine(endRow).length;
  7873. }
  7874. // Build the textline using the FoldLine walker.
  7875. var doc = this.doc;
  7876. var textLine = "";
  7877. foldLine.walk(function(placeholder, row, column, lastColumn) {
  7878. if (row < startRow) {
  7879. return;
  7880. } else if (row == startRow) {
  7881. if (column < startColumn) {
  7882. return;
  7883. }
  7884. lastColumn = Math.max(startColumn, lastColumn);
  7885. }
  7886. if (placeholder) {
  7887. textLine += placeholder;
  7888. } else {
  7889. textLine += doc.getLine(row).substring(lastColumn, column);
  7890. }
  7891. }.bind(this), endRow, endColumn);
  7892. return textLine;
  7893. };
  7894. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  7895. var foldLine = this.getFoldLine(row);
  7896. if (!foldLine) {
  7897. var line;
  7898. line = this.doc.getLine(row);
  7899. return line.substring(startColumn || 0, endColumn || line.length);
  7900. } else {
  7901. return this.getFoldDisplayLine(
  7902. foldLine, row, endColumn, startRow, startColumn);
  7903. }
  7904. };
  7905. this.$cloneFoldData = function() {
  7906. var fd = [];
  7907. fd = this.$foldData.map(function(foldLine) {
  7908. var folds = foldLine.folds.map(function(fold) {
  7909. return fold.clone();
  7910. });
  7911. return new FoldLine(fd, folds);
  7912. });
  7913. return fd;
  7914. };
  7915. this.toggleFold = function(tryToUnfold) {
  7916. var selection = this.selection;
  7917. var range = selection.getRange();
  7918. var fold;
  7919. var bracketPos;
  7920. if (range.isEmpty()) {
  7921. var cursor = range.start;
  7922. fold = this.getFoldAt(cursor.row, cursor.column);
  7923. if (fold) {
  7924. this.expandFold(fold);
  7925. return;
  7926. }
  7927. else if (bracketPos = this.findMatchingBracket(cursor)) {
  7928. if (range.comparePoint(bracketPos) == 1) {
  7929. range.end = bracketPos;
  7930. }
  7931. else {
  7932. range.start = bracketPos;
  7933. range.start.column++;
  7934. range.end.column--;
  7935. }
  7936. }
  7937. else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  7938. if (range.comparePoint(bracketPos) == 1)
  7939. range.end = bracketPos;
  7940. else
  7941. range.start = bracketPos;
  7942. range.start.column++;
  7943. }
  7944. else {
  7945. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  7946. }
  7947. } else {
  7948. var folds = this.getFoldsInRange(range);
  7949. if (tryToUnfold && folds.length) {
  7950. this.expandFolds(folds);
  7951. return;
  7952. }
  7953. else if (folds.length == 1 ) {
  7954. fold = folds[0];
  7955. }
  7956. }
  7957. if (!fold)
  7958. fold = this.getFoldAt(range.start.row, range.start.column);
  7959. if (fold && fold.range.toString() == range.toString()) {
  7960. this.expandFold(fold);
  7961. return;
  7962. }
  7963. var placeholder = "...";
  7964. if (!range.isMultiLine()) {
  7965. placeholder = this.getTextRange(range);
  7966. if(placeholder.length < 4)
  7967. return;
  7968. placeholder = placeholder.trim().substring(0, 2) + "..";
  7969. }
  7970. this.addFold(placeholder, range);
  7971. };
  7972. this.getCommentFoldRange = function(row, column) {
  7973. var iterator = new TokenIterator(this, row, column);
  7974. var token = iterator.getCurrentToken();
  7975. if (token && /^comment|string/.test(token.type)) {
  7976. var range = new Range();
  7977. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  7978. do {
  7979. token = iterator.stepBackward();
  7980. } while(token && re.test(token.type));
  7981. iterator.stepForward();
  7982. range.start.row = iterator.getCurrentTokenRow();
  7983. range.start.column = iterator.getCurrentTokenColumn() + 2;
  7984. iterator = new TokenIterator(this, row, column);
  7985. do {
  7986. token = iterator.stepForward();
  7987. } while(token && re.test(token.type));
  7988. token = iterator.stepBackward();
  7989. range.end.row = iterator.getCurrentTokenRow();
  7990. range.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  7991. return range;
  7992. }
  7993. };
  7994. this.foldAll = function(startRow, endRow) {
  7995. var foldWidgets = this.foldWidgets;
  7996. endRow = endRow || this.getLength();
  7997. for (var row = startRow || 0; row < endRow; row++) {
  7998. if (foldWidgets[row] == null)
  7999. foldWidgets[row] = this.getFoldWidget(row);
  8000. if (foldWidgets[row] != "start")
  8001. continue;
  8002. var range = this.getFoldWidgetRange(row);
  8003. // sometimes range can be incompatible with existing fold
  8004. // wouldn't it be better for addFold to return null istead of throwing?
  8005. if (range && range.end.row < endRow) try {
  8006. this.addFold("...", range);
  8007. } catch(e) {}
  8008. }
  8009. };
  8010. this.$foldStyles = {
  8011. "manual": 1,
  8012. "markbegin": 1,
  8013. "markbeginend": 1
  8014. };
  8015. this.$foldStyle = "markbegin";
  8016. this.setFoldStyle = function(style) {
  8017. if (!this.$foldStyles[style])
  8018. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  8019. if (this.$foldStyle == style)
  8020. return;
  8021. this.$foldStyle = style;
  8022. if (style == "manual")
  8023. this.unfold();
  8024. // reset folding
  8025. var mode = this.$foldMode;
  8026. this.$setFolding(null);
  8027. this.$setFolding(mode);
  8028. };
  8029. // structured folding
  8030. this.$setFolding = function(foldMode) {
  8031. if (this.$foldMode == foldMode)
  8032. return;
  8033. this.$foldMode = foldMode;
  8034. this.removeListener('change', this.$updateFoldWidgets);
  8035. this._emit("changeAnnotation");
  8036. if (!foldMode || this.$foldStyle == "manual") {
  8037. this.foldWidgets = null;
  8038. return;
  8039. }
  8040. this.foldWidgets = [];
  8041. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  8042. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  8043. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  8044. this.on('change', this.$updateFoldWidgets);
  8045. };
  8046. this.onFoldWidgetClick = function(row, e) {
  8047. var type = this.getFoldWidget(row);
  8048. var line = this.getLine(row);
  8049. var onlySubfolds = e.shiftKey;
  8050. var addSubfolds = onlySubfolds || e.ctrlKey || e.altKey || e.metaKey;
  8051. var fold;
  8052. if (type == "end")
  8053. fold = this.getFoldAt(row, 0, -1);
  8054. else
  8055. fold = this.getFoldAt(row, line.length, 1);
  8056. if (fold) {
  8057. if (addSubfolds)
  8058. this.removeFold(fold);
  8059. else
  8060. this.expandFold(fold);
  8061. return;
  8062. }
  8063. var range = this.getFoldWidgetRange(row);
  8064. if (range) {
  8065. // sometimes singleline folds can be missed by the code above
  8066. if (!range.isMultiLine()) {
  8067. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  8068. if (fold && range.isEqual(fold.range)) {
  8069. this.removeFold(fold);
  8070. return;
  8071. }
  8072. }
  8073. if (!onlySubfolds)
  8074. this.addFold("...", range);
  8075. if (addSubfolds)
  8076. this.foldAll(range.start.row + 1, range.end.row);
  8077. } else {
  8078. if (addSubfolds)
  8079. this.foldAll(row + 1, this.getLength());
  8080. e.target.className += " invalid"
  8081. }
  8082. };
  8083. this.updateFoldWidgets = function(e) {
  8084. var delta = e.data;
  8085. var range = delta.range;
  8086. var firstRow = range.start.row;
  8087. var len = range.end.row - firstRow;
  8088. if (len === 0) {
  8089. this.foldWidgets[firstRow] = null;
  8090. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  8091. this.foldWidgets.splice(firstRow, len + 1, null);
  8092. } else {
  8093. var args = Array(len + 1);
  8094. args.unshift(firstRow, 1);
  8095. this.foldWidgets.splice.apply(this.foldWidgets, args);
  8096. }
  8097. };
  8098. }
  8099. exports.Folding = Folding;
  8100. });
  8101. ace.define('ace/edit_session/fold_line', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  8102. var Range = require("../range").Range;
  8103. function FoldLine(foldData, folds) {
  8104. this.foldData = foldData;
  8105. if (Array.isArray(folds)) {
  8106. this.folds = folds;
  8107. } else {
  8108. folds = this.folds = [ folds ];
  8109. }
  8110. var last = folds[folds.length - 1]
  8111. this.range = new Range(folds[0].start.row, folds[0].start.column,
  8112. last.end.row, last.end.column);
  8113. this.start = this.range.start;
  8114. this.end = this.range.end;
  8115. this.folds.forEach(function(fold) {
  8116. fold.setFoldLine(this);
  8117. }, this);
  8118. }
  8119. (function() {
  8120. /*
  8121. * Note: This doesn't update wrapData!
  8122. */
  8123. this.shiftRow = function(shift) {
  8124. this.start.row += shift;
  8125. this.end.row += shift;
  8126. this.folds.forEach(function(fold) {
  8127. fold.start.row += shift;
  8128. fold.end.row += shift;
  8129. });
  8130. }
  8131. this.addFold = function(fold) {
  8132. if (fold.sameRow) {
  8133. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  8134. throw "Can't add a fold to this FoldLine as it has no connection";
  8135. }
  8136. this.folds.push(fold);
  8137. this.folds.sort(function(a, b) {
  8138. return -a.range.compareEnd(b.start.row, b.start.column);
  8139. });
  8140. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  8141. this.end.row = fold.end.row;
  8142. this.end.column = fold.end.column;
  8143. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  8144. this.start.row = fold.start.row;
  8145. this.start.column = fold.start.column;
  8146. }
  8147. } else if (fold.start.row == this.end.row) {
  8148. this.folds.push(fold);
  8149. this.end.row = fold.end.row;
  8150. this.end.column = fold.end.column;
  8151. } else if (fold.end.row == this.start.row) {
  8152. this.folds.unshift(fold);
  8153. this.start.row = fold.start.row;
  8154. this.start.column = fold.start.column;
  8155. } else {
  8156. throw "Trying to add fold to FoldRow that doesn't have a matching row";
  8157. }
  8158. fold.foldLine = this;
  8159. }
  8160. this.containsRow = function(row) {
  8161. return row >= this.start.row && row <= this.end.row;
  8162. }
  8163. this.walk = function(callback, endRow, endColumn) {
  8164. var lastEnd = 0,
  8165. folds = this.folds,
  8166. fold,
  8167. comp, stop, isNewRow = true;
  8168. if (endRow == null) {
  8169. endRow = this.end.row;
  8170. endColumn = this.end.column;
  8171. }
  8172. for (var i = 0; i < folds.length; i++) {
  8173. fold = folds[i];
  8174. comp = fold.range.compareStart(endRow, endColumn);
  8175. // This fold is after the endRow/Column.
  8176. if (comp == -1) {
  8177. callback(null, endRow, endColumn, lastEnd, isNewRow);
  8178. return;
  8179. }
  8180. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  8181. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  8182. // If the user requested to stop the walk or endRow/endColumn is
  8183. // inside of this fold (comp == 0), then end here.
  8184. if (stop || comp == 0) {
  8185. return;
  8186. }
  8187. // Note the new lastEnd might not be on the same line. However,
  8188. // it's the callback's job to recognize this.
  8189. isNewRow = !fold.sameRow;
  8190. lastEnd = fold.end.column;
  8191. }
  8192. callback(null, endRow, endColumn, lastEnd, isNewRow);
  8193. }
  8194. this.getNextFoldTo = function(row, column) {
  8195. var fold, cmp;
  8196. for (var i = 0; i < this.folds.length; i++) {
  8197. fold = this.folds[i];
  8198. cmp = fold.range.compareEnd(row, column);
  8199. if (cmp == -1) {
  8200. return {
  8201. fold: fold,
  8202. kind: "after"
  8203. };
  8204. } else if (cmp == 0) {
  8205. return {
  8206. fold: fold,
  8207. kind: "inside"
  8208. }
  8209. }
  8210. }
  8211. return null;
  8212. }
  8213. this.addRemoveChars = function(row, column, len) {
  8214. var ret = this.getNextFoldTo(row, column),
  8215. fold, folds;
  8216. if (ret) {
  8217. fold = ret.fold;
  8218. if (ret.kind == "inside"
  8219. && fold.start.column != column
  8220. && fold.start.row != row)
  8221. {
  8222. //throwing here breaks whole editor
  8223. //@todo properly handle this
  8224. window.console && window.console.log(row, column, fold);
  8225. } else if (fold.start.row == row) {
  8226. folds = this.folds;
  8227. var i = folds.indexOf(fold);
  8228. if (i == 0) {
  8229. this.start.column += len;
  8230. }
  8231. for (i; i < folds.length; i++) {
  8232. fold = folds[i];
  8233. fold.start.column += len;
  8234. if (!fold.sameRow) {
  8235. return;
  8236. }
  8237. fold.end.column += len;
  8238. }
  8239. this.end.column += len;
  8240. }
  8241. }
  8242. }
  8243. this.split = function(row, column) {
  8244. var fold = this.getNextFoldTo(row, column).fold,
  8245. folds = this.folds;
  8246. var foldData = this.foldData;
  8247. if (!fold) {
  8248. return null;
  8249. }
  8250. var i = folds.indexOf(fold);
  8251. var foldBefore = folds[i - 1];
  8252. this.end.row = foldBefore.end.row;
  8253. this.end.column = foldBefore.end.column;
  8254. // Remove the folds after row/column and create a new FoldLine
  8255. // containing these removed folds.
  8256. folds = folds.splice(i, folds.length - i);
  8257. var newFoldLine = new FoldLine(foldData, folds);
  8258. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  8259. return newFoldLine;
  8260. }
  8261. this.merge = function(foldLineNext) {
  8262. var folds = foldLineNext.folds;
  8263. for (var i = 0; i < folds.length; i++) {
  8264. this.addFold(folds[i]);
  8265. }
  8266. // Remove the foldLineNext - no longer needed, as
  8267. // it's merged now with foldLineNext.
  8268. var foldData = this.foldData;
  8269. foldData.splice(foldData.indexOf(foldLineNext), 1);
  8270. }
  8271. this.toString = function() {
  8272. var ret = [this.range.toString() + ": [" ];
  8273. this.folds.forEach(function(fold) {
  8274. ret.push(" " + fold.toString());
  8275. });
  8276. ret.push("]")
  8277. return ret.join("\n");
  8278. }
  8279. this.idxToPosition = function(idx) {
  8280. var lastFoldEndColumn = 0;
  8281. var fold;
  8282. for (var i = 0; i < this.folds.length; i++) {
  8283. var fold = this.folds[i];
  8284. idx -= fold.start.column - lastFoldEndColumn;
  8285. if (idx < 0) {
  8286. return {
  8287. row: fold.start.row,
  8288. column: fold.start.column + idx
  8289. };
  8290. }
  8291. idx -= fold.placeholder.length;
  8292. if (idx < 0) {
  8293. return fold.start;
  8294. }
  8295. lastFoldEndColumn = fold.end.column;
  8296. }
  8297. return {
  8298. row: this.end.row,
  8299. column: this.end.column + idx
  8300. };
  8301. }
  8302. }).call(FoldLine.prototype);
  8303. exports.FoldLine = FoldLine;
  8304. });
  8305. ace.define('ace/edit_session/fold', ['require', 'exports', 'module' ], function(require, exports, module) {
  8306. /*
  8307. * Simple fold-data struct.
  8308. **/
  8309. var Fold = exports.Fold = function(range, placeholder) {
  8310. this.foldLine = null;
  8311. this.placeholder = placeholder;
  8312. this.range = range;
  8313. this.start = range.start;
  8314. this.end = range.end;
  8315. this.sameRow = range.start.row == range.end.row;
  8316. this.subFolds = [];
  8317. };
  8318. (function() {
  8319. this.toString = function() {
  8320. return '"' + this.placeholder + '" ' + this.range.toString();
  8321. };
  8322. this.setFoldLine = function(foldLine) {
  8323. this.foldLine = foldLine;
  8324. this.subFolds.forEach(function(fold) {
  8325. fold.setFoldLine(foldLine);
  8326. });
  8327. };
  8328. this.clone = function() {
  8329. var range = this.range.clone();
  8330. var fold = new Fold(range, this.placeholder);
  8331. this.subFolds.forEach(function(subFold) {
  8332. fold.subFolds.push(subFold.clone());
  8333. });
  8334. return fold;
  8335. };
  8336. this.addSubFold = function(fold) {
  8337. if (this.range.isEqual(fold))
  8338. return this;
  8339. if (!this.range.containsRange(fold))
  8340. throw "A fold can't intersect already existing fold" + fold.range + this.range;
  8341. var row = fold.range.start.row, column = fold.range.start.column;
  8342. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  8343. cmp = this.subFolds[i].range.compare(row, column);
  8344. if (cmp != 1)
  8345. break;
  8346. }
  8347. var afterStart = this.subFolds[i];
  8348. if (cmp == 0)
  8349. return afterStart.addSubFold(fold)
  8350. // cmp == -1
  8351. var row = fold.range.end.row, column = fold.range.end.column;
  8352. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  8353. cmp = this.subFolds[j].range.compare(row, column);
  8354. if (cmp != 1)
  8355. break;
  8356. }
  8357. var afterEnd = this.subFolds[j];
  8358. if (cmp == 0)
  8359. throw "A fold can't intersect already existing fold" + fold.range + this.range;
  8360. var consumedFolds = this.subFolds.splice(i, j - i, fold)
  8361. fold.setFoldLine(this.foldLine);
  8362. return fold;
  8363. }
  8364. }).call(Fold.prototype);
  8365. });
  8366. ace.define('ace/token_iterator', ['require', 'exports', 'module' ], function(require, exports, module) {
  8367. /**
  8368. * class TokenIterator
  8369. *
  8370. * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens.
  8371. *
  8372. **/
  8373. /**
  8374. * new TokenIterator(session, initialRow, initialColumn)
  8375. * - session (EditSession): The session to associate with
  8376. * - initialRow (Number): The row to start the tokenizing at
  8377. * - initialColumn (Number): The column to start the tokenizing at
  8378. *
  8379. * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates.
  8380. *
  8381. **/
  8382. var TokenIterator = function(session, initialRow, initialColumn) {
  8383. this.$session = session;
  8384. this.$row = initialRow;
  8385. this.$rowTokens = session.getTokens(initialRow);
  8386. var token = session.getTokenAt(initialRow, initialColumn);
  8387. this.$tokenIndex = token ? token.index : -1;
  8388. };
  8389. (function() {
  8390. /**
  8391. * TokenIterator.stepBackward() -> [String]
  8392. * + (String): If the current point is not at the top of the file, this function returns `null`. Otherwise, it returns an array of the tokenized strings.
  8393. *
  8394. * Tokenizes all the items from the current point to the row prior in the document.
  8395. **/
  8396. this.stepBackward = function() {
  8397. this.$tokenIndex -= 1;
  8398. while (this.$tokenIndex < 0) {
  8399. this.$row -= 1;
  8400. if (this.$row < 0) {
  8401. this.$row = 0;
  8402. return null;
  8403. }
  8404. this.$rowTokens = this.$session.getTokens(this.$row);
  8405. this.$tokenIndex = this.$rowTokens.length - 1;
  8406. }
  8407. return this.$rowTokens[this.$tokenIndex];
  8408. };
  8409. this.stepForward = function() {
  8410. var rowCount = this.$session.getLength();
  8411. this.$tokenIndex += 1;
  8412. while (this.$tokenIndex >= this.$rowTokens.length) {
  8413. this.$row += 1;
  8414. if (this.$row >= rowCount) {
  8415. this.$row = rowCount - 1;
  8416. return null;
  8417. }
  8418. this.$rowTokens = this.$session.getTokens(this.$row);
  8419. this.$tokenIndex = 0;
  8420. }
  8421. return this.$rowTokens[this.$tokenIndex];
  8422. };
  8423. this.getCurrentToken = function () {
  8424. return this.$rowTokens[this.$tokenIndex];
  8425. };
  8426. this.getCurrentTokenRow = function () {
  8427. return this.$row;
  8428. };
  8429. this.getCurrentTokenColumn = function() {
  8430. var rowTokens = this.$rowTokens;
  8431. var tokenIndex = this.$tokenIndex;
  8432. // If a column was cached by EditSession.getTokenAt, then use it
  8433. var column = rowTokens[tokenIndex].start;
  8434. if (column !== undefined)
  8435. return column;
  8436. column = 0;
  8437. while (tokenIndex > 0) {
  8438. tokenIndex -= 1;
  8439. column += rowTokens[tokenIndex].value.length;
  8440. }
  8441. return column;
  8442. };
  8443. }).call(TokenIterator.prototype);
  8444. exports.TokenIterator = TokenIterator;
  8445. });
  8446. ace.define('ace/edit_session/bracket_match', ['require', 'exports', 'module' , 'ace/token_iterator', 'ace/range'], function(require, exports, module) {
  8447. var TokenIterator = require("../token_iterator").TokenIterator;
  8448. var Range = require("../range").Range;
  8449. /**
  8450. * new BracketMatch(position)
  8451. * - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
  8452. * - commands (Array): A list of commands
  8453. *
  8454. * TODO
  8455. *
  8456. *
  8457. **/
  8458. function BracketMatch() {
  8459. /**
  8460. * new findMatchingBracket(position)
  8461. * - position (Number): Identifier for the platform; must be either `'mac'` or `'win'`
  8462. * - commands (Array): A list of commands
  8463. *
  8464. * TODO
  8465. *
  8466. *
  8467. **/
  8468. this.findMatchingBracket = function(position) {
  8469. if (position.column == 0) return null;
  8470. var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
  8471. if (charBeforeCursor == "") return null;
  8472. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  8473. if (!match)
  8474. return null;
  8475. if (match[1])
  8476. return this.$findClosingBracket(match[1], position);
  8477. else
  8478. return this.$findOpeningBracket(match[2], position);
  8479. };
  8480. this.getBracketRange = function(pos) {
  8481. var line = this.getLine(pos.row);
  8482. var before = true, range;
  8483. var chr = line.charAt(pos.column-1);
  8484. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  8485. if (!match) {
  8486. chr = line.charAt(pos.column);
  8487. pos.column++;
  8488. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  8489. before = false;
  8490. }
  8491. if (!match)
  8492. return null;
  8493. if (match[1]) {
  8494. var bracketPos = this.$findClosingBracket(match[1], pos);
  8495. if (!bracketPos)
  8496. return null;
  8497. range = Range.fromPoints(pos, bracketPos);
  8498. if (!before) {
  8499. range.end.column++;
  8500. range.start.column--;
  8501. }
  8502. range.cursor = range.end;
  8503. } else {
  8504. var bracketPos = this.$findOpeningBracket(match[2], pos);
  8505. if (!bracketPos)
  8506. return null;
  8507. range = Range.fromPoints(bracketPos, pos);
  8508. if (!before) {
  8509. range.start.column++;
  8510. range.end.column--;
  8511. }
  8512. range.cursor = range.start;
  8513. }
  8514. if (!before)
  8515. pos.column--;
  8516. return range;
  8517. };
  8518. this.$brackets = {
  8519. ")": "(",
  8520. "(": ")",
  8521. "]": "[",
  8522. "[": "]",
  8523. "{": "}",
  8524. "}": "{"
  8525. };
  8526. this.$findOpeningBracket = function(bracket, position, typeRe) {
  8527. var openBracket = this.$brackets[bracket];
  8528. var depth = 1;
  8529. var iterator = new TokenIterator(this, position.row, position.column);
  8530. var token = iterator.getCurrentToken();
  8531. if (!token)
  8532. token = iterator.stepForward();
  8533. if (!token)
  8534. return
  8535. if (!typeRe){
  8536. typeRe = new RegExp(
  8537. "(\\.?" +
  8538. token.type.replace(".", "\\.").replace("rparen", ".paren")
  8539. + ")+"
  8540. );
  8541. }
  8542. // Start searching in token, just before the character at position.column
  8543. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  8544. var value = token.value;
  8545. while (true) {
  8546. while (valueIndex >= 0) {
  8547. var chr = value.charAt(valueIndex);
  8548. if (chr == openBracket) {
  8549. depth -= 1;
  8550. if (depth == 0) {
  8551. return {row: iterator.getCurrentTokenRow(),
  8552. column: valueIndex + iterator.getCurrentTokenColumn()};
  8553. }
  8554. }
  8555. else if (chr == bracket) {
  8556. depth += 1;
  8557. }
  8558. valueIndex -= 1;
  8559. }
  8560. // Scan backward through the document, looking for the next token
  8561. // whose type matches typeRe
  8562. do {
  8563. token = iterator.stepBackward();
  8564. } while (token && !typeRe.test(token.type));
  8565. if (token == null)
  8566. break;
  8567. value = token.value;
  8568. valueIndex = value.length - 1;
  8569. }
  8570. return null;
  8571. };
  8572. this.$findClosingBracket = function(bracket, position, typeRe, allowBlankLine) {
  8573. var closingBracket = this.$brackets[bracket];
  8574. var depth = 1;
  8575. var iterator = new TokenIterator(this, position.row, position.column);
  8576. var token = iterator.getCurrentToken();
  8577. if (!token)
  8578. token = iterator.stepForward();
  8579. if (!token)
  8580. return
  8581. if (!typeRe){
  8582. typeRe = new RegExp(
  8583. "(\\.?" +
  8584. token.type.replace(".", "\\.").replace("lparen", ".paren")
  8585. + ")+"
  8586. );
  8587. }
  8588. // Start searching in token, after the character at position.column
  8589. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  8590. while (true) {
  8591. var value = token.value;
  8592. var valueLength = value.length;
  8593. while (valueIndex < valueLength) {
  8594. var chr = value.charAt(valueIndex);
  8595. if (chr == closingBracket) {
  8596. depth -= 1;
  8597. if (depth == 0) {
  8598. return {row: iterator.getCurrentTokenRow(),
  8599. column: valueIndex + iterator.getCurrentTokenColumn()};
  8600. }
  8601. }
  8602. else if (chr == bracket) {
  8603. depth += 1;
  8604. }
  8605. valueIndex += 1;
  8606. }
  8607. // Scan forward through the document, looking for the next token
  8608. // whose type matches typeRe
  8609. do {
  8610. token = iterator.stepForward();
  8611. if (allowBlankLine) {
  8612. // if you've reached the doc end, or, you match a new content line
  8613. if (token === null || token.type == "string") {
  8614. return {row: iterator.getCurrentTokenRow() + (token === null ? 1 : -1), column: 0};
  8615. }
  8616. }
  8617. } while (token && !typeRe.test(token.type));
  8618. if (token == null)
  8619. break;
  8620. valueIndex = 0;
  8621. }
  8622. return null;
  8623. };
  8624. }
  8625. exports.BracketMatch = BracketMatch;
  8626. });
  8627. ace.define('ace/search', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
  8628. var lang = require("./lib/lang");
  8629. var oop = require("./lib/oop");
  8630. var Range = require("./range").Range;
  8631. /**
  8632. * new Search()
  8633. *
  8634. * Creates a new `Search` object. The following search options are avaliable:
  8635. *
  8636. * * needle: string or regular expression
  8637. * * backwards: false
  8638. * * wrap: false
  8639. * * caseSensitive: false
  8640. * * wholeWord: false
  8641. * * range: Range or null for whole document
  8642. * * regExp: false
  8643. * * start: Range or position
  8644. * * skipCurrent: false
  8645. *
  8646. **/
  8647. var Search = function() {
  8648. this.$options = {};
  8649. };
  8650. (function() {
  8651. /**
  8652. * Search.set(options) -> Search
  8653. * - options (Object): An object containing all the new search properties
  8654. *
  8655. * Sets the search options via the `options` parameter.
  8656. *
  8657. **/
  8658. this.set = function(options) {
  8659. oop.mixin(this.$options, options);
  8660. return this;
  8661. };
  8662. this.getOptions = function() {
  8663. return lang.copyObject(this.$options);
  8664. };
  8665. this.setOptions = function(options) {
  8666. this.$options = options;
  8667. };
  8668. this.find = function(session) {
  8669. var iterator = this.$matchIterator(session, this.$options);
  8670. if (!iterator)
  8671. return false;
  8672. var firstRange = null;
  8673. iterator.forEach(function(range, row, offset) {
  8674. if (!range.start) {
  8675. var column = range.offset + (offset || 0);
  8676. firstRange = new Range(row, column, row, column+range.length);
  8677. } else
  8678. firstRange = range;
  8679. return true;
  8680. });
  8681. return firstRange;
  8682. };
  8683. this.findAll = function(session) {
  8684. var options = this.$options;
  8685. if (!options.needle)
  8686. return [];
  8687. this.$assembleRegExp(options);
  8688. if (options.range) {
  8689. var range = options.range;
  8690. var lines = session.getLines(range.start.row, range.end.row);
  8691. } else
  8692. var lines = session.doc.getAllLines();
  8693. var ranges = [];
  8694. var re = options.re;
  8695. if (options.$isMultiLine) {
  8696. var len = re.length;
  8697. var maxRow = lines.length - len;
  8698. for (var row = re.offset || 0; row < maxRow; row++) {
  8699. for (var j = 0; j < re.length; j++)
  8700. if (lines[row + j].search(re[j]) == -1)
  8701. break;
  8702. var startIndex = lines[row + j].match(re[0])[0].length;
  8703. var endIndex = line.match(re[len - 1])[0].length;
  8704. ranges.push(new Range(
  8705. row, startLine.length - startIndex,
  8706. row + len - 1, endIndex
  8707. ));
  8708. }
  8709. } else {
  8710. for (var i = 0; i < lines.length; i++) {
  8711. var matches = lang.getMatchOffsets(lines[i], re);
  8712. for (var j = 0; j < matches.length; j++) {
  8713. var match = matches[j];
  8714. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8715. };
  8716. }
  8717. }
  8718. if (options.range) {
  8719. var startColumn = range.start.column;
  8720. var endColumn = range.start.column;
  8721. var i = 0, j = ranges.length - 1;
  8722. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8723. i++;
  8724. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8725. j--;
  8726. return ranges.slice(i, j + 1);
  8727. }
  8728. return ranges;
  8729. };
  8730. this.replace = function(input, replacement) {
  8731. var options = this.$options;
  8732. var re = this.$assembleRegExp(options);
  8733. if (options.$isMultiLine)
  8734. return replacement;
  8735. if (!re)
  8736. return;
  8737. var match = re.exec(input);
  8738. if (!match || match[0].length != input.length)
  8739. return null;
  8740. replacement = input.replace(re, replacement)
  8741. if (options.preserveCase) {
  8742. replacement = replacement.split("");
  8743. for (var i = Math.min(input.length, input.length); i--; ) {
  8744. var ch = input[i];
  8745. if (ch && ch.toLowerCase() != ch)
  8746. replacement[i] = replacement[i].toUpperCase();
  8747. else
  8748. replacement[i] = replacement[i].toLowerCase();
  8749. }
  8750. replacement = replacement.join("");
  8751. }
  8752. return replacement;
  8753. };
  8754. this.$matchIterator = function(session, options) {
  8755. var re = this.$assembleRegExp(options);
  8756. if (!re)
  8757. return false;
  8758. var self = this, callback, backwards = options.backwards;
  8759. if (options.$isMultiLine) {
  8760. var len = re.length;
  8761. var matchIterator = function(line, row, offset) {
  8762. var startIndex = line.search(re[0]);
  8763. if (startIndex == -1)
  8764. return;
  8765. for (var i = 1; i < len; i++) {
  8766. line = session.getLine(row + i);
  8767. if (line.search(re[i]) == -1)
  8768. return;
  8769. }
  8770. var endIndex = line.match(re[len - 1])[0].length;
  8771. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8772. if (re.offset == 1) {
  8773. range.start.row--;
  8774. range.start.column = Number.MAX_VALUE;
  8775. } else if (offset)
  8776. range.start.column += offset;
  8777. if (callback(range))
  8778. return true;
  8779. }
  8780. } else if (backwards) {
  8781. var matchIterator = function(line, row, startIndex) {
  8782. var matches = lang.getMatchOffsets(line, re);
  8783. for (var i = matches.length-1; i >= 0; i--)
  8784. if (callback(matches[i], row, startIndex))
  8785. return true;
  8786. }
  8787. } else {
  8788. var matchIterator = function(line, row, startIndex) {
  8789. var matches = lang.getMatchOffsets(line, re);
  8790. for (var i = 0; i < matches.length; i++)
  8791. if (callback(matches[i], row, startIndex))
  8792. return true;
  8793. }
  8794. }
  8795. return {
  8796. forEach: function(_callback) {
  8797. callback = _callback;
  8798. self.$lineIterator(session, options).forEach(matchIterator);
  8799. }
  8800. };
  8801. };
  8802. this.$assembleRegExp = function(options) {
  8803. if (options.needle instanceof RegExp)
  8804. return options.re = options.needle;
  8805. var needle = options.needle;
  8806. if (!options.needle)
  8807. return options.re = false;
  8808. if (!options.regExp)
  8809. needle = lang.escapeRegExp(needle);
  8810. if (options.wholeWord)
  8811. needle = "\\b" + needle + "\\b";
  8812. var modifier = options.caseSensitive ? "g" : "gi";
  8813. options.$isMultiLine = /[\n\r]/.test(needle);
  8814. if (options.$isMultiLine)
  8815. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8816. try {
  8817. var re = new RegExp(needle, modifier);
  8818. } catch(e) {
  8819. var re = false;
  8820. }
  8821. return options.re = re;
  8822. };
  8823. this.$assembleMultilineRegExp = function(needle, modifier) {
  8824. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8825. var re = [];
  8826. for (var i = 0; i < parts.length; i++) try {
  8827. re.push(new RegExp(parts[i], modifier));
  8828. } catch(e) {
  8829. return false;
  8830. }
  8831. if (parts[0] == "") {
  8832. re.shift();
  8833. re.offset = 1;
  8834. } else {
  8835. re.offset = 0;
  8836. }
  8837. return re;
  8838. };
  8839. this.$lineIterator = function(session, options) {
  8840. var range = options.range;
  8841. var backwards = options.backwards == true;
  8842. var skipCurrent = options.skipCurrent != false;
  8843. var range = options.range;
  8844. var start = options.start;
  8845. if (!start)
  8846. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8847. if (start.start)
  8848. start = start[skipCurrent != backwards ? "end" : "start"];
  8849. var firstRow = range ? range.start.row : 0;
  8850. var firstColumn = range ? range.start.column : 0;
  8851. var lastRow = range ? range.end.row : session.getLength() - 1;
  8852. if (!backwards) {
  8853. var forEach = function(callback) {
  8854. var row = start.row;
  8855. var line = session.getLine(row).substr(start.column);
  8856. if (callback(line, row, start.column))
  8857. return;
  8858. for (row = row+1; row <= lastRow; row++)
  8859. if (callback(session.getLine(row), row))
  8860. return;
  8861. if (options.wrap == false)
  8862. return;
  8863. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8864. if (callback(session.getLine(row), row))
  8865. return;
  8866. }
  8867. } else {
  8868. var forEach = function(callback) {
  8869. var row = start.row;
  8870. var line = session.getLine(row).substring(0, start.column);
  8871. if (callback(line, row))
  8872. return;
  8873. for (row--; row >= firstRow; row--)
  8874. if (callback(session.getLine(row), row))
  8875. return;
  8876. if (options.wrap == false)
  8877. return;
  8878. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8879. if (callback(session.getLine(row), row))
  8880. return;
  8881. }
  8882. }
  8883. return {forEach: forEach};
  8884. };
  8885. }).call(Search.prototype);
  8886. exports.Search = Search;
  8887. });
  8888. ace.define('ace/commands/command_manager', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/lib/event_emitter'], function(require, exports, module) {
  8889. var oop = require("../lib/oop");
  8890. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  8891. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  8892. /**
  8893. * new CommandManager(platform, commands)
  8894. * - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
  8895. * - commands (Array): A list of commands
  8896. *
  8897. * TODO
  8898. *
  8899. *
  8900. **/
  8901. var CommandManager = function(platform, commands) {
  8902. this.platform = platform;
  8903. this.commands = {};
  8904. this.commmandKeyBinding = {};
  8905. this.addCommands(commands);
  8906. this.setDefaultHandler("exec", function(e) {
  8907. return e.command.exec(e.editor, e.args || {});
  8908. });
  8909. };
  8910. oop.inherits(CommandManager, HashHandler);
  8911. (function() {
  8912. oop.implement(this, EventEmitter);
  8913. this.exec = function(command, editor, args) {
  8914. if (typeof command === 'string')
  8915. command = this.commands[command];
  8916. if (!command)
  8917. return false;
  8918. if (editor && editor.$readOnly && !command.readOnly)
  8919. return false;
  8920. var retvalue = this._emit("exec", {
  8921. editor: editor,
  8922. command: command,
  8923. args: args
  8924. });
  8925. return retvalue === false ? false : true;
  8926. };
  8927. this.toggleRecording = function() {
  8928. if (this.$inReplay)
  8929. return;
  8930. if (this.recording) {
  8931. this.macro.pop();
  8932. this.removeEventListener("exec", this.$addCommandToMacro);
  8933. if (!this.macro.length)
  8934. this.macro = this.oldMacro;
  8935. return this.recording = false;
  8936. }
  8937. if (!this.$addCommandToMacro) {
  8938. this.$addCommandToMacro = function(e) {
  8939. this.macro.push([e.command, e.args]);
  8940. }.bind(this);
  8941. }
  8942. this.oldMacro = this.macro;
  8943. this.macro = [];
  8944. this.on("exec", this.$addCommandToMacro);
  8945. return this.recording = true;
  8946. };
  8947. this.replay = function(editor) {
  8948. if (this.$inReplay || !this.macro)
  8949. return;
  8950. if (this.recording)
  8951. return this.toggleRecording();
  8952. try {
  8953. this.$inReplay = true;
  8954. this.macro.forEach(function(x) {
  8955. if (typeof x == "string")
  8956. this.exec(x, editor);
  8957. else
  8958. this.exec(x[0], editor, x[1]);
  8959. }, this);
  8960. } finally {
  8961. this.$inReplay = false;
  8962. }
  8963. };
  8964. this.trimMacro = function(m) {
  8965. return m.map(function(x){
  8966. if (typeof x[0] != "string")
  8967. x[0] = x[0].name;
  8968. if (!x[1])
  8969. x = x[0];
  8970. return x;
  8971. });
  8972. };
  8973. }).call(CommandManager.prototype);
  8974. exports.CommandManager = CommandManager;
  8975. });
  8976. ace.define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
  8977. var keyUtil = require("../lib/keys");
  8978. function HashHandler(config, platform) {
  8979. this.platform = platform;
  8980. this.commands = {};
  8981. this.commmandKeyBinding = {};
  8982. this.addCommands(config);
  8983. };
  8984. (function() {
  8985. this.addCommand = function(command) {
  8986. if (this.commands[command.name])
  8987. this.removeCommand(command);
  8988. this.commands[command.name] = command;
  8989. if (command.bindKey)
  8990. this._buildKeyHash(command);
  8991. };
  8992. this.removeCommand = function(command) {
  8993. var name = (typeof command === 'string' ? command : command.name);
  8994. command = this.commands[name];
  8995. delete this.commands[name];
  8996. // exhaustive search is brute force but since removeCommand is
  8997. // not a performance critical operation this should be OK
  8998. var ckb = this.commmandKeyBinding;
  8999. for (var hashId in ckb) {
  9000. for (var key in ckb[hashId]) {
  9001. if (ckb[hashId][key] == command)
  9002. delete ckb[hashId][key];
  9003. }
  9004. }
  9005. };
  9006. this.bindKey = function(key, command) {
  9007. if(!key)
  9008. return;
  9009. if (typeof command == "function") {
  9010. this.addCommand({exec: command, bindKey: key, name: key});
  9011. return;
  9012. }
  9013. var ckb = this.commmandKeyBinding;
  9014. key.split("|").forEach(function(keyPart) {
  9015. var binding = this.parseKeys(keyPart, command);
  9016. var hashId = binding.hashId;
  9017. (ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
  9018. }, this);
  9019. };
  9020. this.addCommands = function(commands) {
  9021. commands && Object.keys(commands).forEach(function(name) {
  9022. var command = commands[name];
  9023. if (typeof command === "string")
  9024. return this.bindKey(command, name);
  9025. if (typeof command === "function")
  9026. command = { exec: command };
  9027. if (!command.name)
  9028. command.name = name;
  9029. this.addCommand(command);
  9030. }, this);
  9031. };
  9032. this.removeCommands = function(commands) {
  9033. Object.keys(commands).forEach(function(name) {
  9034. this.removeCommand(commands[name]);
  9035. }, this);
  9036. };
  9037. this.bindKeys = function(keyList) {
  9038. Object.keys(keyList).forEach(function(key) {
  9039. this.bindKey(key, keyList[key]);
  9040. }, this);
  9041. };
  9042. this._buildKeyHash = function(command) {
  9043. var binding = command.bindKey;
  9044. if (!binding)
  9045. return;
  9046. var key = typeof binding == "string" ? binding: binding[this.platform];
  9047. this.bindKey(key, command);
  9048. };
  9049. this.parseKeys = function(keys) {
  9050. var key;
  9051. var hashId = 0;
  9052. var parts = keys.toLowerCase().trim().split(/\s*\-\s*/);
  9053. for (var i = 0, l = parts.length; i < l; i++) {
  9054. if (keyUtil.KEY_MODS[parts[i]])
  9055. hashId = hashId | keyUtil.KEY_MODS[parts[i]];
  9056. else
  9057. key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
  9058. }
  9059. if (parts[0] == "text" && parts.length == 2) {
  9060. hashId = -1;
  9061. key = parts[1];
  9062. }
  9063. return {
  9064. key: key,
  9065. hashId: hashId
  9066. };
  9067. };
  9068. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9069. var ckbr = this.commmandKeyBinding;
  9070. return ckbr[hashId] && ckbr[hashId][keyString.toLowerCase()];
  9071. };
  9072. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9073. return {
  9074. command: this.findKeyCommand(hashId, keyString)
  9075. };
  9076. };
  9077. }).call(HashHandler.prototype)
  9078. exports.HashHandler = HashHandler;
  9079. });
  9080. ace.define('ace/commands/default_commands', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
  9081. var lang = require("../lib/lang");
  9082. function bindKey(win, mac) {
  9083. return {
  9084. win: win,
  9085. mac: mac
  9086. };
  9087. }
  9088. exports.commands = [{
  9089. name: "selectall",
  9090. bindKey: bindKey("Ctrl-A", "Command-A"),
  9091. exec: function(editor) { editor.selectAll(); },
  9092. readOnly: true
  9093. }, {
  9094. name: "centerselection",
  9095. bindKey: bindKey(null, "Ctrl-L"),
  9096. exec: function(editor) { editor.centerSelection(); },
  9097. readOnly: true
  9098. }, {
  9099. name: "gotoline",
  9100. bindKey: bindKey("Ctrl-L", "Command-L"),
  9101. exec: function(editor) {
  9102. var line = parseInt(prompt("Enter line number:"), 10);
  9103. if (!isNaN(line)) {
  9104. editor.gotoLine(line);
  9105. }
  9106. },
  9107. readOnly: true
  9108. }, {
  9109. name: "fold",
  9110. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9111. exec: function(editor) { editor.session.toggleFold(false); },
  9112. readOnly: true
  9113. }, {
  9114. name: "unfold",
  9115. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9116. exec: function(editor) { editor.session.toggleFold(true); },
  9117. readOnly: true
  9118. }, {
  9119. name: "foldall",
  9120. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9121. exec: function(editor) { editor.session.foldAll(); },
  9122. readOnly: true
  9123. }, {
  9124. name: "unfoldall",
  9125. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9126. exec: function(editor) { editor.session.unfold(); },
  9127. readOnly: true
  9128. }, {
  9129. name: "findnext",
  9130. bindKey: bindKey("Ctrl-K", "Command-G"),
  9131. exec: function(editor) { editor.findNext(); },
  9132. readOnly: true
  9133. }, {
  9134. name: "findprevious",
  9135. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9136. exec: function(editor) { editor.findPrevious(); },
  9137. readOnly: true
  9138. }, {
  9139. name: "find",
  9140. bindKey: bindKey("Ctrl-F", "Command-F"),
  9141. exec: function(editor) {
  9142. var needle = prompt("Find:", editor.getCopyText());
  9143. editor.find(needle);
  9144. },
  9145. readOnly: true
  9146. }, {
  9147. name: "overwrite",
  9148. bindKey: "Insert",
  9149. exec: function(editor) { editor.toggleOverwrite(); },
  9150. readOnly: true
  9151. }, {
  9152. name: "selecttostart",
  9153. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9154. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9155. readOnly: true
  9156. }, {
  9157. name: "gotostart",
  9158. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9159. exec: function(editor) { editor.navigateFileStart(); },
  9160. readOnly: true
  9161. }, {
  9162. name: "selectup",
  9163. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9164. exec: function(editor) { editor.getSelection().selectUp(); },
  9165. multiSelectAction: "forEach",
  9166. readOnly: true
  9167. }, {
  9168. name: "golineup",
  9169. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9170. exec: function(editor, args) { editor.navigateUp(args.times); },
  9171. multiSelectAction: "forEach",
  9172. readOnly: true
  9173. }, {
  9174. name: "selecttoend",
  9175. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9176. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9177. multiSelectAction: "forEach",
  9178. readOnly: true
  9179. }, {
  9180. name: "gotoend",
  9181. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9182. exec: function(editor) { editor.navigateFileEnd(); },
  9183. multiSelectAction: "forEach",
  9184. readOnly: true
  9185. }, {
  9186. name: "selectdown",
  9187. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9188. exec: function(editor) { editor.getSelection().selectDown(); },
  9189. multiSelectAction: "forEach",
  9190. readOnly: true
  9191. }, {
  9192. name: "golinedown",
  9193. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9194. exec: function(editor, args) { editor.navigateDown(args.times); },
  9195. multiSelectAction: "forEach",
  9196. readOnly: true
  9197. }, {
  9198. name: "selectwordleft",
  9199. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9200. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9201. multiSelectAction: "forEach",
  9202. readOnly: true
  9203. }, {
  9204. name: "gotowordleft",
  9205. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9206. exec: function(editor) { editor.navigateWordLeft(); },
  9207. multiSelectAction: "forEach",
  9208. readOnly: true
  9209. }, {
  9210. name: "selecttolinestart",
  9211. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9212. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9213. multiSelectAction: "forEach",
  9214. readOnly: true
  9215. }, {
  9216. name: "gotolinestart",
  9217. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9218. exec: function(editor) { editor.navigateLineStart(); },
  9219. multiSelectAction: "forEach",
  9220. readOnly: true
  9221. }, {
  9222. name: "selectleft",
  9223. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9224. exec: function(editor) { editor.getSelection().selectLeft(); },
  9225. multiSelectAction: "forEach",
  9226. readOnly: true
  9227. }, {
  9228. name: "gotoleft",
  9229. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9230. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9231. multiSelectAction: "forEach",
  9232. readOnly: true
  9233. }, {
  9234. name: "selectwordright",
  9235. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9236. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9237. multiSelectAction: "forEach",
  9238. readOnly: true
  9239. }, {
  9240. name: "gotowordright",
  9241. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9242. exec: function(editor) { editor.navigateWordRight(); },
  9243. multiSelectAction: "forEach",
  9244. readOnly: true
  9245. }, {
  9246. name: "selecttolineend",
  9247. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9248. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9249. multiSelectAction: "forEach",
  9250. readOnly: true
  9251. }, {
  9252. name: "gotolineend",
  9253. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9254. exec: function(editor) { editor.navigateLineEnd(); },
  9255. multiSelectAction: "forEach",
  9256. readOnly: true
  9257. }, {
  9258. name: "selectright",
  9259. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9260. exec: function(editor) { editor.getSelection().selectRight(); },
  9261. multiSelectAction: "forEach",
  9262. readOnly: true
  9263. }, {
  9264. name: "gotoright",
  9265. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9266. exec: function(editor, args) { editor.navigateRight(args.times); },
  9267. multiSelectAction: "forEach",
  9268. readOnly: true
  9269. }, {
  9270. name: "selectpagedown",
  9271. bindKey: "Shift-PageDown",
  9272. exec: function(editor) { editor.selectPageDown(); },
  9273. readOnly: true
  9274. }, {
  9275. name: "pagedown",
  9276. bindKey: bindKey(null, "Option-PageDown"),
  9277. exec: function(editor) { editor.scrollPageDown(); },
  9278. readOnly: true
  9279. }, {
  9280. name: "gotopagedown",
  9281. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9282. exec: function(editor) { editor.gotoPageDown(); },
  9283. readOnly: true
  9284. }, {
  9285. name: "selectpageup",
  9286. bindKey: "Shift-PageUp",
  9287. exec: function(editor) { editor.selectPageUp(); },
  9288. readOnly: true
  9289. }, {
  9290. name: "pageup",
  9291. bindKey: bindKey(null, "Option-PageUp"),
  9292. exec: function(editor) { editor.scrollPageUp(); },
  9293. readOnly: true
  9294. }, {
  9295. name: "gotopageup",
  9296. bindKey: "PageUp",
  9297. exec: function(editor) { editor.gotoPageUp(); },
  9298. readOnly: true
  9299. }, {
  9300. name: "scrollup",
  9301. bindKey: bindKey("Ctrl-Up", null),
  9302. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9303. readOnly: true
  9304. }, {
  9305. name: "scrolldown",
  9306. bindKey: bindKey("Ctrl-Down", null),
  9307. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9308. readOnly: true
  9309. }, {
  9310. name: "selectlinestart",
  9311. bindKey: "Shift-Home",
  9312. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9313. multiSelectAction: "forEach",
  9314. readOnly: true
  9315. }, {
  9316. name: "selectlineend",
  9317. bindKey: "Shift-End",
  9318. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9319. multiSelectAction: "forEach",
  9320. readOnly: true
  9321. }, {
  9322. name: "togglerecording",
  9323. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9324. exec: function(editor) { editor.commands.toggleRecording(); },
  9325. readOnly: true
  9326. }, {
  9327. name: "replaymacro",
  9328. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9329. exec: function(editor) { editor.commands.replay(editor); },
  9330. readOnly: true
  9331. }, {
  9332. name: "jumptomatching",
  9333. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9334. exec: function(editor) { editor.jumpToMatching(); },
  9335. multiSelectAction: "forEach",
  9336. readOnly: true
  9337. }, {
  9338. name: "selecttomatching",
  9339. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9340. exec: function(editor) { editor.jumpToMatching(true); },
  9341. readOnly: true
  9342. },
  9343. // commands disabled in readOnly mode
  9344. {
  9345. name: "cut",
  9346. exec: function(editor) {
  9347. var range = editor.getSelectionRange();
  9348. editor._emit("cut", range);
  9349. if (!editor.selection.isEmpty()) {
  9350. editor.session.remove(range);
  9351. editor.clearSelection();
  9352. }
  9353. },
  9354. multiSelectAction: "forEach"
  9355. }, {
  9356. name: "removeline",
  9357. bindKey: bindKey("Ctrl-D", "Command-D"),
  9358. exec: function(editor) { editor.removeLines(); },
  9359. multiSelectAction: "forEach"
  9360. }, {
  9361. name: "duplicateSelection",
  9362. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9363. exec: function(editor) { editor.duplicateSelection(); },
  9364. multiSelectAction: "forEach"
  9365. }, {
  9366. name: "togglecomment",
  9367. bindKey: bindKey("Ctrl-/", "Command-/"),
  9368. exec: function(editor) { editor.toggleCommentLines(); },
  9369. multiSelectAction: "forEach"
  9370. }, {
  9371. name: "replace",
  9372. bindKey: bindKey("Ctrl-R", "Command-Option-F"),
  9373. exec: function(editor) {
  9374. var needle = prompt("Find:", editor.getCopyText());
  9375. if (!needle)
  9376. return;
  9377. var replacement = prompt("Replacement:");
  9378. if (!replacement)
  9379. return;
  9380. editor.replace(replacement, {needle: needle});
  9381. }
  9382. }, {
  9383. name: "replaceall",
  9384. bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
  9385. exec: function(editor) {
  9386. var needle = prompt("Find:");
  9387. if (!needle)
  9388. return;
  9389. var replacement = prompt("Replacement:");
  9390. if (!replacement)
  9391. return;
  9392. editor.replaceAll(replacement, {needle: needle});
  9393. }
  9394. }, {
  9395. name: "undo",
  9396. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9397. exec: function(editor) { editor.undo(); }
  9398. }, {
  9399. name: "redo",
  9400. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9401. exec: function(editor) { editor.redo(); }
  9402. }, {
  9403. name: "copylinesup",
  9404. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9405. exec: function(editor) { editor.copyLinesUp(); }
  9406. }, {
  9407. name: "movelinesup",
  9408. bindKey: bindKey("Alt-Up", "Option-Up"),
  9409. exec: function(editor) { editor.moveLinesUp(); }
  9410. }, {
  9411. name: "copylinesdown",
  9412. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9413. exec: function(editor) { editor.copyLinesDown(); }
  9414. }, {
  9415. name: "movelinesdown",
  9416. bindKey: bindKey("Alt-Down", "Option-Down"),
  9417. exec: function(editor) { editor.moveLinesDown(); }
  9418. }, {
  9419. name: "del",
  9420. bindKey: bindKey("Delete", "Delete|Ctrl-D"),
  9421. exec: function(editor) { editor.remove("right"); },
  9422. multiSelectAction: "forEach"
  9423. }, {
  9424. name: "backspace",
  9425. bindKey: bindKey(
  9426. "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
  9427. "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9428. ),
  9429. exec: function(editor) { editor.remove("left"); },
  9430. multiSelectAction: "forEach"
  9431. }, {
  9432. name: "removetolinestart",
  9433. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9434. exec: function(editor) { editor.removeToLineStart(); },
  9435. multiSelectAction: "forEach"
  9436. }, {
  9437. name: "removetolineend",
  9438. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9439. exec: function(editor) { editor.removeToLineEnd(); },
  9440. multiSelectAction: "forEach"
  9441. }, {
  9442. name: "removewordleft",
  9443. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9444. exec: function(editor) { editor.removeWordLeft(); },
  9445. multiSelectAction: "forEach"
  9446. }, {
  9447. name: "removewordright",
  9448. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9449. exec: function(editor) { editor.removeWordRight(); },
  9450. multiSelectAction: "forEach"
  9451. }, {
  9452. name: "outdent",
  9453. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9454. exec: function(editor) { editor.blockOutdent(); },
  9455. multiSelectAction: "forEach"
  9456. }, {
  9457. name: "indent",
  9458. bindKey: bindKey("Tab", "Tab"),
  9459. exec: function(editor) { editor.indent(); },
  9460. multiSelectAction: "forEach"
  9461. }, {
  9462. name: "insertstring",
  9463. exec: function(editor, str) { editor.insert(str); },
  9464. multiSelectAction: "forEach"
  9465. }, {
  9466. name: "inserttext",
  9467. exec: function(editor, args) {
  9468. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9469. },
  9470. multiSelectAction: "forEach"
  9471. }, {
  9472. name: "splitline",
  9473. bindKey: bindKey(null, "Ctrl-O"),
  9474. exec: function(editor) { editor.splitLine(); },
  9475. multiSelectAction: "forEach"
  9476. }, {
  9477. name: "transposeletters",
  9478. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9479. exec: function(editor) { editor.transposeLetters(); },
  9480. multiSelectAction: function(editor) {editor.transposeSelections(1); }
  9481. }, {
  9482. name: "touppercase",
  9483. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9484. exec: function(editor) { editor.toUpperCase(); },
  9485. multiSelectAction: "forEach"
  9486. }, {
  9487. name: "tolowercase",
  9488. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9489. exec: function(editor) { editor.toLowerCase(); },
  9490. multiSelectAction: "forEach"
  9491. }];
  9492. });
  9493. ace.define('ace/undomanager', ['require', 'exports', 'module' ], function(require, exports, module) {
  9494. /**
  9495. * class UndoManager
  9496. *
  9497. * This object maintains the undo stack for an [[EditSession `EditSession`]].
  9498. *
  9499. **/
  9500. /**
  9501. * new UndoManager()
  9502. *
  9503. * Resets the current undo state and creates a new `UndoManager`.
  9504. **/
  9505. var UndoManager = function() {
  9506. this.reset();
  9507. };
  9508. (function() {
  9509. /**
  9510. * UndoManager.execute(options) -> Void
  9511. * - options (Object): Contains additional properties
  9512. *
  9513. * Provides a means for implementing your own undo manager. `options` has one property, `args`, an [[Array `Array`]], with two elements:
  9514. * * `args[0]` is an array of deltas
  9515. * * `args[1]` is the document to associate with
  9516. *
  9517. **/
  9518. this.execute = function(options) {
  9519. var deltas = options.args[0];
  9520. this.$doc = options.args[1];
  9521. this.$undoStack.push(deltas);
  9522. this.$redoStack = [];
  9523. };
  9524. this.undo = function(dontSelect) {
  9525. var deltas = this.$undoStack.pop();
  9526. var undoSelectionRange = null;
  9527. if (deltas) {
  9528. undoSelectionRange =
  9529. this.$doc.undoChanges(deltas, dontSelect);
  9530. this.$redoStack.push(deltas);
  9531. }
  9532. return undoSelectionRange;
  9533. };
  9534. this.redo = function(dontSelect) {
  9535. var deltas = this.$redoStack.pop();
  9536. var redoSelectionRange = null;
  9537. if (deltas) {
  9538. redoSelectionRange =
  9539. this.$doc.redoChanges(deltas, dontSelect);
  9540. this.$undoStack.push(deltas);
  9541. }
  9542. return redoSelectionRange;
  9543. };
  9544. this.reset = function() {
  9545. this.$undoStack = [];
  9546. this.$redoStack = [];
  9547. };
  9548. this.hasUndo = function() {
  9549. return this.$undoStack.length > 0;
  9550. };
  9551. this.hasRedo = function() {
  9552. return this.$redoStack.length > 0;
  9553. };
  9554. }).call(UndoManager.prototype);
  9555. exports.UndoManager = UndoManager;
  9556. });
  9557. ace.define('ace/virtual_renderer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/useragent', 'ace/config', 'ace/lib/net', 'ace/layer/gutter', 'ace/layer/marker', 'ace/layer/text', 'ace/layer/cursor', 'ace/scrollbar', 'ace/renderloop', 'ace/lib/event_emitter', 'text!ace/css/editor.css'], function(require, exports, module) {
  9558. var oop = require("./lib/oop");
  9559. var dom = require("./lib/dom");
  9560. var event = require("./lib/event");
  9561. var useragent = require("./lib/useragent");
  9562. var config = require("./config");
  9563. var net = require("./lib/net");
  9564. var GutterLayer = require("./layer/gutter").Gutter;
  9565. var MarkerLayer = require("./layer/marker").Marker;
  9566. var TextLayer = require("./layer/text").Text;
  9567. var CursorLayer = require("./layer/cursor").Cursor;
  9568. var ScrollBar = require("./scrollbar").ScrollBar;
  9569. var RenderLoop = require("./renderloop").RenderLoop;
  9570. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9571. var editorCss = require("text!./css/editor.css");
  9572. dom.importCssString(editorCss, "ace_editor");
  9573. /**
  9574. * new VirtualRenderer(container, theme)
  9575. * - container (DOMElement): The root element of the editor
  9576. * - theme (String): The starting theme
  9577. *
  9578. * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`.
  9579. *
  9580. **/
  9581. var VirtualRenderer = function(container, theme) {
  9582. var _self = this;
  9583. this.container = container;
  9584. // TODO: this breaks rendering in Cloud9 with multiple ace instances
  9585. // // Imports CSS once per DOM document ('ace_editor' serves as an identifier).
  9586. // dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
  9587. // in IE <= 9 the native cursor always shines through
  9588. this.$keepTextAreaAtCursor = !useragent.isIE;
  9589. dom.addCssClass(container, "ace_editor");
  9590. this.setTheme(theme);
  9591. this.$gutter = dom.createElement("div");
  9592. this.$gutter.className = "ace_gutter";
  9593. this.container.appendChild(this.$gutter);
  9594. this.scroller = dom.createElement("div");
  9595. this.scroller.className = "ace_scroller";
  9596. this.container.appendChild(this.scroller);
  9597. this.content = dom.createElement("div");
  9598. this.content.className = "ace_content";
  9599. this.scroller.appendChild(this.content);
  9600. this.$gutterLayer = new GutterLayer(this.$gutter);
  9601. this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
  9602. this.setFadeFoldWidgets(true);
  9603. this.$markerBack = new MarkerLayer(this.content);
  9604. var textLayer = this.$textLayer = new TextLayer(this.content);
  9605. this.canvas = textLayer.element;
  9606. this.$markerFront = new MarkerLayer(this.content);
  9607. this.characterWidth = textLayer.getCharacterWidth();
  9608. this.lineHeight = textLayer.getLineHeight();
  9609. this.$cursorLayer = new CursorLayer(this.content);
  9610. this.$cursorPadding = 8;
  9611. // Indicates whether the horizontal scrollbar is visible
  9612. this.$horizScroll = false;
  9613. this.$horizScrollAlwaysVisible = false;
  9614. this.$animatedScroll = false;
  9615. this.scrollBar = new ScrollBar(container);
  9616. this.scrollBar.addEventListener("scroll", function(e) {
  9617. if (!_self.$inScrollAnimation)
  9618. _self.session.setScrollTop(e.data);
  9619. });
  9620. this.scrollTop = 0;
  9621. this.scrollLeft = 0;
  9622. event.addListener(this.scroller, "scroll", function() {
  9623. var scrollLeft = _self.scroller.scrollLeft;
  9624. _self.scrollLeft = scrollLeft;
  9625. _self.session.setScrollLeft(scrollLeft);
  9626. });
  9627. this.cursorPos = {
  9628. row : 0,
  9629. column : 0
  9630. };
  9631. this.$textLayer.addEventListener("changeCharacterSize", function() {
  9632. _self.characterWidth = textLayer.getCharacterWidth();
  9633. _self.lineHeight = textLayer.getLineHeight();
  9634. _self.$updatePrintMargin();
  9635. _self.onResize(true);
  9636. _self.$loop.schedule(_self.CHANGE_FULL);
  9637. });
  9638. this.$size = {
  9639. width: 0,
  9640. height: 0,
  9641. scrollerHeight: 0,
  9642. scrollerWidth: 0
  9643. };
  9644. this.layerConfig = {
  9645. width : 1,
  9646. padding : 0,
  9647. firstRow : 0,
  9648. firstRowScreen: 0,
  9649. lastRow : 0,
  9650. lineHeight : 1,
  9651. characterWidth : 1,
  9652. minHeight : 1,
  9653. maxHeight : 1,
  9654. offset : 0,
  9655. height : 1
  9656. };
  9657. this.$loop = new RenderLoop(
  9658. this.$renderChanges.bind(this),
  9659. this.container.ownerDocument.defaultView
  9660. );
  9661. this.$loop.schedule(this.CHANGE_FULL);
  9662. this.setPadding(4);
  9663. this.$updatePrintMargin();
  9664. };
  9665. (function() {
  9666. this.showGutter = true;
  9667. this.CHANGE_CURSOR = 1;
  9668. this.CHANGE_MARKER = 2;
  9669. this.CHANGE_GUTTER = 4;
  9670. this.CHANGE_SCROLL = 8;
  9671. this.CHANGE_LINES = 16;
  9672. this.CHANGE_TEXT = 32;
  9673. this.CHANGE_SIZE = 64;
  9674. this.CHANGE_MARKER_BACK = 128;
  9675. this.CHANGE_MARKER_FRONT = 256;
  9676. this.CHANGE_FULL = 512;
  9677. this.CHANGE_H_SCROLL = 1024;
  9678. oop.implement(this, EventEmitter);
  9679. this.setSession = function(session) {
  9680. this.session = session;
  9681. this.scroller.className = "ace_scroller";
  9682. this.$cursorLayer.setSession(session);
  9683. this.$markerBack.setSession(session);
  9684. this.$markerFront.setSession(session);
  9685. this.$gutterLayer.setSession(session);
  9686. this.$textLayer.setSession(session);
  9687. this.$loop.schedule(this.CHANGE_FULL);
  9688. };
  9689. this.updateLines = function(firstRow, lastRow) {
  9690. if (lastRow === undefined)
  9691. lastRow = Infinity;
  9692. if (!this.$changedLines) {
  9693. this.$changedLines = {
  9694. firstRow: firstRow,
  9695. lastRow: lastRow
  9696. };
  9697. }
  9698. else {
  9699. if (this.$changedLines.firstRow > firstRow)
  9700. this.$changedLines.firstRow = firstRow;
  9701. if (this.$changedLines.lastRow < lastRow)
  9702. this.$changedLines.lastRow = lastRow;
  9703. }
  9704. this.$loop.schedule(this.CHANGE_LINES);
  9705. };
  9706. this.updateText = function() {
  9707. this.$loop.schedule(this.CHANGE_TEXT);
  9708. };
  9709. this.updateFull = function() {
  9710. this.$loop.schedule(this.CHANGE_FULL);
  9711. };
  9712. this.updateFontSize = function() {
  9713. this.$textLayer.checkForSizeChanges();
  9714. };
  9715. this.onResize = function(force) {
  9716. var changes = this.CHANGE_SIZE;
  9717. var size = this.$size;
  9718. var height = dom.getInnerHeight(this.container);
  9719. if (force || size.height != height) {
  9720. size.height = height;
  9721. this.scroller.style.height = height + "px";
  9722. size.scrollerHeight = this.scroller.clientHeight;
  9723. this.scrollBar.setHeight(size.scrollerHeight);
  9724. if (this.session) {
  9725. this.session.setScrollTop(this.getScrollTop());
  9726. changes = changes | this.CHANGE_FULL;
  9727. }
  9728. }
  9729. var width = dom.getInnerWidth(this.container);
  9730. if (force || size.width != width) {
  9731. size.width = width;
  9732. var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
  9733. this.scroller.style.left = gutterWidth + "px";
  9734. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
  9735. this.scroller.style.width = size.scrollerWidth + "px";
  9736. if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  9737. changes = changes | this.CHANGE_FULL;
  9738. }
  9739. this.$loop.schedule(changes);
  9740. };
  9741. this.adjustWrapLimit = function() {
  9742. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  9743. var limit = Math.floor(availableWidth / this.characterWidth);
  9744. return this.session.adjustWrapLimit(limit);
  9745. };
  9746. this.setAnimatedScroll = function(shouldAnimate){
  9747. this.$animatedScroll = shouldAnimate;
  9748. };
  9749. this.getAnimatedScroll = function() {
  9750. return this.$animatedScroll;
  9751. };
  9752. this.setShowInvisibles = function(showInvisibles) {
  9753. if (this.$textLayer.setShowInvisibles(showInvisibles))
  9754. this.$loop.schedule(this.CHANGE_TEXT);
  9755. };
  9756. this.getShowInvisibles = function() {
  9757. return this.$textLayer.showInvisibles;
  9758. };
  9759. this.$showPrintMargin = true;
  9760. this.setShowPrintMargin = function(showPrintMargin) {
  9761. this.$showPrintMargin = showPrintMargin;
  9762. this.$updatePrintMargin();
  9763. };
  9764. this.getShowPrintMargin = function() {
  9765. return this.$showPrintMargin;
  9766. };
  9767. this.$printMarginColumn = 80;
  9768. this.setPrintMarginColumn = function(showPrintMargin) {
  9769. this.$printMarginColumn = showPrintMargin;
  9770. this.$updatePrintMargin();
  9771. };
  9772. this.getPrintMarginColumn = function() {
  9773. return this.$printMarginColumn;
  9774. };
  9775. this.getShowGutter = function(){
  9776. return this.showGutter;
  9777. };
  9778. this.setShowGutter = function(show){
  9779. if(this.showGutter === show)
  9780. return;
  9781. this.$gutter.style.display = show ? "block" : "none";
  9782. this.showGutter = show;
  9783. this.onResize(true);
  9784. };
  9785. this.getFadeFoldWidgets = function(){
  9786. return dom.hasCssClass(this.$gutter, "ace_fade-fold-widgets");
  9787. };
  9788. this.setFadeFoldWidgets = function(show) {
  9789. if (show)
  9790. dom.addCssClass(this.$gutter, "ace_fade-fold-widgets");
  9791. else
  9792. dom.removeCssClass(this.$gutter, "ace_fade-fold-widgets");
  9793. };
  9794. this.$highlightGutterLine = true;
  9795. this.setHighlightGutterLine = function(shouldHighlight) {
  9796. if (this.$highlightGutterLine == shouldHighlight)
  9797. return;
  9798. this.$highlightGutterLine = shouldHighlight;
  9799. this.$loop.schedule(this.CHANGE_GUTTER);
  9800. };
  9801. this.getHighlightGutterLine = function() {
  9802. return this.$highlightGutterLine;
  9803. };
  9804. this.$updateGutterLineHighlight = function(gutterReady) {
  9805. var i = this.session.selection.lead.row;
  9806. if (i == this.$gutterLineHighlight)
  9807. return;
  9808. if (!gutterReady) {
  9809. var lineEl, ch = this.$gutterLayer.element.children;
  9810. var index = this.$gutterLineHighlight - this.layerConfig.firstRow;
  9811. if (index >= 0 && (lineEl = ch[index]))
  9812. dom.removeCssClass(lineEl, "ace_gutter_active_line");
  9813. index = i - this.layerConfig.firstRow;
  9814. if (index >= 0 && (lineEl = ch[index]))
  9815. dom.addCssClass(lineEl, "ace_gutter_active_line");
  9816. }
  9817. this.$gutterLayer.removeGutterDecoration(this.$gutterLineHighlight, "ace_gutter_active_line");
  9818. this.$gutterLayer.addGutterDecoration(i, "ace_gutter_active_line");
  9819. this.$gutterLineHighlight = i;
  9820. };
  9821. this.$updatePrintMargin = function() {
  9822. var containerEl;
  9823. if (!this.$showPrintMargin && !this.$printMarginEl)
  9824. return;
  9825. if (!this.$printMarginEl) {
  9826. containerEl = dom.createElement("div");
  9827. containerEl.className = "ace_print_margin_layer";
  9828. this.$printMarginEl = dom.createElement("div");
  9829. this.$printMarginEl.className = "ace_print_margin";
  9830. containerEl.appendChild(this.$printMarginEl);
  9831. this.content.insertBefore(containerEl, this.$textLayer.element);
  9832. }
  9833. var style = this.$printMarginEl.style;
  9834. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  9835. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  9836. };
  9837. this.getContainerElement = function() {
  9838. return this.container;
  9839. };
  9840. this.getMouseEventTarget = function() {
  9841. return this.content;
  9842. };
  9843. this.getTextAreaContainer = function() {
  9844. return this.container;
  9845. };
  9846. // move text input over the cursor
  9847. // this is required for iOS and IME
  9848. this.$moveTextAreaToCursor = function() {
  9849. if (!this.$keepTextAreaAtCursor)
  9850. return;
  9851. var posTop = this.$cursorLayer.$pixelPos.top;
  9852. var posLeft = this.$cursorLayer.$pixelPos.left;
  9853. posTop -= this.layerConfig.offset;
  9854. if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight)
  9855. return;
  9856. var w = this.characterWidth;
  9857. if (this.$composition)
  9858. w += this.textarea.scrollWidth;
  9859. posLeft -= this.scrollLeft;
  9860. if (posLeft > this.$size.scrollerWidth - w)
  9861. posLeft = this.$size.scrollerWidth - w;
  9862. if (this.showGutter)
  9863. posLeft += this.$gutterLayer.gutterWidth;
  9864. this.textarea.style.height = this.lineHeight + "px";
  9865. this.textarea.style.width = w + "px";
  9866. this.textarea.style.left = posLeft + "px";
  9867. this.textarea.style.top = posTop - 1 + "px";
  9868. };
  9869. this.getFirstVisibleRow = function() {
  9870. return this.layerConfig.firstRow;
  9871. };
  9872. this.getFirstFullyVisibleRow = function() {
  9873. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  9874. };
  9875. this.getLastFullyVisibleRow = function() {
  9876. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  9877. return this.layerConfig.firstRow - 1 + flint;
  9878. };
  9879. this.getLastVisibleRow = function() {
  9880. return this.layerConfig.lastRow;
  9881. };
  9882. this.$padding = null;
  9883. this.setPadding = function(padding) {
  9884. this.$padding = padding;
  9885. this.$textLayer.setPadding(padding);
  9886. this.$cursorLayer.setPadding(padding);
  9887. this.$markerFront.setPadding(padding);
  9888. this.$markerBack.setPadding(padding);
  9889. this.$loop.schedule(this.CHANGE_FULL);
  9890. this.$updatePrintMargin();
  9891. };
  9892. this.getHScrollBarAlwaysVisible = function() {
  9893. return this.$horizScrollAlwaysVisible;
  9894. };
  9895. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  9896. if (this.$horizScrollAlwaysVisible != alwaysVisible) {
  9897. this.$horizScrollAlwaysVisible = alwaysVisible;
  9898. if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
  9899. this.$loop.schedule(this.CHANGE_SCROLL);
  9900. }
  9901. };
  9902. this.$updateScrollBar = function() {
  9903. this.scrollBar.setInnerHeight(this.layerConfig.maxHeight);
  9904. this.scrollBar.setScrollTop(this.scrollTop);
  9905. };
  9906. this.$renderChanges = function(changes) {
  9907. if (!changes || !this.session || !this.container.offsetWidth)
  9908. return;
  9909. // text, scrolling and resize changes can cause the view port size to change
  9910. if (changes & this.CHANGE_FULL ||
  9911. changes & this.CHANGE_SIZE ||
  9912. changes & this.CHANGE_TEXT ||
  9913. changes & this.CHANGE_LINES ||
  9914. changes & this.CHANGE_SCROLL
  9915. )
  9916. this.$computeLayerConfig();
  9917. // horizontal scrolling
  9918. if (changes & this.CHANGE_H_SCROLL) {
  9919. this.scroller.scrollLeft = this.scrollLeft;
  9920. // read the value after writing it since the value might get clipped
  9921. var scrollLeft = this.scroller.scrollLeft;
  9922. this.scrollLeft = scrollLeft;
  9923. this.session.setScrollLeft(scrollLeft);
  9924. this.scroller.className = this.scrollLeft == 0 ? "ace_scroller" : "ace_scroller horscroll";
  9925. }
  9926. // full
  9927. if (changes & this.CHANGE_FULL) {
  9928. this.$textLayer.checkForSizeChanges();
  9929. // update scrollbar first to not lose scroll position when gutter calls resize
  9930. this.$updateScrollBar();
  9931. this.$textLayer.update(this.layerConfig);
  9932. if (this.showGutter) {
  9933. if (this.$highlightGutterLine)
  9934. this.$updateGutterLineHighlight(true);
  9935. this.$gutterLayer.update(this.layerConfig);
  9936. }
  9937. this.$markerBack.update(this.layerConfig);
  9938. this.$markerFront.update(this.layerConfig);
  9939. this.$cursorLayer.update(this.layerConfig);
  9940. this.$moveTextAreaToCursor();
  9941. return;
  9942. }
  9943. // scrolling
  9944. if (changes & this.CHANGE_SCROLL) {
  9945. this.$updateScrollBar();
  9946. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  9947. this.$textLayer.update(this.layerConfig);
  9948. else
  9949. this.$textLayer.scrollLines(this.layerConfig);
  9950. if (this.showGutter) {
  9951. if (this.$highlightGutterLine)
  9952. this.$updateGutterLineHighlight(true);
  9953. this.$gutterLayer.update(this.layerConfig);
  9954. }
  9955. this.$markerBack.update(this.layerConfig);
  9956. this.$markerFront.update(this.layerConfig);
  9957. this.$cursorLayer.update(this.layerConfig);
  9958. this.$moveTextAreaToCursor();
  9959. return;
  9960. }
  9961. if (changes & this.CHANGE_TEXT) {
  9962. this.$textLayer.update(this.layerConfig);
  9963. if (this.showGutter)
  9964. this.$gutterLayer.update(this.layerConfig);
  9965. }
  9966. else if (changes & this.CHANGE_LINES) {
  9967. if (this.$updateLines()) {
  9968. this.$updateScrollBar();
  9969. if (this.showGutter)
  9970. this.$gutterLayer.update(this.layerConfig);
  9971. }
  9972. } else if (changes & this.CHANGE_GUTTER) {
  9973. if (this.showGutter)
  9974. this.$gutterLayer.update(this.layerConfig);
  9975. }
  9976. if (changes & this.CHANGE_CURSOR) {
  9977. this.$cursorLayer.update(this.layerConfig);
  9978. this.$moveTextAreaToCursor();
  9979. this.$highlightGutterLine && this.$updateGutterLineHighlight(false);
  9980. }
  9981. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  9982. this.$markerFront.update(this.layerConfig);
  9983. }
  9984. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  9985. this.$markerBack.update(this.layerConfig);
  9986. }
  9987. if (changes & this.CHANGE_SIZE)
  9988. this.$updateScrollBar();
  9989. };
  9990. this.$computeLayerConfig = function() {
  9991. var session = this.session;
  9992. var offset = this.scrollTop % this.lineHeight;
  9993. var minHeight = this.$size.scrollerHeight + this.lineHeight;
  9994. var longestLine = this.$getLongestLine();
  9995. var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0;
  9996. var horizScrollChanged = this.$horizScroll !== horizScroll;
  9997. this.$horizScroll = horizScroll;
  9998. if (horizScrollChanged) {
  9999. this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden";
  10000. // when we hide scrollbar scroll event isn't emited
  10001. // leaving session with wrong scrollLeft value
  10002. if (!horizScroll)
  10003. this.session.setScrollLeft(0);
  10004. }
  10005. var maxHeight = this.session.getScreenLength() * this.lineHeight;
  10006. this.session.setScrollTop(Math.max(0, Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight)));
  10007. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  10008. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  10009. var lastRow = firstRow + lineCount;
  10010. // Map lines on the screen to lines in the document.
  10011. var firstRowScreen, firstRowHeight;
  10012. var lineHeight = { lineHeight: this.lineHeight };
  10013. firstRow = session.screenToDocumentRow(firstRow, 0);
  10014. // Check if firstRow is inside of a foldLine. If true, then use the first
  10015. // row of the foldLine.
  10016. var foldLine = session.getFoldLine(firstRow);
  10017. if (foldLine) {
  10018. firstRow = foldLine.start.row;
  10019. }
  10020. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  10021. firstRowHeight = session.getRowHeight(lineHeight, firstRow);
  10022. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  10023. minHeight = this.$size.scrollerHeight + session.getRowHeight(lineHeight, lastRow)+
  10024. firstRowHeight;
  10025. offset = this.scrollTop - firstRowScreen * this.lineHeight;
  10026. this.layerConfig = {
  10027. width : longestLine,
  10028. padding : this.$padding,
  10029. firstRow : firstRow,
  10030. firstRowScreen: firstRowScreen,
  10031. lastRow : lastRow,
  10032. lineHeight : this.lineHeight,
  10033. characterWidth : this.characterWidth,
  10034. minHeight : minHeight,
  10035. maxHeight : maxHeight,
  10036. offset : offset,
  10037. height : this.$size.scrollerHeight
  10038. };
  10039. // For debugging.
  10040. // console.log(JSON.stringify(this.layerConfig));
  10041. this.$gutterLayer.element.style.marginTop = (-offset) + "px";
  10042. this.content.style.marginTop = (-offset) + "px";
  10043. this.content.style.width = longestLine + 2 * this.$padding + "px";
  10044. this.content.style.height = minHeight + "px";
  10045. // Horizontal scrollbar visibility may have changed, which changes
  10046. // the client height of the scroller
  10047. if (horizScrollChanged)
  10048. this.onResize(true);
  10049. };
  10050. this.$updateLines = function() {
  10051. var firstRow = this.$changedLines.firstRow;
  10052. var lastRow = this.$changedLines.lastRow;
  10053. this.$changedLines = null;
  10054. var layerConfig = this.layerConfig;
  10055. if (firstRow > layerConfig.lastRow + 1) { return; }
  10056. if (lastRow < layerConfig.firstRow) { return; }
  10057. // if the last row is unknown -> redraw everything
  10058. if (lastRow === Infinity) {
  10059. if (this.showGutter)
  10060. this.$gutterLayer.update(layerConfig);
  10061. this.$textLayer.update(layerConfig);
  10062. return;
  10063. }
  10064. // else update only the changed rows
  10065. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  10066. return true;
  10067. };
  10068. this.$getLongestLine = function() {
  10069. var charCount = this.session.getScreenWidth();
  10070. if (this.$textLayer.showInvisibles)
  10071. charCount += 1;
  10072. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  10073. };
  10074. this.updateFrontMarkers = function() {
  10075. this.$markerFront.setMarkers(this.session.getMarkers(true));
  10076. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  10077. };
  10078. this.updateBackMarkers = function() {
  10079. this.$markerBack.setMarkers(this.session.getMarkers());
  10080. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  10081. };
  10082. this.addGutterDecoration = function(row, className){
  10083. this.$gutterLayer.addGutterDecoration(row, className);
  10084. this.$loop.schedule(this.CHANGE_GUTTER);
  10085. };
  10086. this.removeGutterDecoration = function(row, className){
  10087. this.$gutterLayer.removeGutterDecoration(row, className);
  10088. this.$loop.schedule(this.CHANGE_GUTTER);
  10089. };
  10090. this.updateBreakpoints = function(rows) {
  10091. this.$loop.schedule(this.CHANGE_GUTTER);
  10092. };
  10093. this.setAnnotations = function(annotations) {
  10094. this.$gutterLayer.setAnnotations(annotations);
  10095. this.$loop.schedule(this.CHANGE_GUTTER);
  10096. };
  10097. this.updateCursor = function() {
  10098. this.$loop.schedule(this.CHANGE_CURSOR);
  10099. };
  10100. this.hideCursor = function() {
  10101. this.$cursorLayer.hideCursor();
  10102. };
  10103. this.showCursor = function() {
  10104. this.$cursorLayer.showCursor();
  10105. };
  10106. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  10107. // first scroll anchor into view then scroll lead into view
  10108. this.scrollCursorIntoView(anchor, offset);
  10109. this.scrollCursorIntoView(lead, offset);
  10110. };
  10111. this.scrollCursorIntoView = function(cursor, offset) {
  10112. // the editor is not visible
  10113. if (this.$size.scrollerHeight === 0)
  10114. return;
  10115. var pos = this.$cursorLayer.getPixelPosition(cursor);
  10116. var left = pos.left;
  10117. var top = pos.top;
  10118. if (this.scrollTop > top) {
  10119. if (offset)
  10120. top -= offset * this.$size.scrollerHeight;
  10121. this.session.setScrollTop(top);
  10122. } else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
  10123. if (offset)
  10124. top += offset * this.$size.scrollerHeight;
  10125. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  10126. }
  10127. var scrollLeft = this.scrollLeft;
  10128. if (scrollLeft > left) {
  10129. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  10130. left = 0;
  10131. this.session.setScrollLeft(left);
  10132. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  10133. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  10134. }
  10135. };
  10136. this.getScrollTop = function() {
  10137. return this.session.getScrollTop();
  10138. };
  10139. this.getScrollLeft = function() {
  10140. return this.session.getScrollLeft();
  10141. };
  10142. this.getScrollTopRow = function() {
  10143. return this.scrollTop / this.lineHeight;
  10144. };
  10145. this.getScrollBottomRow = function() {
  10146. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  10147. };
  10148. this.scrollToRow = function(row) {
  10149. this.session.setScrollTop(row * this.lineHeight);
  10150. };
  10151. this.alignCursor = function(cursor, alignment) {
  10152. if (typeof cursor == "number")
  10153. cursor = {row: cursor, column: 0};
  10154. var pos = this.$cursorLayer.getPixelPosition(cursor);
  10155. var offset = pos.top - this.$size.scrollerHeight * (alignment || 0);
  10156. this.session.setScrollTop(offset);
  10157. };
  10158. this.STEPS = 8;
  10159. this.$calcSteps = function(fromValue, toValue){
  10160. var i = 0;
  10161. var l = this.STEPS;
  10162. var steps = [];
  10163. var func = function(t, x_min, dx) {
  10164. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  10165. };
  10166. for (i = 0; i < l; ++i)
  10167. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  10168. return steps;
  10169. };
  10170. this.scrollToLine = function(line, center, animate, callback) {
  10171. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  10172. var offset = pos.top;
  10173. if (center)
  10174. offset -= this.$size.scrollerHeight / 2;
  10175. var initialScroll = this.scrollTop;
  10176. this.session.setScrollTop(offset);
  10177. if (animate !== false)
  10178. this.animateScrolling(initialScroll, callback);
  10179. };
  10180. this.animateScrolling = function(fromValue, callback) {
  10181. var toValue = this.scrollTop;
  10182. if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) {
  10183. var _self = this;
  10184. var steps = _self.$calcSteps(fromValue, toValue);
  10185. this.$inScrollAnimation = true;
  10186. clearInterval(this.$timer);
  10187. _self.session.setScrollTop(steps.shift());
  10188. this.$timer = setInterval(function() {
  10189. if (steps.length) {
  10190. _self.session.setScrollTop(steps.shift());
  10191. // trick session to think it's already scrolled to not loose toValue
  10192. _self.session.$scrollTop = toValue;
  10193. } else if (toValue != null) {
  10194. _self.session.$scrollTop = -1;
  10195. _self.session.setScrollTop(toValue);
  10196. toValue = null;
  10197. } else {
  10198. // do this on separate step to not get spurious scroll event from scrollbar
  10199. _self.$timer = clearInterval(_self.$timer);
  10200. _self.$inScrollAnimation = false;
  10201. callback && callback();
  10202. }
  10203. }, 10);
  10204. }
  10205. };
  10206. this.scrollToY = function(scrollTop) {
  10207. // after calling scrollBar.setScrollTop
  10208. // scrollbar sends us event with same scrollTop. ignore it
  10209. if (this.scrollTop !== scrollTop) {
  10210. this.$loop.schedule(this.CHANGE_SCROLL);
  10211. this.scrollTop = scrollTop;
  10212. }
  10213. };
  10214. this.scrollToX = function(scrollLeft) {
  10215. if (scrollLeft < 0)
  10216. scrollLeft = 0;
  10217. if (this.scrollLeft !== scrollLeft)
  10218. this.scrollLeft = scrollLeft;
  10219. this.$loop.schedule(this.CHANGE_H_SCROLL);
  10220. };
  10221. this.scrollBy = function(deltaX, deltaY) {
  10222. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  10223. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  10224. };
  10225. this.isScrollableBy = function(deltaX, deltaY) {
  10226. if (deltaY < 0 && this.session.getScrollTop() > 0)
  10227. return true;
  10228. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight < this.layerConfig.maxHeight)
  10229. return true;
  10230. // todo: handle horizontal scrolling
  10231. };
  10232. this.pixelToScreenCoordinates = function(x, y) {
  10233. var canvasPos = this.scroller.getBoundingClientRect();
  10234. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  10235. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  10236. var col = Math.round(offset);
  10237. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  10238. };
  10239. this.screenToTextCoordinates = function(x, y) {
  10240. var canvasPos = this.scroller.getBoundingClientRect();
  10241. var col = Math.round(
  10242. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  10243. );
  10244. var row = Math.floor(
  10245. (y + this.scrollTop - canvasPos.top) / this.lineHeight
  10246. );
  10247. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  10248. };
  10249. this.textToScreenCoordinates = function(row, column) {
  10250. var canvasPos = this.scroller.getBoundingClientRect();
  10251. var pos = this.session.documentToScreenPosition(row, column);
  10252. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  10253. var y = pos.row * this.lineHeight;
  10254. return {
  10255. pageX: canvasPos.left + x - this.scrollLeft,
  10256. pageY: canvasPos.top + y - this.scrollTop
  10257. };
  10258. };
  10259. this.visualizeFocus = function() {
  10260. dom.addCssClass(this.container, "ace_focus");
  10261. };
  10262. this.visualizeBlur = function() {
  10263. dom.removeCssClass(this.container, "ace_focus");
  10264. };
  10265. this.showComposition = function(position) {
  10266. if (!this.$composition)
  10267. this.$composition = {
  10268. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  10269. cssText: this.textarea.style.cssText
  10270. };
  10271. this.$keepTextAreaAtCursor = true;
  10272. dom.addCssClass(this.textarea, "ace_composition");
  10273. this.textarea.style.cssText = "";
  10274. this.$moveTextAreaToCursor();
  10275. };
  10276. this.setCompositionText = function(text) {
  10277. this.$moveTextAreaToCursor();
  10278. };
  10279. this.hideComposition = function() {
  10280. if (!this.$composition)
  10281. return;
  10282. dom.removeCssClass(this.textarea, "ace_composition");
  10283. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  10284. this.textarea.style.cssText = this.$composition.cssText;
  10285. this.$composition = null;
  10286. };
  10287. this._loadTheme = function(name, callback) {
  10288. if (!config.get("packaged"))
  10289. return callback();
  10290. var base = name.split("/").pop();
  10291. var filename = config.get("themePath") + "/theme-" + base + config.get("suffix");
  10292. net.loadScript(filename, callback);
  10293. };
  10294. this.setTheme = function(theme) {
  10295. var _self = this;
  10296. this.$themeValue = theme;
  10297. if (!theme || typeof theme == "string") {
  10298. var moduleName = theme || "ace/theme/textmate";
  10299. var module;
  10300. try {
  10301. module = require(moduleName);
  10302. } catch (e) {};
  10303. if (module)
  10304. return afterLoad(module);
  10305. _self._loadTheme(moduleName, function() {
  10306. require([moduleName], function(module) {
  10307. if (_self.$themeValue !== theme)
  10308. return;
  10309. afterLoad(module);
  10310. });
  10311. });
  10312. } else {
  10313. afterLoad(theme);
  10314. }
  10315. function afterLoad(theme) {
  10316. dom.importCssString(
  10317. theme.cssText,
  10318. theme.cssClass,
  10319. _self.container.ownerDocument
  10320. );
  10321. if (_self.$theme)
  10322. dom.removeCssClass(_self.container, _self.$theme);
  10323. _self.$theme = theme ? theme.cssClass : null;
  10324. if (_self.$theme)
  10325. dom.addCssClass(_self.container, _self.$theme);
  10326. if (theme && theme.isDark)
  10327. dom.addCssClass(_self.container, "ace_dark");
  10328. else
  10329. dom.removeCssClass(_self.container, "ace_dark");
  10330. // force re-measure of the gutter width
  10331. if (_self.$size) {
  10332. _self.$size.width = 0;
  10333. _self.onResize();
  10334. }
  10335. }
  10336. };
  10337. this.getTheme = function() {
  10338. return this.$themeValue;
  10339. };
  10340. // Methods allows to add / remove CSS classnames to the editor element.
  10341. // This feature can be used by plug-ins to provide a visual indication of
  10342. // a certain mode that editor is in.
  10343. /**
  10344. * VirtualRenderer.setStyle(style) -> Void
  10345. * - style (String): A class name
  10346. *
  10347. * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
  10348. **/
  10349. this.setStyle = function setStyle(style) {
  10350. dom.addCssClass(this.container, style);
  10351. };
  10352. this.unsetStyle = function unsetStyle(style) {
  10353. dom.removeCssClass(this.container, style);
  10354. };
  10355. this.destroy = function() {
  10356. this.$textLayer.destroy();
  10357. this.$cursorLayer.destroy();
  10358. };
  10359. }).call(VirtualRenderer.prototype);
  10360. exports.VirtualRenderer = VirtualRenderer;
  10361. });
  10362. ace.define('ace/layer/gutter', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
  10363. var dom = require("../lib/dom");
  10364. var oop = require("../lib/oop");
  10365. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  10366. var Gutter = function(parentEl) {
  10367. this.element = dom.createElement("div");
  10368. this.element.className = "ace_layer ace_gutter-layer";
  10369. parentEl.appendChild(this.element);
  10370. this.setShowFoldWidgets(this.$showFoldWidgets);
  10371. this.gutterWidth = 0;
  10372. this.$breakpoints = [];
  10373. this.$annotations = [];
  10374. this.$decorations = [];
  10375. };
  10376. (function() {
  10377. oop.implement(this, EventEmitter);
  10378. this.setSession = function(session) {
  10379. this.session = session;
  10380. };
  10381. this.addGutterDecoration = function(row, className){
  10382. if (!this.$decorations[row])
  10383. this.$decorations[row] = "";
  10384. this.$decorations[row] += " " + className;
  10385. };
  10386. this.removeGutterDecoration = function(row, className){
  10387. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  10388. };
  10389. this.setAnnotations = function(annotations) {
  10390. // iterate over sparse array
  10391. this.$annotations = [];
  10392. for (var row in annotations) if (annotations.hasOwnProperty(row)) {
  10393. var rowAnnotations = annotations[row];
  10394. if (!rowAnnotations)
  10395. continue;
  10396. var rowInfo = this.$annotations[row] = {
  10397. text: []
  10398. };
  10399. for (var i=0; i<rowAnnotations.length; i++) {
  10400. var annotation = rowAnnotations[i];
  10401. var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;");
  10402. if (rowInfo.text.indexOf(annoText) === -1)
  10403. rowInfo.text.push(annoText);
  10404. var type = annotation.type;
  10405. if (type == "error")
  10406. rowInfo.className = "ace_error";
  10407. else if (type == "warning" && rowInfo.className != "ace_error")
  10408. rowInfo.className = "ace_warning";
  10409. else if (type == "info" && (!rowInfo.className))
  10410. rowInfo.className = "ace_info";
  10411. }
  10412. }
  10413. };
  10414. this.update = function(config) {
  10415. this.$config = config;
  10416. var emptyAnno = {className: "", text: []};
  10417. var html = [];
  10418. var i = config.firstRow;
  10419. var lastRow = config.lastRow;
  10420. var fold = this.session.getNextFoldLine(i);
  10421. var foldStart = fold ? fold.start.row : Infinity;
  10422. var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
  10423. var breakpoints = this.session.$breakpoints;
  10424. while (true) {
  10425. if(i > foldStart) {
  10426. i = fold.end.row + 1;
  10427. fold = this.session.getNextFoldLine(i, fold);
  10428. foldStart = fold ?fold.start.row :Infinity;
  10429. }
  10430. if(i > lastRow)
  10431. break;
  10432. var annotation = this.$annotations[i] || emptyAnno;
  10433. html.push("<div class='ace_gutter-cell",
  10434. this.$decorations[i] || "",
  10435. breakpoints[i] ? " ace_breakpoint " : " ",
  10436. annotation.className,
  10437. "' title='", annotation.text.join("\n"),
  10438. "' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i+1));
  10439. if (foldWidgets) {
  10440. var c = foldWidgets[i];
  10441. // check if cached value is invalidated and we need to recompute
  10442. if (c == null)
  10443. c = foldWidgets[i] = this.session.getFoldWidget(i);
  10444. if (c)
  10445. html.push(
  10446. "<span class='ace_fold-widget ", c,
  10447. c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
  10448. "'></span>"
  10449. );
  10450. }
  10451. html.push("</div>");
  10452. i++;
  10453. }
  10454. if (this.session.$useWrapMode)
  10455. html.push(
  10456. "<div class='ace_gutter-cell' style='pointer-events:none;opacity:0'>",
  10457. this.session.getLength() - 1,
  10458. "</div>"
  10459. );
  10460. this.element = dom.setInnerHtml(this.element, html.join(""));
  10461. this.element.style.height = config.minHeight + "px";
  10462. var gutterWidth = this.element.offsetWidth;
  10463. if (gutterWidth !== this.gutterWidth) {
  10464. this.gutterWidth = gutterWidth;
  10465. this._emit("changeGutterWidth", gutterWidth);
  10466. }
  10467. };
  10468. this.$showFoldWidgets = true;
  10469. this.setShowFoldWidgets = function(show) {
  10470. if (show)
  10471. dom.addCssClass(this.element, "ace_folding-enabled");
  10472. else
  10473. dom.removeCssClass(this.element, "ace_folding-enabled");
  10474. this.$showFoldWidgets = show;
  10475. };
  10476. this.getShowFoldWidgets = function() {
  10477. return this.$showFoldWidgets;
  10478. };
  10479. }).call(Gutter.prototype);
  10480. exports.Gutter = Gutter;
  10481. });
  10482. ace.define('ace/layer/marker', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/dom'], function(require, exports, module) {
  10483. var Range = require("../range").Range;
  10484. var dom = require("../lib/dom");
  10485. var Marker = function(parentEl) {
  10486. this.element = dom.createElement("div");
  10487. this.element.className = "ace_layer ace_marker-layer";
  10488. parentEl.appendChild(this.element);
  10489. };
  10490. (function() {
  10491. this.$padding = 0;
  10492. this.setPadding = function(padding) {
  10493. this.$padding = padding;
  10494. };
  10495. this.setSession = function(session) {
  10496. this.session = session;
  10497. };
  10498. this.setMarkers = function(markers) {
  10499. this.markers = markers;
  10500. };
  10501. this.update = function(config) {
  10502. var config = config || this.config;
  10503. if (!config)
  10504. return;
  10505. this.config = config;
  10506. var html = [];
  10507. for ( var key in this.markers) {
  10508. var marker = this.markers[key];
  10509. if (!marker.range) {
  10510. marker.update(html, this, this.session, config);
  10511. continue;
  10512. }
  10513. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  10514. if (range.isEmpty()) continue;
  10515. range = range.toScreenRange(this.session);
  10516. if (marker.renderer) {
  10517. var top = this.$getTop(range.start.row, config);
  10518. var left = Math.round(
  10519. this.$padding + range.start.column * config.characterWidth
  10520. );
  10521. marker.renderer(html, range, left, top, config);
  10522. }
  10523. else if (range.isMultiLine()) {
  10524. if (marker.type == "text") {
  10525. this.drawTextMarker(html, range, marker.clazz, config);
  10526. } else {
  10527. this.drawMultiLineMarker(
  10528. html, range, marker.clazz, config,
  10529. marker.type
  10530. );
  10531. }
  10532. }
  10533. else {
  10534. this.drawSingleLineMarker(
  10535. html, range, marker.clazz + " start", config,
  10536. null, marker.type
  10537. );
  10538. }
  10539. }
  10540. this.element = dom.setInnerHtml(this.element, html.join(""));
  10541. };
  10542. this.$getTop = function(row, layerConfig) {
  10543. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  10544. };
  10545. // Draws a marker, which spans a range of text on multiple lines
  10546. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
  10547. // selection start
  10548. var row = range.start.row;
  10549. var lineRange = new Range(
  10550. row, range.start.column,
  10551. row, this.session.getScreenLastRowColumn(row)
  10552. );
  10553. this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " start", layerConfig, 1, "text");
  10554. // selection end
  10555. row = range.end.row;
  10556. lineRange = new Range(row, 0, row, range.end.column);
  10557. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, "text");
  10558. for (row = range.start.row + 1; row < range.end.row; row++) {
  10559. lineRange.start.row = row;
  10560. lineRange.end.row = row;
  10561. lineRange.end.column = this.session.getScreenLastRowColumn(row);
  10562. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, "text");
  10563. }
  10564. };
  10565. // Draws a multi line marker, where lines span the full width
  10566. this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
  10567. var padding = type === "background" ? 0 : this.$padding;
  10568. var layerWidth = layerConfig.width + 2 * this.$padding - padding;
  10569. // from selection start to the end of the line
  10570. var height = layerConfig.lineHeight;
  10571. var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth));
  10572. var top = this.$getTop(range.start.row, layerConfig);
  10573. var left = Math.round(
  10574. padding + range.start.column * layerConfig.characterWidth
  10575. );
  10576. stringBuilder.push(
  10577. "<div class='", clazz, " start' style='",
  10578. "height:", height, "px;",
  10579. "width:", width, "px;",
  10580. "top:", top, "px;",
  10581. "left:", left, "px;'></div>"
  10582. );
  10583. // from start of the last line to the selection end
  10584. top = this.$getTop(range.end.row, layerConfig);
  10585. width = Math.round(range.end.column * layerConfig.characterWidth);
  10586. stringBuilder.push(
  10587. "<div class='", clazz, "' style='",
  10588. "height:", height, "px;",
  10589. "width:", width, "px;",
  10590. "top:", top, "px;",
  10591. "left:", padding, "px;'></div>"
  10592. );
  10593. // all the complete lines
  10594. height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight;
  10595. if (height < 0)
  10596. return;
  10597. top = this.$getTop(range.start.row + 1, layerConfig);
  10598. stringBuilder.push(
  10599. "<div class='", clazz, "' style='",
  10600. "height:", height, "px;",
  10601. "width:", layerWidth, "px;",
  10602. "top:", top, "px;",
  10603. "left:", padding, "px;'></div>"
  10604. );
  10605. };
  10606. // Draws a marker which covers part or whole width of a single screen line
  10607. this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) {
  10608. var padding = type === "background" ? 0 : this.$padding;
  10609. var height = layerConfig.lineHeight;
  10610. if (type === "background")
  10611. var width = layerConfig.width;
  10612. else
  10613. width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
  10614. var top = this.$getTop(range.start.row, layerConfig);
  10615. var left = Math.round(
  10616. padding + range.start.column * layerConfig.characterWidth
  10617. );
  10618. stringBuilder.push(
  10619. "<div class='", clazz, "' style='",
  10620. "height:", height, "px;",
  10621. "width:", width, "px;",
  10622. "top:", top, "px;",
  10623. "left:", left,"px;'></div>"
  10624. );
  10625. };
  10626. }).call(Marker.prototype);
  10627. exports.Marker = Marker;
  10628. });
  10629. 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) {
  10630. var oop = require("../lib/oop");
  10631. var dom = require("../lib/dom");
  10632. var lang = require("../lib/lang");
  10633. var useragent = require("../lib/useragent");
  10634. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  10635. var Text = function(parentEl) {
  10636. this.element = dom.createElement("div");
  10637. this.element.className = "ace_layer ace_text-layer";
  10638. parentEl.appendChild(this.element);
  10639. this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
  10640. this.$pollSizeChanges();
  10641. };
  10642. (function() {
  10643. oop.implement(this, EventEmitter);
  10644. this.EOF_CHAR = "\xB6"; //"&para;";
  10645. this.EOL_CHAR = "\xAC"; //"&not;";
  10646. this.TAB_CHAR = "\u2192"; //"&rarr;" "\u21E5";
  10647. this.SPACE_CHAR = "\xB7"; //"&middot;";
  10648. this.$padding = 0;
  10649. this.setPadding = function(padding) {
  10650. this.$padding = padding;
  10651. this.element.style.padding = "0 " + padding + "px";
  10652. };
  10653. this.getLineHeight = function() {
  10654. return this.$characterSize.height || 1;
  10655. };
  10656. this.getCharacterWidth = function() {
  10657. return this.$characterSize.width || 1;
  10658. };
  10659. this.checkForSizeChanges = function() {
  10660. var size = this.$measureSizes();
  10661. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  10662. this.$characterSize = size;
  10663. this._emit("changeCharacterSize", {data: size});
  10664. }
  10665. };
  10666. this.$pollSizeChanges = function() {
  10667. var self = this;
  10668. this.$pollSizeChangesTimer = setInterval(function() {
  10669. self.checkForSizeChanges();
  10670. }, 500);
  10671. };
  10672. this.$fontStyles = {
  10673. fontFamily : 1,
  10674. fontSize : 1,
  10675. fontWeight : 1,
  10676. fontStyle : 1,
  10677. lineHeight : 1
  10678. };
  10679. this.$measureSizes = useragent.isIE || useragent.isOldGecko ? function() {
  10680. var n = 1000;
  10681. if (!this.$measureNode) {
  10682. var measureNode = this.$measureNode = dom.createElement("div");
  10683. var style = measureNode.style;
  10684. style.width = style.height = "auto";
  10685. style.left = style.top = (-n * 40) + "px";
  10686. style.visibility = "hidden";
  10687. style.position = "fixed";
  10688. style.overflow = "visible";
  10689. style.whiteSpace = "nowrap";
  10690. // in FF 3.6 monospace fonts can have a fixed sub pixel width.
  10691. // that's why we have to measure many characters
  10692. // Note: characterWidth can be a float!
  10693. measureNode.innerHTML = lang.stringRepeat("Xy", n);
  10694. if (this.element.ownerDocument.body) {
  10695. this.element.ownerDocument.body.appendChild(measureNode);
  10696. } else {
  10697. var container = this.element.parentNode;
  10698. while (!dom.hasCssClass(container, "ace_editor"))
  10699. container = container.parentNode;
  10700. container.appendChild(measureNode);
  10701. }
  10702. }
  10703. // Size and width can be null if the editor is not visible or
  10704. // detached from the document
  10705. if (!this.element.offsetWidth)
  10706. return null;
  10707. var style = this.$measureNode.style;
  10708. var computedStyle = dom.computedStyle(this.element);
  10709. for (var prop in this.$fontStyles)
  10710. style[prop] = computedStyle[prop];
  10711. var size = {
  10712. height: this.$measureNode.offsetHeight,
  10713. width: this.$measureNode.offsetWidth / (n * 2)
  10714. };
  10715. // Size and width can be null if the editor is not visible or
  10716. // detached from the document
  10717. if (size.width == 0 || size.height == 0)
  10718. return null;
  10719. return size;
  10720. }
  10721. : function() {
  10722. if (!this.$measureNode) {
  10723. var measureNode = this.$measureNode = dom.createElement("div");
  10724. var style = measureNode.style;
  10725. style.width = style.height = "auto";
  10726. style.left = style.top = -100 + "px";
  10727. style.visibility = "hidden";
  10728. style.position = "fixed";
  10729. style.overflow = "visible";
  10730. style.whiteSpace = "nowrap";
  10731. measureNode.innerHTML = "X";
  10732. var container = this.element.parentNode;
  10733. while (container && !dom.hasCssClass(container, "ace_editor"))
  10734. container = container.parentNode;
  10735. if (!container)
  10736. return this.$measureNode = null;
  10737. container.appendChild(measureNode);
  10738. }
  10739. var rect = this.$measureNode.getBoundingClientRect();
  10740. var size = {
  10741. height: rect.height,
  10742. width: rect.width
  10743. };
  10744. // Size and width can be null if the editor is not visible or
  10745. // detached from the document
  10746. if (size.width == 0 || size.height == 0)
  10747. return null;
  10748. return size;
  10749. };
  10750. this.setSession = function(session) {
  10751. this.session = session;
  10752. };
  10753. this.showInvisibles = false;
  10754. this.setShowInvisibles = function(showInvisibles) {
  10755. if (this.showInvisibles == showInvisibles)
  10756. return false;
  10757. this.showInvisibles = showInvisibles;
  10758. return true;
  10759. };
  10760. this.$tabStrings = [];
  10761. this.$computeTabString = function() {
  10762. var tabSize = this.session.getTabSize();
  10763. var tabStr = this.$tabStrings = [0];
  10764. for (var i = 1; i < tabSize + 1; i++) {
  10765. if (this.showInvisibles) {
  10766. tabStr.push("<span class='ace_invisible'>"
  10767. + this.TAB_CHAR
  10768. + new Array(i).join("&#160;")
  10769. + "</span>");
  10770. } else {
  10771. tabStr.push(new Array(i+1).join("&#160;"));
  10772. }
  10773. }
  10774. };
  10775. this.updateLines = function(config, firstRow, lastRow) {
  10776. this.$computeTabString();
  10777. // Due to wrap line changes there can be new lines if e.g.
  10778. // the line to updated wrapped in the meantime.
  10779. if (this.config.lastRow != config.lastRow ||
  10780. this.config.firstRow != config.firstRow) {
  10781. this.scrollLines(config);
  10782. }
  10783. this.config = config;
  10784. var first = Math.max(firstRow, config.firstRow);
  10785. var last = Math.min(lastRow, config.lastRow);
  10786. var lineElements = this.element.childNodes;
  10787. var lineElementsIdx = 0;
  10788. for (var row = config.firstRow; row < first; row++) {
  10789. var foldLine = this.session.getFoldLine(row);
  10790. if (foldLine) {
  10791. if (foldLine.containsRow(first)) {
  10792. first = foldLine.start.row;
  10793. break;
  10794. } else {
  10795. row = foldLine.end.row;
  10796. }
  10797. }
  10798. lineElementsIdx ++;
  10799. }
  10800. for (var i=first; i<=last; i++) {
  10801. var lineElement = lineElements[lineElementsIdx++];
  10802. if (!lineElement)
  10803. continue;
  10804. var html = [];
  10805. var tokens = this.session.getTokens(i);
  10806. this.$renderLine(html, i, tokens, !this.$useLineGroups());
  10807. lineElement = dom.setInnerHtml(lineElement, html.join(""));
  10808. i = this.session.getRowFoldEnd(i);
  10809. }
  10810. };
  10811. this.scrollLines = function(config) {
  10812. this.$computeTabString();
  10813. var oldConfig = this.config;
  10814. this.config = config;
  10815. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  10816. return this.update(config);
  10817. if (config.lastRow < oldConfig.firstRow)
  10818. return this.update(config);
  10819. var el = this.element;
  10820. if (oldConfig.firstRow < config.firstRow)
  10821. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  10822. el.removeChild(el.firstChild);
  10823. if (oldConfig.lastRow > config.lastRow)
  10824. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  10825. el.removeChild(el.lastChild);
  10826. if (config.firstRow < oldConfig.firstRow) {
  10827. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  10828. if (el.firstChild)
  10829. el.insertBefore(fragment, el.firstChild);
  10830. else
  10831. el.appendChild(fragment);
  10832. }
  10833. if (config.lastRow > oldConfig.lastRow) {
  10834. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  10835. el.appendChild(fragment);
  10836. }
  10837. };
  10838. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  10839. var fragment = this.element.ownerDocument.createDocumentFragment();
  10840. var row = firstRow;
  10841. var foldLine = this.session.getNextFoldLine(row);
  10842. var foldStart = foldLine ? foldLine.start.row : Infinity;
  10843. while (true) {
  10844. if (row > foldStart) {
  10845. row = foldLine.end.row+1;
  10846. foldLine = this.session.getNextFoldLine(row, foldLine);
  10847. foldStart = foldLine ? foldLine.start.row : Infinity;
  10848. }
  10849. if (row > lastRow)
  10850. break;
  10851. var container = dom.createElement("div");
  10852. var html = [];
  10853. // Get the tokens per line as there might be some lines in between
  10854. // beeing folded.
  10855. var tokens = this.session.getTokens(row);
  10856. this.$renderLine(html, row, tokens, false);
  10857. // don't use setInnerHtml since we are working with an empty DIV
  10858. container.innerHTML = html.join("");
  10859. if (this.$useLineGroups()) {
  10860. container.className = 'ace_line_group';
  10861. fragment.appendChild(container);
  10862. } else {
  10863. var lines = container.childNodes
  10864. while(lines.length)
  10865. fragment.appendChild(lines[0]);
  10866. }
  10867. row++;
  10868. }
  10869. return fragment;
  10870. };
  10871. this.update = function(config) {
  10872. this.$computeTabString();
  10873. this.config = config;
  10874. var html = [];
  10875. var firstRow = config.firstRow, lastRow = config.lastRow;
  10876. var row = firstRow;
  10877. var foldLine = this.session.getNextFoldLine(row);
  10878. var foldStart = foldLine ? foldLine.start.row : Infinity;
  10879. while (true) {
  10880. if (row > foldStart) {
  10881. row = foldLine.end.row+1;
  10882. foldLine = this.session.getNextFoldLine(row, foldLine);
  10883. foldStart = foldLine ? foldLine.start.row :Infinity;
  10884. }
  10885. if (row > lastRow)
  10886. break;
  10887. if (this.$useLineGroups())
  10888. html.push("<div class='ace_line_group'>")
  10889. // Get the tokens per line as there might be some lines in between
  10890. // beeing folded.
  10891. var tokens = this.session.getTokens(row);
  10892. this.$renderLine(html, row, tokens, false);
  10893. if (this.$useLineGroups())
  10894. html.push("</div>"); // end the line group
  10895. row++;
  10896. }
  10897. this.element = dom.setInnerHtml(this.element, html.join(""));
  10898. };
  10899. this.$textToken = {
  10900. "text": true,
  10901. "rparen": true,
  10902. "lparen": true
  10903. };
  10904. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  10905. var self = this;
  10906. var replaceReg = /\t|&|<|( +)|([\u0000-\u0019\u00a0\u1680\u180E\u2000-\u200b\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
  10907. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  10908. if (a) {
  10909. return new Array(c.length+1).join("&#160;");
  10910. } else if (c == "&") {
  10911. return "&#38;";
  10912. } else if (c == "<") {
  10913. return "&#60;";
  10914. } else if (c == "\t") {
  10915. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  10916. screenColumn += tabSize - 1;
  10917. return self.$tabStrings[tabSize];
  10918. } else if (c == "\u3000") {
  10919. // U+3000 is both invisible AND full-width, so must be handled uniquely
  10920. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk";
  10921. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  10922. screenColumn += 1;
  10923. return "<span class='" + classToUse + "' style='width:" +
  10924. (self.config.characterWidth * 2) +
  10925. "px'>" + space + "</span>";
  10926. } else if (b) {
  10927. return "<span class='ace_invisible ace_invalid'>" + self.SPACE_CHAR + "</span>";
  10928. } else {
  10929. screenColumn += 1;
  10930. return "<span class='ace_cjk' style='width:" +
  10931. (self.config.characterWidth * 2) +
  10932. "px'>" + c + "</span>";
  10933. }
  10934. };
  10935. var output = value.replace(replaceReg, replaceFunc);
  10936. if (!this.$textToken[token.type]) {
  10937. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  10938. var style = "";
  10939. if (token.type == "fold")
  10940. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  10941. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  10942. }
  10943. else {
  10944. stringBuilder.push(output);
  10945. }
  10946. return screenColumn + value.length;
  10947. };
  10948. this.$renderLineCore = function(stringBuilder, lastRow, tokens, splits, onlyContents) {
  10949. var chars = 0;
  10950. var split = 0;
  10951. var splitChars;
  10952. var screenColumn = 0;
  10953. var self = this;
  10954. if (!splits || splits.length == 0)
  10955. splitChars = Number.MAX_VALUE;
  10956. else
  10957. splitChars = splits[0];
  10958. if (!onlyContents) {
  10959. stringBuilder.push("<div class='ace_line' style='height:",
  10960. this.config.lineHeight, "px",
  10961. "'>"
  10962. );
  10963. }
  10964. for (var i = 0; i < tokens.length; i++) {
  10965. var token = tokens[i];
  10966. var value = token.value;
  10967. if (chars + value.length < splitChars) {
  10968. screenColumn = self.$renderToken(
  10969. stringBuilder, screenColumn, token, value
  10970. );
  10971. chars += value.length;
  10972. }
  10973. else {
  10974. while (chars + value.length >= splitChars) {
  10975. screenColumn = self.$renderToken(
  10976. stringBuilder, screenColumn,
  10977. token, value.substring(0, splitChars - chars)
  10978. );
  10979. value = value.substring(splitChars - chars);
  10980. chars = splitChars;
  10981. if (!onlyContents) {
  10982. stringBuilder.push("</div>",
  10983. "<div class='ace_line' style='height:",
  10984. this.config.lineHeight, "px",
  10985. "'>"
  10986. );
  10987. }
  10988. split ++;
  10989. screenColumn = 0;
  10990. splitChars = splits[split] || Number.MAX_VALUE;
  10991. }
  10992. if (value.length != 0) {
  10993. chars += value.length;
  10994. screenColumn = self.$renderToken(
  10995. stringBuilder, screenColumn, token, value
  10996. );
  10997. }
  10998. }
  10999. }
  11000. if (this.showInvisibles) {
  11001. if (lastRow !== this.session.getLength() - 1)
  11002. stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
  11003. else
  11004. stringBuilder.push("<span class='ace_invisible'>" + this.EOF_CHAR + "</span>");
  11005. }
  11006. if (!onlyContents)
  11007. stringBuilder.push("</div>");
  11008. };
  11009. this.$renderLine = function(stringBuilder, row, tokens, onlyContents) {
  11010. // Check if the line to render is folded or not. If not, things are
  11011. // simple, otherwise, we need to fake some things...
  11012. if (!this.session.isRowFolded(row)) {
  11013. var splits = this.session.getRowSplitData(row);
  11014. this.$renderLineCore(stringBuilder, row, tokens, splits, onlyContents);
  11015. } else {
  11016. this.$renderFoldLine(stringBuilder, row, tokens, onlyContents);
  11017. }
  11018. };
  11019. this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
  11020. var session = this.session,
  11021. foldLine = session.getFoldLine(row),
  11022. renderTokens = [];
  11023. function addTokens(tokens, from, to) {
  11024. var idx = 0, col = 0;
  11025. while ((col + tokens[idx].value.length) < from) {
  11026. col += tokens[idx].value.length;
  11027. idx++;
  11028. if (idx == tokens.length) {
  11029. return;
  11030. }
  11031. }
  11032. if (col != from) {
  11033. var value = tokens[idx].value.substring(from - col);
  11034. // Check if the token value is longer then the from...to spacing.
  11035. if (value.length > (to - from)) {
  11036. value = value.substring(0, to - from);
  11037. }
  11038. renderTokens.push({
  11039. type: tokens[idx].type,
  11040. value: value
  11041. });
  11042. col = from + value.length;
  11043. idx += 1;
  11044. }
  11045. while (col < to) {
  11046. var value = tokens[idx].value;
  11047. if (value.length + col > to) {
  11048. value = value.substring(0, to - col);
  11049. }
  11050. renderTokens.push({
  11051. type: tokens[idx].type,
  11052. value: value
  11053. });
  11054. col += value.length;
  11055. idx += 1;
  11056. }
  11057. }
  11058. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  11059. if (placeholder) {
  11060. renderTokens.push({
  11061. type: "fold",
  11062. value: placeholder
  11063. });
  11064. } else {
  11065. if (isNewRow)
  11066. tokens = this.session.getTokens(row);
  11067. if (tokens.length)
  11068. addTokens(tokens, lastColumn, column);
  11069. }
  11070. }.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  11071. // TODO: Build a fake splits array!
  11072. var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
  11073. this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
  11074. };
  11075. this.$useLineGroups = function() {
  11076. // For the updateLines function to work correctly, it's important that the
  11077. // child nodes of this.element correspond on a 1-to-1 basis to rows in the
  11078. // document (as distinct from lines on the screen). For sessions that are
  11079. // wrapped, this means we need to add a layer to the node hierarchy (tagged
  11080. // with the class name ace_line_group).
  11081. return this.session.getUseWrapMode();
  11082. };
  11083. this.destroy = function() {
  11084. clearInterval(this.$pollSizeChangesTimer);
  11085. if (this.$measureNode)
  11086. this.$measureNode.parentNode.removeChild(this.$measureNode);
  11087. delete this.$measureNode;
  11088. };
  11089. }).call(Text.prototype);
  11090. exports.Text = Text;
  11091. });
  11092. ace.define('ace/layer/cursor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
  11093. var dom = require("../lib/dom");
  11094. var Cursor = function(parentEl) {
  11095. this.element = dom.createElement("div");
  11096. this.element.className = "ace_layer ace_cursor-layer";
  11097. parentEl.appendChild(this.element);
  11098. this.isVisible = false;
  11099. this.cursors = [];
  11100. this.cursor = this.addCursor();
  11101. };
  11102. (function() {
  11103. this.$padding = 0;
  11104. this.setPadding = function(padding) {
  11105. this.$padding = padding;
  11106. };
  11107. this.setSession = function(session) {
  11108. this.session = session;
  11109. };
  11110. this.addCursor = function() {
  11111. var el = dom.createElement("div");
  11112. var className = "ace_cursor";
  11113. if (!this.isVisible)
  11114. className += " ace_hidden";
  11115. if (this.overwrite)
  11116. className += " ace_overwrite";
  11117. el.className = className;
  11118. this.element.appendChild(el);
  11119. this.cursors.push(el);
  11120. return el;
  11121. };
  11122. this.removeCursor = function() {
  11123. if (this.cursors.length > 1) {
  11124. var el = this.cursors.pop();
  11125. el.parentNode.removeChild(el);
  11126. return el;
  11127. }
  11128. };
  11129. this.hideCursor = function() {
  11130. this.isVisible = false;
  11131. for (var i = this.cursors.length; i--; )
  11132. dom.addCssClass(this.cursors[i], "ace_hidden");
  11133. clearInterval(this.blinkId);
  11134. };
  11135. this.showCursor = function() {
  11136. this.isVisible = true;
  11137. for (var i = this.cursors.length; i--; )
  11138. dom.removeCssClass(this.cursors[i], "ace_hidden");
  11139. this.element.style.visibility = "";
  11140. this.restartTimer();
  11141. };
  11142. this.restartTimer = function() {
  11143. clearInterval(this.blinkId);
  11144. if (!this.isVisible)
  11145. return;
  11146. var element = this.cursors.length == 1 ? this.cursor : this.element;
  11147. this.blinkId = setInterval(function() {
  11148. element.style.visibility = "hidden";
  11149. setTimeout(function() {
  11150. element.style.visibility = "";
  11151. }, 400);
  11152. }, 1000);
  11153. };
  11154. this.getPixelPosition = function(position, onScreen) {
  11155. if (!this.config || !this.session) {
  11156. return {
  11157. left : 0,
  11158. top : 0
  11159. };
  11160. }
  11161. if (!position)
  11162. position = this.session.selection.getCursor();
  11163. var pos = this.session.documentToScreenPosition(position);
  11164. var cursorLeft = Math.round(this.$padding +
  11165. pos.column * this.config.characterWidth);
  11166. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  11167. this.config.lineHeight;
  11168. return {
  11169. left : cursorLeft,
  11170. top : cursorTop
  11171. };
  11172. };
  11173. this.update = function(config) {
  11174. this.config = config;
  11175. if (this.session.selectionMarkerCount > 0) {
  11176. var selections = this.session.$selectionMarkers;
  11177. var i = 0, sel, cursorIndex = 0;
  11178. for (var i = selections.length; i--; ) {
  11179. sel = selections[i];
  11180. var pixelPos = this.getPixelPosition(sel.cursor, true);
  11181. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  11182. style.left = pixelPos.left + "px";
  11183. style.top = pixelPos.top + "px";
  11184. style.width = config.characterWidth + "px";
  11185. style.height = config.lineHeight + "px";
  11186. }
  11187. if (cursorIndex > 1)
  11188. while (this.cursors.length > cursorIndex)
  11189. this.removeCursor();
  11190. } else {
  11191. var pixelPos = this.getPixelPosition(null, true);
  11192. var style = this.cursor.style;
  11193. style.left = pixelPos.left + "px";
  11194. style.top = pixelPos.top + "px";
  11195. style.width = config.characterWidth + "px";
  11196. style.height = config.lineHeight + "px";
  11197. while (this.cursors.length > 1)
  11198. this.removeCursor();
  11199. }
  11200. var overwrite = this.session.getOverwrite();
  11201. if (overwrite != this.overwrite)
  11202. this.$setOverite(overwrite);
  11203. // cache for textarea and gutter highlight
  11204. this.$pixelPos = pixelPos;
  11205. this.restartTimer();
  11206. };
  11207. this.$setOverite = function(overwrite) {
  11208. this.overwrite = overwrite;
  11209. for (var i = this.cursors.length; i--; ) {
  11210. if (overwrite)
  11211. dom.addCssClass(this.cursors[i], "ace_overwrite");
  11212. else
  11213. dom.removeCssClass(this.cursors[i], "ace_overwrite");
  11214. }
  11215. };
  11216. this.destroy = function() {
  11217. clearInterval(this.blinkId);
  11218. }
  11219. }).call(Cursor.prototype);
  11220. exports.Cursor = Cursor;
  11221. });
  11222. ace.define('ace/scrollbar', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) {
  11223. var oop = require("./lib/oop");
  11224. var dom = require("./lib/dom");
  11225. var event = require("./lib/event");
  11226. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  11227. /**
  11228. * new ScrollBar(parent)
  11229. * - parent (DOMElement): A DOM element
  11230. *
  11231. * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
  11232. *
  11233. **/
  11234. var ScrollBar = function(parent) {
  11235. this.element = dom.createElement("div");
  11236. this.element.className = "ace_sb";
  11237. this.inner = dom.createElement("div");
  11238. this.element.appendChild(this.inner);
  11239. parent.appendChild(this.element);
  11240. // in OSX lion the scrollbars appear to have no width. In this case resize
  11241. // the to show the scrollbar but still pretend that the scrollbar has a width
  11242. // of 0px
  11243. // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
  11244. // make element a little bit wider to retain scrollbar when page is zoomed
  11245. this.width = dom.scrollbarWidth(parent.ownerDocument);
  11246. this.element.style.width = (this.width || 15) + 5 + "px";
  11247. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  11248. };
  11249. (function() {
  11250. oop.implement(this, EventEmitter);
  11251. this.onScroll = function() {
  11252. this._emit("scroll", {data: this.element.scrollTop});
  11253. };
  11254. this.getWidth = function() {
  11255. return this.width;
  11256. };
  11257. this.setHeight = function(height) {
  11258. this.element.style.height = height + "px";
  11259. };
  11260. this.setInnerHeight = function(height) {
  11261. this.inner.style.height = height + "px";
  11262. };
  11263. // TODO: on chrome 17+ after for small zoom levels after this function
  11264. // this.element.scrollTop != scrollTop which makes page to scroll up.
  11265. this.setScrollTop = function(scrollTop) {
  11266. this.element.scrollTop = scrollTop;
  11267. };
  11268. }).call(ScrollBar.prototype);
  11269. exports.ScrollBar = ScrollBar;
  11270. });
  11271. ace.define('ace/renderloop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
  11272. var event = require("./lib/event");
  11273. /** internal, hide
  11274. * new RenderLoop(onRender, win)
  11275. *
  11276. *
  11277. *
  11278. **/
  11279. var RenderLoop = function(onRender, win) {
  11280. this.onRender = onRender;
  11281. this.pending = false;
  11282. this.changes = 0;
  11283. this.window = win || window;
  11284. };
  11285. (function() {
  11286. /** internal, hide
  11287. * RenderLoop.schedule(change)
  11288. * - change (Array):
  11289. *
  11290. *
  11291. **/
  11292. this.schedule = function(change) {
  11293. //this.onRender(change);
  11294. //return;
  11295. this.changes = this.changes | change;
  11296. if (!this.pending) {
  11297. this.pending = true;
  11298. var _self = this;
  11299. event.nextTick(function() {
  11300. _self.pending = false;
  11301. var changes;
  11302. while (changes = _self.changes) {
  11303. _self.changes = 0;
  11304. _self.onRender(changes);
  11305. }
  11306. }, this.window);
  11307. }
  11308. };
  11309. }).call(RenderLoop.prototype);
  11310. exports.RenderLoop = RenderLoop;
  11311. });
  11312. ace.define("text!ace/css/editor.css", [], ".ace_editor {\n" +
  11313. " position: absolute;\n" +
  11314. " overflow: hidden;\n" +
  11315. " font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;\n" +
  11316. " font-size: 12px;\n" +
  11317. "}\n" +
  11318. "\n" +
  11319. ".ace_scroller {\n" +
  11320. " position: absolute;\n" +
  11321. " overflow: hidden;\n" +
  11322. "}\n" +
  11323. "\n" +
  11324. ".ace_content {\n" +
  11325. " position: absolute;\n" +
  11326. " box-sizing: border-box;\n" +
  11327. " -moz-box-sizing: border-box;\n" +
  11328. " -webkit-box-sizing: border-box;\n" +
  11329. " cursor: text;\n" +
  11330. "}\n" +
  11331. "\n" +
  11332. ".ace_gutter {\n" +
  11333. " position: absolute;\n" +
  11334. " overflow : hidden;\n" +
  11335. " height: 100%;\n" +
  11336. " width: auto;\n" +
  11337. " cursor: default;\n" +
  11338. " z-index: 4;\n" +
  11339. "}\n" +
  11340. "\n" +
  11341. ".ace_scroller.horscroll {\n" +
  11342. " box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n" +
  11343. "}\n" +
  11344. "\n" +
  11345. ".ace_gutter-cell {\n" +
  11346. " padding-left: 19px;\n" +
  11347. " padding-right: 6px;\n" +
  11348. "}\n" +
  11349. "\n" +
  11350. ".ace_gutter-cell.ace_error {\n" +
  11351. " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTQ4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTU4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBMjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBMzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkgXxbAAAAJbSURBVHjapFNNaBNBFH4zs5vdZLP5sQmNpT82QY209heh1ioWisaDRcSKF0WKJ0GQnrzrxasHsR6EnlrwD0TagxJabaVEpFYxLWlLSS822tr87m66ccfd2GKyVhA6MMybgfe97/vmPUQphd0sZjto9XIn9OOsvlu2nkqRzVU+6vvlzPf8W6bk8dxQ0NPbxAALgCgg2JkaQuhzQau/El0zbmUA7U0Es8v2CiYmKQJHGO1QICCLoqilMhkmurDAyapKgqItezi/USRdJqEYY4D5jCy03ht2yMkkvL91jTTX10qzyyu2hruPRN7jgbH+EOsXcMLgYiThEgAMhABW85oqy1DXdRIdvP1AHJ2acQXvDIrVHcdQNrEKNYSVMSZGMjEzIIAwDXIo+6G/FxcGnzkC3T2oMhLjre49sBB+RRcHLqdafK6sYdE/GGBwU1VpFNj0aN8pJbe+BkZyevUrvLl6Xmm0W9IuTc0DxrDNAJd5oEvI/KRsNC3bQyNjPO9yQ1YHcfj2QvfQc/5TUhJTBc2iM0U7AWDQtc1nJHvD/cfO2s7jaGkiTEfa/Ep8coLu7zmNmh8+dc5lZDuUeFAGUNA/OY6JVaypQ0vjr7XYjUvJM37vt+j1vuTK5DgVfVUoTjVe+y3/LxMxY2GgU+CSLy4cpfsYorRXuXIOi0Vt40h67uZFTdIo6nLaZcwUJWAzwNS0tBnqqKzQDnjdG/iPyZxo46HaKUpbvYkj8qYRTZsBhge+JHhZyh0x9b95JqjVJkT084kZIPwu/mPWqPgfQ5jXh2+92Ay7HedfAgwA6KDWafb4w3cAAAAASUVORK5CYII=\");\n" +
  11352. " background-repeat: no-repeat;\n" +
  11353. " background-position: 2px center;\n" +
  11354. "}\n" +
  11355. "\n" +
  11356. ".ace_gutter-cell.ace_warning {\n" +
  11357. " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTg4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTk4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBNjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBNzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pgd7PfIAAAGmSURBVHjaYvr//z8DJZiJgUIANoCRkREb9gLiSVAaQx4OQM7AAkwd7XU2/v++/rOttdYGEB9dASEvOMydGKfH8Gv/p4XTkvRBfLxeQAP+1cUhXopyvzhP7P/IoSj7g7Mw09cNKO6J1QQ0L4gICPIv/veg/8W+JdFvQNLHVsW9/nmn9zk7B+cCkDwhL7gt6knSZnx9/LuCEOcvkIAMP+cvto9nfqyZmmUAksfnBUtbM60gX/3/kgyv3/xSFOL5DZT+L8vP+Yfh5cvfPvp/xUHyQHXGyAYwgpwBjZYFT3Y1OEl/OfCH4ffv3wzc4iwMvNIsDJ+f/mH4+vIPAxsb631WW0Yln6ZpQLXdMK/DXGDflh+sIv37EivD5x//Gb7+YWT4y86sl7BCCkSD+Z++/1dkvsFRl+HnD1Rvje4F8whjMXmGj58YGf5zsDMwcnAwfPvKcml62DsQDeaDxN+/Y0qwlpEHqrdB94IRNIDUgfgfKJChGK4OikEW3gTiXUB950ASLFAF54AC94A0G9QAfOnmF9DCDzABFqS08IHYDIScdijOjQABBgC+/9awBH96jwAAAABJRU5ErkJggg==\");\n" +
  11358. " background-repeat: no-repeat;\n" +
  11359. " background-position: 2px center;\n" +
  11360. "}\n" +
  11361. "\n" +
  11362. ".ace_gutter-cell.ace_info {\n" +
  11363. " background-image: url(\"data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7\");\n" +
  11364. " background-repeat: no-repeat;\n" +
  11365. " background-position: 2px center;\n" +
  11366. "}\n" +
  11367. "\n" +
  11368. ".ace_editor .ace_sb {\n" +
  11369. " position: absolute;\n" +
  11370. " overflow-x: hidden;\n" +
  11371. " overflow-y: scroll;\n" +
  11372. " right: 0;\n" +
  11373. "}\n" +
  11374. "\n" +
  11375. ".ace_editor .ace_sb div {\n" +
  11376. " position: absolute;\n" +
  11377. " width: 1px;\n" +
  11378. " left: 0;\n" +
  11379. "}\n" +
  11380. "\n" +
  11381. ".ace_editor .ace_print_margin_layer {\n" +
  11382. " z-index: 0;\n" +
  11383. " position: absolute;\n" +
  11384. " overflow: hidden;\n" +
  11385. " margin: 0;\n" +
  11386. " left: 0;\n" +
  11387. " height: 100%;\n" +
  11388. " width: 100%;\n" +
  11389. "}\n" +
  11390. "\n" +
  11391. ".ace_editor .ace_print_margin {\n" +
  11392. " position: absolute;\n" +
  11393. " height: 100%;\n" +
  11394. "}\n" +
  11395. "\n" +
  11396. ".ace_editor > textarea {\n" +
  11397. " position: absolute;\n" +
  11398. " z-index: 0;\n" +
  11399. " width: 0.5em;\n" +
  11400. " height: 1em;\n" +
  11401. " opacity: 0;\n" +
  11402. " background: transparent;\n" +
  11403. " appearance: none;\n" +
  11404. " -moz-appearance: none;\n" +
  11405. " border: none;\n" +
  11406. " resize: none;\n" +
  11407. " outline: none;\n" +
  11408. " overflow: hidden;\n" +
  11409. "}\n" +
  11410. "\n" +
  11411. ".ace_editor > textarea.ace_composition {\n" +
  11412. " background: #fff;\n" +
  11413. " color: #000;\n" +
  11414. " z-index: 1000;\n" +
  11415. " opacity: 1;\n" +
  11416. " border: solid lightgray 1px;\n" +
  11417. " margin: -1px\n" +
  11418. "}\n" +
  11419. "\n" +
  11420. ".ace_layer {\n" +
  11421. " z-index: 1;\n" +
  11422. " position: absolute;\n" +
  11423. " overflow: hidden;\n" +
  11424. " white-space: nowrap;\n" +
  11425. " height: 100%;\n" +
  11426. " width: 100%;\n" +
  11427. " box-sizing: border-box;\n" +
  11428. " -moz-box-sizing: border-box;\n" +
  11429. " -webkit-box-sizing: border-box;\n" +
  11430. " /* setting pointer-events: auto; on node under the mouse, which changes\n" +
  11431. " during scroll, will break mouse wheel scrolling in Safari */\n" +
  11432. " pointer-events: none;\n" +
  11433. "}\n" +
  11434. "\n" +
  11435. ".ace_gutter .ace_layer {\n" +
  11436. " position: relative;\n" +
  11437. " min-width: 40px;\n" +
  11438. " width: auto;\n" +
  11439. " text-align: right;\n" +
  11440. " pointer-events: auto;\n" +
  11441. "}\n" +
  11442. "\n" +
  11443. ".ace_text-layer {\n" +
  11444. " color: black;\n" +
  11445. " font: inherit !important;\n" +
  11446. "}\n" +
  11447. "\n" +
  11448. ".ace_cjk {\n" +
  11449. " display: inline-block;\n" +
  11450. " text-align: center;\n" +
  11451. "}\n" +
  11452. "\n" +
  11453. ".ace_cursor-layer {\n" +
  11454. " z-index: 4;\n" +
  11455. "}\n" +
  11456. "\n" +
  11457. ".ace_cursor {\n" +
  11458. " z-index: 4;\n" +
  11459. " position: absolute;\n" +
  11460. "}\n" +
  11461. "\n" +
  11462. ".ace_cursor.ace_hidden {\n" +
  11463. " opacity: 0.2;\n" +
  11464. "}\n" +
  11465. "\n" +
  11466. ".ace_editor.multiselect .ace_cursor {\n" +
  11467. " border-left-width: 1px;\n" +
  11468. "}\n" +
  11469. "\n" +
  11470. ".ace_line {\n" +
  11471. " white-space: nowrap;\n" +
  11472. "}\n" +
  11473. "\n" +
  11474. ".ace_marker-layer .ace_step {\n" +
  11475. " position: absolute;\n" +
  11476. " z-index: 3;\n" +
  11477. "}\n" +
  11478. "\n" +
  11479. ".ace_marker-layer .ace_selection {\n" +
  11480. " position: absolute;\n" +
  11481. " z-index: 5;\n" +
  11482. "}\n" +
  11483. "\n" +
  11484. ".ace_marker-layer .ace_bracket {\n" +
  11485. " position: absolute;\n" +
  11486. " z-index: 6;\n" +
  11487. "}\n" +
  11488. "\n" +
  11489. ".ace_marker-layer .ace_active_line {\n" +
  11490. " position: absolute;\n" +
  11491. " z-index: 2;\n" +
  11492. "}\n" +
  11493. "\n" +
  11494. ".ace_marker-layer .ace_selected_word {\n" +
  11495. " position: absolute;\n" +
  11496. " z-index: 4;\n" +
  11497. " box-sizing: border-box;\n" +
  11498. " -moz-box-sizing: border-box;\n" +
  11499. " -webkit-box-sizing: border-box;\n" +
  11500. "}\n" +
  11501. "\n" +
  11502. ".ace_line .ace_fold {\n" +
  11503. " box-sizing: border-box;\n" +
  11504. " -moz-box-sizing: border-box;\n" +
  11505. " -webkit-box-sizing: border-box;\n" +
  11506. "\n" +
  11507. " display: inline-block;\n" +
  11508. " height: 11px;\n" +
  11509. " margin-top: -2px;\n" +
  11510. " vertical-align: middle;\n" +
  11511. "\n" +
  11512. " background-image:\n" +
  11513. " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" +
  11514. " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82\");\n" +
  11515. " background-repeat: no-repeat, repeat-x;\n" +
  11516. " background-position: center center, top left;\n" +
  11517. " color: transparent;\n" +
  11518. "\n" +
  11519. " border: 1px solid black;\n" +
  11520. " -moz-border-radius: 2px;\n" +
  11521. " -webkit-border-radius: 2px;\n" +
  11522. " border-radius: 2px;\n" +
  11523. "\n" +
  11524. " cursor: pointer;\n" +
  11525. " pointer-events: auto;\n" +
  11526. "}\n" +
  11527. "\n" +
  11528. ".ace_dark .ace_fold {\n" +
  11529. "}\n" +
  11530. "\n" +
  11531. ".ace_fold:hover{\n" +
  11532. " background-image:\n" +
  11533. " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" +
  11534. " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82\");\n" +
  11535. " background-repeat: no-repeat, repeat-x;\n" +
  11536. " background-position: center center, top left;\n" +
  11537. "}\n" +
  11538. "\n" +
  11539. ".ace_dragging .ace_content {\n" +
  11540. " cursor: move;\n" +
  11541. "}\n" +
  11542. "\n" +
  11543. ".ace_folding-enabled > .ace_gutter-cell {\n" +
  11544. " padding-right: 13px;\n" +
  11545. "}\n" +
  11546. "\n" +
  11547. ".ace_fold-widget {\n" +
  11548. " box-sizing: border-box;\n" +
  11549. " -moz-box-sizing: border-box;\n" +
  11550. " -webkit-box-sizing: border-box;\n" +
  11551. "\n" +
  11552. " margin: 0 -12px 1px 1px;\n" +
  11553. " display: inline-block;\n" +
  11554. " height: 14px;\n" +
  11555. " width: 11px;\n" +
  11556. " vertical-align: text-bottom;\n" +
  11557. "\n" +
  11558. " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82\");\n" +
  11559. " background-repeat: no-repeat;\n" +
  11560. " background-position: center 5px;\n" +
  11561. "\n" +
  11562. " border-radius: 3px;\n" +
  11563. "}\n" +
  11564. "\n" +
  11565. ".ace_fold-widget.end {\n" +
  11566. " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82\");\n" +
  11567. "}\n" +
  11568. "\n" +
  11569. ".ace_fold-widget.closed {\n" +
  11570. " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82\");\n" +
  11571. "}\n" +
  11572. "\n" +
  11573. ".ace_fold-widget:hover {\n" +
  11574. " border: 1px solid rgba(0, 0, 0, 0.3);\n" +
  11575. " background-color: rgba(255, 255, 255, 0.2);\n" +
  11576. " -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11577. " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11578. " -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11579. " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11580. " box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11581. " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
  11582. " background-position: center 4px;\n" +
  11583. "}\n" +
  11584. "\n" +
  11585. ".ace_fold-widget:active {\n" +
  11586. " border: 1px solid rgba(0, 0, 0, 0.4);\n" +
  11587. " background-color: rgba(0, 0, 0, 0.05);\n" +
  11588. " -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
  11589. " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
  11590. " -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
  11591. " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
  11592. " box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
  11593. " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
  11594. "}\n" +
  11595. "\n" +
  11596. ".ace_fold-widget.invalid {\n" +
  11597. " background-color: #FFB4B4;\n" +
  11598. " border-color: #DE5555;\n" +
  11599. "}\n" +
  11600. "\n" +
  11601. ".ace_fade-fold-widgets .ace_fold-widget {\n" +
  11602. " -moz-transition: opacity 0.4s ease 0.05s;\n" +
  11603. " -webkit-transition: opacity 0.4s ease 0.05s;\n" +
  11604. " -o-transition: opacity 0.4s ease 0.05s;\n" +
  11605. " -ms-transition: opacity 0.4s ease 0.05s;\n" +
  11606. " transition: opacity 0.4s ease 0.05s;\n" +
  11607. " opacity: 0;\n" +
  11608. "}\n" +
  11609. "\n" +
  11610. ".ace_fade-fold-widgets:hover .ace_fold-widget {\n" +
  11611. " -moz-transition: opacity 0.05s ease 0.05s;\n" +
  11612. " -webkit-transition: opacity 0.05s ease 0.05s;\n" +
  11613. " -o-transition: opacity 0.05s ease 0.05s;\n" +
  11614. " -ms-transition: opacity 0.05s ease 0.05s;\n" +
  11615. " transition: opacity 0.05s ease 0.05s;\n" +
  11616. " opacity:1;\n" +
  11617. "}\n" +
  11618. "");
  11619. ace.define('ace/multi_select', ['require', 'exports', 'module' , 'ace/range_list', 'ace/range', 'ace/selection', 'ace/mouse/multi_select_handler', 'ace/lib/event', 'ace/commands/multi_select_commands', 'ace/search', 'ace/edit_session', 'ace/editor'], function(require, exports, module) {
  11620. var RangeList = require("./range_list").RangeList;
  11621. var Range = require("./range").Range;
  11622. var Selection = require("./selection").Selection;
  11623. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  11624. var event = require("./lib/event");
  11625. var commands = require("./commands/multi_select_commands");
  11626. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  11627. // Todo: session.find or editor.findVolatile that returns range
  11628. var Search = require("./search").Search;
  11629. var search = new Search();
  11630. function find(session, needle, dir) {
  11631. search.$options.wrap = true;
  11632. search.$options.needle = needle;
  11633. search.$options.backwards = dir == -1;
  11634. return search.find(session);
  11635. }
  11636. // extend EditSession
  11637. var EditSession = require("./edit_session").EditSession;
  11638. (function() {
  11639. this.getSelectionMarkers = function() {
  11640. return this.$selectionMarkers;
  11641. };
  11642. }).call(EditSession.prototype);
  11643. // extend Selection
  11644. (function() {
  11645. // list of ranges in reverse addition order
  11646. this.ranges = null;
  11647. // automatically sorted list of ranges
  11648. this.rangeList = null;
  11649. this.addRange = function(range, $blockChangeEvents) {
  11650. if (!range)
  11651. return;
  11652. if (!this.inMultiSelectMode && this.rangeCount == 0) {
  11653. var oldRange = this.toOrientedRange();
  11654. if (range.intersects(oldRange))
  11655. return $blockChangeEvents || this.fromOrientedRange(range);
  11656. this.rangeList.add(oldRange);
  11657. this.$onAddRange(oldRange);
  11658. }
  11659. if (!range.cursor)
  11660. range.cursor = range.end;
  11661. var removed = this.rangeList.add(range);
  11662. this.$onAddRange(range);
  11663. if (removed.length)
  11664. this.$onRemoveRange(removed);
  11665. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  11666. this._emit("multiSelect");
  11667. this.inMultiSelectMode = true;
  11668. this.session.$undoSelect = false;
  11669. this.rangeList.attach(this.session);
  11670. }
  11671. return $blockChangeEvents || this.fromOrientedRange(range);
  11672. };
  11673. this.toSingleRange = function(range) {
  11674. range = range || this.ranges[0];
  11675. var removed = this.rangeList.removeAll();
  11676. if (removed.length)
  11677. this.$onRemoveRange(removed);
  11678. range && this.fromOrientedRange(range);
  11679. };
  11680. this.substractPoint = function(pos) {
  11681. var removed = this.rangeList.substractPoint(pos);
  11682. if (removed) {
  11683. this.$onRemoveRange(removed);
  11684. return removed[0];
  11685. }
  11686. };
  11687. this.mergeOverlappingRanges = function() {
  11688. var removed = this.rangeList.merge();
  11689. if (removed.length)
  11690. this.$onRemoveRange(removed);
  11691. else if(this.ranges[0])
  11692. this.fromOrientedRange(this.ranges[0]);
  11693. };
  11694. this.$onAddRange = function(range) {
  11695. this.rangeCount = this.rangeList.ranges.length;
  11696. this.ranges.unshift(range);
  11697. this._emit("addRange", {range: range});
  11698. };
  11699. this.$onRemoveRange = function(removed) {
  11700. this.rangeCount = this.rangeList.ranges.length;
  11701. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  11702. var lastRange = this.rangeList.ranges.pop();
  11703. removed.push(lastRange);
  11704. this.rangeCount = 0;
  11705. }
  11706. for (var i = removed.length; i--; ) {
  11707. var index = this.ranges.indexOf(removed[i]);
  11708. this.ranges.splice(index, 1);
  11709. }
  11710. this._emit("removeRange", {ranges: removed});
  11711. if (this.rangeCount == 0 && this.inMultiSelectMode) {
  11712. this.inMultiSelectMode = false;
  11713. this._emit("singleSelect");
  11714. this.session.$undoSelect = true;
  11715. this.rangeList.detach(this.session);
  11716. }
  11717. lastRange = lastRange || this.ranges[0];
  11718. if (lastRange && !lastRange.isEqual(this.getRange()))
  11719. this.fromOrientedRange(lastRange);
  11720. };
  11721. // adds multicursor support to selection
  11722. this.$initRangeList = function() {
  11723. if (this.rangeList)
  11724. return;
  11725. this.rangeList = new RangeList();
  11726. this.ranges = [];
  11727. this.rangeCount = 0;
  11728. };
  11729. this.getAllRanges = function() {
  11730. return this.rangeList.ranges.concat();
  11731. };
  11732. this.splitIntoLines = function () {
  11733. if (this.rangeCount > 1) {
  11734. var ranges = this.rangeList.ranges;
  11735. var lastRange = ranges[ranges.length - 1];
  11736. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  11737. this.toSingleRange();
  11738. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  11739. } else {
  11740. var range = this.getRange();
  11741. var startRow = range.start.row;
  11742. var endRow = range.end.row;
  11743. if (startRow == endRow)
  11744. return;
  11745. var rectSel = [];
  11746. var r = this.getLineRange(startRow, true);
  11747. r.start.column = range.start.column;
  11748. rectSel.push(r);
  11749. for (var i = startRow + 1; i < endRow; i++)
  11750. rectSel.push(this.getLineRange(i, true));
  11751. r = this.getLineRange(endRow, true);
  11752. r.end.column = range.end.column;
  11753. rectSel.push(r);
  11754. rectSel.forEach(this.addRange, this);
  11755. }
  11756. };
  11757. this.toggleBlockSelection = function () {
  11758. if (this.rangeCount > 1) {
  11759. var ranges = this.rangeList.ranges;
  11760. var lastRange = ranges[ranges.length - 1];
  11761. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  11762. this.toSingleRange();
  11763. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  11764. } else {
  11765. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  11766. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  11767. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  11768. rectSel.forEach(this.addRange, this);
  11769. }
  11770. };
  11771. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  11772. var rectSel = [];
  11773. var xBackwards = screenCursor.column < screenAnchor.column;
  11774. if (xBackwards) {
  11775. var startColumn = screenCursor.column;
  11776. var endColumn = screenAnchor.column;
  11777. } else {
  11778. var startColumn = screenAnchor.column;
  11779. var endColumn = screenCursor.column;
  11780. }
  11781. var yBackwards = screenCursor.row < screenAnchor.row;
  11782. if (yBackwards) {
  11783. var startRow = screenCursor.row;
  11784. var endRow = screenAnchor.row;
  11785. } else {
  11786. var startRow = screenAnchor.row;
  11787. var endRow = screenCursor.row;
  11788. }
  11789. if (startColumn < 0)
  11790. startColumn = 0;
  11791. if (startRow < 0)
  11792. startRow = 0;
  11793. if (startRow == endRow)
  11794. includeEmptyLines = true;
  11795. for (var row = startRow; row <= endRow; row++) {
  11796. var range = Range.fromPoints(
  11797. this.session.screenToDocumentPosition(row, startColumn),
  11798. this.session.screenToDocumentPosition(row, endColumn)
  11799. );
  11800. if (range.isEmpty()) {
  11801. if (docEnd && isSamePoint(range.end, docEnd))
  11802. break;
  11803. var docEnd = range.end;
  11804. }
  11805. range.cursor = xBackwards ? range.start : range.end;
  11806. rectSel.push(range);
  11807. }
  11808. if (yBackwards)
  11809. rectSel.reverse();
  11810. if (!includeEmptyLines) {
  11811. var end = rectSel.length - 1;
  11812. while (rectSel[end].isEmpty() && end > 0)
  11813. end--;
  11814. if (end > 0) {
  11815. var start = 0;
  11816. while (rectSel[start].isEmpty())
  11817. start++;
  11818. }
  11819. for (var i = end; i >= start; i--) {
  11820. if (rectSel[i].isEmpty())
  11821. rectSel.splice(i, 1);
  11822. }
  11823. }
  11824. return rectSel;
  11825. };
  11826. }).call(Selection.prototype);
  11827. // extend Editor
  11828. var Editor = require("./editor").Editor;
  11829. (function() {
  11830. /** extension
  11831. * Editor.updateSelectionMarkers()
  11832. *
  11833. * Updates the cursor and marker layers.
  11834. **/
  11835. this.updateSelectionMarkers = function() {
  11836. this.renderer.updateCursor();
  11837. this.renderer.updateBackMarkers();
  11838. };
  11839. this.addSelectionMarker = function(orientedRange) {
  11840. if (!orientedRange.cursor)
  11841. orientedRange.cursor = orientedRange.end;
  11842. var style = this.getSelectionStyle();
  11843. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  11844. this.session.$selectionMarkers.push(orientedRange);
  11845. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  11846. return orientedRange;
  11847. };
  11848. this.removeSelectionMarker = function(range) {
  11849. if (!range.marker)
  11850. return;
  11851. this.session.removeMarker(range.marker);
  11852. var index = this.session.$selectionMarkers.indexOf(range);
  11853. if (index != -1)
  11854. this.session.$selectionMarkers.splice(index, 1);
  11855. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  11856. };
  11857. this.removeSelectionMarkers = function(ranges) {
  11858. var markerList = this.session.$selectionMarkers;
  11859. for (var i = ranges.length; i--; ) {
  11860. var range = ranges[i];
  11861. if (!range.marker)
  11862. continue;
  11863. this.session.removeMarker(range.marker);
  11864. var index = markerList.indexOf(range);
  11865. if (index != -1)
  11866. markerList.splice(index, 1);
  11867. }
  11868. this.session.selectionMarkerCount = markerList.length;
  11869. };
  11870. this.$onAddRange = function(e) {
  11871. this.addSelectionMarker(e.range);
  11872. this.renderer.updateCursor();
  11873. this.renderer.updateBackMarkers();
  11874. };
  11875. this.$onRemoveRange = function(e) {
  11876. this.removeSelectionMarkers(e.ranges);
  11877. this.renderer.updateCursor();
  11878. this.renderer.updateBackMarkers();
  11879. };
  11880. this.$onMultiSelect = function(e) {
  11881. if (this.inMultiSelectMode)
  11882. return;
  11883. this.inMultiSelectMode = true;
  11884. this.setStyle("multiselect");
  11885. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  11886. this.commands.on("exec", this.$onMultiSelectExec);
  11887. this.renderer.updateCursor();
  11888. this.renderer.updateBackMarkers();
  11889. };
  11890. this.$onSingleSelect = function(e) {
  11891. if (this.session.multiSelect.inVirtualMode)
  11892. return;
  11893. this.inMultiSelectMode = false;
  11894. this.unsetStyle("multiselect");
  11895. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  11896. this.commands.removeEventListener("exec", this.$onMultiSelectExec);
  11897. this.renderer.updateCursor();
  11898. this.renderer.updateBackMarkers();
  11899. };
  11900. this.$onMultiSelectExec = function(e) {
  11901. var command = e.command;
  11902. var editor = e.editor;
  11903. if (!editor.multiSelect)
  11904. return;
  11905. if (!command.multiSelectAction) {
  11906. command.exec(editor, e.args || {});
  11907. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  11908. editor.multiSelect.mergeOverlappingRanges();
  11909. } else if (command.multiSelectAction == "forEach") {
  11910. editor.forEachSelection(command, e.args);
  11911. } else if (command.multiSelectAction == "single") {
  11912. editor.exitMultiSelectMode();
  11913. command.exec(editor, e.args || {});
  11914. } else {
  11915. command.multiSelectAction(editor, e.args || {});
  11916. }
  11917. e.preventDefault();
  11918. };
  11919. this.forEachSelection = function(cmd, args) {
  11920. if (this.inVirtualSelectionMode)
  11921. return;
  11922. var session = this.session;
  11923. var selection = this.selection;
  11924. var rangeList = selection.rangeList;
  11925. var reg = selection._eventRegistry;
  11926. selection._eventRegistry = {};
  11927. var tmpSel = new Selection(session);
  11928. this.inVirtualSelectionMode = true;
  11929. for (var i = rangeList.ranges.length; i--;) {
  11930. tmpSel.fromOrientedRange(rangeList.ranges[i]);
  11931. this.selection = session.selection = tmpSel;
  11932. cmd.exec(this, args || {});
  11933. tmpSel.toOrientedRange(rangeList.ranges[i]);
  11934. }
  11935. tmpSel.detach();
  11936. this.selection = session.selection = selection;
  11937. this.inVirtualSelectionMode = false;
  11938. selection._eventRegistry = reg;
  11939. selection.mergeOverlappingRanges();
  11940. this.onCursorChange();
  11941. this.onSelectionChange();
  11942. };
  11943. this.exitMultiSelectMode = function() {
  11944. if (this.inVirtualSelectionMode)
  11945. return;
  11946. this.multiSelect.toSingleRange();
  11947. };
  11948. this.getCopyText = function() {
  11949. var text = "";
  11950. if (this.inMultiSelectMode) {
  11951. var ranges = this.multiSelect.rangeList.ranges;
  11952. text = [];
  11953. for (var i = 0; i < ranges.length; i++) {
  11954. text.push(this.session.getTextRange(ranges[i]));
  11955. }
  11956. text = text.join(this.session.getDocument().getNewLineCharacter());
  11957. } else if (!this.selection.isEmpty()) {
  11958. text = this.session.getTextRange(this.getSelectionRange());
  11959. }
  11960. return text;
  11961. };
  11962. this.onPaste = function(text) {
  11963. this._emit("paste", text);
  11964. if (!this.inMultiSelectMode)
  11965. return this.insert(text);
  11966. var lines = text.split(/\r\n|\r|\n/);
  11967. var ranges = this.selection.rangeList.ranges;
  11968. if (lines.length > ranges.length || (lines.length <= 2 || !lines[1]))
  11969. return this.commands.exec("insertstring", this, text);
  11970. for (var i = ranges.length; i--; ) {
  11971. var range = ranges[i];
  11972. if (!range.isEmpty())
  11973. this.session.remove(range);
  11974. this.session.insert(range.start, lines[i]);
  11975. }
  11976. };
  11977. this.findAll = function(needle, options, additive) {
  11978. options = options || {};
  11979. options.needle = needle || options.needle;
  11980. this.$search.set(options);
  11981. var ranges = this.$search.findAll(this.session);
  11982. if (!ranges.length)
  11983. return 0;
  11984. this.$blockScrolling += 1;
  11985. var selection = this.multiSelect;
  11986. if (!additive)
  11987. selection.toSingleRange(ranges[0]);
  11988. for (var i = ranges.length; i--; )
  11989. selection.addRange(ranges[i], true);
  11990. this.$blockScrolling -= 1;
  11991. return ranges.length;
  11992. };
  11993. // commands
  11994. /** extension
  11995. * Editor.selectMoreLines(dir, skip)
  11996. * - dir (Number): The direction of lines to select: -1 for up, 1 for down
  11997. * - skip (Boolean): If `true`, removes the active selection range
  11998. *
  11999. * Adds a cursor above or below the active cursor.
  12000. **/
  12001. this.selectMoreLines = function(dir, skip) {
  12002. var range = this.selection.toOrientedRange();
  12003. var isBackwards = range.cursor == range.end;
  12004. var screenLead = this.session.documentToScreenPosition(range.cursor);
  12005. if (this.selection.$desiredColumn)
  12006. screenLead.column = this.selection.$desiredColumn;
  12007. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  12008. if (!range.isEmpty()) {
  12009. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  12010. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  12011. } else {
  12012. var anchor = lead;
  12013. }
  12014. if (isBackwards) {
  12015. var newRange = Range.fromPoints(lead, anchor);
  12016. newRange.cursor = newRange.start;
  12017. } else {
  12018. var newRange = Range.fromPoints(anchor, lead);
  12019. newRange.cursor = newRange.end;
  12020. }
  12021. newRange.desiredColumn = screenLead.column;
  12022. if (!this.selection.inMultiSelectMode) {
  12023. this.selection.addRange(range);
  12024. } else {
  12025. if (skip)
  12026. var toRemove = range.cursor;
  12027. }
  12028. this.selection.addRange(newRange);
  12029. if (toRemove)
  12030. this.selection.substractPoint(toRemove);
  12031. };
  12032. this.transposeSelections = function(dir) {
  12033. var session = this.session;
  12034. var sel = session.multiSelect;
  12035. var all = sel.ranges;
  12036. for (var i = all.length; i--; ) {
  12037. var range = all[i];
  12038. if (range.isEmpty()) {
  12039. var tmp = session.getWordRange(range.start.row, range.start.column);
  12040. range.start.row = tmp.start.row;
  12041. range.start.column = tmp.start.column;
  12042. range.end.row = tmp.end.row;
  12043. range.end.column = tmp.end.column;
  12044. }
  12045. }
  12046. sel.mergeOverlappingRanges();
  12047. var words = [];
  12048. for (var i = all.length; i--; ) {
  12049. var range = all[i];
  12050. words.unshift(session.getTextRange(range));
  12051. }
  12052. if (dir < 0)
  12053. words.unshift(words.pop());
  12054. else
  12055. words.push(words.shift());
  12056. for (var i = all.length; i--; ) {
  12057. var range = all[i];
  12058. var tmp = range.clone();
  12059. session.replace(range, words[i]);
  12060. range.start.row = tmp.start.row;
  12061. range.start.column = tmp.start.column;
  12062. }
  12063. }
  12064. /** extension
  12065. * Editor.selectMore(dir, skip)
  12066. * - dir (Number): The direction of lines to select: -1 for up, 1 for down
  12067. * - skip (Boolean): If `true`, removes the active selection range
  12068. *
  12069. * Finds the next occurence of text in an active selection and adds it to the selections.
  12070. **/
  12071. this.selectMore = function (dir, skip) {
  12072. var session = this.session;
  12073. var sel = session.multiSelect;
  12074. var range = sel.toOrientedRange();
  12075. if (range.isEmpty()) {
  12076. var range = session.getWordRange(range.start.row, range.start.column);
  12077. range.cursor = range.end;
  12078. this.multiSelect.addRange(range);
  12079. }
  12080. var needle = session.getTextRange(range);
  12081. var newRange = find(session, needle, dir);
  12082. if (newRange) {
  12083. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  12084. this.multiSelect.addRange(newRange);
  12085. }
  12086. if (skip)
  12087. this.multiSelect.substractPoint(range.cursor);
  12088. };
  12089. }).call(Editor.prototype);
  12090. function isSamePoint(p1, p2) {
  12091. return p1.row == p2.row && p1.column == p2.column;
  12092. }
  12093. // patch
  12094. // adds multicursor support to a session
  12095. exports.onSessionChange = function(e) {
  12096. var session = e.session;
  12097. if (!session.multiSelect) {
  12098. session.$selectionMarkers = [];
  12099. session.selection.$initRangeList();
  12100. session.multiSelect = session.selection;
  12101. }
  12102. this.multiSelect = session.multiSelect;
  12103. var oldSession = e.oldSession;
  12104. if (oldSession) {
  12105. // todo use events
  12106. if (oldSession.multiSelect && oldSession.multiSelect.editor == this)
  12107. oldSession.multiSelect.editor = null;
  12108. session.multiSelect.removeEventListener("addRange", this.$onAddRange);
  12109. session.multiSelect.removeEventListener("removeRange", this.$onRemoveRange);
  12110. session.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect);
  12111. session.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect);
  12112. }
  12113. session.multiSelect.on("addRange", this.$onAddRange);
  12114. session.multiSelect.on("removeRange", this.$onRemoveRange);
  12115. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  12116. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  12117. // this.$onSelectionChange = this.onSelectionChange.bind(this);
  12118. if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  12119. if (session.selection.inMultiSelectMode)
  12120. this.$onMultiSelect();
  12121. else
  12122. this.$onSingleSelect();
  12123. }
  12124. };
  12125. // MultiSelect(editor)
  12126. // adds multiple selection support to the editor
  12127. // (note: should be called only once for each editor instance)
  12128. function MultiSelect(editor) {
  12129. editor.$onAddRange = editor.$onAddRange.bind(editor);
  12130. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  12131. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  12132. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  12133. exports.onSessionChange.call(editor, editor);
  12134. editor.on("changeSession", exports.onSessionChange.bind(editor));
  12135. editor.on("mousedown", onMouseDown);
  12136. editor.commands.addCommands(commands.defaultCommands);
  12137. addAltCursorListeners(editor);
  12138. }
  12139. function addAltCursorListeners(editor){
  12140. var el = editor.textInput.getElement();
  12141. var altCursor = false;
  12142. var contentEl = editor.renderer.content;
  12143. event.addListener(el, "keydown", function(e) {
  12144. if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
  12145. if (!altCursor) {
  12146. contentEl.style.cursor = "crosshair";
  12147. altCursor = true;
  12148. }
  12149. } else if (altCursor) {
  12150. contentEl.style.cursor = "";
  12151. }
  12152. });
  12153. event.addListener(el, "keyup", reset);
  12154. event.addListener(el, "blur", reset);
  12155. function reset() {
  12156. if (altCursor) {
  12157. contentEl.style.cursor = "";
  12158. altCursor = false;
  12159. }
  12160. }
  12161. }
  12162. exports.MultiSelect = MultiSelect;
  12163. });
  12164. ace.define('ace/range_list', ['require', 'exports', 'module' ], function(require, exports, module) {
  12165. var RangeList = function() {
  12166. this.ranges = [];
  12167. };
  12168. (function() {
  12169. this.comparePoints = function(p1, p2) {
  12170. return p1.row - p2.row || p1.column - p2.column;
  12171. };
  12172. this.pointIndex = function(pos, startIndex) {
  12173. var list = this.ranges;
  12174. for (var i = startIndex || 0; i < list.length; i++) {
  12175. var range = list[i];
  12176. var cmp = this.comparePoints(pos, range.end);
  12177. if (cmp > 0)
  12178. continue;
  12179. if (cmp == 0)
  12180. return i;
  12181. cmp = this.comparePoints(pos, range.start);
  12182. if (cmp >= 0)
  12183. return i;
  12184. return -i-1;
  12185. }
  12186. return -i - 1;
  12187. };
  12188. this.add = function(range) {
  12189. var startIndex = this.pointIndex(range.start);
  12190. if (startIndex < 0)
  12191. startIndex = -startIndex - 1;
  12192. var endIndex = this.pointIndex(range.end, startIndex);
  12193. if (endIndex < 0)
  12194. endIndex = -endIndex - 1;
  12195. else
  12196. endIndex++;
  12197. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  12198. };
  12199. this.addList = function(list) {
  12200. var removed = [];
  12201. for (var i = list.length; i--; ) {
  12202. removed.push.call(removed, this.add(list[i]));
  12203. }
  12204. return removed;
  12205. };
  12206. this.substractPoint = function(pos) {
  12207. var i = this.pointIndex(pos);
  12208. if (i >= 0)
  12209. return this.ranges.splice(i, 1);
  12210. };
  12211. // merge overlapping ranges
  12212. this.merge = function() {
  12213. var removed = [];
  12214. var list = this.ranges;
  12215. var next = list[0], range;
  12216. for (var i = 1; i < list.length; i++) {
  12217. range = next;
  12218. next = list[i];
  12219. var cmp = this.comparePoints(range.end, next.start);
  12220. if (cmp < 0)
  12221. continue;
  12222. if (cmp == 0 && !(range.isEmpty() || next.isEmpty()))
  12223. continue;
  12224. if (this.comparePoints(range.end, next.end) < 0) {
  12225. range.end.row = next.end.row;
  12226. range.end.column = next.end.column;
  12227. }
  12228. list.splice(i, 1);
  12229. removed.push(next);
  12230. next = range;
  12231. i--;
  12232. }
  12233. return removed;
  12234. };
  12235. this.contains = function(row, column) {
  12236. return this.pointIndex({row: row, column: column}) >= 0;
  12237. };
  12238. this.containsPoint = function(pos) {
  12239. return this.pointIndex(pos) >= 0;
  12240. };
  12241. this.rangeAtPoint = function(pos) {
  12242. var i = this.pointIndex(pos);
  12243. if (i >= 0)
  12244. return this.ranges[i];
  12245. };
  12246. this.clipRows = function(startRow, endRow) {
  12247. var list = this.ranges;
  12248. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  12249. return [];
  12250. var startIndex = this.pointIndex({row: startRow, column: 0});
  12251. if (startIndex < 0)
  12252. startIndex = -startIndex - 1;
  12253. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  12254. if (endIndex < 0)
  12255. endIndex = -endIndex - 1;
  12256. var clipped = [];
  12257. for (var i = startIndex; i < endIndex; i++) {
  12258. clipped.push(list[i]);
  12259. }
  12260. return clipped;
  12261. };
  12262. this.removeAll = function() {
  12263. return this.ranges.splice(0, this.ranges.length);
  12264. };
  12265. this.attach = function(session) {
  12266. if (this.session)
  12267. this.detach();
  12268. this.session = session;
  12269. this.onChange = this.$onChange.bind(this);
  12270. this.session.on('change', this.onChange);
  12271. };
  12272. this.detach = function() {
  12273. if (!this.session)
  12274. return;
  12275. this.session.removeListener('change', this.onChange);
  12276. this.session = null;
  12277. };
  12278. this.$onChange = function(e) {
  12279. var changeRange = e.data.range;
  12280. if (e.data.action[0] == "i"){
  12281. var start = changeRange.start;
  12282. var end = changeRange.end;
  12283. } else {
  12284. var end = changeRange.start;
  12285. var start = changeRange.end;
  12286. }
  12287. var startRow = start.row;
  12288. var endRow = end.row;
  12289. var lineDif = endRow - startRow;
  12290. var colDiff = -start.column + end.column;
  12291. var ranges = this.ranges;
  12292. for (var i = 0, n = ranges.length; i < n; i++) {
  12293. var r = ranges[i];
  12294. if (r.end.row < startRow)
  12295. continue;
  12296. if (r.start.row > startRow)
  12297. break;
  12298. if (r.start.row == startRow && r.start.column >= start.column ) {
  12299. r.start.column += colDiff;
  12300. r.start.row += lineDif;
  12301. }
  12302. if (r.end.row == startRow && r.end.column >= start.column) {
  12303. r.end.column += colDiff;
  12304. r.end.row += lineDif;
  12305. }
  12306. }
  12307. if (lineDif != 0 && i < n) {
  12308. for (; i < n; i++) {
  12309. var r = ranges[i];
  12310. r.start.row += lineDif;
  12311. r.end.row += lineDif;
  12312. }
  12313. }
  12314. };
  12315. }).call(RangeList.prototype);
  12316. exports.RangeList = RangeList;
  12317. });
  12318. ace.define('ace/mouse/multi_select_handler', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
  12319. var event = require("../lib/event");
  12320. // mouse
  12321. function isSamePoint(p1, p2) {
  12322. return p1.row == p2.row && p1.column == p2.column;
  12323. }
  12324. function onMouseDown(e) {
  12325. var ev = e.domEvent;
  12326. var alt = ev.altKey;
  12327. var shift = ev.shiftKey;
  12328. var ctrl = e.getAccelKey();
  12329. var button = e.getButton();
  12330. if (e.editor.inMultiSelectMode && button == 2) {
  12331. e.editor.textInput.onContextMenu(e.domEvent);
  12332. return;
  12333. }
  12334. if (!ctrl && !alt) {
  12335. if (button == 0 && e.editor.inMultiSelectMode)
  12336. e.editor.exitMultiSelectMode();
  12337. return;
  12338. }
  12339. var editor = e.editor;
  12340. var selection = editor.selection;
  12341. var isMultiSelect = editor.inMultiSelectMode;
  12342. var pos = e.getDocumentPosition();
  12343. var cursor = selection.getCursor();
  12344. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  12345. var mouseX = e.x, mouseY = e.y;
  12346. var onMouseSelection = function(e) {
  12347. mouseX = e.clientX;
  12348. mouseY = e.clientY;
  12349. };
  12350. var blockSelect = function() {
  12351. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  12352. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  12353. if (isSamePoint(screenCursor, newCursor)
  12354. && isSamePoint(cursor, selection.selectionLead))
  12355. return;
  12356. screenCursor = newCursor;
  12357. editor.selection.moveCursorToPosition(cursor);
  12358. editor.selection.clearSelection();
  12359. editor.renderer.scrollCursorIntoView();
  12360. editor.removeSelectionMarkers(rectSel);
  12361. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  12362. rectSel.forEach(editor.addSelectionMarker, editor);
  12363. editor.updateSelectionMarkers();
  12364. };
  12365. var session = editor.session;
  12366. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  12367. var screenCursor = screenAnchor;
  12368. if (ctrl && !shift && !alt && button == 0) {
  12369. if (!isMultiSelect && inSelection)
  12370. return; // dragging
  12371. if (!isMultiSelect) {
  12372. var range = selection.toOrientedRange();
  12373. editor.addSelectionMarker(range);
  12374. }
  12375. var oldRange = selection.rangeList.rangeAtPoint(pos);
  12376. event.capture(editor.container, function(){}, function() {
  12377. var tmpSel = selection.toOrientedRange();
  12378. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  12379. selection.substractPoint(tmpSel.cursor);
  12380. else {
  12381. if (range) {
  12382. editor.removeSelectionMarker(range);
  12383. selection.addRange(range);
  12384. }
  12385. selection.addRange(tmpSel);
  12386. }
  12387. });
  12388. } else if (!shift && alt && button == 0) {
  12389. e.stop();
  12390. if (isMultiSelect && !ctrl)
  12391. selection.toSingleRange();
  12392. else if (!isMultiSelect && ctrl)
  12393. selection.addRange();
  12394. selection.moveCursorToPosition(pos);
  12395. selection.clearSelection();
  12396. var rectSel = [];
  12397. var onMouseSelectionEnd = function(e) {
  12398. clearInterval(timerId);
  12399. editor.removeSelectionMarkers(rectSel);
  12400. for (var i = 0; i < rectSel.length; i++)
  12401. selection.addRange(rectSel[i]);
  12402. };
  12403. var onSelectionInterval = blockSelect;
  12404. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  12405. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  12406. return e.preventDefault();
  12407. }
  12408. }
  12409. exports.onMouseDown = onMouseDown;
  12410. });
  12411. ace.define('ace/commands/multi_select_commands', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler'], function(require, exports, module) {
  12412. // commands to enter multiselect mode
  12413. exports.defaultCommands = [{
  12414. name: "addCursorAbove",
  12415. exec: function(editor) { editor.selectMoreLines(-1); },
  12416. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  12417. readonly: true
  12418. }, {
  12419. name: "addCursorBelow",
  12420. exec: function(editor) { editor.selectMoreLines(1); },
  12421. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  12422. readonly: true
  12423. }, {
  12424. name: "addCursorAboveSkipCurrent",
  12425. exec: function(editor) { editor.selectMoreLines(-1, true); },
  12426. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  12427. readonly: true
  12428. }, {
  12429. name: "addCursorBelowSkipCurrent",
  12430. exec: function(editor) { editor.selectMoreLines(1, true); },
  12431. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  12432. readonly: true
  12433. }, {
  12434. name: "selectMoreBefore",
  12435. exec: function(editor) { editor.selectMore(-1); },
  12436. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  12437. readonly: true
  12438. }, {
  12439. name: "selectMoreAfter",
  12440. exec: function(editor) { editor.selectMore(1); },
  12441. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  12442. readonly: true
  12443. }, {
  12444. name: "selectNextBefore",
  12445. exec: function(editor) { editor.selectMore(-1, true); },
  12446. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  12447. readonly: true
  12448. }, {
  12449. name: "selectNextAfter",
  12450. exec: function(editor) { editor.selectMore(1, true); },
  12451. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  12452. readonly: true
  12453. }, {
  12454. name: "splitIntoLines",
  12455. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  12456. bindKey: {win: "Ctrl-Shift-L", mac: "Ctrl-Shift-L"},
  12457. readonly: true
  12458. }];
  12459. // commands active in multiselect mode
  12460. exports.multiSelectCommands = [{
  12461. name: "singleSelection",
  12462. bindKey: "esc",
  12463. exec: function(editor) { editor.exitMultiSelectMode(); },
  12464. readonly: true,
  12465. isAvailable: function(editor) {return editor.inMultiSelectMode}
  12466. }];
  12467. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  12468. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  12469. });
  12470. ace.define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/config'], function(require, exports, module) {
  12471. var oop = require("../lib/oop");
  12472. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12473. var config = require("../config");
  12474. var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
  12475. this.changeListener = this.changeListener.bind(this);
  12476. if (config.get("packaged")) {
  12477. this.$worker = new Worker(config.get("workerPath") + "/" + packagedJs);
  12478. }
  12479. else {
  12480. var workerUrl;
  12481. if (typeof require.supports !== "undefined" && require.supports.indexOf("ucjs2-pinf-0") >= 0) {
  12482. // We are running in the sourcemint loader.
  12483. workerUrl = require.nameToUrl("ace/worker/worker_sourcemint");
  12484. } else {
  12485. // We are running in RequireJS.
  12486. // nameToUrl is renamed to toUrl in requirejs 2
  12487. if (require.nameToUrl && !require.toUrl)
  12488. require.toUrl = require.nameToUrl;
  12489. workerUrl = this.$normalizePath(require.toUrl("ace/worker/worker", null, "_"));
  12490. }
  12491. this.$worker = new Worker(workerUrl);
  12492. var tlns = {};
  12493. for (var i=0; i<topLevelNamespaces.length; i++) {
  12494. var ns = topLevelNamespaces[i];
  12495. var path = this.$normalizePath(require.toUrl(ns, null, "_").replace(/.js$/, ""));
  12496. tlns[ns] = path;
  12497. }
  12498. }
  12499. this.$worker.postMessage({
  12500. init : true,
  12501. tlns: tlns,
  12502. module: mod,
  12503. classname: classname
  12504. });
  12505. this.callbackId = 1;
  12506. this.callbacks = {};
  12507. var _self = this;
  12508. this.$worker.onerror = function(e) {
  12509. window.console && console.log && console.log(e);
  12510. throw e;
  12511. };
  12512. this.$worker.onmessage = function(e) {
  12513. var msg = e.data;
  12514. switch(msg.type) {
  12515. case "log":
  12516. window.console && console.log && console.log(msg.data);
  12517. break;
  12518. case "event":
  12519. _self._emit(msg.name, {data: msg.data});
  12520. break;
  12521. case "call":
  12522. var callback = _self.callbacks[msg.id];
  12523. if (callback) {
  12524. callback(msg.data);
  12525. delete _self.callbacks[msg.id];
  12526. }
  12527. break;
  12528. }
  12529. };
  12530. };
  12531. (function(){
  12532. oop.implement(this, EventEmitter);
  12533. this.$normalizePath = function(path) {
  12534. path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
  12535. path = location.protocol + "//" + location.host
  12536. // paths starting with a slash are relative to the root (host)
  12537. + (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
  12538. + "/" + path.replace(/^[\/]+/, "");
  12539. return path;
  12540. };
  12541. this.terminate = function() {
  12542. this._emit("terminate", {});
  12543. this.$worker.terminate();
  12544. this.$worker = null;
  12545. this.$doc.removeEventListener("change", this.changeListener);
  12546. this.$doc = null;
  12547. };
  12548. this.send = function(cmd, args) {
  12549. this.$worker.postMessage({command: cmd, args: args});
  12550. };
  12551. this.call = function(cmd, args, callback) {
  12552. if (callback) {
  12553. var id = this.callbackId++;
  12554. this.callbacks[id] = callback;
  12555. args.push(id);
  12556. }
  12557. this.send(cmd, args);
  12558. };
  12559. this.emit = function(event, data) {
  12560. try {
  12561. // firefox refuses to clone objects which have function properties
  12562. // TODO: cleanup event
  12563. this.$worker.postMessage({event: event, data: {data: data.data}});
  12564. }
  12565. catch(ex) {}
  12566. };
  12567. this.attachToDocument = function(doc) {
  12568. if(this.$doc)
  12569. this.terminate();
  12570. this.$doc = doc;
  12571. this.call("setValue", [doc.getValue()]);
  12572. doc.on("change", this.changeListener);
  12573. };
  12574. this.changeListener = function(e) {
  12575. e.range = {
  12576. start: e.data.range.start,
  12577. end: e.data.range.end
  12578. };
  12579. this.emit("change", e);
  12580. };
  12581. }).call(WorkerClient.prototype);
  12582. exports.WorkerClient = WorkerClient;
  12583. });
  12584. ace.define('ace/keyboard/state_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
  12585. // If you're developing a new keymapping and want to get an idea what's going
  12586. // on, then enable debugging.
  12587. var DEBUG = false;
  12588. function StateHandler(keymapping) {
  12589. this.keymapping = this.$buildKeymappingRegex(keymapping);
  12590. }
  12591. StateHandler.prototype = {
  12592. /*
  12593. * Build the RegExp from the keymapping as RegExp can't stored directly
  12594. * in the metadata JSON and as the RegExp used to match the keys/buffer
  12595. * need to be adapted.
  12596. */
  12597. $buildKeymappingRegex: function(keymapping) {
  12598. for (var state in keymapping) {
  12599. this.$buildBindingsRegex(keymapping[state]);
  12600. }
  12601. return keymapping;
  12602. },
  12603. $buildBindingsRegex: function(bindings) {
  12604. // Escape a given Regex string.
  12605. bindings.forEach(function(binding) {
  12606. if (binding.key) {
  12607. binding.key = new RegExp('^' + binding.key + '$');
  12608. } else if (Array.isArray(binding.regex)) {
  12609. if (!('key' in binding))
  12610. binding.key = new RegExp('^' + binding.regex[1] + '$');
  12611. binding.regex = new RegExp(binding.regex.join('') + '$');
  12612. } else if (binding.regex) {
  12613. binding.regex = new RegExp(binding.regex + '$');
  12614. }
  12615. });
  12616. },
  12617. $composeBuffer: function(data, hashId, key, e) {
  12618. // Initialize the data object.
  12619. if (data.state == null || data.buffer == null) {
  12620. data.state = "start";
  12621. data.buffer = "";
  12622. }
  12623. var keyArray = [];
  12624. if (hashId & 1) keyArray.push("ctrl");
  12625. if (hashId & 8) keyArray.push("command");
  12626. if (hashId & 2) keyArray.push("option");
  12627. if (hashId & 4) keyArray.push("shift");
  12628. if (key) keyArray.push(key);
  12629. var symbolicName = keyArray.join("-");
  12630. var bufferToUse = data.buffer + symbolicName;
  12631. // Don't add the symbolic name to the key buffer if the alt_ key is
  12632. // part of the symbolic name. If it starts with alt_, this means
  12633. // that the user hit an alt keycombo and there will be a single,
  12634. // new character detected after this event, which then will be
  12635. // added to the buffer (e.g. alt_j will result in ∆).
  12636. //
  12637. // We test for 2 and not for & 2 as we only want to exclude the case where
  12638. // the option key is pressed alone.
  12639. if (hashId != 2) {
  12640. data.buffer = bufferToUse;
  12641. }
  12642. var bufferObj = {
  12643. bufferToUse: bufferToUse,
  12644. symbolicName: symbolicName,
  12645. };
  12646. if (e) {
  12647. bufferObj.keyIdentifier = e.keyIdentifier
  12648. }
  12649. return bufferObj;
  12650. },
  12651. $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
  12652. // Holds the command to execute and the args if a command matched.
  12653. var result = {};
  12654. // Loop over all the bindings of the keymap until a match is found.
  12655. this.keymapping[data.state].some(function(binding) {
  12656. var match;
  12657. // Check if the key matches.
  12658. if (binding.key && !binding.key.test(symbolicName)) {
  12659. return false;
  12660. }
  12661. // Check if the regex matches.
  12662. if (binding.regex && !(match = binding.regex.exec(buffer))) {
  12663. return false;
  12664. }
  12665. // Check if the match function matches.
  12666. if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
  12667. return false;
  12668. }
  12669. // Check for disallowed matches.
  12670. if (binding.disallowMatches) {
  12671. for (var i = 0; i < binding.disallowMatches.length; i++) {
  12672. if (!!match[binding.disallowMatches[i]]) {
  12673. return false;
  12674. }
  12675. }
  12676. }
  12677. // If there is a command to execute, then figure out the
  12678. // command and the arguments.
  12679. if (binding.exec) {
  12680. result.command = binding.exec;
  12681. // Build the arguments.
  12682. if (binding.params) {
  12683. var value;
  12684. result.args = {};
  12685. binding.params.forEach(function(param) {
  12686. if (param.match != null && match != null) {
  12687. value = match[param.match] || param.defaultValue;
  12688. } else {
  12689. value = param.defaultValue;
  12690. }
  12691. if (param.type === 'number') {
  12692. value = parseInt(value);
  12693. }
  12694. result.args[param.name] = value;
  12695. });
  12696. }
  12697. data.buffer = "";
  12698. }
  12699. // Handle the 'then' property.
  12700. if (binding.then) {
  12701. data.state = binding.then;
  12702. data.buffer = "";
  12703. }
  12704. // If no command is set, then execute the "null" fake command.
  12705. if (result.command == null) {
  12706. result.command = "null";
  12707. }
  12708. if (DEBUG) {
  12709. console.log("KeyboardStateMapper#find", binding);
  12710. }
  12711. return true;
  12712. });
  12713. if (result.command) {
  12714. return result;
  12715. } else {
  12716. data.buffer = "";
  12717. return false;
  12718. }
  12719. },
  12720. /*
  12721. * This function is called by keyBinding.
  12722. */
  12723. handleKeyboard: function(data, hashId, key, keyCode, e) {
  12724. if (hashId == -1)
  12725. hashId = 0
  12726. // If we pressed any command key but no other key, then ignore the input.
  12727. // Otherwise "shift-" is added to the buffer, and later on "shift-g"
  12728. // which results in "shift-shift-g" which doesn't make sense.
  12729. if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
  12730. return null;
  12731. }
  12732. // Compute the current value of the keyboard input buffer.
  12733. var r = this.$composeBuffer(data, hashId, key, e);
  12734. var buffer = r.bufferToUse;
  12735. var symbolicName = r.symbolicName;
  12736. var keyId = r.keyIdentifier;
  12737. r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
  12738. if (DEBUG) {
  12739. console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
  12740. }
  12741. return r;
  12742. }
  12743. }
  12744. /*
  12745. * This is a useful matching function and therefore is defined here so that
  12746. * users of KeyboardStateMapper can use it.
  12747. *
  12748. * @return boolean
  12749. * If no command key (Command|Option|Shift|Ctrl) is pressed, it
  12750. * returns true. If the only the Shift key is pressed + a character
  12751. * true is returned as well. Otherwise, false is returned.
  12752. * Summing up, the function returns true whenever the user typed
  12753. * a normal character on the keyboard and no shortcut.
  12754. */
  12755. exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
  12756. // If no command keys are pressed, then catch the input.
  12757. if (hashId == 0) {
  12758. return true;
  12759. }
  12760. // If only the shift key is pressed and a character key, then
  12761. // catch that input as well.
  12762. else if ((hashId == 4) && key.length == 1) {
  12763. return true;
  12764. }
  12765. // Otherwise, we let the input got through.
  12766. else {
  12767. return false;
  12768. }
  12769. };
  12770. exports.StateHandler = StateHandler;
  12771. });
  12772. ace.define('ace/placeholder', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/event_emitter', 'ace/lib/oop'], function(require, exports, module) {
  12773. var Range = require('./range').Range;
  12774. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12775. var oop = require("./lib/oop");
  12776. /**
  12777. * new PlaceHolder(session, length, pos, others, mainClass, othersClass)
  12778. * - session (Document): The document to associate with the anchor
  12779. * - length (Number): The starting row position
  12780. * - pos (Number): The starting column position
  12781. * - others (String):
  12782. * - mainClass (String):
  12783. * - othersClass (String):
  12784. *
  12785. * TODO
  12786. *
  12787. **/
  12788. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  12789. var _self = this;
  12790. this.length = length;
  12791. this.session = session;
  12792. this.doc = session.getDocument();
  12793. this.mainClass = mainClass;
  12794. this.othersClass = othersClass;
  12795. this.$onUpdate = this.onUpdate.bind(this);
  12796. this.doc.on("change", this.$onUpdate);
  12797. this.$others = others;
  12798. this.$onCursorChange = function() {
  12799. setTimeout(function() {
  12800. _self.onCursorChange();
  12801. });
  12802. };
  12803. this.$pos = pos;
  12804. // Used for reset
  12805. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  12806. this.$undoStackDepth = undoStack.length;
  12807. this.setup();
  12808. session.selection.on("changeCursor", this.$onCursorChange);
  12809. };
  12810. (function() {
  12811. oop.implement(this, EventEmitter);
  12812. this.setup = function() {
  12813. var _self = this;
  12814. var doc = this.doc;
  12815. var session = this.session;
  12816. var pos = this.$pos;
  12817. this.pos = doc.createAnchor(pos.row, pos.column);
  12818. this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  12819. this.pos.on("change", function(event) {
  12820. session.removeMarker(_self.markerId);
  12821. _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
  12822. });
  12823. this.others = [];
  12824. this.$others.forEach(function(other) {
  12825. var anchor = doc.createAnchor(other.row, other.column);
  12826. _self.others.push(anchor);
  12827. });
  12828. session.setUndoSelect(false);
  12829. };
  12830. this.showOtherMarkers = function() {
  12831. if(this.othersActive) return;
  12832. var session = this.session;
  12833. var _self = this;
  12834. this.othersActive = true;
  12835. this.others.forEach(function(anchor) {
  12836. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  12837. anchor.on("change", function(event) {
  12838. session.removeMarker(anchor.markerId);
  12839. anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
  12840. });
  12841. });
  12842. };
  12843. this.hideOtherMarkers = function() {
  12844. if(!this.othersActive) return;
  12845. this.othersActive = false;
  12846. for (var i = 0; i < this.others.length; i++) {
  12847. this.session.removeMarker(this.others[i].markerId);
  12848. }
  12849. };
  12850. this.onUpdate = function(event) {
  12851. var delta = event.data;
  12852. var range = delta.range;
  12853. if(range.start.row !== range.end.row) return;
  12854. if(range.start.row !== this.pos.row) return;
  12855. if (this.$updating) return;
  12856. this.$updating = true;
  12857. var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
  12858. if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
  12859. var distanceFromStart = range.start.column - this.pos.column;
  12860. this.length += lengthDiff;
  12861. if(!this.session.$fromUndo) {
  12862. if(delta.action === "insertText") {
  12863. for (var i = this.others.length - 1; i >= 0; i--) {
  12864. var otherPos = this.others[i];
  12865. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  12866. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  12867. newPos.column += lengthDiff;
  12868. this.doc.insert(newPos, delta.text);
  12869. }
  12870. } else if(delta.action === "removeText") {
  12871. for (var i = this.others.length - 1; i >= 0; i--) {
  12872. var otherPos = this.others[i];
  12873. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  12874. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  12875. newPos.column += lengthDiff;
  12876. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  12877. }
  12878. }
  12879. // Special case: insert in beginning
  12880. if(range.start.column === this.pos.column && delta.action === "insertText") {
  12881. setTimeout(function() {
  12882. this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
  12883. for (var i = 0; i < this.others.length; i++) {
  12884. var other = this.others[i];
  12885. var newPos = {row: other.row, column: other.column - lengthDiff};
  12886. if(other.row === range.start.row && range.start.column < other.column)
  12887. newPos.column += lengthDiff;
  12888. other.setPosition(newPos.row, newPos.column);
  12889. }
  12890. }.bind(this), 0);
  12891. }
  12892. else if(range.start.column === this.pos.column && delta.action === "removeText") {
  12893. setTimeout(function() {
  12894. for (var i = 0; i < this.others.length; i++) {
  12895. var other = this.others[i];
  12896. if(other.row === range.start.row && range.start.column < other.column) {
  12897. other.setPosition(other.row, other.column - lengthDiff);
  12898. }
  12899. }
  12900. }.bind(this), 0);
  12901. }
  12902. }
  12903. this.pos._emit("change", {value: this.pos});
  12904. for (var i = 0; i < this.others.length; i++) {
  12905. this.others[i]._emit("change", {value: this.others[i]});
  12906. }
  12907. }
  12908. this.$updating = false;
  12909. };
  12910. this.onCursorChange = function(event) {
  12911. if (this.$updating) return;
  12912. var pos = this.session.selection.getCursor();
  12913. if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  12914. this.showOtherMarkers();
  12915. this._emit("cursorEnter", event);
  12916. } else {
  12917. this.hideOtherMarkers();
  12918. this._emit("cursorLeave", event);
  12919. }
  12920. };
  12921. this.detach = function() {
  12922. this.session.removeMarker(this.markerId);
  12923. this.hideOtherMarkers();
  12924. this.doc.removeEventListener("change", this.$onUpdate);
  12925. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  12926. this.pos.detach();
  12927. for (var i = 0; i < this.others.length; i++) {
  12928. this.others[i].detach();
  12929. }
  12930. this.session.setUndoSelect(true);
  12931. };
  12932. this.cancel = function() {
  12933. if(this.$undoStackDepth === -1)
  12934. throw Error("Canceling placeholders only supported with undo manager attached to session.");
  12935. var undoManager = this.session.getUndoManager();
  12936. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  12937. for (var i = 0; i < undosRequired; i++) {
  12938. undoManager.undo(true);
  12939. }
  12940. };
  12941. }).call(PlaceHolder.prototype);
  12942. exports.PlaceHolder = PlaceHolder;
  12943. });
  12944. ace.define('ace/theme/textmate', ['require', 'exports', 'module' , 'text!ace/theme/textmate.css', 'ace/lib/dom'], function(require, exports, module) {
  12945. exports.isDark = false;
  12946. exports.cssClass = "ace-tm";
  12947. exports.cssText = require('text!./textmate.css');
  12948. var dom = require("../lib/dom");
  12949. dom.importCssString(exports.cssText, exports.cssClass);
  12950. });
  12951. ace.define("text!ace/theme/textmate.css", [], ".ace-tm .ace_editor {\n" +
  12952. " border: 2px solid rgb(159, 159, 159);\n" +
  12953. "}\n" +
  12954. "\n" +
  12955. ".ace-tm .ace_editor.ace_focus {\n" +
  12956. " border: 2px solid #327fbd;\n" +
  12957. "}\n" +
  12958. "\n" +
  12959. ".ace-tm .ace_gutter {\n" +
  12960. " background: #e8e8e8;\n" +
  12961. " color: #333;\n" +
  12962. "}\n" +
  12963. "\n" +
  12964. ".ace-tm .ace_print_margin {\n" +
  12965. " width: 1px;\n" +
  12966. " background: #e8e8e8;\n" +
  12967. "}\n" +
  12968. "\n" +
  12969. ".ace-tm .ace_fold {\n" +
  12970. " background-color: #6B72E6;\n" +
  12971. "}\n" +
  12972. "\n" +
  12973. ".ace-tm .ace_text-layer {\n" +
  12974. " cursor: text;\n" +
  12975. "}\n" +
  12976. "\n" +
  12977. ".ace-tm .ace_cursor {\n" +
  12978. " border-left: 2px solid black;\n" +
  12979. "}\n" +
  12980. "\n" +
  12981. ".ace-tm .ace_cursor.ace_overwrite {\n" +
  12982. " border-left: 0px;\n" +
  12983. " border-bottom: 1px solid black;\n" +
  12984. "}\n" +
  12985. " \n" +
  12986. ".ace-tm .ace_line .ace_invisible {\n" +
  12987. " color: rgb(191, 191, 191);\n" +
  12988. "}\n" +
  12989. "\n" +
  12990. ".ace-tm .ace_line .ace_storage,\n" +
  12991. ".ace-tm .ace_line .ace_keyword {\n" +
  12992. " color: blue;\n" +
  12993. "}\n" +
  12994. "\n" +
  12995. ".ace-tm .ace_line .ace_constant {\n" +
  12996. " color: rgb(197, 6, 11);\n" +
  12997. "}\n" +
  12998. "\n" +
  12999. ".ace-tm .ace_line .ace_constant.ace_buildin {\n" +
  13000. " color: rgb(88, 72, 246);\n" +
  13001. "}\n" +
  13002. "\n" +
  13003. ".ace-tm .ace_line .ace_constant.ace_language {\n" +
  13004. " color: rgb(88, 92, 246);\n" +
  13005. "}\n" +
  13006. "\n" +
  13007. ".ace-tm .ace_line .ace_constant.ace_library {\n" +
  13008. " color: rgb(6, 150, 14);\n" +
  13009. "}\n" +
  13010. "\n" +
  13011. ".ace-tm .ace_line .ace_invalid {\n" +
  13012. " background-color: rgba(255, 0, 0, 0.1);\n" +
  13013. " color: red;\n" +
  13014. "}\n" +
  13015. "\n" +
  13016. ".ace-tm .ace_line .ace_support.ace_function {\n" +
  13017. " color: rgb(60, 76, 114);\n" +
  13018. "}\n" +
  13019. "\n" +
  13020. ".ace-tm .ace_line .ace_support.ace_constant {\n" +
  13021. " color: rgb(6, 150, 14);\n" +
  13022. "}\n" +
  13023. "\n" +
  13024. ".ace-tm .ace_line .ace_support.ace_type,\n" +
  13025. ".ace-tm .ace_line .ace_support.ace_class {\n" +
  13026. " color: rgb(109, 121, 222);\n" +
  13027. "}\n" +
  13028. "\n" +
  13029. ".ace-tm .ace_line .ace_keyword.ace_operator {\n" +
  13030. " color: rgb(104, 118, 135);\n" +
  13031. "}\n" +
  13032. "\n" +
  13033. ".ace-tm .ace_line .ace_string {\n" +
  13034. " color: rgb(3, 106, 7);\n" +
  13035. "}\n" +
  13036. "\n" +
  13037. ".ace-tm .ace_line .ace_comment {\n" +
  13038. " color: rgb(76, 136, 107);\n" +
  13039. "}\n" +
  13040. "\n" +
  13041. ".ace-tm .ace_line .ace_comment.ace_doc {\n" +
  13042. " color: rgb(0, 102, 255);\n" +
  13043. "}\n" +
  13044. "\n" +
  13045. ".ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\n" +
  13046. " color: rgb(128, 159, 191);\n" +
  13047. "}\n" +
  13048. "\n" +
  13049. ".ace-tm .ace_line .ace_constant.ace_numeric {\n" +
  13050. " color: rgb(0, 0, 205);\n" +
  13051. "}\n" +
  13052. "\n" +
  13053. ".ace-tm .ace_line .ace_variable {\n" +
  13054. " color: rgb(49, 132, 149);\n" +
  13055. "}\n" +
  13056. "\n" +
  13057. ".ace-tm .ace_line .ace_xml_pe {\n" +
  13058. " color: rgb(104, 104, 91);\n" +
  13059. "}\n" +
  13060. "\n" +
  13061. ".ace-tm .ace_entity.ace_name.ace_function {\n" +
  13062. " color: #0000A2;\n" +
  13063. "}\n" +
  13064. "\n" +
  13065. ".ace-tm .ace_markup.ace_markupine {\n" +
  13066. " text-decoration:underline;\n" +
  13067. "}\n" +
  13068. "\n" +
  13069. ".ace-tm .ace_markup.ace_heading {\n" +
  13070. " color: rgb(12, 7, 255);\n" +
  13071. "}\n" +
  13072. "\n" +
  13073. ".ace-tm .ace_markup.ace_list {\n" +
  13074. " color:rgb(185, 6, 144);\n" +
  13075. "}\n" +
  13076. "\n" +
  13077. ".ace-tm .ace_marker-layer .ace_selection {\n" +
  13078. " background: rgb(181, 213, 255);\n" +
  13079. "}\n" +
  13080. ".ace-tm.multiselect .ace_selection.start {\n" +
  13081. " box-shadow: 0 0 3px 0px white;\n" +
  13082. " border-radius: 2px;\n" +
  13083. "}\n" +
  13084. ".ace-tm .ace_marker-layer .ace_step {\n" +
  13085. " background: rgb(252, 255, 0);\n" +
  13086. "}\n" +
  13087. "\n" +
  13088. ".ace-tm .ace_marker-layer .ace_stack {\n" +
  13089. " background: rgb(164, 229, 101);\n" +
  13090. "}\n" +
  13091. "\n" +
  13092. ".ace-tm .ace_marker-layer .ace_bracket {\n" +
  13093. " margin: -1px 0 0 -1px;\n" +
  13094. " border: 1px solid rgb(192, 192, 192);\n" +
  13095. "}\n" +
  13096. "\n" +
  13097. ".ace-tm .ace_marker-layer .ace_active_line {\n" +
  13098. " background: rgba(0, 0, 0, 0.07);\n" +
  13099. "}\n" +
  13100. ".ace-tm .ace_gutter_active_line{\n" +
  13101. " background-color : #dcdcdc;\n" +
  13102. "}\n" +
  13103. "\n" +
  13104. ".ace-tm .ace_marker-layer .ace_selected_word {\n" +
  13105. " background: rgb(250, 250, 255);\n" +
  13106. " border: 1px solid rgb(200, 200, 250);\n" +
  13107. "}\n" +
  13108. "\n" +
  13109. ".ace-tm .ace_meta.ace_tag {\n" +
  13110. " color:rgb(0, 50, 198);\n" +
  13111. "}\n" +
  13112. "\n" +
  13113. ".ace-tm .ace_string.ace_regex {\n" +
  13114. " color: rgb(255, 0, 0)\n" +
  13115. "}");
  13116. ;
  13117. (function() {
  13118. ace.require(["ace/ace"], function(a) {
  13119. a && a.config.init();
  13120. if (!window.ace)
  13121. window.ace = {};
  13122. for (var key in a) if (a.hasOwnProperty(key))
  13123. ace[key] = a[key];
  13124. });
  13125. })();
  13126. })(undefined, undefined, undefined);