ace.js 629 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /**
  31. * Define a module along with a payload
  32. * @param module a name for the payload
  33. * @param payload a function to call with (require, exports, module) params
  34. */
  35. (function() {
  36. var ACE_NAMESPACE = "";
  37. var global = (function() { return this; })();
  38. if (!global && typeof window != "undefined") global = window; // strict mode
  39. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  40. return;
  41. var define = function(module, deps, payload) {
  42. if (typeof module !== "string") {
  43. if (define.original)
  44. define.original.apply(this, arguments);
  45. else {
  46. console.error("dropping module because define wasn\'t a string.");
  47. console.trace();
  48. }
  49. return;
  50. }
  51. if (arguments.length == 2)
  52. payload = deps;
  53. if (!define.modules[module]) {
  54. define.payloads[module] = payload;
  55. define.modules[module] = null;
  56. }
  57. };
  58. define.modules = {};
  59. define.payloads = {};
  60. /**
  61. * Get at functionality define()ed using the function above
  62. */
  63. var _require = function(parentId, module, callback) {
  64. if (typeof module === "string") {
  65. var payload = lookup(parentId, module);
  66. if (payload != undefined) {
  67. callback && callback();
  68. return payload;
  69. }
  70. } else if (Object.prototype.toString.call(module) === "[object Array]") {
  71. var params = [];
  72. for (var i = 0, l = module.length; i < l; ++i) {
  73. var dep = lookup(parentId, module[i]);
  74. if (dep == undefined && require.original)
  75. return;
  76. params.push(dep);
  77. }
  78. return callback && callback.apply(null, params) || true;
  79. }
  80. };
  81. var require = function(module, callback) {
  82. var packagedModule = _require("", module, callback);
  83. if (packagedModule == undefined && require.original)
  84. return require.original.apply(this, arguments);
  85. return packagedModule;
  86. };
  87. var normalizeModule = function(parentId, moduleName) {
  88. // normalize plugin requires
  89. if (moduleName.indexOf("!") !== -1) {
  90. var chunks = moduleName.split("!");
  91. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  92. }
  93. // normalize relative requires
  94. if (moduleName.charAt(0) == ".") {
  95. var base = parentId.split("/").slice(0, -1).join("/");
  96. moduleName = base + "/" + moduleName;
  97. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  98. var previous = moduleName;
  99. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  100. }
  101. }
  102. return moduleName;
  103. };
  104. /**
  105. * Internal function to lookup moduleNames and resolve them by calling the
  106. * definition function if needed.
  107. */
  108. var lookup = function(parentId, moduleName) {
  109. moduleName = normalizeModule(parentId, moduleName);
  110. var module = define.modules[moduleName];
  111. if (!module) {
  112. module = define.payloads[moduleName];
  113. if (typeof module === 'function') {
  114. var exports = {};
  115. var mod = {
  116. id: moduleName,
  117. uri: '',
  118. exports: exports,
  119. packaged: true
  120. };
  121. var req = function(module, callback) {
  122. return _require(moduleName, module, callback);
  123. };
  124. var returnValue = module(req, exports, mod);
  125. exports = returnValue || mod.exports;
  126. define.modules[moduleName] = exports;
  127. delete define.payloads[moduleName];
  128. }
  129. module = define.modules[moduleName] = exports || module;
  130. }
  131. return module;
  132. };
  133. function exportAce(ns) {
  134. var root = global;
  135. if (ns) {
  136. if (!global[ns])
  137. global[ns] = {};
  138. root = global[ns];
  139. }
  140. if (!root.define || !root.define.packaged) {
  141. define.original = root.define;
  142. root.define = define;
  143. root.define.packaged = true;
  144. }
  145. if (!root.require || !root.require.packaged) {
  146. require.original = root.require;
  147. root.require = require;
  148. root.require.packaged = true;
  149. }
  150. }
  151. exportAce(ACE_NAMESPACE);
  152. })();
  153. define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  154. "use strict";
  155. var real = {
  156. exec: RegExp.prototype.exec,
  157. test: RegExp.prototype.test,
  158. match: String.prototype.match,
  159. replace: String.prototype.replace,
  160. split: String.prototype.split
  161. },
  162. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  163. compliantLastIndexIncrement = function () {
  164. var x = /^/g;
  165. real.test.call(x, "");
  166. return !x.lastIndex;
  167. }();
  168. if (compliantLastIndexIncrement && compliantExecNpcg)
  169. return;
  170. RegExp.prototype.exec = function (str) {
  171. var match = real.exec.apply(this, arguments),
  172. name, r2;
  173. if ( typeof(str) == 'string' && match) {
  174. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  175. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  176. real.replace.call(str.slice(match.index), r2, function () {
  177. for (var i = 1; i < arguments.length - 2; i++) {
  178. if (arguments[i] === undefined)
  179. match[i] = undefined;
  180. }
  181. });
  182. }
  183. if (this._xregexp && this._xregexp.captureNames) {
  184. for (var i = 1; i < match.length; i++) {
  185. name = this._xregexp.captureNames[i - 1];
  186. if (name)
  187. match[name] = match[i];
  188. }
  189. }
  190. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  191. this.lastIndex--;
  192. }
  193. return match;
  194. };
  195. if (!compliantLastIndexIncrement) {
  196. RegExp.prototype.test = function (str) {
  197. var match = real.exec.call(this, str);
  198. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  199. this.lastIndex--;
  200. return !!match;
  201. };
  202. }
  203. function getNativeFlags (regex) {
  204. return (regex.global ? "g" : "") +
  205. (regex.ignoreCase ? "i" : "") +
  206. (regex.multiline ? "m" : "") +
  207. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  208. (regex.sticky ? "y" : "");
  209. }
  210. function indexOf (array, item, from) {
  211. if (Array.prototype.indexOf) // Use the native array method if available
  212. return array.indexOf(item, from);
  213. for (var i = from || 0; i < array.length; i++) {
  214. if (array[i] === item)
  215. return i;
  216. }
  217. return -1;
  218. }
  219. });
  220. define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  221. function Empty() {}
  222. if (!Function.prototype.bind) {
  223. Function.prototype.bind = function bind(that) { // .length is 1
  224. var target = this;
  225. if (typeof target != "function") {
  226. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  227. }
  228. var args = slice.call(arguments, 1); // for normal call
  229. var bound = function () {
  230. if (this instanceof bound) {
  231. var result = target.apply(
  232. this,
  233. args.concat(slice.call(arguments))
  234. );
  235. if (Object(result) === result) {
  236. return result;
  237. }
  238. return this;
  239. } else {
  240. return target.apply(
  241. that,
  242. args.concat(slice.call(arguments))
  243. );
  244. }
  245. };
  246. if(target.prototype) {
  247. Empty.prototype = target.prototype;
  248. bound.prototype = new Empty();
  249. Empty.prototype = null;
  250. }
  251. return bound;
  252. };
  253. }
  254. var call = Function.prototype.call;
  255. var prototypeOfArray = Array.prototype;
  256. var prototypeOfObject = Object.prototype;
  257. var slice = prototypeOfArray.slice;
  258. var _toString = call.bind(prototypeOfObject.toString);
  259. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  260. var defineGetter;
  261. var defineSetter;
  262. var lookupGetter;
  263. var lookupSetter;
  264. var supportsAccessors;
  265. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  266. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  267. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  268. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  269. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  270. }
  271. if ([1,2].splice(0).length != 2) {
  272. if(function() { // test IE < 9 to splice bug - see issue #138
  273. function makeArray(l) {
  274. var a = new Array(l+2);
  275. a[0] = a[1] = 0;
  276. return a;
  277. }
  278. var array = [], lengthBefore;
  279. array.splice.apply(array, makeArray(20));
  280. array.splice.apply(array, makeArray(26));
  281. lengthBefore = array.length; //46
  282. array.splice(5, 0, "XXX"); // add one element
  283. lengthBefore + 1 == array.length
  284. if (lengthBefore + 1 == array.length) {
  285. return true;// has right splice implementation without bugs
  286. }
  287. }()) {//IE 6/7
  288. var array_splice = Array.prototype.splice;
  289. Array.prototype.splice = function(start, deleteCount) {
  290. if (!arguments.length) {
  291. return [];
  292. } else {
  293. return array_splice.apply(this, [
  294. start === void 0 ? 0 : start,
  295. deleteCount === void 0 ? (this.length - start) : deleteCount
  296. ].concat(slice.call(arguments, 2)))
  297. }
  298. };
  299. } else {//IE8
  300. Array.prototype.splice = function(pos, removeCount){
  301. var length = this.length;
  302. if (pos > 0) {
  303. if (pos > length)
  304. pos = length;
  305. } else if (pos == void 0) {
  306. pos = 0;
  307. } else if (pos < 0) {
  308. pos = Math.max(length + pos, 0);
  309. }
  310. if (!(pos+removeCount < length))
  311. removeCount = length - pos;
  312. var removed = this.slice(pos, pos+removeCount);
  313. var insert = slice.call(arguments, 2);
  314. var add = insert.length;
  315. if (pos === length) {
  316. if (add) {
  317. this.push.apply(this, insert);
  318. }
  319. } else {
  320. var remove = Math.min(removeCount, length - pos);
  321. var tailOldPos = pos + remove;
  322. var tailNewPos = tailOldPos + add - remove;
  323. var tailCount = length - tailOldPos;
  324. var lengthAfterRemove = length - remove;
  325. if (tailNewPos < tailOldPos) { // case A
  326. for (var i = 0; i < tailCount; ++i) {
  327. this[tailNewPos+i] = this[tailOldPos+i];
  328. }
  329. } else if (tailNewPos > tailOldPos) { // case B
  330. for (i = tailCount; i--; ) {
  331. this[tailNewPos+i] = this[tailOldPos+i];
  332. }
  333. } // else, add == remove (nothing to do)
  334. if (add && pos === lengthAfterRemove) {
  335. this.length = lengthAfterRemove; // truncate array
  336. this.push.apply(this, insert);
  337. } else {
  338. this.length = lengthAfterRemove + add; // reserves space
  339. for (i = 0; i < add; ++i) {
  340. this[pos+i] = insert[i];
  341. }
  342. }
  343. }
  344. return removed;
  345. };
  346. }
  347. }
  348. if (!Array.isArray) {
  349. Array.isArray = function isArray(obj) {
  350. return _toString(obj) == "[object Array]";
  351. };
  352. }
  353. var boxedString = Object("a"),
  354. splitString = boxedString[0] != "a" || !(0 in boxedString);
  355. if (!Array.prototype.forEach) {
  356. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. thisp = arguments[1],
  362. i = -1,
  363. length = self.length >>> 0;
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(); // TODO message
  366. }
  367. while (++i < length) {
  368. if (i in self) {
  369. fun.call(thisp, self[i], i, object);
  370. }
  371. }
  372. };
  373. }
  374. if (!Array.prototype.map) {
  375. Array.prototype.map = function map(fun /*, thisp*/) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = Array(length),
  382. thisp = arguments[1];
  383. if (_toString(fun) != "[object Function]") {
  384. throw new TypeError(fun + " is not a function");
  385. }
  386. for (var i = 0; i < length; i++) {
  387. if (i in self)
  388. result[i] = fun.call(thisp, self[i], i, object);
  389. }
  390. return result;
  391. };
  392. }
  393. if (!Array.prototype.filter) {
  394. Array.prototype.filter = function filter(fun /*, thisp */) {
  395. var object = toObject(this),
  396. self = splitString && _toString(this) == "[object String]" ?
  397. this.split("") :
  398. object,
  399. length = self.length >>> 0,
  400. result = [],
  401. value,
  402. thisp = arguments[1];
  403. if (_toString(fun) != "[object Function]") {
  404. throw new TypeError(fun + " is not a function");
  405. }
  406. for (var i = 0; i < length; i++) {
  407. if (i in self) {
  408. value = self[i];
  409. if (fun.call(thisp, value, i, object)) {
  410. result.push(value);
  411. }
  412. }
  413. }
  414. return result;
  415. };
  416. }
  417. if (!Array.prototype.every) {
  418. Array.prototype.every = function every(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && !fun.call(thisp, self[i], i, object)) {
  430. return false;
  431. }
  432. }
  433. return true;
  434. };
  435. }
  436. if (!Array.prototype.some) {
  437. Array.prototype.some = function some(fun /*, thisp */) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0,
  443. thisp = arguments[1];
  444. if (_toString(fun) != "[object Function]") {
  445. throw new TypeError(fun + " is not a function");
  446. }
  447. for (var i = 0; i < length; i++) {
  448. if (i in self && fun.call(thisp, self[i], i, object)) {
  449. return true;
  450. }
  451. }
  452. return false;
  453. };
  454. }
  455. if (!Array.prototype.reduce) {
  456. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  457. var object = toObject(this),
  458. self = splitString && _toString(this) == "[object String]" ?
  459. this.split("") :
  460. object,
  461. length = self.length >>> 0;
  462. if (_toString(fun) != "[object Function]") {
  463. throw new TypeError(fun + " is not a function");
  464. }
  465. if (!length && arguments.length == 1) {
  466. throw new TypeError("reduce of empty array with no initial value");
  467. }
  468. var i = 0;
  469. var result;
  470. if (arguments.length >= 2) {
  471. result = arguments[1];
  472. } else {
  473. do {
  474. if (i in self) {
  475. result = self[i++];
  476. break;
  477. }
  478. if (++i >= length) {
  479. throw new TypeError("reduce of empty array with no initial value");
  480. }
  481. } while (true);
  482. }
  483. for (; i < length; i++) {
  484. if (i in self) {
  485. result = fun.call(void 0, result, self[i], i, object);
  486. }
  487. }
  488. return result;
  489. };
  490. }
  491. if (!Array.prototype.reduceRight) {
  492. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  493. var object = toObject(this),
  494. self = splitString && _toString(this) == "[object String]" ?
  495. this.split("") :
  496. object,
  497. length = self.length >>> 0;
  498. if (_toString(fun) != "[object Function]") {
  499. throw new TypeError(fun + " is not a function");
  500. }
  501. if (!length && arguments.length == 1) {
  502. throw new TypeError("reduceRight of empty array with no initial value");
  503. }
  504. var result, i = length - 1;
  505. if (arguments.length >= 2) {
  506. result = arguments[1];
  507. } else {
  508. do {
  509. if (i in self) {
  510. result = self[i--];
  511. break;
  512. }
  513. if (--i < 0) {
  514. throw new TypeError("reduceRight of empty array with no initial value");
  515. }
  516. } while (true);
  517. }
  518. do {
  519. if (i in this) {
  520. result = fun.call(void 0, result, self[i], i, object);
  521. }
  522. } while (i--);
  523. return result;
  524. };
  525. }
  526. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  527. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  528. var self = splitString && _toString(this) == "[object String]" ?
  529. this.split("") :
  530. toObject(this),
  531. length = self.length >>> 0;
  532. if (!length) {
  533. return -1;
  534. }
  535. var i = 0;
  536. if (arguments.length > 1) {
  537. i = toInteger(arguments[1]);
  538. }
  539. i = i >= 0 ? i : Math.max(0, length + i);
  540. for (; i < length; i++) {
  541. if (i in self && self[i] === sought) {
  542. return i;
  543. }
  544. }
  545. return -1;
  546. };
  547. }
  548. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  549. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  550. var self = splitString && _toString(this) == "[object String]" ?
  551. this.split("") :
  552. toObject(this),
  553. length = self.length >>> 0;
  554. if (!length) {
  555. return -1;
  556. }
  557. var i = length - 1;
  558. if (arguments.length > 1) {
  559. i = Math.min(i, toInteger(arguments[1]));
  560. }
  561. i = i >= 0 ? i : length - Math.abs(i);
  562. for (; i >= 0; i--) {
  563. if (i in self && sought === self[i]) {
  564. return i;
  565. }
  566. }
  567. return -1;
  568. };
  569. }
  570. if (!Object.getPrototypeOf) {
  571. Object.getPrototypeOf = function getPrototypeOf(object) {
  572. return object.__proto__ || (
  573. object.constructor ?
  574. object.constructor.prototype :
  575. prototypeOfObject
  576. );
  577. };
  578. }
  579. if (!Object.getOwnPropertyDescriptor) {
  580. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  581. "non-object: ";
  582. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  583. if ((typeof object != "object" && typeof object != "function") || object === null)
  584. throw new TypeError(ERR_NON_OBJECT + object);
  585. if (!owns(object, property))
  586. return;
  587. var descriptor, getter, setter;
  588. descriptor = { enumerable: true, configurable: true };
  589. if (supportsAccessors) {
  590. var prototype = object.__proto__;
  591. object.__proto__ = prototypeOfObject;
  592. var getter = lookupGetter(object, property);
  593. var setter = lookupSetter(object, property);
  594. object.__proto__ = prototype;
  595. if (getter || setter) {
  596. if (getter) descriptor.get = getter;
  597. if (setter) descriptor.set = setter;
  598. return descriptor;
  599. }
  600. }
  601. descriptor.value = object[property];
  602. return descriptor;
  603. };
  604. }
  605. if (!Object.getOwnPropertyNames) {
  606. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  607. return Object.keys(object);
  608. };
  609. }
  610. if (!Object.create) {
  611. var createEmpty;
  612. if (Object.prototype.__proto__ === null) {
  613. createEmpty = function () {
  614. return { "__proto__": null };
  615. };
  616. } else {
  617. createEmpty = function () {
  618. var empty = {};
  619. for (var i in empty)
  620. empty[i] = null;
  621. empty.constructor =
  622. empty.hasOwnProperty =
  623. empty.propertyIsEnumerable =
  624. empty.isPrototypeOf =
  625. empty.toLocaleString =
  626. empty.toString =
  627. empty.valueOf =
  628. empty.__proto__ = null;
  629. return empty;
  630. }
  631. }
  632. Object.create = function create(prototype, properties) {
  633. var object;
  634. if (prototype === null) {
  635. object = createEmpty();
  636. } else {
  637. if (typeof prototype != "object")
  638. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  639. var Type = function () {};
  640. Type.prototype = prototype;
  641. object = new Type();
  642. object.__proto__ = prototype;
  643. }
  644. if (properties !== void 0)
  645. Object.defineProperties(object, properties);
  646. return object;
  647. };
  648. }
  649. function doesDefinePropertyWork(object) {
  650. try {
  651. Object.defineProperty(object, "sentinel", {});
  652. return "sentinel" in object;
  653. } catch (exception) {
  654. }
  655. }
  656. if (Object.defineProperty) {
  657. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  658. var definePropertyWorksOnDom = typeof document == "undefined" ||
  659. doesDefinePropertyWork(document.createElement("div"));
  660. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  661. var definePropertyFallback = Object.defineProperty;
  662. }
  663. }
  664. if (!Object.defineProperty || definePropertyFallback) {
  665. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  666. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  667. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  668. "on this javascript engine";
  669. Object.defineProperty = function defineProperty(object, property, descriptor) {
  670. if ((typeof object != "object" && typeof object != "function") || object === null)
  671. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  672. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  673. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  674. if (definePropertyFallback) {
  675. try {
  676. return definePropertyFallback.call(Object, object, property, descriptor);
  677. } catch (exception) {
  678. }
  679. }
  680. if (owns(descriptor, "value")) {
  681. if (supportsAccessors && (lookupGetter(object, property) ||
  682. lookupSetter(object, property)))
  683. {
  684. var prototype = object.__proto__;
  685. object.__proto__ = prototypeOfObject;
  686. delete object[property];
  687. object[property] = descriptor.value;
  688. object.__proto__ = prototype;
  689. } else {
  690. object[property] = descriptor.value;
  691. }
  692. } else {
  693. if (!supportsAccessors)
  694. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  695. if (owns(descriptor, "get"))
  696. defineGetter(object, property, descriptor.get);
  697. if (owns(descriptor, "set"))
  698. defineSetter(object, property, descriptor.set);
  699. }
  700. return object;
  701. };
  702. }
  703. if (!Object.defineProperties) {
  704. Object.defineProperties = function defineProperties(object, properties) {
  705. for (var property in properties) {
  706. if (owns(properties, property))
  707. Object.defineProperty(object, property, properties[property]);
  708. }
  709. return object;
  710. };
  711. }
  712. if (!Object.seal) {
  713. Object.seal = function seal(object) {
  714. return object;
  715. };
  716. }
  717. if (!Object.freeze) {
  718. Object.freeze = function freeze(object) {
  719. return object;
  720. };
  721. }
  722. try {
  723. Object.freeze(function () {});
  724. } catch (exception) {
  725. Object.freeze = (function freeze(freezeObject) {
  726. return function freeze(object) {
  727. if (typeof object == "function") {
  728. return object;
  729. } else {
  730. return freezeObject(object);
  731. }
  732. };
  733. })(Object.freeze);
  734. }
  735. if (!Object.preventExtensions) {
  736. Object.preventExtensions = function preventExtensions(object) {
  737. return object;
  738. };
  739. }
  740. if (!Object.isSealed) {
  741. Object.isSealed = function isSealed(object) {
  742. return false;
  743. };
  744. }
  745. if (!Object.isFrozen) {
  746. Object.isFrozen = function isFrozen(object) {
  747. return false;
  748. };
  749. }
  750. if (!Object.isExtensible) {
  751. Object.isExtensible = function isExtensible(object) {
  752. if (Object(object) === object) {
  753. throw new TypeError(); // TODO message
  754. }
  755. var name = '';
  756. while (owns(object, name)) {
  757. name += '?';
  758. }
  759. object[name] = true;
  760. var returnValue = owns(object, name);
  761. delete object[name];
  762. return returnValue;
  763. };
  764. }
  765. if (!Object.keys) {
  766. var hasDontEnumBug = true,
  767. dontEnums = [
  768. "toString",
  769. "toLocaleString",
  770. "valueOf",
  771. "hasOwnProperty",
  772. "isPrototypeOf",
  773. "propertyIsEnumerable",
  774. "constructor"
  775. ],
  776. dontEnumsLength = dontEnums.length;
  777. for (var key in {"toString": null}) {
  778. hasDontEnumBug = false;
  779. }
  780. Object.keys = function keys(object) {
  781. if (
  782. (typeof object != "object" && typeof object != "function") ||
  783. object === null
  784. ) {
  785. throw new TypeError("Object.keys called on a non-object");
  786. }
  787. var keys = [];
  788. for (var name in object) {
  789. if (owns(object, name)) {
  790. keys.push(name);
  791. }
  792. }
  793. if (hasDontEnumBug) {
  794. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  795. var dontEnum = dontEnums[i];
  796. if (owns(object, dontEnum)) {
  797. keys.push(dontEnum);
  798. }
  799. }
  800. }
  801. return keys;
  802. };
  803. }
  804. if (!Date.now) {
  805. Date.now = function now() {
  806. return new Date().getTime();
  807. };
  808. }
  809. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  810. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  811. "\u2029\uFEFF";
  812. if (!String.prototype.trim || ws.trim()) {
  813. ws = "[" + ws + "]";
  814. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  815. trimEndRegexp = new RegExp(ws + ws + "*$");
  816. String.prototype.trim = function trim() {
  817. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  818. };
  819. }
  820. function toInteger(n) {
  821. n = +n;
  822. if (n !== n) { // isNaN
  823. n = 0;
  824. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  825. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  826. }
  827. return n;
  828. }
  829. function isPrimitive(input) {
  830. var type = typeof input;
  831. return (
  832. input === null ||
  833. type === "undefined" ||
  834. type === "boolean" ||
  835. type === "number" ||
  836. type === "string"
  837. );
  838. }
  839. function toPrimitive(input) {
  840. var val, valueOf, toString;
  841. if (isPrimitive(input)) {
  842. return input;
  843. }
  844. valueOf = input.valueOf;
  845. if (typeof valueOf === "function") {
  846. val = valueOf.call(input);
  847. if (isPrimitive(val)) {
  848. return val;
  849. }
  850. }
  851. toString = input.toString;
  852. if (typeof toString === "function") {
  853. val = toString.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. throw new TypeError();
  859. }
  860. var toObject = function (o) {
  861. if (o == null) { // this matches both null and undefined
  862. throw new TypeError("can't convert "+o+" to object");
  863. }
  864. return Object(o);
  865. };
  866. });
  867. define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  868. "use strict";
  869. require("./regexp");
  870. require("./es5-shim");
  871. });
  872. define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  873. "use strict";
  874. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  875. exports.getDocumentHead = function(doc) {
  876. if (!doc)
  877. doc = document;
  878. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  879. };
  880. exports.createElement = function(tag, ns) {
  881. return document.createElementNS ?
  882. document.createElementNS(ns || XHTML_NS, tag) :
  883. document.createElement(tag);
  884. };
  885. exports.hasCssClass = function(el, name) {
  886. var classes = (el.className || "").split(/\s+/g);
  887. return classes.indexOf(name) !== -1;
  888. };
  889. exports.addCssClass = function(el, name) {
  890. if (!exports.hasCssClass(el, name)) {
  891. el.className += " " + name;
  892. }
  893. };
  894. exports.removeCssClass = function(el, name) {
  895. var classes = el.className.split(/\s+/g);
  896. while (true) {
  897. var index = classes.indexOf(name);
  898. if (index == -1) {
  899. break;
  900. }
  901. classes.splice(index, 1);
  902. }
  903. el.className = classes.join(" ");
  904. };
  905. exports.toggleCssClass = function(el, name) {
  906. var classes = el.className.split(/\s+/g), add = true;
  907. while (true) {
  908. var index = classes.indexOf(name);
  909. if (index == -1) {
  910. break;
  911. }
  912. add = false;
  913. classes.splice(index, 1);
  914. }
  915. if (add)
  916. classes.push(name);
  917. el.className = classes.join(" ");
  918. return add;
  919. };
  920. exports.setCssClass = function(node, className, include) {
  921. if (include) {
  922. exports.addCssClass(node, className);
  923. } else {
  924. exports.removeCssClass(node, className);
  925. }
  926. };
  927. exports.hasCssString = function(id, doc) {
  928. var index = 0, sheets;
  929. doc = doc || document;
  930. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  931. while (index < sheets.length)
  932. if (sheets[index++].owningElement.id === id) return true;
  933. } else if ((sheets = doc.getElementsByTagName("style"))) {
  934. while (index < sheets.length)
  935. if (sheets[index++].id === id) return true;
  936. }
  937. return false;
  938. };
  939. exports.importCssString = function importCssString(cssText, id, doc) {
  940. doc = doc || document;
  941. if (id && exports.hasCssString(id, doc))
  942. return null;
  943. var style;
  944. if (id)
  945. cssText += "\n/*# sourceURL=ace/css/" + id + " */";
  946. if (doc.createStyleSheet) {
  947. style = doc.createStyleSheet();
  948. style.cssText = cssText;
  949. if (id)
  950. style.owningElement.id = id;
  951. } else {
  952. style = exports.createElement("style");
  953. style.appendChild(doc.createTextNode(cssText));
  954. if (id)
  955. style.id = id;
  956. exports.getDocumentHead(doc).appendChild(style);
  957. }
  958. };
  959. exports.importCssStylsheet = function(uri, doc) {
  960. if (doc.createStyleSheet) {
  961. doc.createStyleSheet(uri);
  962. } else {
  963. var link = exports.createElement('link');
  964. link.rel = 'stylesheet';
  965. link.href = uri;
  966. exports.getDocumentHead(doc).appendChild(link);
  967. }
  968. };
  969. exports.getInnerWidth = function(element) {
  970. return (
  971. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  972. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  973. element.clientWidth
  974. );
  975. };
  976. exports.getInnerHeight = function(element) {
  977. return (
  978. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  979. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  980. element.clientHeight
  981. );
  982. };
  983. exports.scrollbarWidth = function(document) {
  984. var inner = exports.createElement("ace_inner");
  985. inner.style.width = "100%";
  986. inner.style.minWidth = "0px";
  987. inner.style.height = "200px";
  988. inner.style.display = "block";
  989. var outer = exports.createElement("ace_outer");
  990. var style = outer.style;
  991. style.position = "absolute";
  992. style.left = "-10000px";
  993. style.overflow = "hidden";
  994. style.width = "200px";
  995. style.minWidth = "0px";
  996. style.height = "150px";
  997. style.display = "block";
  998. outer.appendChild(inner);
  999. var body = document.documentElement;
  1000. body.appendChild(outer);
  1001. var noScrollbar = inner.offsetWidth;
  1002. style.overflow = "scroll";
  1003. var withScrollbar = inner.offsetWidth;
  1004. if (noScrollbar == withScrollbar) {
  1005. withScrollbar = outer.clientWidth;
  1006. }
  1007. body.removeChild(outer);
  1008. return noScrollbar-withScrollbar;
  1009. };
  1010. if (typeof document == "undefined") {
  1011. exports.importCssString = function() {};
  1012. return;
  1013. }
  1014. if (window.pageYOffset !== undefined) {
  1015. exports.getPageScrollTop = function() {
  1016. return window.pageYOffset;
  1017. };
  1018. exports.getPageScrollLeft = function() {
  1019. return window.pageXOffset;
  1020. };
  1021. }
  1022. else {
  1023. exports.getPageScrollTop = function() {
  1024. return document.body.scrollTop;
  1025. };
  1026. exports.getPageScrollLeft = function() {
  1027. return document.body.scrollLeft;
  1028. };
  1029. }
  1030. if (window.getComputedStyle)
  1031. exports.computedStyle = function(element, style) {
  1032. if (style)
  1033. return (window.getComputedStyle(element, "") || {})[style] || "";
  1034. return window.getComputedStyle(element, "") || {};
  1035. };
  1036. else
  1037. exports.computedStyle = function(element, style) {
  1038. if (style)
  1039. return element.currentStyle[style];
  1040. return element.currentStyle;
  1041. };
  1042. exports.setInnerHtml = function(el, innerHtml) {
  1043. var element = el.cloneNode(false);//document.createElement("div");
  1044. element.innerHTML = innerHtml;
  1045. el.parentNode.replaceChild(element, el);
  1046. return element;
  1047. };
  1048. if ("textContent" in document.documentElement) {
  1049. exports.setInnerText = function(el, innerText) {
  1050. el.textContent = innerText;
  1051. };
  1052. exports.getInnerText = function(el) {
  1053. return el.textContent;
  1054. };
  1055. }
  1056. else {
  1057. exports.setInnerText = function(el, innerText) {
  1058. el.innerText = innerText;
  1059. };
  1060. exports.getInnerText = function(el) {
  1061. return el.innerText;
  1062. };
  1063. }
  1064. exports.getParentWindow = function(document) {
  1065. return document.defaultView || document.parentWindow;
  1066. };
  1067. });
  1068. define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1069. "use strict";
  1070. exports.inherits = function(ctor, superCtor) {
  1071. ctor.super_ = superCtor;
  1072. ctor.prototype = Object.create(superCtor.prototype, {
  1073. constructor: {
  1074. value: ctor,
  1075. enumerable: false,
  1076. writable: true,
  1077. configurable: true
  1078. }
  1079. });
  1080. };
  1081. exports.mixin = function(obj, mixin) {
  1082. for (var key in mixin) {
  1083. obj[key] = mixin[key];
  1084. }
  1085. return obj;
  1086. };
  1087. exports.implement = function(proto, mixin) {
  1088. exports.mixin(proto, mixin);
  1089. };
  1090. });
  1091. define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1092. "use strict";
  1093. require("./fixoldbrowsers");
  1094. var oop = require("./oop");
  1095. var Keys = (function() {
  1096. var ret = {
  1097. MODIFIER_KEYS: {
  1098. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1099. },
  1100. KEY_MODS: {
  1101. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1102. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1103. },
  1104. FUNCTION_KEYS : {
  1105. 8 : "Backspace",
  1106. 9 : "Tab",
  1107. 13 : "Return",
  1108. 19 : "Pause",
  1109. 27 : "Esc",
  1110. 32 : "Space",
  1111. 33 : "PageUp",
  1112. 34 : "PageDown",
  1113. 35 : "End",
  1114. 36 : "Home",
  1115. 37 : "Left",
  1116. 38 : "Up",
  1117. 39 : "Right",
  1118. 40 : "Down",
  1119. 44 : "Print",
  1120. 45 : "Insert",
  1121. 46 : "Delete",
  1122. 96 : "Numpad0",
  1123. 97 : "Numpad1",
  1124. 98 : "Numpad2",
  1125. 99 : "Numpad3",
  1126. 100: "Numpad4",
  1127. 101: "Numpad5",
  1128. 102: "Numpad6",
  1129. 103: "Numpad7",
  1130. 104: "Numpad8",
  1131. 105: "Numpad9",
  1132. '-13': "NumpadEnter",
  1133. 112: "F1",
  1134. 113: "F2",
  1135. 114: "F3",
  1136. 115: "F4",
  1137. 116: "F5",
  1138. 117: "F6",
  1139. 118: "F7",
  1140. 119: "F8",
  1141. 120: "F9",
  1142. 121: "F10",
  1143. 122: "F11",
  1144. 123: "F12",
  1145. 144: "Numlock",
  1146. 145: "Scrolllock"
  1147. },
  1148. PRINTABLE_KEYS: {
  1149. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1150. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1151. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1152. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1153. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1154. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1155. 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
  1156. 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*'
  1157. }
  1158. };
  1159. var name, i;
  1160. for (i in ret.FUNCTION_KEYS) {
  1161. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1162. ret[name] = parseInt(i, 10);
  1163. }
  1164. for (i in ret.PRINTABLE_KEYS) {
  1165. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1166. ret[name] = parseInt(i, 10);
  1167. }
  1168. oop.mixin(ret, ret.MODIFIER_KEYS);
  1169. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1170. oop.mixin(ret, ret.FUNCTION_KEYS);
  1171. ret.enter = ret["return"];
  1172. ret.escape = ret.esc;
  1173. ret.del = ret["delete"];
  1174. ret[173] = '-';
  1175. (function() {
  1176. var mods = ["cmd", "ctrl", "alt", "shift"];
  1177. for (var i = Math.pow(2, mods.length); i--;) {
  1178. ret.KEY_MODS[i] = mods.filter(function(x) {
  1179. return i & ret.KEY_MODS[x];
  1180. }).join("-") + "-";
  1181. }
  1182. })();
  1183. ret.KEY_MODS[0] = "";
  1184. ret.KEY_MODS[-1] = "input-";
  1185. return ret;
  1186. })();
  1187. oop.mixin(exports, Keys);
  1188. exports.keyCodeToString = function(keyCode) {
  1189. var keyString = Keys[keyCode];
  1190. if (typeof keyString != "string")
  1191. keyString = String.fromCharCode(keyCode);
  1192. return keyString.toLowerCase();
  1193. };
  1194. });
  1195. define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1196. "use strict";
  1197. exports.OS = {
  1198. LINUX: "LINUX",
  1199. MAC: "MAC",
  1200. WINDOWS: "WINDOWS"
  1201. };
  1202. exports.getOS = function() {
  1203. if (exports.isMac) {
  1204. return exports.OS.MAC;
  1205. } else if (exports.isLinux) {
  1206. return exports.OS.LINUX;
  1207. } else {
  1208. return exports.OS.WINDOWS;
  1209. }
  1210. };
  1211. if (typeof navigator != "object")
  1212. return;
  1213. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1214. var ua = navigator.userAgent;
  1215. exports.isWin = (os == "win");
  1216. exports.isMac = (os == "mac");
  1217. exports.isLinux = (os == "linux");
  1218. exports.isIE =
  1219. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1220. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1221. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1222. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1223. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1224. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1225. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1226. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1227. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1228. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1229. exports.isIPad = ua.indexOf("iPad") >= 0;
  1230. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1231. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1232. });
  1233. define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1234. "use strict";
  1235. var keys = require("./keys");
  1236. var useragent = require("./useragent");
  1237. var pressedKeys = null;
  1238. var ts = 0;
  1239. exports.addListener = function(elem, type, callback) {
  1240. if (elem.addEventListener) {
  1241. return elem.addEventListener(type, callback, false);
  1242. }
  1243. if (elem.attachEvent) {
  1244. var wrapper = function() {
  1245. callback.call(elem, window.event);
  1246. };
  1247. callback._wrapper = wrapper;
  1248. elem.attachEvent("on" + type, wrapper);
  1249. }
  1250. };
  1251. exports.removeListener = function(elem, type, callback) {
  1252. if (elem.removeEventListener) {
  1253. return elem.removeEventListener(type, callback, false);
  1254. }
  1255. if (elem.detachEvent) {
  1256. elem.detachEvent("on" + type, callback._wrapper || callback);
  1257. }
  1258. };
  1259. exports.stopEvent = function(e) {
  1260. exports.stopPropagation(e);
  1261. exports.preventDefault(e);
  1262. return false;
  1263. };
  1264. exports.stopPropagation = function(e) {
  1265. if (e.stopPropagation)
  1266. e.stopPropagation();
  1267. else
  1268. e.cancelBubble = true;
  1269. };
  1270. exports.preventDefault = function(e) {
  1271. if (e.preventDefault)
  1272. e.preventDefault();
  1273. else
  1274. e.returnValue = false;
  1275. };
  1276. exports.getButton = function(e) {
  1277. if (e.type == "dblclick")
  1278. return 0;
  1279. if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
  1280. return 2;
  1281. if (e.preventDefault) {
  1282. return e.button;
  1283. }
  1284. else {
  1285. return {1:0, 2:2, 4:1}[e.button];
  1286. }
  1287. };
  1288. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1289. function onMouseUp(e) {
  1290. eventHandler && eventHandler(e);
  1291. releaseCaptureHandler && releaseCaptureHandler(e);
  1292. exports.removeListener(document, "mousemove", eventHandler, true);
  1293. exports.removeListener(document, "mouseup", onMouseUp, true);
  1294. exports.removeListener(document, "dragstart", onMouseUp, true);
  1295. }
  1296. exports.addListener(document, "mousemove", eventHandler, true);
  1297. exports.addListener(document, "mouseup", onMouseUp, true);
  1298. exports.addListener(document, "dragstart", onMouseUp, true);
  1299. return onMouseUp;
  1300. };
  1301. exports.addTouchMoveListener = function (el, callback) {
  1302. if ("ontouchmove" in el) {
  1303. var startx, starty;
  1304. exports.addListener(el, "touchstart", function (e) {
  1305. var touchObj = e.changedTouches[0];
  1306. startx = touchObj.clientX;
  1307. starty = touchObj.clientY;
  1308. });
  1309. exports.addListener(el, "touchmove", function (e) {
  1310. var factor = 1,
  1311. touchObj = e.changedTouches[0];
  1312. e.wheelX = -(touchObj.clientX - startx) / factor;
  1313. e.wheelY = -(touchObj.clientY - starty) / factor;
  1314. startx = touchObj.clientX;
  1315. starty = touchObj.clientY;
  1316. callback(e);
  1317. });
  1318. }
  1319. };
  1320. exports.addMouseWheelListener = function(el, callback) {
  1321. if ("onmousewheel" in el) {
  1322. exports.addListener(el, "mousewheel", function(e) {
  1323. var factor = 8;
  1324. if (e.wheelDeltaX !== undefined) {
  1325. e.wheelX = -e.wheelDeltaX / factor;
  1326. e.wheelY = -e.wheelDeltaY / factor;
  1327. } else {
  1328. e.wheelX = 0;
  1329. e.wheelY = -e.wheelDelta / factor;
  1330. }
  1331. callback(e);
  1332. });
  1333. } else if ("onwheel" in el) {
  1334. exports.addListener(el, "wheel", function(e) {
  1335. var factor = 0.35;
  1336. switch (e.deltaMode) {
  1337. case e.DOM_DELTA_PIXEL:
  1338. e.wheelX = e.deltaX * factor || 0;
  1339. e.wheelY = e.deltaY * factor || 0;
  1340. break;
  1341. case e.DOM_DELTA_LINE:
  1342. case e.DOM_DELTA_PAGE:
  1343. e.wheelX = (e.deltaX || 0) * 5;
  1344. e.wheelY = (e.deltaY || 0) * 5;
  1345. break;
  1346. }
  1347. callback(e);
  1348. });
  1349. } else {
  1350. exports.addListener(el, "DOMMouseScroll", function(e) {
  1351. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1352. e.wheelX = (e.detail || 0) * 5;
  1353. e.wheelY = 0;
  1354. } else {
  1355. e.wheelX = 0;
  1356. e.wheelY = (e.detail || 0) * 5;
  1357. }
  1358. callback(e);
  1359. });
  1360. }
  1361. };
  1362. exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
  1363. var clicks = 0;
  1364. var startX, startY, timer;
  1365. var eventNames = {
  1366. 2: "dblclick",
  1367. 3: "tripleclick",
  1368. 4: "quadclick"
  1369. };
  1370. exports.addListener(el, "mousedown", function(e) {
  1371. if (exports.getButton(e) !== 0) {
  1372. clicks = 0;
  1373. } else if (e.detail > 1) {
  1374. clicks++;
  1375. if (clicks > 4)
  1376. clicks = 1;
  1377. } else {
  1378. clicks = 1;
  1379. }
  1380. if (useragent.isIE) {
  1381. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1382. if (!timer || isNewClick)
  1383. clicks = 1;
  1384. if (timer)
  1385. clearTimeout(timer);
  1386. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1387. if (clicks == 1) {
  1388. startX = e.clientX;
  1389. startY = e.clientY;
  1390. }
  1391. }
  1392. e._clicks = clicks;
  1393. eventHandler[callbackName]("mousedown", e);
  1394. if (clicks > 4)
  1395. clicks = 0;
  1396. else if (clicks > 1)
  1397. return eventHandler[callbackName](eventNames[clicks], e);
  1398. });
  1399. if (useragent.isOldIE) {
  1400. exports.addListener(el, "dblclick", function(e) {
  1401. clicks = 2;
  1402. if (timer)
  1403. clearTimeout(timer);
  1404. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1405. eventHandler[callbackName]("mousedown", e);
  1406. eventHandler[callbackName](eventNames[clicks], e);
  1407. });
  1408. }
  1409. };
  1410. var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
  1411. ? function(e) {
  1412. return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1413. }
  1414. : function(e) {
  1415. return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1416. };
  1417. exports.getModifierString = function(e) {
  1418. return keys.KEY_MODS[getModifierHash(e)];
  1419. };
  1420. function normalizeCommandKeys(callback, e, keyCode) {
  1421. var hashId = getModifierHash(e);
  1422. if (!useragent.isMac && pressedKeys) {
  1423. if (pressedKeys.OSKey)
  1424. hashId |= 8;
  1425. if (pressedKeys.altGr) {
  1426. if ((3 & hashId) != 3)
  1427. pressedKeys.altGr = 0;
  1428. else
  1429. return;
  1430. }
  1431. if (keyCode === 18 || keyCode === 17) {
  1432. var location = "location" in e ? e.location : e.keyLocation;
  1433. if (keyCode === 17 && location === 1) {
  1434. if (pressedKeys[keyCode] == 1)
  1435. ts = e.timeStamp;
  1436. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1437. var dt = e.timeStamp - ts;
  1438. if (dt < 50)
  1439. pressedKeys.altGr = true;
  1440. }
  1441. }
  1442. }
  1443. if (keyCode in keys.MODIFIER_KEYS) {
  1444. keyCode = -1;
  1445. }
  1446. if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) {
  1447. keyCode = -1;
  1448. }
  1449. if (!hashId && keyCode === 13) {
  1450. var location = "location" in e ? e.location : e.keyLocation;
  1451. if (location === 3) {
  1452. callback(e, hashId, -keyCode);
  1453. if (e.defaultPrevented)
  1454. return;
  1455. }
  1456. }
  1457. if (useragent.isChromeOS && hashId & 8) {
  1458. callback(e, hashId, keyCode);
  1459. if (e.defaultPrevented)
  1460. return;
  1461. else
  1462. hashId &= ~8;
  1463. }
  1464. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1465. return false;
  1466. }
  1467. return callback(e, hashId, keyCode);
  1468. }
  1469. exports.addCommandKeyListener = function(el, callback) {
  1470. var addListener = exports.addListener;
  1471. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1472. var lastKeyDownKeyCode = null;
  1473. addListener(el, "keydown", function(e) {
  1474. lastKeyDownKeyCode = e.keyCode;
  1475. });
  1476. addListener(el, "keypress", function(e) {
  1477. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1478. });
  1479. } else {
  1480. var lastDefaultPrevented = null;
  1481. addListener(el, "keydown", function(e) {
  1482. var keyCode = e.keyCode;
  1483. pressedKeys[keyCode] = (pressedKeys[keyCode] || 0) + 1;
  1484. if (keyCode == 91 || keyCode == 92) {
  1485. pressedKeys.OSKey = true;
  1486. } else if (pressedKeys.OSKey) {
  1487. if (e.timeStamp - pressedKeys.lastT > 200 && pressedKeys.count == 1)
  1488. resetPressedKeys();
  1489. }
  1490. if (pressedKeys[keyCode] == 1)
  1491. pressedKeys.count++;
  1492. pressedKeys.lastT = e.timeStamp;
  1493. var result = normalizeCommandKeys(callback, e, keyCode);
  1494. lastDefaultPrevented = e.defaultPrevented;
  1495. return result;
  1496. });
  1497. addListener(el, "keypress", function(e) {
  1498. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1499. exports.stopEvent(e);
  1500. lastDefaultPrevented = null;
  1501. }
  1502. });
  1503. addListener(el, "keyup", function(e) {
  1504. var keyCode = e.keyCode;
  1505. if (!pressedKeys[keyCode]) {
  1506. resetPressedKeys();
  1507. } else {
  1508. pressedKeys.count = Math.max(pressedKeys.count - 1, 0);
  1509. }
  1510. if (keyCode == 91 || keyCode == 92) {
  1511. pressedKeys.OSKey = false;
  1512. }
  1513. pressedKeys[keyCode] = null;
  1514. });
  1515. if (!pressedKeys) {
  1516. resetPressedKeys();
  1517. addListener(window, "focus", resetPressedKeys);
  1518. }
  1519. }
  1520. };
  1521. function resetPressedKeys() {
  1522. pressedKeys = Object.create(null);
  1523. pressedKeys.count = 0;
  1524. pressedKeys.lastT = 0;
  1525. }
  1526. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1527. var postMessageId = 1;
  1528. exports.nextTick = function(callback, win) {
  1529. win = win || window;
  1530. var messageName = "zero-timeout-message-" + postMessageId;
  1531. exports.addListener(win, "message", function listener(e) {
  1532. if (e.data == messageName) {
  1533. exports.stopPropagation(e);
  1534. exports.removeListener(win, "message", listener);
  1535. callback();
  1536. }
  1537. });
  1538. win.postMessage(messageName, "*");
  1539. };
  1540. }
  1541. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1542. || window.mozRequestAnimationFrame
  1543. || window.webkitRequestAnimationFrame
  1544. || window.msRequestAnimationFrame
  1545. || window.oRequestAnimationFrame);
  1546. if (exports.nextFrame)
  1547. exports.nextFrame = exports.nextFrame.bind(window);
  1548. else
  1549. exports.nextFrame = function(callback) {
  1550. setTimeout(callback, 17);
  1551. };
  1552. });
  1553. define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1554. "use strict";
  1555. exports.last = function(a) {
  1556. return a[a.length - 1];
  1557. };
  1558. exports.stringReverse = function(string) {
  1559. return string.split("").reverse().join("");
  1560. };
  1561. exports.stringRepeat = function (string, count) {
  1562. var result = '';
  1563. while (count > 0) {
  1564. if (count & 1)
  1565. result += string;
  1566. if (count >>= 1)
  1567. string += string;
  1568. }
  1569. return result;
  1570. };
  1571. var trimBeginRegexp = /^\s\s*/;
  1572. var trimEndRegexp = /\s\s*$/;
  1573. exports.stringTrimLeft = function (string) {
  1574. return string.replace(trimBeginRegexp, '');
  1575. };
  1576. exports.stringTrimRight = function (string) {
  1577. return string.replace(trimEndRegexp, '');
  1578. };
  1579. exports.copyObject = function(obj) {
  1580. var copy = {};
  1581. for (var key in obj) {
  1582. copy[key] = obj[key];
  1583. }
  1584. return copy;
  1585. };
  1586. exports.copyArray = function(array){
  1587. var copy = [];
  1588. for (var i=0, l=array.length; i<l; i++) {
  1589. if (array[i] && typeof array[i] == "object")
  1590. copy[i] = this.copyObject( array[i] );
  1591. else
  1592. copy[i] = array[i];
  1593. }
  1594. return copy;
  1595. };
  1596. exports.deepCopy = function deepCopy(obj) {
  1597. if (typeof obj !== "object" || !obj)
  1598. return obj;
  1599. var copy;
  1600. if (Array.isArray(obj)) {
  1601. copy = [];
  1602. for (var key = 0; key < obj.length; key++) {
  1603. copy[key] = deepCopy(obj[key]);
  1604. }
  1605. return copy;
  1606. }
  1607. var cons = obj.constructor;
  1608. if (cons === RegExp)
  1609. return obj;
  1610. copy = cons();
  1611. for (var key in obj) {
  1612. copy[key] = deepCopy(obj[key]);
  1613. }
  1614. return copy;
  1615. };
  1616. exports.arrayToMap = function(arr) {
  1617. var map = {};
  1618. for (var i=0; i<arr.length; i++) {
  1619. map[arr[i]] = 1;
  1620. }
  1621. return map;
  1622. };
  1623. exports.createMap = function(props) {
  1624. var map = Object.create(null);
  1625. for (var i in props) {
  1626. map[i] = props[i];
  1627. }
  1628. return map;
  1629. };
  1630. exports.arrayRemove = function(array, value) {
  1631. for (var i = 0; i <= array.length; i++) {
  1632. if (value === array[i]) {
  1633. array.splice(i, 1);
  1634. }
  1635. }
  1636. };
  1637. exports.escapeRegExp = function(str) {
  1638. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1639. };
  1640. exports.escapeHTML = function(str) {
  1641. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1642. };
  1643. exports.getMatchOffsets = function(string, regExp) {
  1644. var matches = [];
  1645. string.replace(regExp, function(str) {
  1646. matches.push({
  1647. offset: arguments[arguments.length-2],
  1648. length: str.length
  1649. });
  1650. });
  1651. return matches;
  1652. };
  1653. exports.deferredCall = function(fcn) {
  1654. var timer = null;
  1655. var callback = function() {
  1656. timer = null;
  1657. fcn();
  1658. };
  1659. var deferred = function(timeout) {
  1660. deferred.cancel();
  1661. timer = setTimeout(callback, timeout || 0);
  1662. return deferred;
  1663. };
  1664. deferred.schedule = deferred;
  1665. deferred.call = function() {
  1666. this.cancel();
  1667. fcn();
  1668. return deferred;
  1669. };
  1670. deferred.cancel = function() {
  1671. clearTimeout(timer);
  1672. timer = null;
  1673. return deferred;
  1674. };
  1675. deferred.isPending = function() {
  1676. return timer;
  1677. };
  1678. return deferred;
  1679. };
  1680. exports.delayedCall = function(fcn, defaultTimeout) {
  1681. var timer = null;
  1682. var callback = function() {
  1683. timer = null;
  1684. fcn();
  1685. };
  1686. var _self = function(timeout) {
  1687. if (timer == null)
  1688. timer = setTimeout(callback, timeout || defaultTimeout);
  1689. };
  1690. _self.delay = function(timeout) {
  1691. timer && clearTimeout(timer);
  1692. timer = setTimeout(callback, timeout || defaultTimeout);
  1693. };
  1694. _self.schedule = _self;
  1695. _self.call = function() {
  1696. this.cancel();
  1697. fcn();
  1698. };
  1699. _self.cancel = function() {
  1700. timer && clearTimeout(timer);
  1701. timer = null;
  1702. };
  1703. _self.isPending = function() {
  1704. return timer;
  1705. };
  1706. return _self;
  1707. };
  1708. });
  1709. define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1710. "use strict";
  1711. var event = require("../lib/event");
  1712. var useragent = require("../lib/useragent");
  1713. var dom = require("../lib/dom");
  1714. var lang = require("../lib/lang");
  1715. var BROKEN_SETDATA = useragent.isChrome < 18;
  1716. var USE_IE_MIME_TYPE = useragent.isIE;
  1717. var TextInput = function(parentNode, host) {
  1718. var text = dom.createElement("textarea");
  1719. text.className = "ace_text-input";
  1720. if (useragent.isTouchPad)
  1721. text.setAttribute("x-palm-disable-auto-cap", true);
  1722. text.setAttribute("wrap", "off");
  1723. text.setAttribute("autocorrect", "off");
  1724. text.setAttribute("autocapitalize", "off");
  1725. text.setAttribute("spellcheck", false);
  1726. text.style.opacity = "0";
  1727. if (useragent.isOldIE) text.style.top = "-1000px";
  1728. parentNode.insertBefore(text, parentNode.firstChild);
  1729. var PLACEHOLDER = "\x01\x01";
  1730. var copied = false;
  1731. var pasted = false;
  1732. var inComposition = false;
  1733. var tempStyle = '';
  1734. var isSelectionEmpty = true;
  1735. try { var isFocused = document.activeElement === text; } catch(e) {}
  1736. event.addListener(text, "blur", function(e) {
  1737. host.onBlur(e);
  1738. isFocused = false;
  1739. });
  1740. event.addListener(text, "focus", function(e) {
  1741. isFocused = true;
  1742. host.onFocus(e);
  1743. resetSelection();
  1744. });
  1745. this.focus = function() {
  1746. if (tempStyle) return text.focus();
  1747. var top = text.style.top;
  1748. text.style.position = "fixed";
  1749. text.style.top = "-1000px";
  1750. text.focus();
  1751. setTimeout(function() {
  1752. text.style.position = "";
  1753. if (text.style.top == "-1000px")
  1754. text.style.top = top;
  1755. }, 0);
  1756. };
  1757. this.blur = function() {
  1758. text.blur();
  1759. };
  1760. this.isFocused = function() {
  1761. return isFocused;
  1762. };
  1763. var syncSelection = lang.delayedCall(function() {
  1764. isFocused && resetSelection(isSelectionEmpty);
  1765. });
  1766. var syncValue = lang.delayedCall(function() {
  1767. if (!inComposition) {
  1768. text.value = PLACEHOLDER;
  1769. isFocused && resetSelection();
  1770. }
  1771. });
  1772. function resetSelection(isEmpty) {
  1773. if (inComposition)
  1774. return;
  1775. inComposition = true;
  1776. if (inputHandler) {
  1777. selectionStart = 0;
  1778. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1779. } else {
  1780. var selectionStart = isEmpty ? 2 : 1;
  1781. var selectionEnd = 2;
  1782. }
  1783. try {
  1784. text.setSelectionRange(selectionStart, selectionEnd);
  1785. } catch(e){}
  1786. inComposition = false;
  1787. }
  1788. function resetValue() {
  1789. if (inComposition)
  1790. return;
  1791. text.value = PLACEHOLDER;
  1792. if (useragent.isWebKit)
  1793. syncValue.schedule();
  1794. }
  1795. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1796. if (host.selection.isEmpty() != isSelectionEmpty) {
  1797. isSelectionEmpty = !isSelectionEmpty;
  1798. syncSelection.schedule();
  1799. }
  1800. });
  1801. resetValue();
  1802. if (isFocused)
  1803. host.onFocus();
  1804. var isAllSelected = function(text) {
  1805. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1806. };
  1807. if (!text.setSelectionRange && text.createTextRange) {
  1808. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1809. var range = this.createTextRange();
  1810. range.collapse(true);
  1811. range.moveStart('character', selectionStart);
  1812. range.moveEnd('character', selectionEnd);
  1813. range.select();
  1814. };
  1815. isAllSelected = function(text) {
  1816. try {
  1817. var range = text.ownerDocument.selection.createRange();
  1818. }catch(e) {}
  1819. if (!range || range.parentElement() != text) return false;
  1820. return range.text == text.value;
  1821. }
  1822. }
  1823. if (useragent.isOldIE) {
  1824. var inPropertyChange = false;
  1825. var onPropertyChange = function(e){
  1826. if (inPropertyChange)
  1827. return;
  1828. var data = text.value;
  1829. if (inComposition || !data || data == PLACEHOLDER)
  1830. return;
  1831. if (e && data == PLACEHOLDER[0])
  1832. return syncProperty.schedule();
  1833. sendText(data);
  1834. inPropertyChange = true;
  1835. resetValue();
  1836. inPropertyChange = false;
  1837. };
  1838. var syncProperty = lang.delayedCall(onPropertyChange);
  1839. event.addListener(text, "propertychange", onPropertyChange);
  1840. var keytable = { 13:1, 27:1 };
  1841. event.addListener(text, "keyup", function (e) {
  1842. if (inComposition && (!text.value || keytable[e.keyCode]))
  1843. setTimeout(onCompositionEnd, 0);
  1844. if ((text.value.charCodeAt(0)||0) < 129) {
  1845. return syncProperty.call();
  1846. }
  1847. inComposition ? onCompositionUpdate() : onCompositionStart();
  1848. });
  1849. event.addListener(text, "keydown", function (e) {
  1850. syncProperty.schedule(50);
  1851. });
  1852. }
  1853. var onSelect = function(e) {
  1854. if (copied) {
  1855. copied = false;
  1856. } else if (isAllSelected(text)) {
  1857. host.selectAll();
  1858. resetSelection();
  1859. } else if (inputHandler) {
  1860. resetSelection(host.selection.isEmpty());
  1861. }
  1862. };
  1863. var inputHandler = null;
  1864. this.setInputHandler = function(cb) {inputHandler = cb};
  1865. this.getInputHandler = function() {return inputHandler};
  1866. var afterContextMenu = false;
  1867. var sendText = function(data) {
  1868. if (inputHandler) {
  1869. data = inputHandler(data);
  1870. inputHandler = null;
  1871. }
  1872. if (pasted) {
  1873. resetSelection();
  1874. if (data)
  1875. host.onPaste(data);
  1876. pasted = false;
  1877. } else if (data == PLACEHOLDER.charAt(0)) {
  1878. if (afterContextMenu)
  1879. host.execCommand("del", {source: "ace"});
  1880. else // some versions of android do not fire keydown when pressing backspace
  1881. host.execCommand("backspace", {source: "ace"});
  1882. } else {
  1883. if (data.substring(0, 2) == PLACEHOLDER)
  1884. data = data.substr(2);
  1885. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1886. data = data.substr(1);
  1887. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1888. data = data.slice(0, -1);
  1889. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1890. data = data.slice(0, -1);
  1891. if (data)
  1892. host.onTextInput(data);
  1893. }
  1894. if (afterContextMenu)
  1895. afterContextMenu = false;
  1896. };
  1897. var onInput = function(e) {
  1898. if (inComposition)
  1899. return;
  1900. var data = text.value;
  1901. sendText(data);
  1902. resetValue();
  1903. };
  1904. var handleClipboardData = function(e, data) {
  1905. var clipboardData = e.clipboardData || window.clipboardData;
  1906. if (!clipboardData || BROKEN_SETDATA)
  1907. return;
  1908. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1909. if (data) {
  1910. return clipboardData.setData(mime, data) !== false;
  1911. } else {
  1912. return clipboardData.getData(mime);
  1913. }
  1914. };
  1915. var doCopy = function(e, isCut) {
  1916. var data = host.getCopyText();
  1917. if (!data)
  1918. return event.preventDefault(e);
  1919. if (handleClipboardData(e, data)) {
  1920. isCut ? host.onCut() : host.onCopy();
  1921. event.preventDefault(e);
  1922. } else {
  1923. copied = true;
  1924. text.value = data;
  1925. text.select();
  1926. setTimeout(function(){
  1927. copied = false;
  1928. resetValue();
  1929. resetSelection();
  1930. isCut ? host.onCut() : host.onCopy();
  1931. });
  1932. }
  1933. };
  1934. var onCut = function(e) {
  1935. doCopy(e, true);
  1936. };
  1937. var onCopy = function(e) {
  1938. doCopy(e, false);
  1939. };
  1940. var onPaste = function(e) {
  1941. var data = handleClipboardData(e);
  1942. if (typeof data == "string") {
  1943. if (data)
  1944. host.onPaste(data, e);
  1945. if (useragent.isIE)
  1946. setTimeout(resetSelection);
  1947. event.preventDefault(e);
  1948. }
  1949. else {
  1950. text.value = "";
  1951. pasted = true;
  1952. }
  1953. };
  1954. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1955. event.addListener(text, "select", onSelect);
  1956. event.addListener(text, "input", onInput);
  1957. event.addListener(text, "cut", onCut);
  1958. event.addListener(text, "copy", onCopy);
  1959. event.addListener(text, "paste", onPaste);
  1960. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1961. event.addListener(parentNode, "keydown", function(e) {
  1962. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1963. return;
  1964. switch (e.keyCode) {
  1965. case 67:
  1966. onCopy(e);
  1967. break;
  1968. case 86:
  1969. onPaste(e);
  1970. break;
  1971. case 88:
  1972. onCut(e);
  1973. break;
  1974. }
  1975. });
  1976. }
  1977. var onCompositionStart = function(e) {
  1978. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1979. return;
  1980. inComposition = {};
  1981. host.onCompositionStart();
  1982. setTimeout(onCompositionUpdate, 0);
  1983. host.on("mousedown", onCompositionEnd);
  1984. if (!host.selection.isEmpty()) {
  1985. host.insert("");
  1986. host.session.markUndoGroup();
  1987. host.selection.clearSelection();
  1988. }
  1989. host.session.markUndoGroup();
  1990. };
  1991. var onCompositionUpdate = function() {
  1992. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1993. return;
  1994. var val = text.value.replace(/\x01/g, "");
  1995. if (inComposition.lastValue === val) return;
  1996. host.onCompositionUpdate(val);
  1997. if (inComposition.lastValue)
  1998. host.undo();
  1999. inComposition.lastValue = val;
  2000. if (inComposition.lastValue) {
  2001. var r = host.selection.getRange();
  2002. host.insert(inComposition.lastValue);
  2003. host.session.markUndoGroup();
  2004. inComposition.range = host.selection.getRange();
  2005. host.selection.setRange(r);
  2006. host.selection.clearSelection();
  2007. }
  2008. };
  2009. var onCompositionEnd = function(e) {
  2010. if (!host.onCompositionEnd || host.$readOnly) return;
  2011. var c = inComposition;
  2012. inComposition = false;
  2013. var timer = setTimeout(function() {
  2014. timer = null;
  2015. var str = text.value.replace(/\x01/g, "");
  2016. if (inComposition)
  2017. return;
  2018. else if (str == c.lastValue)
  2019. resetValue();
  2020. else if (!c.lastValue && str) {
  2021. resetValue();
  2022. sendText(str);
  2023. }
  2024. });
  2025. inputHandler = function compositionInputHandler(str) {
  2026. if (timer)
  2027. clearTimeout(timer);
  2028. str = str.replace(/\x01/g, "");
  2029. if (str == c.lastValue)
  2030. return "";
  2031. if (c.lastValue && timer)
  2032. host.undo();
  2033. return str;
  2034. };
  2035. host.onCompositionEnd();
  2036. host.removeListener("mousedown", onCompositionEnd);
  2037. if (e.type == "compositionend" && c.range) {
  2038. host.selection.setRange(c.range);
  2039. }
  2040. };
  2041. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2042. event.addListener(text, "compositionstart", onCompositionStart);
  2043. if (useragent.isGecko) {
  2044. event.addListener(text, "text", function(){syncComposition.schedule()});
  2045. } else {
  2046. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2047. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2048. }
  2049. event.addListener(text, "compositionend", onCompositionEnd);
  2050. this.getElement = function() {
  2051. return text;
  2052. };
  2053. this.setReadOnly = function(readOnly) {
  2054. text.readOnly = readOnly;
  2055. };
  2056. this.onContextMenu = function(e) {
  2057. afterContextMenu = true;
  2058. resetSelection(host.selection.isEmpty());
  2059. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2060. this.moveToMouse(e, true);
  2061. };
  2062. this.moveToMouse = function(e, bringToFront) {
  2063. if (!bringToFront && useragent.isOldIE)
  2064. return;
  2065. if (!tempStyle)
  2066. tempStyle = text.style.cssText;
  2067. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2068. + "height:" + text.style.height + ";"
  2069. + (useragent.isIE ? "opacity:0.1;" : "");
  2070. var rect = host.container.getBoundingClientRect();
  2071. var style = dom.computedStyle(host.container);
  2072. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2073. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2074. var maxTop = rect.bottom - top - text.clientHeight -2;
  2075. var move = function(e) {
  2076. text.style.left = e.clientX - left - 2 + "px";
  2077. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2078. };
  2079. move(e);
  2080. if (e.type != "mousedown")
  2081. return;
  2082. if (host.renderer.$keepTextAreaAtCursor)
  2083. host.renderer.$keepTextAreaAtCursor = null;
  2084. if (useragent.isWin && !useragent.isOldIE)
  2085. event.capture(host.container, move, onContextMenuClose);
  2086. };
  2087. this.onContextMenuClose = onContextMenuClose;
  2088. var closeTimeout;
  2089. function onContextMenuClose() {
  2090. clearTimeout(closeTimeout);
  2091. closeTimeout = setTimeout(function () {
  2092. if (tempStyle) {
  2093. text.style.cssText = tempStyle;
  2094. tempStyle = '';
  2095. }
  2096. if (host.renderer.$keepTextAreaAtCursor == null) {
  2097. host.renderer.$keepTextAreaAtCursor = true;
  2098. host.renderer.$moveTextAreaToCursor();
  2099. }
  2100. }, useragent.isOldIE ? 200 : 0);
  2101. }
  2102. var onContextMenu = function(e) {
  2103. host.textInput.onContextMenu(e);
  2104. onContextMenuClose();
  2105. };
  2106. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2107. event.addListener(text, "contextmenu", onContextMenu);
  2108. };
  2109. exports.TextInput = TextInput;
  2110. });
  2111. define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2112. "use strict";
  2113. var dom = require("../lib/dom");
  2114. var event = require("../lib/event");
  2115. var useragent = require("../lib/useragent");
  2116. var DRAG_OFFSET = 0; // pixels
  2117. function DefaultHandlers(mouseHandler) {
  2118. mouseHandler.$clickSelection = null;
  2119. var editor = mouseHandler.editor;
  2120. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2121. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2122. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2123. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2124. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2125. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2126. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2127. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2128. exports.forEach(function(x) {
  2129. mouseHandler[x] = this[x];
  2130. }, this);
  2131. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2132. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2133. }
  2134. (function() {
  2135. this.onMouseDown = function(ev) {
  2136. var inSelection = ev.inSelection();
  2137. var pos = ev.getDocumentPosition();
  2138. this.mousedownEvent = ev;
  2139. var editor = this.editor;
  2140. var button = ev.getButton();
  2141. if (button !== 0) {
  2142. var selectionRange = editor.getSelectionRange();
  2143. var selectionEmpty = selectionRange.isEmpty();
  2144. editor.$blockScrolling++;
  2145. if (selectionEmpty)
  2146. editor.selection.moveToPosition(pos);
  2147. editor.$blockScrolling--;
  2148. editor.textInput.onContextMenu(ev.domEvent);
  2149. return; // stopping event here breaks contextmenu on ff mac
  2150. }
  2151. this.mousedownEvent.time = Date.now();
  2152. if (inSelection && !editor.isFocused()) {
  2153. editor.focus();
  2154. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2155. this.setState("focusWait");
  2156. this.captureMouse(ev);
  2157. return;
  2158. }
  2159. }
  2160. this.captureMouse(ev);
  2161. this.startSelect(pos, ev.domEvent._clicks > 1);
  2162. return ev.preventDefault();
  2163. };
  2164. this.startSelect = function(pos, waitForClickSelection) {
  2165. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2166. var editor = this.editor;
  2167. editor.$blockScrolling++;
  2168. if (this.mousedownEvent.getShiftKey())
  2169. editor.selection.selectToPosition(pos);
  2170. else if (!waitForClickSelection)
  2171. editor.selection.moveToPosition(pos);
  2172. if (!waitForClickSelection)
  2173. this.select();
  2174. if (editor.renderer.scroller.setCapture) {
  2175. editor.renderer.scroller.setCapture();
  2176. }
  2177. editor.setStyle("ace_selecting");
  2178. this.setState("select");
  2179. editor.$blockScrolling--;
  2180. };
  2181. this.select = function() {
  2182. var anchor, editor = this.editor;
  2183. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2184. editor.$blockScrolling++;
  2185. if (this.$clickSelection) {
  2186. var cmp = this.$clickSelection.comparePoint(cursor);
  2187. if (cmp == -1) {
  2188. anchor = this.$clickSelection.end;
  2189. } else if (cmp == 1) {
  2190. anchor = this.$clickSelection.start;
  2191. } else {
  2192. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2193. cursor = orientedRange.cursor;
  2194. anchor = orientedRange.anchor;
  2195. }
  2196. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2197. }
  2198. editor.selection.selectToPosition(cursor);
  2199. editor.$blockScrolling--;
  2200. editor.renderer.scrollCursorIntoView();
  2201. };
  2202. this.extendSelectionBy = function(unitName) {
  2203. var anchor, editor = this.editor;
  2204. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2205. var range = editor.selection[unitName](cursor.row, cursor.column);
  2206. editor.$blockScrolling++;
  2207. if (this.$clickSelection) {
  2208. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2209. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2210. if (cmpStart == -1 && cmpEnd <= 0) {
  2211. anchor = this.$clickSelection.end;
  2212. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2213. cursor = range.start;
  2214. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2215. anchor = this.$clickSelection.start;
  2216. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2217. cursor = range.end;
  2218. } else if (cmpStart == -1 && cmpEnd == 1) {
  2219. cursor = range.end;
  2220. anchor = range.start;
  2221. } else {
  2222. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2223. cursor = orientedRange.cursor;
  2224. anchor = orientedRange.anchor;
  2225. }
  2226. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2227. }
  2228. editor.selection.selectToPosition(cursor);
  2229. editor.$blockScrolling--;
  2230. editor.renderer.scrollCursorIntoView();
  2231. };
  2232. this.selectEnd =
  2233. this.selectAllEnd =
  2234. this.selectByWordsEnd =
  2235. this.selectByLinesEnd = function() {
  2236. this.$clickSelection = null;
  2237. this.editor.unsetStyle("ace_selecting");
  2238. if (this.editor.renderer.scroller.releaseCapture) {
  2239. this.editor.renderer.scroller.releaseCapture();
  2240. }
  2241. };
  2242. this.focusWait = function() {
  2243. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2244. var time = Date.now();
  2245. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2246. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2247. };
  2248. this.onDoubleClick = function(ev) {
  2249. var pos = ev.getDocumentPosition();
  2250. var editor = this.editor;
  2251. var session = editor.session;
  2252. var range = session.getBracketRange(pos);
  2253. if (range) {
  2254. if (range.isEmpty()) {
  2255. range.start.column--;
  2256. range.end.column++;
  2257. }
  2258. this.setState("select");
  2259. } else {
  2260. range = editor.selection.getWordRange(pos.row, pos.column);
  2261. this.setState("selectByWords");
  2262. }
  2263. this.$clickSelection = range;
  2264. this.select();
  2265. };
  2266. this.onTripleClick = function(ev) {
  2267. var pos = ev.getDocumentPosition();
  2268. var editor = this.editor;
  2269. this.setState("selectByLines");
  2270. var range = editor.getSelectionRange();
  2271. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2272. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2273. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2274. } else {
  2275. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2276. }
  2277. this.select();
  2278. };
  2279. this.onQuadClick = function(ev) {
  2280. var editor = this.editor;
  2281. editor.selectAll();
  2282. this.$clickSelection = editor.getSelectionRange();
  2283. this.setState("selectAll");
  2284. };
  2285. this.onMouseWheel = function(ev) {
  2286. if (ev.getAccelKey())
  2287. return;
  2288. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2289. ev.wheelX = ev.wheelY;
  2290. ev.wheelY = 0;
  2291. }
  2292. var t = ev.domEvent.timeStamp;
  2293. var dt = t - (this.$lastScrollTime||0);
  2294. var editor = this.editor;
  2295. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2296. if (isScrolable || dt < 200) {
  2297. this.$lastScrollTime = t;
  2298. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2299. return ev.stop();
  2300. }
  2301. };
  2302. this.onTouchMove = function (ev) {
  2303. var t = ev.domEvent.timeStamp;
  2304. var dt = t - (this.$lastScrollTime || 0);
  2305. var editor = this.editor;
  2306. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2307. if (isScrolable || dt < 200) {
  2308. this.$lastScrollTime = t;
  2309. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2310. return ev.stop();
  2311. }
  2312. };
  2313. }).call(DefaultHandlers.prototype);
  2314. exports.DefaultHandlers = DefaultHandlers;
  2315. function calcDistance(ax, ay, bx, by) {
  2316. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2317. }
  2318. function calcRangeOrientation(range, cursor) {
  2319. if (range.start.row == range.end.row)
  2320. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2321. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2322. var cmp = cursor.column - 4;
  2323. else
  2324. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2325. if (cmp < 0)
  2326. return {cursor: range.start, anchor: range.end};
  2327. else
  2328. return {cursor: range.end, anchor: range.start};
  2329. }
  2330. });
  2331. define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2332. "use strict";
  2333. var oop = require("./lib/oop");
  2334. var dom = require("./lib/dom");
  2335. function Tooltip (parentNode) {
  2336. this.isOpen = false;
  2337. this.$element = null;
  2338. this.$parentNode = parentNode;
  2339. }
  2340. (function() {
  2341. this.$init = function() {
  2342. this.$element = dom.createElement("div");
  2343. this.$element.className = "ace_tooltip";
  2344. this.$element.style.display = "none";
  2345. this.$parentNode.appendChild(this.$element);
  2346. return this.$element;
  2347. };
  2348. this.getElement = function() {
  2349. return this.$element || this.$init();
  2350. };
  2351. this.setText = function(text) {
  2352. dom.setInnerText(this.getElement(), text);
  2353. };
  2354. this.setHtml = function(html) {
  2355. this.getElement().innerHTML = html;
  2356. };
  2357. this.setPosition = function(x, y) {
  2358. this.getElement().style.left = x + "px";
  2359. this.getElement().style.top = y + "px";
  2360. };
  2361. this.setClassName = function(className) {
  2362. dom.addCssClass(this.getElement(), className);
  2363. };
  2364. this.show = function(text, x, y) {
  2365. if (text != null)
  2366. this.setText(text);
  2367. if (x != null && y != null)
  2368. this.setPosition(x, y);
  2369. if (!this.isOpen) {
  2370. this.getElement().style.display = "block";
  2371. this.isOpen = true;
  2372. }
  2373. };
  2374. this.hide = function() {
  2375. if (this.isOpen) {
  2376. this.getElement().style.display = "none";
  2377. this.isOpen = false;
  2378. }
  2379. };
  2380. this.getHeight = function() {
  2381. return this.getElement().offsetHeight;
  2382. };
  2383. this.getWidth = function() {
  2384. return this.getElement().offsetWidth;
  2385. };
  2386. }).call(Tooltip.prototype);
  2387. exports.Tooltip = Tooltip;
  2388. });
  2389. define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
  2390. "use strict";
  2391. var dom = require("../lib/dom");
  2392. var oop = require("../lib/oop");
  2393. var event = require("../lib/event");
  2394. var Tooltip = require("../tooltip").Tooltip;
  2395. function GutterHandler(mouseHandler) {
  2396. var editor = mouseHandler.editor;
  2397. var gutter = editor.renderer.$gutterLayer;
  2398. var tooltip = new GutterTooltip(editor.container);
  2399. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2400. if (!editor.isFocused() || e.getButton() != 0)
  2401. return;
  2402. var gutterRegion = gutter.getRegion(e);
  2403. if (gutterRegion == "foldWidgets")
  2404. return;
  2405. var row = e.getDocumentPosition().row;
  2406. var selection = editor.session.selection;
  2407. if (e.getShiftKey())
  2408. selection.selectTo(row, 0);
  2409. else {
  2410. if (e.domEvent.detail == 2) {
  2411. editor.selectAll();
  2412. return e.preventDefault();
  2413. }
  2414. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2415. }
  2416. mouseHandler.setState("selectByLines");
  2417. mouseHandler.captureMouse(e);
  2418. return e.preventDefault();
  2419. });
  2420. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2421. function showTooltip() {
  2422. var row = mouseEvent.getDocumentPosition().row;
  2423. var annotation = gutter.$annotations[row];
  2424. if (!annotation)
  2425. return hideTooltip();
  2426. var maxRow = editor.session.getLength();
  2427. if (row == maxRow) {
  2428. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2429. var pos = mouseEvent.$pos;
  2430. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2431. return hideTooltip();
  2432. }
  2433. if (tooltipAnnotation == annotation)
  2434. return;
  2435. tooltipAnnotation = annotation.text.join("<br/>");
  2436. tooltip.setHtml(tooltipAnnotation);
  2437. tooltip.show();
  2438. editor.on("mousewheel", hideTooltip);
  2439. if (mouseHandler.$tooltipFollowsMouse) {
  2440. moveTooltip(mouseEvent);
  2441. } else {
  2442. var gutterElement = mouseEvent.domEvent.target;
  2443. var rect = gutterElement.getBoundingClientRect();
  2444. var style = tooltip.getElement().style;
  2445. style.left = rect.right + "px";
  2446. style.top = rect.bottom + "px";
  2447. }
  2448. }
  2449. function hideTooltip() {
  2450. if (tooltipTimeout)
  2451. tooltipTimeout = clearTimeout(tooltipTimeout);
  2452. if (tooltipAnnotation) {
  2453. tooltip.hide();
  2454. tooltipAnnotation = null;
  2455. editor.removeEventListener("mousewheel", hideTooltip);
  2456. }
  2457. }
  2458. function moveTooltip(e) {
  2459. tooltip.setPosition(e.x, e.y);
  2460. }
  2461. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2462. var target = e.domEvent.target || e.domEvent.srcElement;
  2463. if (dom.hasCssClass(target, "ace_fold-widget"))
  2464. return hideTooltip();
  2465. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2466. moveTooltip(e);
  2467. mouseEvent = e;
  2468. if (tooltipTimeout)
  2469. return;
  2470. tooltipTimeout = setTimeout(function() {
  2471. tooltipTimeout = null;
  2472. if (mouseEvent && !mouseHandler.isMousePressed)
  2473. showTooltip();
  2474. else
  2475. hideTooltip();
  2476. }, 50);
  2477. });
  2478. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2479. mouseEvent = null;
  2480. if (!tooltipAnnotation || tooltipTimeout)
  2481. return;
  2482. tooltipTimeout = setTimeout(function() {
  2483. tooltipTimeout = null;
  2484. hideTooltip();
  2485. }, 50);
  2486. });
  2487. editor.on("changeSession", hideTooltip);
  2488. }
  2489. function GutterTooltip(parentNode) {
  2490. Tooltip.call(this, parentNode);
  2491. }
  2492. oop.inherits(GutterTooltip, Tooltip);
  2493. (function(){
  2494. this.setPosition = function(x, y) {
  2495. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2496. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2497. var width = this.getWidth();
  2498. var height = this.getHeight();
  2499. x += 15;
  2500. y += 15;
  2501. if (x + width > windowWidth) {
  2502. x -= (x + width) - windowWidth;
  2503. }
  2504. if (y + height > windowHeight) {
  2505. y -= 20 + height;
  2506. }
  2507. Tooltip.prototype.setPosition.call(this, x, y);
  2508. };
  2509. }).call(GutterTooltip.prototype);
  2510. exports.GutterHandler = GutterHandler;
  2511. });
  2512. define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2513. "use strict";
  2514. var event = require("../lib/event");
  2515. var useragent = require("../lib/useragent");
  2516. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2517. this.domEvent = domEvent;
  2518. this.editor = editor;
  2519. this.x = this.clientX = domEvent.clientX;
  2520. this.y = this.clientY = domEvent.clientY;
  2521. this.$pos = null;
  2522. this.$inSelection = null;
  2523. this.propagationStopped = false;
  2524. this.defaultPrevented = false;
  2525. };
  2526. (function() {
  2527. this.stopPropagation = function() {
  2528. event.stopPropagation(this.domEvent);
  2529. this.propagationStopped = true;
  2530. };
  2531. this.preventDefault = function() {
  2532. event.preventDefault(this.domEvent);
  2533. this.defaultPrevented = true;
  2534. };
  2535. this.stop = function() {
  2536. this.stopPropagation();
  2537. this.preventDefault();
  2538. };
  2539. this.getDocumentPosition = function() {
  2540. if (this.$pos)
  2541. return this.$pos;
  2542. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2543. return this.$pos;
  2544. };
  2545. this.inSelection = function() {
  2546. if (this.$inSelection !== null)
  2547. return this.$inSelection;
  2548. var editor = this.editor;
  2549. var selectionRange = editor.getSelectionRange();
  2550. if (selectionRange.isEmpty())
  2551. this.$inSelection = false;
  2552. else {
  2553. var pos = this.getDocumentPosition();
  2554. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2555. }
  2556. return this.$inSelection;
  2557. };
  2558. this.getButton = function() {
  2559. return event.getButton(this.domEvent);
  2560. };
  2561. this.getShiftKey = function() {
  2562. return this.domEvent.shiftKey;
  2563. };
  2564. this.getAccelKey = useragent.isMac
  2565. ? function() { return this.domEvent.metaKey; }
  2566. : function() { return this.domEvent.ctrlKey; };
  2567. }).call(MouseEvent.prototype);
  2568. });
  2569. define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2570. "use strict";
  2571. var dom = require("../lib/dom");
  2572. var event = require("../lib/event");
  2573. var useragent = require("../lib/useragent");
  2574. var AUTOSCROLL_DELAY = 200;
  2575. var SCROLL_CURSOR_DELAY = 200;
  2576. var SCROLL_CURSOR_HYSTERESIS = 5;
  2577. function DragdropHandler(mouseHandler) {
  2578. var editor = mouseHandler.editor;
  2579. var blankImage = dom.createElement("img");
  2580. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2581. if (useragent.isOpera)
  2582. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2583. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2584. exports.forEach(function(x) {
  2585. mouseHandler[x] = this[x];
  2586. }, this);
  2587. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2588. var mouseTarget = editor.container;
  2589. var dragSelectionMarker, x, y;
  2590. var timerId, range;
  2591. var dragCursor, counter = 0;
  2592. var dragOperation;
  2593. var isInternal;
  2594. var autoScrollStartTime;
  2595. var cursorMovedTime;
  2596. var cursorPointOnCaretMoved;
  2597. this.onDragStart = function(e) {
  2598. if (this.cancelDrag || !mouseTarget.draggable) {
  2599. var self = this;
  2600. setTimeout(function(){
  2601. self.startSelect();
  2602. self.captureMouse(e);
  2603. }, 0);
  2604. return e.preventDefault();
  2605. }
  2606. range = editor.getSelectionRange();
  2607. var dataTransfer = e.dataTransfer;
  2608. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2609. if (useragent.isOpera) {
  2610. editor.container.appendChild(blankImage);
  2611. blankImage.scrollTop = 0;
  2612. }
  2613. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2614. if (useragent.isOpera) {
  2615. editor.container.removeChild(blankImage);
  2616. }
  2617. dataTransfer.clearData();
  2618. dataTransfer.setData("Text", editor.session.getTextRange());
  2619. isInternal = true;
  2620. this.setState("drag");
  2621. };
  2622. this.onDragEnd = function(e) {
  2623. mouseTarget.draggable = false;
  2624. isInternal = false;
  2625. this.setState(null);
  2626. if (!editor.getReadOnly()) {
  2627. var dropEffect = e.dataTransfer.dropEffect;
  2628. if (!dragOperation && dropEffect == "move")
  2629. editor.session.remove(editor.getSelectionRange());
  2630. editor.renderer.$cursorLayer.setBlinking(true);
  2631. }
  2632. this.editor.unsetStyle("ace_dragging");
  2633. this.editor.renderer.setCursorStyle("");
  2634. };
  2635. this.onDragEnter = function(e) {
  2636. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2637. return;
  2638. x = e.clientX;
  2639. y = e.clientY;
  2640. if (!dragSelectionMarker)
  2641. addDragMarker();
  2642. counter++;
  2643. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2644. return event.preventDefault(e);
  2645. };
  2646. this.onDragOver = function(e) {
  2647. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2648. return;
  2649. x = e.clientX;
  2650. y = e.clientY;
  2651. if (!dragSelectionMarker) {
  2652. addDragMarker();
  2653. counter++;
  2654. }
  2655. if (onMouseMoveTimer !== null)
  2656. onMouseMoveTimer = null;
  2657. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2658. return event.preventDefault(e);
  2659. };
  2660. this.onDragLeave = function(e) {
  2661. counter--;
  2662. if (counter <= 0 && dragSelectionMarker) {
  2663. clearDragMarker();
  2664. dragOperation = null;
  2665. return event.preventDefault(e);
  2666. }
  2667. };
  2668. this.onDrop = function(e) {
  2669. if (!dragCursor)
  2670. return;
  2671. var dataTransfer = e.dataTransfer;
  2672. if (isInternal) {
  2673. switch (dragOperation) {
  2674. case "move":
  2675. if (range.contains(dragCursor.row, dragCursor.column)) {
  2676. range = {
  2677. start: dragCursor,
  2678. end: dragCursor
  2679. };
  2680. } else {
  2681. range = editor.moveText(range, dragCursor);
  2682. }
  2683. break;
  2684. case "copy":
  2685. range = editor.moveText(range, dragCursor, true);
  2686. break;
  2687. }
  2688. } else {
  2689. var dropData = dataTransfer.getData('Text');
  2690. range = {
  2691. start: dragCursor,
  2692. end: editor.session.insert(dragCursor, dropData)
  2693. };
  2694. editor.focus();
  2695. dragOperation = null;
  2696. }
  2697. clearDragMarker();
  2698. return event.preventDefault(e);
  2699. };
  2700. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2701. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2702. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2703. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2704. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2705. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2706. function scrollCursorIntoView(cursor, prevCursor) {
  2707. var now = Date.now();
  2708. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2709. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2710. if (!cursorMovedTime || vMovement || hMovement) {
  2711. editor.$blockScrolling += 1;
  2712. editor.moveCursorToPosition(cursor);
  2713. editor.$blockScrolling -= 1;
  2714. cursorMovedTime = now;
  2715. cursorPointOnCaretMoved = {x: x, y: y};
  2716. } else {
  2717. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2718. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2719. cursorMovedTime = null;
  2720. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2721. editor.renderer.scrollCursorIntoView();
  2722. cursorMovedTime = null;
  2723. }
  2724. }
  2725. }
  2726. function autoScroll(cursor, prevCursor) {
  2727. var now = Date.now();
  2728. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2729. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2730. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2731. var offsets = {
  2732. x: {
  2733. left: x - editorRect.left,
  2734. right: editorRect.right - x
  2735. },
  2736. y: {
  2737. top: y - editorRect.top,
  2738. bottom: editorRect.bottom - y
  2739. }
  2740. };
  2741. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2742. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2743. var scrollCursor = {row: cursor.row, column: cursor.column};
  2744. if (nearestXOffset / characterWidth <= 2) {
  2745. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2746. }
  2747. if (nearestYOffset / lineHeight <= 1) {
  2748. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2749. }
  2750. var vScroll = cursor.row != scrollCursor.row;
  2751. var hScroll = cursor.column != scrollCursor.column;
  2752. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2753. if (vScroll || (hScroll && !vMovement)) {
  2754. if (!autoScrollStartTime)
  2755. autoScrollStartTime = now;
  2756. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2757. editor.renderer.scrollCursorIntoView(scrollCursor);
  2758. } else {
  2759. autoScrollStartTime = null;
  2760. }
  2761. }
  2762. function onDragInterval() {
  2763. var prevCursor = dragCursor;
  2764. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2765. scrollCursorIntoView(dragCursor, prevCursor);
  2766. autoScroll(dragCursor, prevCursor);
  2767. }
  2768. function addDragMarker() {
  2769. range = editor.selection.toOrientedRange();
  2770. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2771. editor.clearSelection();
  2772. if (editor.isFocused())
  2773. editor.renderer.$cursorLayer.setBlinking(false);
  2774. clearInterval(timerId);
  2775. onDragInterval();
  2776. timerId = setInterval(onDragInterval, 20);
  2777. counter = 0;
  2778. event.addListener(document, "mousemove", onMouseMove);
  2779. }
  2780. function clearDragMarker() {
  2781. clearInterval(timerId);
  2782. editor.session.removeMarker(dragSelectionMarker);
  2783. dragSelectionMarker = null;
  2784. editor.$blockScrolling += 1;
  2785. editor.selection.fromOrientedRange(range);
  2786. editor.$blockScrolling -= 1;
  2787. if (editor.isFocused() && !isInternal)
  2788. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2789. range = null;
  2790. dragCursor = null;
  2791. counter = 0;
  2792. autoScrollStartTime = null;
  2793. cursorMovedTime = null;
  2794. event.removeListener(document, "mousemove", onMouseMove);
  2795. }
  2796. var onMouseMoveTimer = null;
  2797. function onMouseMove() {
  2798. if (onMouseMoveTimer == null) {
  2799. onMouseMoveTimer = setTimeout(function() {
  2800. if (onMouseMoveTimer != null && dragSelectionMarker)
  2801. clearDragMarker();
  2802. }, 20);
  2803. }
  2804. }
  2805. function canAccept(dataTransfer) {
  2806. var types = dataTransfer.types;
  2807. return !types || Array.prototype.some.call(types, function(type) {
  2808. return type == 'text/plain' || type == 'Text';
  2809. });
  2810. }
  2811. function getDropEffect(e) {
  2812. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2813. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2814. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2815. var effectAllowed = "uninitialized";
  2816. try {
  2817. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2818. } catch (e) {}
  2819. var dropEffect = "none";
  2820. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2821. dropEffect = "copy";
  2822. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2823. dropEffect = "move";
  2824. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2825. dropEffect = "copy";
  2826. return dropEffect;
  2827. }
  2828. }
  2829. (function() {
  2830. this.dragWait = function() {
  2831. var interval = Date.now() - this.mousedownEvent.time;
  2832. if (interval > this.editor.getDragDelay())
  2833. this.startDrag();
  2834. };
  2835. this.dragWaitEnd = function() {
  2836. var target = this.editor.container;
  2837. target.draggable = false;
  2838. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2839. this.selectEnd();
  2840. };
  2841. this.dragReadyEnd = function(e) {
  2842. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2843. this.editor.unsetStyle("ace_dragging");
  2844. this.editor.renderer.setCursorStyle("");
  2845. this.dragWaitEnd();
  2846. };
  2847. this.startDrag = function(){
  2848. this.cancelDrag = false;
  2849. var editor = this.editor;
  2850. var target = editor.container;
  2851. target.draggable = true;
  2852. editor.renderer.$cursorLayer.setBlinking(false);
  2853. editor.setStyle("ace_dragging");
  2854. var cursorStyle = useragent.isWin ? "default" : "move";
  2855. editor.renderer.setCursorStyle(cursorStyle);
  2856. this.setState("dragReady");
  2857. };
  2858. this.onMouseDrag = function(e) {
  2859. var target = this.editor.container;
  2860. if (useragent.isIE && this.state == "dragReady") {
  2861. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2862. if (distance > 3)
  2863. target.dragDrop();
  2864. }
  2865. if (this.state === "dragWait") {
  2866. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2867. if (distance > 0) {
  2868. target.draggable = false;
  2869. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2870. }
  2871. }
  2872. };
  2873. this.onMouseDown = function(e) {
  2874. if (!this.$dragEnabled)
  2875. return;
  2876. this.mousedownEvent = e;
  2877. var editor = this.editor;
  2878. var inSelection = e.inSelection();
  2879. var button = e.getButton();
  2880. var clickCount = e.domEvent.detail || 1;
  2881. if (clickCount === 1 && button === 0 && inSelection) {
  2882. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2883. return;
  2884. this.mousedownEvent.time = Date.now();
  2885. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2886. if ("unselectable" in eventTarget)
  2887. eventTarget.unselectable = "on";
  2888. if (editor.getDragDelay()) {
  2889. if (useragent.isWebKit) {
  2890. this.cancelDrag = true;
  2891. var mouseTarget = editor.container;
  2892. mouseTarget.draggable = true;
  2893. }
  2894. this.setState("dragWait");
  2895. } else {
  2896. this.startDrag();
  2897. }
  2898. this.captureMouse(e, this.onMouseDrag.bind(this));
  2899. e.defaultPrevented = true;
  2900. }
  2901. };
  2902. }).call(DragdropHandler.prototype);
  2903. function calcDistance(ax, ay, bx, by) {
  2904. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2905. }
  2906. exports.DragdropHandler = DragdropHandler;
  2907. });
  2908. define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2909. "use strict";
  2910. var dom = require("./dom");
  2911. exports.get = function (url, callback) {
  2912. var xhr = new XMLHttpRequest();
  2913. xhr.open('GET', url, true);
  2914. xhr.onreadystatechange = function () {
  2915. if (xhr.readyState === 4) {
  2916. callback(xhr.responseText);
  2917. }
  2918. };
  2919. xhr.send(null);
  2920. };
  2921. exports.loadScript = function(path, callback) {
  2922. var head = dom.getDocumentHead();
  2923. var s = document.createElement('script');
  2924. s.src = path;
  2925. head.appendChild(s);
  2926. s.onload = s.onreadystatechange = function(_, isAbort) {
  2927. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2928. s = s.onload = s.onreadystatechange = null;
  2929. if (!isAbort)
  2930. callback();
  2931. }
  2932. };
  2933. };
  2934. exports.qualifyURL = function(url) {
  2935. var a = document.createElement('a');
  2936. a.href = url;
  2937. return a.href;
  2938. }
  2939. });
  2940. define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2941. "use strict";
  2942. var EventEmitter = {};
  2943. var stopPropagation = function() { this.propagationStopped = true; };
  2944. var preventDefault = function() { this.defaultPrevented = true; };
  2945. EventEmitter._emit =
  2946. EventEmitter._dispatchEvent = function(eventName, e) {
  2947. this._eventRegistry || (this._eventRegistry = {});
  2948. this._defaultHandlers || (this._defaultHandlers = {});
  2949. var listeners = this._eventRegistry[eventName] || [];
  2950. var defaultHandler = this._defaultHandlers[eventName];
  2951. if (!listeners.length && !defaultHandler)
  2952. return;
  2953. if (typeof e != "object" || !e)
  2954. e = {};
  2955. if (!e.type)
  2956. e.type = eventName;
  2957. if (!e.stopPropagation)
  2958. e.stopPropagation = stopPropagation;
  2959. if (!e.preventDefault)
  2960. e.preventDefault = preventDefault;
  2961. listeners = listeners.slice();
  2962. for (var i=0; i<listeners.length; i++) {
  2963. listeners[i](e, this);
  2964. if (e.propagationStopped)
  2965. break;
  2966. }
  2967. if (defaultHandler && !e.defaultPrevented)
  2968. return defaultHandler(e, this);
  2969. };
  2970. EventEmitter._signal = function(eventName, e) {
  2971. var listeners = (this._eventRegistry || {})[eventName];
  2972. if (!listeners)
  2973. return;
  2974. listeners = listeners.slice();
  2975. for (var i=0; i<listeners.length; i++)
  2976. listeners[i](e, this);
  2977. };
  2978. EventEmitter.once = function(eventName, callback) {
  2979. var _self = this;
  2980. callback && this.addEventListener(eventName, function newCallback() {
  2981. _self.removeEventListener(eventName, newCallback);
  2982. callback.apply(null, arguments);
  2983. });
  2984. };
  2985. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2986. var handlers = this._defaultHandlers
  2987. if (!handlers)
  2988. handlers = this._defaultHandlers = {_disabled_: {}};
  2989. if (handlers[eventName]) {
  2990. var old = handlers[eventName];
  2991. var disabled = handlers._disabled_[eventName];
  2992. if (!disabled)
  2993. handlers._disabled_[eventName] = disabled = [];
  2994. disabled.push(old);
  2995. var i = disabled.indexOf(callback);
  2996. if (i != -1)
  2997. disabled.splice(i, 1);
  2998. }
  2999. handlers[eventName] = callback;
  3000. };
  3001. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  3002. var handlers = this._defaultHandlers
  3003. if (!handlers)
  3004. return;
  3005. var disabled = handlers._disabled_[eventName];
  3006. if (handlers[eventName] == callback) {
  3007. var old = handlers[eventName];
  3008. if (disabled)
  3009. this.setDefaultHandler(eventName, disabled.pop());
  3010. } else if (disabled) {
  3011. var i = disabled.indexOf(callback);
  3012. if (i != -1)
  3013. disabled.splice(i, 1);
  3014. }
  3015. };
  3016. EventEmitter.on =
  3017. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  3018. this._eventRegistry = this._eventRegistry || {};
  3019. var listeners = this._eventRegistry[eventName];
  3020. if (!listeners)
  3021. listeners = this._eventRegistry[eventName] = [];
  3022. if (listeners.indexOf(callback) == -1)
  3023. listeners[capturing ? "unshift" : "push"](callback);
  3024. return callback;
  3025. };
  3026. EventEmitter.off =
  3027. EventEmitter.removeListener =
  3028. EventEmitter.removeEventListener = function(eventName, callback) {
  3029. this._eventRegistry = this._eventRegistry || {};
  3030. var listeners = this._eventRegistry[eventName];
  3031. if (!listeners)
  3032. return;
  3033. var index = listeners.indexOf(callback);
  3034. if (index !== -1)
  3035. listeners.splice(index, 1);
  3036. };
  3037. EventEmitter.removeAllListeners = function(eventName) {
  3038. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3039. };
  3040. exports.EventEmitter = EventEmitter;
  3041. });
  3042. define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3043. "no use strict";
  3044. var oop = require("./oop");
  3045. var EventEmitter = require("./event_emitter").EventEmitter;
  3046. var optionsProvider = {
  3047. setOptions: function(optList) {
  3048. Object.keys(optList).forEach(function(key) {
  3049. this.setOption(key, optList[key]);
  3050. }, this);
  3051. },
  3052. getOptions: function(optionNames) {
  3053. var result = {};
  3054. if (!optionNames) {
  3055. optionNames = Object.keys(this.$options);
  3056. } else if (!Array.isArray(optionNames)) {
  3057. result = optionNames;
  3058. optionNames = Object.keys(result);
  3059. }
  3060. optionNames.forEach(function(key) {
  3061. result[key] = this.getOption(key);
  3062. }, this);
  3063. return result;
  3064. },
  3065. setOption: function(name, value) {
  3066. if (this["$" + name] === value)
  3067. return;
  3068. var opt = this.$options[name];
  3069. if (!opt) {
  3070. return warn('misspelled option "' + name + '"');
  3071. }
  3072. if (opt.forwardTo)
  3073. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3074. if (!opt.handlesSet)
  3075. this["$" + name] = value;
  3076. if (opt && opt.set)
  3077. opt.set.call(this, value);
  3078. },
  3079. getOption: function(name) {
  3080. var opt = this.$options[name];
  3081. if (!opt) {
  3082. return warn('misspelled option "' + name + '"');
  3083. }
  3084. if (opt.forwardTo)
  3085. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3086. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3087. }
  3088. };
  3089. function warn(message) {
  3090. if (typeof console != "undefined" && console.warn)
  3091. console.warn.apply(console, arguments);
  3092. }
  3093. function reportError(msg, data) {
  3094. var e = new Error(msg);
  3095. e.data = data;
  3096. if (typeof console == "object" && console.error)
  3097. console.error(e);
  3098. setTimeout(function() { throw e; });
  3099. }
  3100. var AppConfig = function() {
  3101. this.$defaultOptions = {};
  3102. };
  3103. (function() {
  3104. oop.implement(this, EventEmitter);
  3105. this.defineOptions = function(obj, path, options) {
  3106. if (!obj.$options)
  3107. this.$defaultOptions[path] = obj.$options = {};
  3108. Object.keys(options).forEach(function(key) {
  3109. var opt = options[key];
  3110. if (typeof opt == "string")
  3111. opt = {forwardTo: opt};
  3112. opt.name || (opt.name = key);
  3113. obj.$options[opt.name] = opt;
  3114. if ("initialValue" in opt)
  3115. obj["$" + opt.name] = opt.initialValue;
  3116. });
  3117. oop.implement(obj, optionsProvider);
  3118. return this;
  3119. };
  3120. this.resetOptions = function(obj) {
  3121. Object.keys(obj.$options).forEach(function(key) {
  3122. var opt = obj.$options[key];
  3123. if ("value" in opt)
  3124. obj.setOption(key, opt.value);
  3125. });
  3126. };
  3127. this.setDefaultValue = function(path, name, value) {
  3128. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3129. if (opts[name]) {
  3130. if (opts.forwardTo)
  3131. this.setDefaultValue(opts.forwardTo, name, value);
  3132. else
  3133. opts[name].value = value;
  3134. }
  3135. };
  3136. this.setDefaultValues = function(path, optionHash) {
  3137. Object.keys(optionHash).forEach(function(key) {
  3138. this.setDefaultValue(path, key, optionHash[key]);
  3139. }, this);
  3140. };
  3141. this.warn = warn;
  3142. this.reportError = reportError;
  3143. }).call(AppConfig.prototype);
  3144. exports.AppConfig = AppConfig;
  3145. });
  3146. define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3147. "no use strict";
  3148. var lang = require("./lib/lang");
  3149. var oop = require("./lib/oop");
  3150. var net = require("./lib/net");
  3151. var AppConfig = require("./lib/app_config").AppConfig;
  3152. module.exports = exports = new AppConfig();
  3153. var global = (function() {
  3154. return this || typeof window != "undefined" && window;
  3155. })();
  3156. var options = {
  3157. packaged: false,
  3158. workerPath: null,
  3159. modePath: null,
  3160. themePath: null,
  3161. basePath: "",
  3162. suffix: ".js",
  3163. $moduleUrls: {}
  3164. };
  3165. exports.get = function(key) {
  3166. if (!options.hasOwnProperty(key))
  3167. throw new Error("Unknown config key: " + key);
  3168. return options[key];
  3169. };
  3170. exports.set = function(key, value) {
  3171. if (!options.hasOwnProperty(key))
  3172. throw new Error("Unknown config key: " + key);
  3173. options[key] = value;
  3174. };
  3175. exports.all = function() {
  3176. return lang.copyObject(options);
  3177. };
  3178. exports.moduleUrl = function(name, component) {
  3179. if (options.$moduleUrls[name])
  3180. return options.$moduleUrls[name];
  3181. var parts = name.split("/");
  3182. component = component || parts[parts.length - 2] || "";
  3183. var sep = component == "snippets" ? "/" : "-";
  3184. var base = parts[parts.length - 1];
  3185. if (component == "worker" && sep == "-") {
  3186. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3187. base = base.replace(re, "");
  3188. }
  3189. if ((!base || base == component) && parts.length > 1)
  3190. base = parts[parts.length - 2];
  3191. var path = options[component + "Path"];
  3192. if (path == null) {
  3193. path = options.basePath;
  3194. } else if (sep == "/") {
  3195. component = sep = "";
  3196. }
  3197. if (path && path.slice(-1) != "/")
  3198. path += "/";
  3199. return path + component + sep + base + this.get("suffix");
  3200. };
  3201. exports.setModuleUrl = function(name, subst) {
  3202. return options.$moduleUrls[name] = subst;
  3203. };
  3204. exports.$loading = {};
  3205. exports.loadModule = function(moduleName, onLoad) {
  3206. var module, moduleType;
  3207. if (Array.isArray(moduleName)) {
  3208. moduleType = moduleName[0];
  3209. moduleName = moduleName[1];
  3210. }
  3211. try {
  3212. module = require(moduleName);
  3213. } catch (e) {}
  3214. if (module && !exports.$loading[moduleName])
  3215. return onLoad && onLoad(module);
  3216. if (!exports.$loading[moduleName])
  3217. exports.$loading[moduleName] = [];
  3218. exports.$loading[moduleName].push(onLoad);
  3219. if (exports.$loading[moduleName].length > 1)
  3220. return;
  3221. var afterLoad = function() {
  3222. require([moduleName], function(module) {
  3223. exports._emit("load.module", {name: moduleName, module: module});
  3224. var listeners = exports.$loading[moduleName];
  3225. exports.$loading[moduleName] = null;
  3226. listeners.forEach(function(onLoad) {
  3227. onLoad && onLoad(module);
  3228. });
  3229. });
  3230. };
  3231. if (!exports.get("packaged"))
  3232. return afterLoad();
  3233. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3234. };
  3235. init(true);function init(packaged) {
  3236. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3237. if (!global.document)
  3238. return "";
  3239. var scriptOptions = {};
  3240. var scriptUrl = "";
  3241. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3242. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3243. var scripts = currentDocument.getElementsByTagName("script");
  3244. for (var i=0; i<scripts.length; i++) {
  3245. var script = scripts[i];
  3246. var src = script.src || script.getAttribute("src");
  3247. if (!src)
  3248. continue;
  3249. var attributes = script.attributes;
  3250. for (var j=0, l=attributes.length; j < l; j++) {
  3251. var attr = attributes[j];
  3252. if (attr.name.indexOf("data-ace-") === 0) {
  3253. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3254. }
  3255. }
  3256. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3257. if (m)
  3258. scriptUrl = m[1];
  3259. }
  3260. if (scriptUrl) {
  3261. scriptOptions.base = scriptOptions.base || scriptUrl;
  3262. scriptOptions.packaged = true;
  3263. }
  3264. scriptOptions.basePath = scriptOptions.base;
  3265. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3266. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3267. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3268. delete scriptOptions.base;
  3269. for (var key in scriptOptions)
  3270. if (typeof scriptOptions[key] !== "undefined")
  3271. exports.set(key, scriptOptions[key]);
  3272. };
  3273. exports.init = init;
  3274. function deHyphenate(str) {
  3275. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3276. }
  3277. });
  3278. define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"], function(require, exports, module) {
  3279. "use strict";
  3280. var event = require("../lib/event");
  3281. var useragent = require("../lib/useragent");
  3282. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3283. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3284. var MouseEvent = require("./mouse_event").MouseEvent;
  3285. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3286. var config = require("../config");
  3287. var MouseHandler = function(editor) {
  3288. var _self = this;
  3289. this.editor = editor;
  3290. new DefaultHandlers(this);
  3291. new DefaultGutterHandler(this);
  3292. new DragdropHandler(this);
  3293. var focusEditor = function(e) {
  3294. if (!document.hasFocus || !document.hasFocus())
  3295. window.focus();
  3296. editor.focus();
  3297. if (!editor.isFocused())
  3298. window.focus();
  3299. };
  3300. var mouseTarget = editor.renderer.getMouseEventTarget();
  3301. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3302. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3303. event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
  3304. if (editor.renderer.scrollBarV) {
  3305. event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
  3306. event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
  3307. if (useragent.isIE) {
  3308. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3309. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3310. }
  3311. }
  3312. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3313. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3314. var gutterEl = editor.renderer.$gutter;
  3315. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3316. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3317. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3318. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3319. event.addListener(mouseTarget, "mousedown", focusEditor);
  3320. event.addListener(gutterEl, "mousedown", function(e) {
  3321. editor.focus();
  3322. return event.preventDefault(e);
  3323. });
  3324. editor.on("mousemove", function(e){
  3325. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3326. return;
  3327. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3328. var range = editor.session.selection.getRange();
  3329. var renderer = editor.renderer;
  3330. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3331. renderer.setCursorStyle("default");
  3332. } else {
  3333. renderer.setCursorStyle("");
  3334. }
  3335. });
  3336. };
  3337. (function() {
  3338. this.onMouseEvent = function(name, e) {
  3339. this.editor._emit(name, new MouseEvent(e, this.editor));
  3340. };
  3341. this.onMouseMove = function(name, e) {
  3342. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3343. if (!listeners || !listeners.length)
  3344. return;
  3345. this.editor._emit(name, new MouseEvent(e, this.editor));
  3346. };
  3347. this.onMouseWheel = function(name, e) {
  3348. var mouseEvent = new MouseEvent(e, this.editor);
  3349. mouseEvent.speed = this.$scrollSpeed * 2;
  3350. mouseEvent.wheelX = e.wheelX;
  3351. mouseEvent.wheelY = e.wheelY;
  3352. this.editor._emit(name, mouseEvent);
  3353. };
  3354. this.onTouchMove = function (name, e) {
  3355. var mouseEvent = new MouseEvent(e, this.editor);
  3356. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3357. mouseEvent.wheelX = e.wheelX;
  3358. mouseEvent.wheelY = e.wheelY;
  3359. this.editor._emit(name, mouseEvent);
  3360. };
  3361. this.setState = function(state) {
  3362. this.state = state;
  3363. };
  3364. this.captureMouse = function(ev, mouseMoveHandler) {
  3365. this.x = ev.x;
  3366. this.y = ev.y;
  3367. this.isMousePressed = true;
  3368. var renderer = this.editor.renderer;
  3369. if (renderer.$keepTextAreaAtCursor)
  3370. renderer.$keepTextAreaAtCursor = null;
  3371. var self = this;
  3372. var onMouseMove = function(e) {
  3373. if (!e) return;
  3374. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3375. return self.releaseMouse();
  3376. self.x = e.clientX;
  3377. self.y = e.clientY;
  3378. mouseMoveHandler && mouseMoveHandler(e);
  3379. self.mouseEvent = new MouseEvent(e, self.editor);
  3380. self.$mouseMoved = true;
  3381. };
  3382. var onCaptureEnd = function(e) {
  3383. clearInterval(timerId);
  3384. onCaptureInterval();
  3385. self[self.state + "End"] && self[self.state + "End"](e);
  3386. self.state = "";
  3387. if (renderer.$keepTextAreaAtCursor == null) {
  3388. renderer.$keepTextAreaAtCursor = true;
  3389. renderer.$moveTextAreaToCursor();
  3390. }
  3391. self.isMousePressed = false;
  3392. self.$onCaptureMouseMove = self.releaseMouse = null;
  3393. e && self.onMouseEvent("mouseup", e);
  3394. };
  3395. var onCaptureInterval = function() {
  3396. self[self.state] && self[self.state]();
  3397. self.$mouseMoved = false;
  3398. };
  3399. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3400. return setTimeout(function() {onCaptureEnd(ev);});
  3401. }
  3402. self.$onCaptureMouseMove = onMouseMove;
  3403. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3404. var timerId = setInterval(onCaptureInterval, 20);
  3405. };
  3406. this.releaseMouse = null;
  3407. this.cancelContextMenu = function() {
  3408. var stop = function(e) {
  3409. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3410. return;
  3411. this.editor.off("nativecontextmenu", stop);
  3412. if (e && e.domEvent)
  3413. event.stopEvent(e.domEvent);
  3414. }.bind(this);
  3415. setTimeout(stop, 10);
  3416. this.editor.on("nativecontextmenu", stop);
  3417. };
  3418. }).call(MouseHandler.prototype);
  3419. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3420. scrollSpeed: {initialValue: 2},
  3421. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3422. dragEnabled: {initialValue: true},
  3423. focusTimout: {initialValue: 0},
  3424. tooltipFollowsMouse: {initialValue: true}
  3425. });
  3426. exports.MouseHandler = MouseHandler;
  3427. });
  3428. define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3429. "use strict";
  3430. function FoldHandler(editor) {
  3431. editor.on("click", function(e) {
  3432. var position = e.getDocumentPosition();
  3433. var session = editor.session;
  3434. var fold = session.getFoldAt(position.row, position.column, 1);
  3435. if (fold) {
  3436. if (e.getAccelKey())
  3437. session.removeFold(fold);
  3438. else
  3439. session.expandFold(fold);
  3440. e.stop();
  3441. }
  3442. });
  3443. editor.on("gutterclick", function(e) {
  3444. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3445. if (gutterRegion == "foldWidgets") {
  3446. var row = e.getDocumentPosition().row;
  3447. var session = editor.session;
  3448. if (session.foldWidgets && session.foldWidgets[row])
  3449. editor.session.onFoldWidgetClick(row, e);
  3450. if (!editor.isFocused())
  3451. editor.focus();
  3452. e.stop();
  3453. }
  3454. });
  3455. editor.on("gutterdblclick", function(e) {
  3456. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3457. if (gutterRegion == "foldWidgets") {
  3458. var row = e.getDocumentPosition().row;
  3459. var session = editor.session;
  3460. var data = session.getParentFoldRangeData(row, true);
  3461. var range = data.range || data.firstRange;
  3462. if (range) {
  3463. row = range.start.row;
  3464. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3465. if (fold) {
  3466. session.removeFold(fold);
  3467. } else {
  3468. session.addFold("...", range);
  3469. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3470. }
  3471. }
  3472. e.stop();
  3473. }
  3474. });
  3475. }
  3476. exports.FoldHandler = FoldHandler;
  3477. });
  3478. define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3479. "use strict";
  3480. var keyUtil = require("../lib/keys");
  3481. var event = require("../lib/event");
  3482. var KeyBinding = function(editor) {
  3483. this.$editor = editor;
  3484. this.$data = {editor: editor};
  3485. this.$handlers = [];
  3486. this.setDefaultHandler(editor.commands);
  3487. };
  3488. (function() {
  3489. this.setDefaultHandler = function(kb) {
  3490. this.removeKeyboardHandler(this.$defaultHandler);
  3491. this.$defaultHandler = kb;
  3492. this.addKeyboardHandler(kb, 0);
  3493. };
  3494. this.setKeyboardHandler = function(kb) {
  3495. var h = this.$handlers;
  3496. if (h[h.length - 1] == kb)
  3497. return;
  3498. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3499. this.removeKeyboardHandler(h[h.length - 1]);
  3500. this.addKeyboardHandler(kb, 1);
  3501. };
  3502. this.addKeyboardHandler = function(kb, pos) {
  3503. if (!kb)
  3504. return;
  3505. if (typeof kb == "function" && !kb.handleKeyboard)
  3506. kb.handleKeyboard = kb;
  3507. var i = this.$handlers.indexOf(kb);
  3508. if (i != -1)
  3509. this.$handlers.splice(i, 1);
  3510. if (pos == undefined)
  3511. this.$handlers.push(kb);
  3512. else
  3513. this.$handlers.splice(pos, 0, kb);
  3514. if (i == -1 && kb.attach)
  3515. kb.attach(this.$editor);
  3516. };
  3517. this.removeKeyboardHandler = function(kb) {
  3518. var i = this.$handlers.indexOf(kb);
  3519. if (i == -1)
  3520. return false;
  3521. this.$handlers.splice(i, 1);
  3522. kb.detach && kb.detach(this.$editor);
  3523. return true;
  3524. };
  3525. this.getKeyboardHandler = function() {
  3526. return this.$handlers[this.$handlers.length - 1];
  3527. };
  3528. this.getStatusText = function() {
  3529. var data = this.$data;
  3530. var editor = data.editor;
  3531. return this.$handlers.map(function(h) {
  3532. return h.getStatusText && h.getStatusText(editor, data) || "";
  3533. }).filter(Boolean).join(" ");
  3534. };
  3535. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3536. var toExecute;
  3537. var success = false;
  3538. var commands = this.$editor.commands;
  3539. for (var i = this.$handlers.length; i--;) {
  3540. toExecute = this.$handlers[i].handleKeyboard(
  3541. this.$data, hashId, keyString, keyCode, e
  3542. );
  3543. if (!toExecute || !toExecute.command)
  3544. continue;
  3545. if (toExecute.command == "null") {
  3546. success = true;
  3547. } else {
  3548. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3549. }
  3550. if (success && e && hashId != -1 &&
  3551. toExecute.passEvent != true && toExecute.command.passEvent != true
  3552. ) {
  3553. event.stopEvent(e);
  3554. }
  3555. if (success)
  3556. break;
  3557. }
  3558. if (!success && hashId == -1) {
  3559. toExecute = {command: "insertstring"};
  3560. success = commands.exec("insertstring", this.$editor, keyString);
  3561. }
  3562. if (success)
  3563. this.$editor._signal("keyboardActivity", toExecute);
  3564. return success;
  3565. };
  3566. this.onCommandKey = function(e, hashId, keyCode) {
  3567. var keyString = keyUtil.keyCodeToString(keyCode);
  3568. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3569. };
  3570. this.onTextInput = function(text) {
  3571. this.$callKeyboardHandlers(-1, text);
  3572. };
  3573. }).call(KeyBinding.prototype);
  3574. exports.KeyBinding = KeyBinding;
  3575. });
  3576. define("ace/range",["require","exports","module"], function(require, exports, module) {
  3577. "use strict";
  3578. var comparePoints = function(p1, p2) {
  3579. return p1.row - p2.row || p1.column - p2.column;
  3580. };
  3581. var Range = function(startRow, startColumn, endRow, endColumn) {
  3582. this.start = {
  3583. row: startRow,
  3584. column: startColumn
  3585. };
  3586. this.end = {
  3587. row: endRow,
  3588. column: endColumn
  3589. };
  3590. };
  3591. (function() {
  3592. this.isEqual = function(range) {
  3593. return this.start.row === range.start.row &&
  3594. this.end.row === range.end.row &&
  3595. this.start.column === range.start.column &&
  3596. this.end.column === range.end.column;
  3597. };
  3598. this.toString = function() {
  3599. return ("Range: [" + this.start.row + "/" + this.start.column +
  3600. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3601. };
  3602. this.contains = function(row, column) {
  3603. return this.compare(row, column) == 0;
  3604. };
  3605. this.compareRange = function(range) {
  3606. var cmp,
  3607. end = range.end,
  3608. start = range.start;
  3609. cmp = this.compare(end.row, end.column);
  3610. if (cmp == 1) {
  3611. cmp = this.compare(start.row, start.column);
  3612. if (cmp == 1) {
  3613. return 2;
  3614. } else if (cmp == 0) {
  3615. return 1;
  3616. } else {
  3617. return 0;
  3618. }
  3619. } else if (cmp == -1) {
  3620. return -2;
  3621. } else {
  3622. cmp = this.compare(start.row, start.column);
  3623. if (cmp == -1) {
  3624. return -1;
  3625. } else if (cmp == 1) {
  3626. return 42;
  3627. } else {
  3628. return 0;
  3629. }
  3630. }
  3631. };
  3632. this.comparePoint = function(p) {
  3633. return this.compare(p.row, p.column);
  3634. };
  3635. this.containsRange = function(range) {
  3636. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3637. };
  3638. this.intersects = function(range) {
  3639. var cmp = this.compareRange(range);
  3640. return (cmp == -1 || cmp == 0 || cmp == 1);
  3641. };
  3642. this.isEnd = function(row, column) {
  3643. return this.end.row == row && this.end.column == column;
  3644. };
  3645. this.isStart = function(row, column) {
  3646. return this.start.row == row && this.start.column == column;
  3647. };
  3648. this.setStart = function(row, column) {
  3649. if (typeof row == "object") {
  3650. this.start.column = row.column;
  3651. this.start.row = row.row;
  3652. } else {
  3653. this.start.row = row;
  3654. this.start.column = column;
  3655. }
  3656. };
  3657. this.setEnd = function(row, column) {
  3658. if (typeof row == "object") {
  3659. this.end.column = row.column;
  3660. this.end.row = row.row;
  3661. } else {
  3662. this.end.row = row;
  3663. this.end.column = column;
  3664. }
  3665. };
  3666. this.inside = function(row, column) {
  3667. if (this.compare(row, column) == 0) {
  3668. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3669. return false;
  3670. } else {
  3671. return true;
  3672. }
  3673. }
  3674. return false;
  3675. };
  3676. this.insideStart = function(row, column) {
  3677. if (this.compare(row, column) == 0) {
  3678. if (this.isEnd(row, column)) {
  3679. return false;
  3680. } else {
  3681. return true;
  3682. }
  3683. }
  3684. return false;
  3685. };
  3686. this.insideEnd = function(row, column) {
  3687. if (this.compare(row, column) == 0) {
  3688. if (this.isStart(row, column)) {
  3689. return false;
  3690. } else {
  3691. return true;
  3692. }
  3693. }
  3694. return false;
  3695. };
  3696. this.compare = function(row, column) {
  3697. if (!this.isMultiLine()) {
  3698. if (row === this.start.row) {
  3699. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3700. };
  3701. }
  3702. if (row < this.start.row)
  3703. return -1;
  3704. if (row > this.end.row)
  3705. return 1;
  3706. if (this.start.row === row)
  3707. return column >= this.start.column ? 0 : -1;
  3708. if (this.end.row === row)
  3709. return column <= this.end.column ? 0 : 1;
  3710. return 0;
  3711. };
  3712. this.compareStart = function(row, column) {
  3713. if (this.start.row == row && this.start.column == column) {
  3714. return -1;
  3715. } else {
  3716. return this.compare(row, column);
  3717. }
  3718. };
  3719. this.compareEnd = function(row, column) {
  3720. if (this.end.row == row && this.end.column == column) {
  3721. return 1;
  3722. } else {
  3723. return this.compare(row, column);
  3724. }
  3725. };
  3726. this.compareInside = function(row, column) {
  3727. if (this.end.row == row && this.end.column == column) {
  3728. return 1;
  3729. } else if (this.start.row == row && this.start.column == column) {
  3730. return -1;
  3731. } else {
  3732. return this.compare(row, column);
  3733. }
  3734. };
  3735. this.clipRows = function(firstRow, lastRow) {
  3736. if (this.end.row > lastRow)
  3737. var end = {row: lastRow + 1, column: 0};
  3738. else if (this.end.row < firstRow)
  3739. var end = {row: firstRow, column: 0};
  3740. if (this.start.row > lastRow)
  3741. var start = {row: lastRow + 1, column: 0};
  3742. else if (this.start.row < firstRow)
  3743. var start = {row: firstRow, column: 0};
  3744. return Range.fromPoints(start || this.start, end || this.end);
  3745. };
  3746. this.extend = function(row, column) {
  3747. var cmp = this.compare(row, column);
  3748. if (cmp == 0)
  3749. return this;
  3750. else if (cmp == -1)
  3751. var start = {row: row, column: column};
  3752. else
  3753. var end = {row: row, column: column};
  3754. return Range.fromPoints(start || this.start, end || this.end);
  3755. };
  3756. this.isEmpty = function() {
  3757. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3758. };
  3759. this.isMultiLine = function() {
  3760. return (this.start.row !== this.end.row);
  3761. };
  3762. this.clone = function() {
  3763. return Range.fromPoints(this.start, this.end);
  3764. };
  3765. this.collapseRows = function() {
  3766. if (this.end.column == 0)
  3767. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3768. else
  3769. return new Range(this.start.row, 0, this.end.row, 0)
  3770. };
  3771. this.toScreenRange = function(session) {
  3772. var screenPosStart = session.documentToScreenPosition(this.start);
  3773. var screenPosEnd = session.documentToScreenPosition(this.end);
  3774. return new Range(
  3775. screenPosStart.row, screenPosStart.column,
  3776. screenPosEnd.row, screenPosEnd.column
  3777. );
  3778. };
  3779. this.moveBy = function(row, column) {
  3780. this.start.row += row;
  3781. this.start.column += column;
  3782. this.end.row += row;
  3783. this.end.column += column;
  3784. };
  3785. }).call(Range.prototype);
  3786. Range.fromPoints = function(start, end) {
  3787. return new Range(start.row, start.column, end.row, end.column);
  3788. };
  3789. Range.comparePoints = comparePoints;
  3790. Range.comparePoints = function(p1, p2) {
  3791. return p1.row - p2.row || p1.column - p2.column;
  3792. };
  3793. exports.Range = Range;
  3794. });
  3795. define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3796. "use strict";
  3797. var oop = require("./lib/oop");
  3798. var lang = require("./lib/lang");
  3799. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3800. var Range = require("./range").Range;
  3801. var Selection = function(session) {
  3802. this.session = session;
  3803. this.doc = session.getDocument();
  3804. this.clearSelection();
  3805. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3806. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3807. var self = this;
  3808. this.lead.on("change", function(e) {
  3809. self._emit("changeCursor");
  3810. if (!self.$isEmpty)
  3811. self._emit("changeSelection");
  3812. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3813. self.$desiredColumn = null;
  3814. });
  3815. this.selectionAnchor.on("change", function() {
  3816. if (!self.$isEmpty)
  3817. self._emit("changeSelection");
  3818. });
  3819. };
  3820. (function() {
  3821. oop.implement(this, EventEmitter);
  3822. this.isEmpty = function() {
  3823. return (this.$isEmpty || (
  3824. this.anchor.row == this.lead.row &&
  3825. this.anchor.column == this.lead.column
  3826. ));
  3827. };
  3828. this.isMultiLine = function() {
  3829. if (this.isEmpty()) {
  3830. return false;
  3831. }
  3832. return this.getRange().isMultiLine();
  3833. };
  3834. this.getCursor = function() {
  3835. return this.lead.getPosition();
  3836. };
  3837. this.setSelectionAnchor = function(row, column) {
  3838. this.anchor.setPosition(row, column);
  3839. if (this.$isEmpty) {
  3840. this.$isEmpty = false;
  3841. this._emit("changeSelection");
  3842. }
  3843. };
  3844. this.getSelectionAnchor = function() {
  3845. if (this.$isEmpty)
  3846. return this.getSelectionLead();
  3847. else
  3848. return this.anchor.getPosition();
  3849. };
  3850. this.getSelectionLead = function() {
  3851. return this.lead.getPosition();
  3852. };
  3853. this.shiftSelection = function(columns) {
  3854. if (this.$isEmpty) {
  3855. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3856. return;
  3857. }
  3858. var anchor = this.getSelectionAnchor();
  3859. var lead = this.getSelectionLead();
  3860. var isBackwards = this.isBackwards();
  3861. if (!isBackwards || anchor.column !== 0)
  3862. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3863. if (isBackwards || lead.column !== 0) {
  3864. this.$moveSelection(function() {
  3865. this.moveCursorTo(lead.row, lead.column + columns);
  3866. });
  3867. }
  3868. };
  3869. this.isBackwards = function() {
  3870. var anchor = this.anchor;
  3871. var lead = this.lead;
  3872. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3873. };
  3874. this.getRange = function() {
  3875. var anchor = this.anchor;
  3876. var lead = this.lead;
  3877. if (this.isEmpty())
  3878. return Range.fromPoints(lead, lead);
  3879. if (this.isBackwards()) {
  3880. return Range.fromPoints(lead, anchor);
  3881. }
  3882. else {
  3883. return Range.fromPoints(anchor, lead);
  3884. }
  3885. };
  3886. this.clearSelection = function() {
  3887. if (!this.$isEmpty) {
  3888. this.$isEmpty = true;
  3889. this._emit("changeSelection");
  3890. }
  3891. };
  3892. this.selectAll = function() {
  3893. var lastRow = this.doc.getLength() - 1;
  3894. this.setSelectionAnchor(0, 0);
  3895. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3896. };
  3897. this.setRange =
  3898. this.setSelectionRange = function(range, reverse) {
  3899. if (reverse) {
  3900. this.setSelectionAnchor(range.end.row, range.end.column);
  3901. this.selectTo(range.start.row, range.start.column);
  3902. } else {
  3903. this.setSelectionAnchor(range.start.row, range.start.column);
  3904. this.selectTo(range.end.row, range.end.column);
  3905. }
  3906. if (this.getRange().isEmpty())
  3907. this.$isEmpty = true;
  3908. this.$desiredColumn = null;
  3909. };
  3910. this.$moveSelection = function(mover) {
  3911. var lead = this.lead;
  3912. if (this.$isEmpty)
  3913. this.setSelectionAnchor(lead.row, lead.column);
  3914. mover.call(this);
  3915. };
  3916. this.selectTo = function(row, column) {
  3917. this.$moveSelection(function() {
  3918. this.moveCursorTo(row, column);
  3919. });
  3920. };
  3921. this.selectToPosition = function(pos) {
  3922. this.$moveSelection(function() {
  3923. this.moveCursorToPosition(pos);
  3924. });
  3925. };
  3926. this.moveTo = function(row, column) {
  3927. this.clearSelection();
  3928. this.moveCursorTo(row, column);
  3929. };
  3930. this.moveToPosition = function(pos) {
  3931. this.clearSelection();
  3932. this.moveCursorToPosition(pos);
  3933. };
  3934. this.selectUp = function() {
  3935. this.$moveSelection(this.moveCursorUp);
  3936. };
  3937. this.selectDown = function() {
  3938. this.$moveSelection(this.moveCursorDown);
  3939. };
  3940. this.selectRight = function() {
  3941. this.$moveSelection(this.moveCursorRight);
  3942. };
  3943. this.selectLeft = function() {
  3944. this.$moveSelection(this.moveCursorLeft);
  3945. };
  3946. this.selectLineStart = function() {
  3947. this.$moveSelection(this.moveCursorLineStart);
  3948. };
  3949. this.selectLineEnd = function() {
  3950. this.$moveSelection(this.moveCursorLineEnd);
  3951. };
  3952. this.selectFileEnd = function() {
  3953. this.$moveSelection(this.moveCursorFileEnd);
  3954. };
  3955. this.selectFileStart = function() {
  3956. this.$moveSelection(this.moveCursorFileStart);
  3957. };
  3958. this.selectWordRight = function() {
  3959. this.$moveSelection(this.moveCursorWordRight);
  3960. };
  3961. this.selectWordLeft = function() {
  3962. this.$moveSelection(this.moveCursorWordLeft);
  3963. };
  3964. this.getWordRange = function(row, column) {
  3965. if (typeof column == "undefined") {
  3966. var cursor = row || this.lead;
  3967. row = cursor.row;
  3968. column = cursor.column;
  3969. }
  3970. return this.session.getWordRange(row, column);
  3971. };
  3972. this.selectWord = function() {
  3973. this.setSelectionRange(this.getWordRange());
  3974. };
  3975. this.selectAWord = function() {
  3976. var cursor = this.getCursor();
  3977. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3978. this.setSelectionRange(range);
  3979. };
  3980. this.getLineRange = function(row, excludeLastChar) {
  3981. var rowStart = typeof row == "number" ? row : this.lead.row;
  3982. var rowEnd;
  3983. var foldLine = this.session.getFoldLine(rowStart);
  3984. if (foldLine) {
  3985. rowStart = foldLine.start.row;
  3986. rowEnd = foldLine.end.row;
  3987. } else {
  3988. rowEnd = rowStart;
  3989. }
  3990. if (excludeLastChar === true)
  3991. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3992. else
  3993. return new Range(rowStart, 0, rowEnd + 1, 0);
  3994. };
  3995. this.selectLine = function() {
  3996. this.setSelectionRange(this.getLineRange());
  3997. };
  3998. this.moveCursorUp = function() {
  3999. this.moveCursorBy(-1, 0);
  4000. };
  4001. this.moveCursorDown = function() {
  4002. this.moveCursorBy(1, 0);
  4003. };
  4004. this.moveCursorLeft = function() {
  4005. var cursor = this.lead.getPosition(),
  4006. fold;
  4007. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  4008. this.moveCursorTo(fold.start.row, fold.start.column);
  4009. } else if (cursor.column === 0) {
  4010. if (cursor.row > 0) {
  4011. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  4012. }
  4013. }
  4014. else {
  4015. var tabSize = this.session.getTabSize();
  4016. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  4017. this.moveCursorBy(0, -tabSize);
  4018. else
  4019. this.moveCursorBy(0, -1);
  4020. }
  4021. };
  4022. this.moveCursorRight = function() {
  4023. var cursor = this.lead.getPosition(),
  4024. fold;
  4025. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4026. this.moveCursorTo(fold.end.row, fold.end.column);
  4027. }
  4028. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4029. if (this.lead.row < this.doc.getLength() - 1) {
  4030. this.moveCursorTo(this.lead.row + 1, 0);
  4031. }
  4032. }
  4033. else {
  4034. var tabSize = this.session.getTabSize();
  4035. var cursor = this.lead;
  4036. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  4037. this.moveCursorBy(0, tabSize);
  4038. else
  4039. this.moveCursorBy(0, 1);
  4040. }
  4041. };
  4042. this.moveCursorLineStart = function() {
  4043. var row = this.lead.row;
  4044. var column = this.lead.column;
  4045. var screenRow = this.session.documentToScreenRow(row, column);
  4046. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4047. var beforeCursor = this.session.getDisplayLine(
  4048. row, null, firstColumnPosition.row,
  4049. firstColumnPosition.column
  4050. );
  4051. var leadingSpace = beforeCursor.match(/^\s*/);
  4052. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4053. firstColumnPosition.column += leadingSpace[0].length;
  4054. this.moveCursorToPosition(firstColumnPosition);
  4055. };
  4056. this.moveCursorLineEnd = function() {
  4057. var lead = this.lead;
  4058. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4059. if (this.lead.column == lineEnd.column) {
  4060. var line = this.session.getLine(lineEnd.row);
  4061. if (lineEnd.column == line.length) {
  4062. var textEnd = line.search(/\s+$/);
  4063. if (textEnd > 0)
  4064. lineEnd.column = textEnd;
  4065. }
  4066. }
  4067. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4068. };
  4069. this.moveCursorFileEnd = function() {
  4070. var row = this.doc.getLength() - 1;
  4071. var column = this.doc.getLine(row).length;
  4072. this.moveCursorTo(row, column);
  4073. };
  4074. this.moveCursorFileStart = function() {
  4075. this.moveCursorTo(0, 0);
  4076. };
  4077. this.moveCursorLongWordRight = function() {
  4078. var row = this.lead.row;
  4079. var column = this.lead.column;
  4080. var line = this.doc.getLine(row);
  4081. var rightOfCursor = line.substring(column);
  4082. var match;
  4083. this.session.nonTokenRe.lastIndex = 0;
  4084. this.session.tokenRe.lastIndex = 0;
  4085. var fold = this.session.getFoldAt(row, column, 1);
  4086. if (fold) {
  4087. this.moveCursorTo(fold.end.row, fold.end.column);
  4088. return;
  4089. }
  4090. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4091. column += this.session.nonTokenRe.lastIndex;
  4092. this.session.nonTokenRe.lastIndex = 0;
  4093. rightOfCursor = line.substring(column);
  4094. }
  4095. if (column >= line.length) {
  4096. this.moveCursorTo(row, line.length);
  4097. this.moveCursorRight();
  4098. if (row < this.doc.getLength() - 1)
  4099. this.moveCursorWordRight();
  4100. return;
  4101. }
  4102. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4103. column += this.session.tokenRe.lastIndex;
  4104. this.session.tokenRe.lastIndex = 0;
  4105. }
  4106. this.moveCursorTo(row, column);
  4107. };
  4108. this.moveCursorLongWordLeft = function() {
  4109. var row = this.lead.row;
  4110. var column = this.lead.column;
  4111. var fold;
  4112. if (fold = this.session.getFoldAt(row, column, -1)) {
  4113. this.moveCursorTo(fold.start.row, fold.start.column);
  4114. return;
  4115. }
  4116. var str = this.session.getFoldStringAt(row, column, -1);
  4117. if (str == null) {
  4118. str = this.doc.getLine(row).substring(0, column);
  4119. }
  4120. var leftOfCursor = lang.stringReverse(str);
  4121. var match;
  4122. this.session.nonTokenRe.lastIndex = 0;
  4123. this.session.tokenRe.lastIndex = 0;
  4124. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4125. column -= this.session.nonTokenRe.lastIndex;
  4126. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4127. this.session.nonTokenRe.lastIndex = 0;
  4128. }
  4129. if (column <= 0) {
  4130. this.moveCursorTo(row, 0);
  4131. this.moveCursorLeft();
  4132. if (row > 0)
  4133. this.moveCursorWordLeft();
  4134. return;
  4135. }
  4136. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4137. column -= this.session.tokenRe.lastIndex;
  4138. this.session.tokenRe.lastIndex = 0;
  4139. }
  4140. this.moveCursorTo(row, column);
  4141. };
  4142. this.$shortWordEndIndex = function(rightOfCursor) {
  4143. var match, index = 0, ch;
  4144. var whitespaceRe = /\s/;
  4145. var tokenRe = this.session.tokenRe;
  4146. tokenRe.lastIndex = 0;
  4147. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4148. index = this.session.tokenRe.lastIndex;
  4149. } else {
  4150. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4151. index ++;
  4152. if (index < 1) {
  4153. tokenRe.lastIndex = 0;
  4154. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4155. tokenRe.lastIndex = 0;
  4156. index ++;
  4157. if (whitespaceRe.test(ch)) {
  4158. if (index > 2) {
  4159. index--;
  4160. break;
  4161. } else {
  4162. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4163. index ++;
  4164. if (index > 2)
  4165. break;
  4166. }
  4167. }
  4168. }
  4169. }
  4170. }
  4171. tokenRe.lastIndex = 0;
  4172. return index;
  4173. };
  4174. this.moveCursorShortWordRight = function() {
  4175. var row = this.lead.row;
  4176. var column = this.lead.column;
  4177. var line = this.doc.getLine(row);
  4178. var rightOfCursor = line.substring(column);
  4179. var fold = this.session.getFoldAt(row, column, 1);
  4180. if (fold)
  4181. return this.moveCursorTo(fold.end.row, fold.end.column);
  4182. if (column == line.length) {
  4183. var l = this.doc.getLength();
  4184. do {
  4185. row++;
  4186. rightOfCursor = this.doc.getLine(row);
  4187. } while (row < l && /^\s*$/.test(rightOfCursor));
  4188. if (!/^\s+/.test(rightOfCursor))
  4189. rightOfCursor = "";
  4190. column = 0;
  4191. }
  4192. var index = this.$shortWordEndIndex(rightOfCursor);
  4193. this.moveCursorTo(row, column + index);
  4194. };
  4195. this.moveCursorShortWordLeft = function() {
  4196. var row = this.lead.row;
  4197. var column = this.lead.column;
  4198. var fold;
  4199. if (fold = this.session.getFoldAt(row, column, -1))
  4200. return this.moveCursorTo(fold.start.row, fold.start.column);
  4201. var line = this.session.getLine(row).substring(0, column);
  4202. if (column === 0) {
  4203. do {
  4204. row--;
  4205. line = this.doc.getLine(row);
  4206. } while (row > 0 && /^\s*$/.test(line));
  4207. column = line.length;
  4208. if (!/\s+$/.test(line))
  4209. line = "";
  4210. }
  4211. var leftOfCursor = lang.stringReverse(line);
  4212. var index = this.$shortWordEndIndex(leftOfCursor);
  4213. return this.moveCursorTo(row, column - index);
  4214. };
  4215. this.moveCursorWordRight = function() {
  4216. if (this.session.$selectLongWords)
  4217. this.moveCursorLongWordRight();
  4218. else
  4219. this.moveCursorShortWordRight();
  4220. };
  4221. this.moveCursorWordLeft = function() {
  4222. if (this.session.$selectLongWords)
  4223. this.moveCursorLongWordLeft();
  4224. else
  4225. this.moveCursorShortWordLeft();
  4226. };
  4227. this.moveCursorBy = function(rows, chars) {
  4228. var screenPos = this.session.documentToScreenPosition(
  4229. this.lead.row,
  4230. this.lead.column
  4231. );
  4232. if (chars === 0) {
  4233. if (this.$desiredColumn)
  4234. screenPos.column = this.$desiredColumn;
  4235. else
  4236. this.$desiredColumn = screenPos.column;
  4237. }
  4238. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4239. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4240. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
  4241. if (docPos.row > 0 || rows > 0)
  4242. docPos.row++;
  4243. }
  4244. }
  4245. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4246. };
  4247. this.moveCursorToPosition = function(position) {
  4248. this.moveCursorTo(position.row, position.column);
  4249. };
  4250. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4251. var fold = this.session.getFoldAt(row, column, 1);
  4252. if (fold) {
  4253. row = fold.start.row;
  4254. column = fold.start.column;
  4255. }
  4256. this.$keepDesiredColumnOnChange = true;
  4257. this.lead.setPosition(row, column);
  4258. this.$keepDesiredColumnOnChange = false;
  4259. if (!keepDesiredColumn)
  4260. this.$desiredColumn = null;
  4261. };
  4262. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4263. var pos = this.session.screenToDocumentPosition(row, column);
  4264. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4265. };
  4266. this.detach = function() {
  4267. this.lead.detach();
  4268. this.anchor.detach();
  4269. this.session = this.doc = null;
  4270. };
  4271. this.fromOrientedRange = function(range) {
  4272. this.setSelectionRange(range, range.cursor == range.start);
  4273. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4274. };
  4275. this.toOrientedRange = function(range) {
  4276. var r = this.getRange();
  4277. if (range) {
  4278. range.start.column = r.start.column;
  4279. range.start.row = r.start.row;
  4280. range.end.column = r.end.column;
  4281. range.end.row = r.end.row;
  4282. } else {
  4283. range = r;
  4284. }
  4285. range.cursor = this.isBackwards() ? range.start : range.end;
  4286. range.desiredColumn = this.$desiredColumn;
  4287. return range;
  4288. };
  4289. this.getRangeOfMovements = function(func) {
  4290. var start = this.getCursor();
  4291. try {
  4292. func.call(null, this);
  4293. var end = this.getCursor();
  4294. return Range.fromPoints(start,end);
  4295. } catch(e) {
  4296. return Range.fromPoints(start,start);
  4297. } finally {
  4298. this.moveCursorToPosition(start);
  4299. }
  4300. };
  4301. this.toJSON = function() {
  4302. if (this.rangeCount) {
  4303. var data = this.ranges.map(function(r) {
  4304. var r1 = r.clone();
  4305. r1.isBackwards = r.cursor == r.start;
  4306. return r1;
  4307. });
  4308. } else {
  4309. var data = this.getRange();
  4310. data.isBackwards = this.isBackwards();
  4311. }
  4312. return data;
  4313. };
  4314. this.fromJSON = function(data) {
  4315. if (data.start == undefined) {
  4316. if (this.rangeList) {
  4317. this.toSingleRange(data[0]);
  4318. for (var i = data.length; i--; ) {
  4319. var r = Range.fromPoints(data[i].start, data[i].end);
  4320. if (data[i].isBackwards)
  4321. r.cursor = r.start;
  4322. this.addRange(r, true);
  4323. }
  4324. return;
  4325. } else
  4326. data = data[0];
  4327. }
  4328. if (this.rangeList)
  4329. this.toSingleRange(data);
  4330. this.setSelectionRange(data, data.isBackwards);
  4331. };
  4332. this.isEqual = function(data) {
  4333. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4334. return false;
  4335. if (!data.length || !this.ranges)
  4336. return this.getRange().isEqual(data);
  4337. for (var i = this.ranges.length; i--; ) {
  4338. if (!this.ranges[i].isEqual(data[i]))
  4339. return false;
  4340. }
  4341. return true;
  4342. };
  4343. }).call(Selection.prototype);
  4344. exports.Selection = Selection;
  4345. });
  4346. define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4347. "use strict";
  4348. var config = require("./config");
  4349. var MAX_TOKEN_COUNT = 2000;
  4350. var Tokenizer = function(rules) {
  4351. this.states = rules;
  4352. this.regExps = {};
  4353. this.matchMappings = {};
  4354. for (var key in this.states) {
  4355. var state = this.states[key];
  4356. var ruleRegExps = [];
  4357. var matchTotal = 0;
  4358. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4359. var flag = "g";
  4360. var splitterRurles = [];
  4361. for (var i = 0; i < state.length; i++) {
  4362. var rule = state[i];
  4363. if (rule.defaultToken)
  4364. mapping.defaultToken = rule.defaultToken;
  4365. if (rule.caseInsensitive)
  4366. flag = "gi";
  4367. if (rule.regex == null)
  4368. continue;
  4369. if (rule.regex instanceof RegExp)
  4370. rule.regex = rule.regex.toString().slice(1, -1);
  4371. var adjustedregex = rule.regex;
  4372. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4373. if (Array.isArray(rule.token)) {
  4374. if (rule.token.length == 1 || matchcount == 1) {
  4375. rule.token = rule.token[0];
  4376. } else if (matchcount - 1 != rule.token.length) {
  4377. this.reportError("number of classes and regexp groups doesn't match", {
  4378. rule: rule,
  4379. groupCount: matchcount - 1
  4380. });
  4381. rule.token = rule.token[0];
  4382. } else {
  4383. rule.tokenArray = rule.token;
  4384. rule.token = null;
  4385. rule.onMatch = this.$arrayTokens;
  4386. }
  4387. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4388. if (matchcount > 1)
  4389. rule.onMatch = this.$applyToken;
  4390. else
  4391. rule.onMatch = rule.token;
  4392. }
  4393. if (matchcount > 1) {
  4394. if (/\\\d/.test(rule.regex)) {
  4395. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4396. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4397. });
  4398. } else {
  4399. matchcount = 1;
  4400. adjustedregex = this.removeCapturingGroups(rule.regex);
  4401. }
  4402. if (!rule.splitRegex && typeof rule.token != "string")
  4403. splitterRurles.push(rule); // flag will be known only at the very end
  4404. }
  4405. mapping[matchTotal] = i;
  4406. matchTotal += matchcount;
  4407. ruleRegExps.push(adjustedregex);
  4408. if (!rule.onMatch)
  4409. rule.onMatch = null;
  4410. }
  4411. if (!ruleRegExps.length) {
  4412. mapping[0] = 0;
  4413. ruleRegExps.push("$");
  4414. }
  4415. splitterRurles.forEach(function(rule) {
  4416. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4417. }, this);
  4418. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4419. }
  4420. };
  4421. (function() {
  4422. this.$setMaxTokenCount = function(m) {
  4423. MAX_TOKEN_COUNT = m | 0;
  4424. };
  4425. this.$applyToken = function(str) {
  4426. var values = this.splitRegex.exec(str).slice(1);
  4427. var types = this.token.apply(this, values);
  4428. if (typeof types === "string")
  4429. return [{type: types, value: str}];
  4430. var tokens = [];
  4431. for (var i = 0, l = types.length; i < l; i++) {
  4432. if (values[i])
  4433. tokens[tokens.length] = {
  4434. type: types[i],
  4435. value: values[i]
  4436. };
  4437. }
  4438. return tokens;
  4439. },
  4440. this.$arrayTokens = function(str) {
  4441. if (!str)
  4442. return [];
  4443. var values = this.splitRegex.exec(str);
  4444. if (!values)
  4445. return "text";
  4446. var tokens = [];
  4447. var types = this.tokenArray;
  4448. for (var i = 0, l = types.length; i < l; i++) {
  4449. if (values[i + 1])
  4450. tokens[tokens.length] = {
  4451. type: types[i],
  4452. value: values[i + 1]
  4453. };
  4454. }
  4455. return tokens;
  4456. };
  4457. this.removeCapturingGroups = function(src) {
  4458. var r = src.replace(
  4459. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4460. function(x, y) {return y ? "(?:" : x;}
  4461. );
  4462. return r;
  4463. };
  4464. this.createSplitterRegexp = function(src, flag) {
  4465. if (src.indexOf("(?=") != -1) {
  4466. var stack = 0;
  4467. var inChClass = false;
  4468. var lastCapture = {};
  4469. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4470. m, esc, parenOpen, parenClose, square, index
  4471. ) {
  4472. if (inChClass) {
  4473. inChClass = square != "]";
  4474. } else if (square) {
  4475. inChClass = true;
  4476. } else if (parenClose) {
  4477. if (stack == lastCapture.stack) {
  4478. lastCapture.end = index+1;
  4479. lastCapture.stack = -1;
  4480. }
  4481. stack--;
  4482. } else if (parenOpen) {
  4483. stack++;
  4484. if (parenOpen.length != 1) {
  4485. lastCapture.stack = stack
  4486. lastCapture.start = index;
  4487. }
  4488. }
  4489. return m;
  4490. });
  4491. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4492. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4493. }
  4494. if (src.charAt(0) != "^") src = "^" + src;
  4495. if (src.charAt(src.length - 1) != "$") src += "$";
  4496. return new RegExp(src, (flag||"").replace("g", ""));
  4497. };
  4498. this.getLineTokens = function(line, startState) {
  4499. if (startState && typeof startState != "string") {
  4500. var stack = startState.slice(0);
  4501. startState = stack[0];
  4502. if (startState === "#tmp") {
  4503. stack.shift()
  4504. startState = stack.shift()
  4505. }
  4506. } else
  4507. var stack = [];
  4508. var currentState = startState || "start";
  4509. var state = this.states[currentState];
  4510. if (!state) {
  4511. currentState = "start";
  4512. state = this.states[currentState];
  4513. }
  4514. var mapping = this.matchMappings[currentState];
  4515. var re = this.regExps[currentState];
  4516. re.lastIndex = 0;
  4517. var match, tokens = [];
  4518. var lastIndex = 0;
  4519. var matchAttempts = 0;
  4520. var token = {type: null, value: ""};
  4521. while (match = re.exec(line)) {
  4522. var type = mapping.defaultToken;
  4523. var rule = null;
  4524. var value = match[0];
  4525. var index = re.lastIndex;
  4526. if (index - value.length > lastIndex) {
  4527. var skipped = line.substring(lastIndex, index - value.length);
  4528. if (token.type == type) {
  4529. token.value += skipped;
  4530. } else {
  4531. if (token.type)
  4532. tokens.push(token);
  4533. token = {type: type, value: skipped};
  4534. }
  4535. }
  4536. for (var i = 0; i < match.length-2; i++) {
  4537. if (match[i + 1] === undefined)
  4538. continue;
  4539. rule = state[mapping[i]];
  4540. if (rule.onMatch)
  4541. type = rule.onMatch(value, currentState, stack);
  4542. else
  4543. type = rule.token;
  4544. if (rule.next) {
  4545. if (typeof rule.next == "string") {
  4546. currentState = rule.next;
  4547. } else {
  4548. currentState = rule.next(currentState, stack);
  4549. }
  4550. state = this.states[currentState];
  4551. if (!state) {
  4552. this.reportError("state doesn't exist", currentState);
  4553. currentState = "start";
  4554. state = this.states[currentState];
  4555. }
  4556. mapping = this.matchMappings[currentState];
  4557. lastIndex = index;
  4558. re = this.regExps[currentState];
  4559. re.lastIndex = index;
  4560. }
  4561. break;
  4562. }
  4563. if (value) {
  4564. if (typeof type === "string") {
  4565. if ((!rule || rule.merge !== false) && token.type === type) {
  4566. token.value += value;
  4567. } else {
  4568. if (token.type)
  4569. tokens.push(token);
  4570. token = {type: type, value: value};
  4571. }
  4572. } else if (type) {
  4573. if (token.type)
  4574. tokens.push(token);
  4575. token = {type: null, value: ""};
  4576. for (var i = 0; i < type.length; i++)
  4577. tokens.push(type[i]);
  4578. }
  4579. }
  4580. if (lastIndex == line.length)
  4581. break;
  4582. lastIndex = index;
  4583. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4584. if (matchAttempts > 2 * line.length) {
  4585. this.reportError("infinite loop with in ace tokenizer", {
  4586. startState: startState,
  4587. line: line
  4588. });
  4589. }
  4590. while (lastIndex < line.length) {
  4591. if (token.type)
  4592. tokens.push(token);
  4593. token = {
  4594. value: line.substring(lastIndex, lastIndex += 2000),
  4595. type: "overflow"
  4596. };
  4597. }
  4598. currentState = "start";
  4599. stack = [];
  4600. break;
  4601. }
  4602. }
  4603. if (token.type)
  4604. tokens.push(token);
  4605. if (stack.length > 1) {
  4606. if (stack[0] !== currentState)
  4607. stack.unshift("#tmp", currentState);
  4608. }
  4609. return {
  4610. tokens : tokens,
  4611. state : stack.length ? stack : currentState
  4612. };
  4613. };
  4614. this.reportError = config.reportError;
  4615. }).call(Tokenizer.prototype);
  4616. exports.Tokenizer = Tokenizer;
  4617. });
  4618. define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4619. "use strict";
  4620. var lang = require("../lib/lang");
  4621. var TextHighlightRules = function() {
  4622. this.$rules = {
  4623. "start" : [{
  4624. token : "empty_line",
  4625. regex : '^$'
  4626. }, {
  4627. defaultToken : "text"
  4628. }]
  4629. };
  4630. };
  4631. (function() {
  4632. this.addRules = function(rules, prefix) {
  4633. if (!prefix) {
  4634. for (var key in rules)
  4635. this.$rules[key] = rules[key];
  4636. return;
  4637. }
  4638. for (var key in rules) {
  4639. var state = rules[key];
  4640. for (var i = 0; i < state.length; i++) {
  4641. var rule = state[i];
  4642. if (rule.next || rule.onMatch) {
  4643. if (typeof rule.next == "string") {
  4644. if (rule.next.indexOf(prefix) !== 0)
  4645. rule.next = prefix + rule.next;
  4646. }
  4647. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4648. rule.nextState = prefix + rule.nextState;
  4649. }
  4650. }
  4651. this.$rules[prefix + key] = state;
  4652. }
  4653. };
  4654. this.getRules = function() {
  4655. return this.$rules;
  4656. };
  4657. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4658. var embedRules = typeof HighlightRules == "function"
  4659. ? new HighlightRules().getRules()
  4660. : HighlightRules;
  4661. if (states) {
  4662. for (var i = 0; i < states.length; i++)
  4663. states[i] = prefix + states[i];
  4664. } else {
  4665. states = [];
  4666. for (var key in embedRules)
  4667. states.push(prefix + key);
  4668. }
  4669. this.addRules(embedRules, prefix);
  4670. if (escapeRules) {
  4671. var addRules = Array.prototype[append ? "push" : "unshift"];
  4672. for (var i = 0; i < states.length; i++)
  4673. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4674. }
  4675. if (!this.$embeds)
  4676. this.$embeds = [];
  4677. this.$embeds.push(prefix);
  4678. };
  4679. this.getEmbeds = function() {
  4680. return this.$embeds;
  4681. };
  4682. var pushState = function(currentState, stack) {
  4683. if (currentState != "start" || stack.length)
  4684. stack.unshift(this.nextState, currentState);
  4685. return this.nextState;
  4686. };
  4687. var popState = function(currentState, stack) {
  4688. stack.shift();
  4689. return stack.shift() || "start";
  4690. };
  4691. this.normalizeRules = function() {
  4692. var id = 0;
  4693. var rules = this.$rules;
  4694. function processState(key) {
  4695. var state = rules[key];
  4696. state.processed = true;
  4697. for (var i = 0; i < state.length; i++) {
  4698. var rule = state[i];
  4699. if (!rule.regex && rule.start) {
  4700. rule.regex = rule.start;
  4701. if (!rule.next)
  4702. rule.next = [];
  4703. rule.next.push({
  4704. defaultToken: rule.token
  4705. }, {
  4706. token: rule.token + ".end",
  4707. regex: rule.end || rule.start,
  4708. next: "pop"
  4709. });
  4710. rule.token = rule.token + ".start";
  4711. rule.push = true;
  4712. }
  4713. var next = rule.next || rule.push;
  4714. if (next && Array.isArray(next)) {
  4715. var stateName = rule.stateName;
  4716. if (!stateName) {
  4717. stateName = rule.token;
  4718. if (typeof stateName != "string")
  4719. stateName = stateName[0] || "";
  4720. if (rules[stateName])
  4721. stateName += id++;
  4722. }
  4723. rules[stateName] = next;
  4724. rule.next = stateName;
  4725. processState(stateName);
  4726. } else if (next == "pop") {
  4727. rule.next = popState;
  4728. }
  4729. if (rule.push) {
  4730. rule.nextState = rule.next || rule.push;
  4731. rule.next = pushState;
  4732. delete rule.push;
  4733. }
  4734. if (rule.rules) {
  4735. for (var r in rule.rules) {
  4736. if (rules[r]) {
  4737. if (rules[r].push)
  4738. rules[r].push.apply(rules[r], rule.rules[r]);
  4739. } else {
  4740. rules[r] = rule.rules[r];
  4741. }
  4742. }
  4743. }
  4744. if (rule.include || typeof rule == "string") {
  4745. var includeName = rule.include || rule;
  4746. var toInsert = rules[includeName];
  4747. } else if (Array.isArray(rule))
  4748. toInsert = rule;
  4749. if (toInsert) {
  4750. var args = [i, 1].concat(toInsert);
  4751. if (rule.noEscape)
  4752. args = args.filter(function(x) {return !x.next;});
  4753. state.splice.apply(state, args);
  4754. i--;
  4755. toInsert = null;
  4756. }
  4757. if (rule.keywordMap) {
  4758. rule.token = this.createKeywordMapper(
  4759. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4760. );
  4761. delete rule.defaultToken;
  4762. }
  4763. }
  4764. }
  4765. Object.keys(rules).forEach(processState, this);
  4766. };
  4767. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4768. var keywords = Object.create(null);
  4769. Object.keys(map).forEach(function(className) {
  4770. var a = map[className];
  4771. if (ignoreCase)
  4772. a = a.toLowerCase();
  4773. var list = a.split(splitChar || "|");
  4774. for (var i = list.length; i--; )
  4775. keywords[list[i]] = className;
  4776. });
  4777. if (Object.getPrototypeOf(keywords)) {
  4778. keywords.__proto__ = null;
  4779. }
  4780. this.$keywordList = Object.keys(keywords);
  4781. map = null;
  4782. return ignoreCase
  4783. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4784. : function(value) {return keywords[value] || defaultToken };
  4785. };
  4786. this.getKeywords = function() {
  4787. return this.$keywords;
  4788. };
  4789. }).call(TextHighlightRules.prototype);
  4790. exports.TextHighlightRules = TextHighlightRules;
  4791. });
  4792. define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4793. "use strict";
  4794. var Behaviour = function() {
  4795. this.$behaviours = {};
  4796. };
  4797. (function () {
  4798. this.add = function (name, action, callback) {
  4799. switch (undefined) {
  4800. case this.$behaviours:
  4801. this.$behaviours = {};
  4802. case this.$behaviours[name]:
  4803. this.$behaviours[name] = {};
  4804. }
  4805. this.$behaviours[name][action] = callback;
  4806. }
  4807. this.addBehaviours = function (behaviours) {
  4808. for (var key in behaviours) {
  4809. for (var action in behaviours[key]) {
  4810. this.add(key, action, behaviours[key][action]);
  4811. }
  4812. }
  4813. }
  4814. this.remove = function (name) {
  4815. if (this.$behaviours && this.$behaviours[name]) {
  4816. delete this.$behaviours[name];
  4817. }
  4818. }
  4819. this.inherit = function (mode, filter) {
  4820. if (typeof mode === "function") {
  4821. var behaviours = new mode().getBehaviours(filter);
  4822. } else {
  4823. var behaviours = mode.getBehaviours(filter);
  4824. }
  4825. this.addBehaviours(behaviours);
  4826. }
  4827. this.getBehaviours = function (filter) {
  4828. if (!filter) {
  4829. return this.$behaviours;
  4830. } else {
  4831. var ret = {}
  4832. for (var i = 0; i < filter.length; i++) {
  4833. if (this.$behaviours[filter[i]]) {
  4834. ret[filter[i]] = this.$behaviours[filter[i]];
  4835. }
  4836. }
  4837. return ret;
  4838. }
  4839. }
  4840. }).call(Behaviour.prototype);
  4841. exports.Behaviour = Behaviour;
  4842. });
  4843. define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4844. "use strict";
  4845. exports.packages = {};
  4846. addUnicodePackage({
  4847. 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",
  4848. 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",
  4849. 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",
  4850. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4851. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4852. 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",
  4853. 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",
  4854. 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",
  4855. 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",
  4856. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4857. 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",
  4858. 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",
  4859. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4860. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4861. 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",
  4862. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4863. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4864. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4865. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4866. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4867. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4868. 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",
  4869. 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",
  4870. 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",
  4871. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4872. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4873. 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",
  4874. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4875. Zs: "002000A01680180E2000-200A202F205F3000",
  4876. Zl: "2028",
  4877. Zp: "2029",
  4878. 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",
  4879. Cc: "0000-001F007F-009F",
  4880. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4881. Co: "E000-F8FF",
  4882. Cs: "D800-DFFF",
  4883. 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"
  4884. });
  4885. function addUnicodePackage (pack) {
  4886. var codePoint = /\w{4}/g;
  4887. for (var name in pack)
  4888. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4889. };
  4890. });
  4891. define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4892. "use strict";
  4893. var TokenIterator = function(session, initialRow, initialColumn) {
  4894. this.$session = session;
  4895. this.$row = initialRow;
  4896. this.$rowTokens = session.getTokens(initialRow);
  4897. var token = session.getTokenAt(initialRow, initialColumn);
  4898. this.$tokenIndex = token ? token.index : -1;
  4899. };
  4900. (function() {
  4901. this.stepBackward = function() {
  4902. this.$tokenIndex -= 1;
  4903. while (this.$tokenIndex < 0) {
  4904. this.$row -= 1;
  4905. if (this.$row < 0) {
  4906. this.$row = 0;
  4907. return null;
  4908. }
  4909. this.$rowTokens = this.$session.getTokens(this.$row);
  4910. this.$tokenIndex = this.$rowTokens.length - 1;
  4911. }
  4912. return this.$rowTokens[this.$tokenIndex];
  4913. };
  4914. this.stepForward = function() {
  4915. this.$tokenIndex += 1;
  4916. var rowCount;
  4917. while (this.$tokenIndex >= this.$rowTokens.length) {
  4918. this.$row += 1;
  4919. if (!rowCount)
  4920. rowCount = this.$session.getLength();
  4921. if (this.$row >= rowCount) {
  4922. this.$row = rowCount - 1;
  4923. return null;
  4924. }
  4925. this.$rowTokens = this.$session.getTokens(this.$row);
  4926. this.$tokenIndex = 0;
  4927. }
  4928. return this.$rowTokens[this.$tokenIndex];
  4929. };
  4930. this.getCurrentToken = function () {
  4931. return this.$rowTokens[this.$tokenIndex];
  4932. };
  4933. this.getCurrentTokenRow = function () {
  4934. return this.$row;
  4935. };
  4936. this.getCurrentTokenColumn = function() {
  4937. var rowTokens = this.$rowTokens;
  4938. var tokenIndex = this.$tokenIndex;
  4939. var column = rowTokens[tokenIndex].start;
  4940. if (column !== undefined)
  4941. return column;
  4942. column = 0;
  4943. while (tokenIndex > 0) {
  4944. tokenIndex -= 1;
  4945. column += rowTokens[tokenIndex].value.length;
  4946. }
  4947. return column;
  4948. };
  4949. this.getCurrentTokenPosition = function() {
  4950. return {row: this.$row, column: this.getCurrentTokenColumn()};
  4951. };
  4952. }).call(TokenIterator.prototype);
  4953. exports.TokenIterator = TokenIterator;
  4954. });
  4955. define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
  4956. "use strict";
  4957. var Tokenizer = require("../tokenizer").Tokenizer;
  4958. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4959. var Behaviour = require("./behaviour").Behaviour;
  4960. var unicode = require("../unicode");
  4961. var lang = require("../lib/lang");
  4962. var TokenIterator = require("../token_iterator").TokenIterator;
  4963. var Range = require("../range").Range;
  4964. var Mode = function() {
  4965. this.HighlightRules = TextHighlightRules;
  4966. this.$behaviour = new Behaviour();
  4967. };
  4968. (function() {
  4969. this.tokenRe = new RegExp("^["
  4970. + unicode.packages.L
  4971. + unicode.packages.Mn + unicode.packages.Mc
  4972. + unicode.packages.Nd
  4973. + unicode.packages.Pc + "\\$_]+", "g"
  4974. );
  4975. this.nonTokenRe = new RegExp("^(?:[^"
  4976. + unicode.packages.L
  4977. + unicode.packages.Mn + unicode.packages.Mc
  4978. + unicode.packages.Nd
  4979. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4980. );
  4981. this.getTokenizer = function() {
  4982. if (!this.$tokenizer) {
  4983. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4984. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4985. }
  4986. return this.$tokenizer;
  4987. };
  4988. this.lineCommentStart = "";
  4989. this.blockComment = "";
  4990. this.toggleCommentLines = function(state, session, startRow, endRow) {
  4991. var doc = session.doc;
  4992. var ignoreBlankLines = true;
  4993. var shouldRemove = true;
  4994. var minIndent = Infinity;
  4995. var tabSize = session.getTabSize();
  4996. var insertAtTabStop = false;
  4997. if (!this.lineCommentStart) {
  4998. if (!this.blockComment)
  4999. return false;
  5000. var lineCommentStart = this.blockComment.start;
  5001. var lineCommentEnd = this.blockComment.end;
  5002. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  5003. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  5004. var comment = function(line, i) {
  5005. if (testRemove(line, i))
  5006. return;
  5007. if (!ignoreBlankLines || /\S/.test(line)) {
  5008. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  5009. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5010. }
  5011. };
  5012. var uncomment = function(line, i) {
  5013. var m;
  5014. if (m = line.match(regexpEnd))
  5015. doc.removeInLine(i, line.length - m[0].length, line.length);
  5016. if (m = line.match(regexpStart))
  5017. doc.removeInLine(i, m[1].length, m[0].length);
  5018. };
  5019. var testRemove = function(line, row) {
  5020. if (regexpStart.test(line))
  5021. return true;
  5022. var tokens = session.getTokens(row);
  5023. for (var i = 0; i < tokens.length; i++) {
  5024. if (tokens[i].type === 'comment')
  5025. return true;
  5026. }
  5027. };
  5028. } else {
  5029. if (Array.isArray(this.lineCommentStart)) {
  5030. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  5031. var lineCommentStart = this.lineCommentStart[0];
  5032. } else {
  5033. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  5034. var lineCommentStart = this.lineCommentStart;
  5035. }
  5036. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  5037. insertAtTabStop = session.getUseSoftTabs();
  5038. var uncomment = function(line, i) {
  5039. var m = line.match(regexpStart);
  5040. if (!m) return;
  5041. var start = m[1].length, end = m[0].length;
  5042. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  5043. end--;
  5044. doc.removeInLine(i, start, end);
  5045. };
  5046. var commentWithSpace = lineCommentStart + " ";
  5047. var comment = function(line, i) {
  5048. if (!ignoreBlankLines || /\S/.test(line)) {
  5049. if (shouldInsertSpace(line, minIndent, minIndent))
  5050. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  5051. else
  5052. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5053. }
  5054. };
  5055. var testRemove = function(line, i) {
  5056. return regexpStart.test(line);
  5057. };
  5058. var shouldInsertSpace = function(line, before, after) {
  5059. var spaces = 0;
  5060. while (before-- && line.charAt(before) == " ")
  5061. spaces++;
  5062. if (spaces % tabSize != 0)
  5063. return false;
  5064. var spaces = 0;
  5065. while (line.charAt(after++) == " ")
  5066. spaces++;
  5067. if (tabSize > 2)
  5068. return spaces % tabSize != tabSize - 1;
  5069. else
  5070. return spaces % tabSize == 0;
  5071. return true;
  5072. };
  5073. }
  5074. function iter(fun) {
  5075. for (var i = startRow; i <= endRow; i++)
  5076. fun(doc.getLine(i), i);
  5077. }
  5078. var minEmptyLength = Infinity;
  5079. iter(function(line, i) {
  5080. var indent = line.search(/\S/);
  5081. if (indent !== -1) {
  5082. if (indent < minIndent)
  5083. minIndent = indent;
  5084. if (shouldRemove && !testRemove(line, i))
  5085. shouldRemove = false;
  5086. } else if (minEmptyLength > line.length) {
  5087. minEmptyLength = line.length;
  5088. }
  5089. });
  5090. if (minIndent == Infinity) {
  5091. minIndent = minEmptyLength;
  5092. ignoreBlankLines = false;
  5093. shouldRemove = false;
  5094. }
  5095. if (insertAtTabStop && minIndent % tabSize != 0)
  5096. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5097. iter(shouldRemove ? uncomment : comment);
  5098. };
  5099. this.toggleBlockComment = function(state, session, range, cursor) {
  5100. var comment = this.blockComment;
  5101. if (!comment)
  5102. return;
  5103. if (!comment.start && comment[0])
  5104. comment = comment[0];
  5105. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5106. var token = iterator.getCurrentToken();
  5107. var sel = session.selection;
  5108. var initialRange = session.selection.toOrientedRange();
  5109. var startRow, colDiff;
  5110. if (token && /comment/.test(token.type)) {
  5111. var startRange, endRange;
  5112. while (token && /comment/.test(token.type)) {
  5113. var i = token.value.indexOf(comment.start);
  5114. if (i != -1) {
  5115. var row = iterator.getCurrentTokenRow();
  5116. var column = iterator.getCurrentTokenColumn() + i;
  5117. startRange = new Range(row, column, row, column + comment.start.length);
  5118. break;
  5119. }
  5120. token = iterator.stepBackward();
  5121. }
  5122. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5123. var token = iterator.getCurrentToken();
  5124. while (token && /comment/.test(token.type)) {
  5125. var i = token.value.indexOf(comment.end);
  5126. if (i != -1) {
  5127. var row = iterator.getCurrentTokenRow();
  5128. var column = iterator.getCurrentTokenColumn() + i;
  5129. endRange = new Range(row, column, row, column + comment.end.length);
  5130. break;
  5131. }
  5132. token = iterator.stepForward();
  5133. }
  5134. if (endRange)
  5135. session.remove(endRange);
  5136. if (startRange) {
  5137. session.remove(startRange);
  5138. startRow = startRange.start.row;
  5139. colDiff = -comment.start.length;
  5140. }
  5141. } else {
  5142. colDiff = comment.start.length;
  5143. startRow = range.start.row;
  5144. session.insert(range.end, comment.end);
  5145. session.insert(range.start, comment.start);
  5146. }
  5147. if (initialRange.start.row == startRow)
  5148. initialRange.start.column += colDiff;
  5149. if (initialRange.end.row == startRow)
  5150. initialRange.end.column += colDiff;
  5151. session.selection.fromOrientedRange(initialRange);
  5152. };
  5153. this.getNextLineIndent = function(state, line, tab) {
  5154. return this.$getIndent(line);
  5155. };
  5156. this.checkOutdent = function(state, line, input) {
  5157. return false;
  5158. };
  5159. this.autoOutdent = function(state, doc, row) {
  5160. };
  5161. this.$getIndent = function(line) {
  5162. return line.match(/^\s*/)[0];
  5163. };
  5164. this.createWorker = function(session) {
  5165. return null;
  5166. };
  5167. this.createModeDelegates = function (mapping) {
  5168. this.$embeds = [];
  5169. this.$modes = {};
  5170. for (var i in mapping) {
  5171. if (mapping[i]) {
  5172. this.$embeds.push(i);
  5173. this.$modes[i] = new mapping[i]();
  5174. }
  5175. }
  5176. var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
  5177. 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
  5178. for (var i = 0; i < delegations.length; i++) {
  5179. (function(scope) {
  5180. var functionName = delegations[i];
  5181. var defaultHandler = scope[functionName];
  5182. scope[delegations[i]] = function() {
  5183. return this.$delegator(functionName, arguments, defaultHandler);
  5184. };
  5185. } (this));
  5186. }
  5187. };
  5188. this.$delegator = function(method, args, defaultHandler) {
  5189. var state = args[0];
  5190. if (typeof state != "string")
  5191. state = state[0];
  5192. for (var i = 0; i < this.$embeds.length; i++) {
  5193. if (!this.$modes[this.$embeds[i]]) continue;
  5194. var split = state.split(this.$embeds[i]);
  5195. if (!split[0] && split[1]) {
  5196. args[0] = split[1];
  5197. var mode = this.$modes[this.$embeds[i]];
  5198. return mode[method].apply(mode, args);
  5199. }
  5200. }
  5201. var ret = defaultHandler.apply(this, args);
  5202. return defaultHandler ? ret : undefined;
  5203. };
  5204. this.transformAction = function(state, action, editor, session, param) {
  5205. if (this.$behaviour) {
  5206. var behaviours = this.$behaviour.getBehaviours();
  5207. for (var key in behaviours) {
  5208. if (behaviours[key][action]) {
  5209. var ret = behaviours[key][action].apply(this, arguments);
  5210. if (ret) {
  5211. return ret;
  5212. }
  5213. }
  5214. }
  5215. }
  5216. };
  5217. this.getKeywords = function(append) {
  5218. if (!this.completionKeywords) {
  5219. var rules = this.$tokenizer.rules;
  5220. var completionKeywords = [];
  5221. for (var rule in rules) {
  5222. var ruleItr = rules[rule];
  5223. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5224. if (typeof ruleItr[r].token === "string") {
  5225. if (/keyword|support|storage/.test(ruleItr[r].token))
  5226. completionKeywords.push(ruleItr[r].regex);
  5227. }
  5228. else if (typeof ruleItr[r].token === "object") {
  5229. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5230. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5231. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5232. completionKeywords.push(rule.substr(1, rule.length - 2));
  5233. }
  5234. }
  5235. }
  5236. }
  5237. }
  5238. this.completionKeywords = completionKeywords;
  5239. }
  5240. if (!append)
  5241. return this.$keywordList;
  5242. return completionKeywords.concat(this.$keywordList || []);
  5243. };
  5244. this.$createKeywordList = function() {
  5245. if (!this.$highlightRules)
  5246. this.getTokenizer();
  5247. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5248. };
  5249. this.getCompletions = function(state, session, pos, prefix) {
  5250. var keywords = this.$keywordList || this.$createKeywordList();
  5251. return keywords.map(function(word) {
  5252. return {
  5253. name: word,
  5254. value: word,
  5255. score: 0,
  5256. meta: "keyword"
  5257. };
  5258. });
  5259. };
  5260. this.$id = "ace/mode/text";
  5261. }).call(Mode.prototype);
  5262. exports.Mode = Mode;
  5263. });
  5264. define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  5265. "use strict";
  5266. function throwDeltaError(delta, errorText){
  5267. console.log("Invalid Delta:", delta);
  5268. throw "Invalid Delta: " + errorText;
  5269. }
  5270. function positionInDocument(docLines, position) {
  5271. return position.row >= 0 && position.row < docLines.length &&
  5272. position.column >= 0 && position.column <= docLines[position.row].length;
  5273. }
  5274. function validateDelta(docLines, delta) {
  5275. if (delta.action != "insert" && delta.action != "remove")
  5276. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  5277. if (!(delta.lines instanceof Array))
  5278. throwDeltaError(delta, "delta.lines must be an Array");
  5279. if (!delta.start || !delta.end)
  5280. throwDeltaError(delta, "delta.start/end must be an present");
  5281. var start = delta.start;
  5282. if (!positionInDocument(docLines, delta.start))
  5283. throwDeltaError(delta, "delta.start must be contained in document");
  5284. var end = delta.end;
  5285. if (delta.action == "remove" && !positionInDocument(docLines, end))
  5286. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  5287. var numRangeRows = end.row - start.row;
  5288. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  5289. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  5290. throwDeltaError(delta, "delta.range must match delta lines");
  5291. }
  5292. exports.applyDelta = function(docLines, delta, doNotValidate) {
  5293. var row = delta.start.row;
  5294. var startColumn = delta.start.column;
  5295. var line = docLines[row] || "";
  5296. switch (delta.action) {
  5297. case "insert":
  5298. var lines = delta.lines;
  5299. if (lines.length === 1) {
  5300. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  5301. } else {
  5302. var args = [row, 1].concat(delta.lines);
  5303. docLines.splice.apply(docLines, args);
  5304. docLines[row] = line.substring(0, startColumn) + docLines[row];
  5305. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  5306. }
  5307. break;
  5308. case "remove":
  5309. var endColumn = delta.end.column;
  5310. var endRow = delta.end.row;
  5311. if (row === endRow) {
  5312. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  5313. } else {
  5314. docLines.splice(
  5315. row, endRow - row + 1,
  5316. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  5317. );
  5318. }
  5319. break;
  5320. }
  5321. }
  5322. });
  5323. define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5324. "use strict";
  5325. var oop = require("./lib/oop");
  5326. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5327. var Anchor = exports.Anchor = function(doc, row, column) {
  5328. this.$onChange = this.onChange.bind(this);
  5329. this.attach(doc);
  5330. if (typeof column == "undefined")
  5331. this.setPosition(row.row, row.column);
  5332. else
  5333. this.setPosition(row, column);
  5334. };
  5335. (function() {
  5336. oop.implement(this, EventEmitter);
  5337. this.getPosition = function() {
  5338. return this.$clipPositionToDocument(this.row, this.column);
  5339. };
  5340. this.getDocument = function() {
  5341. return this.document;
  5342. };
  5343. this.$insertRight = false;
  5344. this.onChange = function(delta) {
  5345. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  5346. return;
  5347. if (delta.start.row > this.row)
  5348. return;
  5349. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  5350. this.setPosition(point.row, point.column, true);
  5351. };
  5352. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  5353. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  5354. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  5355. }
  5356. function $getTransformedPoint(delta, point, moveIfEqual) {
  5357. var deltaIsInsert = delta.action == "insert";
  5358. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  5359. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  5360. var deltaStart = delta.start;
  5361. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  5362. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  5363. return {
  5364. row: point.row,
  5365. column: point.column
  5366. };
  5367. }
  5368. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  5369. return {
  5370. row: point.row + deltaRowShift,
  5371. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  5372. };
  5373. }
  5374. return {
  5375. row: deltaStart.row,
  5376. column: deltaStart.column
  5377. };
  5378. }
  5379. this.setPosition = function(row, column, noClip) {
  5380. var pos;
  5381. if (noClip) {
  5382. pos = {
  5383. row: row,
  5384. column: column
  5385. };
  5386. } else {
  5387. pos = this.$clipPositionToDocument(row, column);
  5388. }
  5389. if (this.row == pos.row && this.column == pos.column)
  5390. return;
  5391. var old = {
  5392. row: this.row,
  5393. column: this.column
  5394. };
  5395. this.row = pos.row;
  5396. this.column = pos.column;
  5397. this._signal("change", {
  5398. old: old,
  5399. value: pos
  5400. });
  5401. };
  5402. this.detach = function() {
  5403. this.document.removeEventListener("change", this.$onChange);
  5404. };
  5405. this.attach = function(doc) {
  5406. this.document = doc || this.document;
  5407. this.document.on("change", this.$onChange);
  5408. };
  5409. this.$clipPositionToDocument = function(row, column) {
  5410. var pos = {};
  5411. if (row >= this.document.getLength()) {
  5412. pos.row = Math.max(0, this.document.getLength() - 1);
  5413. pos.column = this.document.getLine(pos.row).length;
  5414. }
  5415. else if (row < 0) {
  5416. pos.row = 0;
  5417. pos.column = 0;
  5418. }
  5419. else {
  5420. pos.row = row;
  5421. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5422. }
  5423. if (column < 0)
  5424. pos.column = 0;
  5425. return pos;
  5426. };
  5427. }).call(Anchor.prototype);
  5428. });
  5429. define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5430. "use strict";
  5431. var oop = require("./lib/oop");
  5432. var applyDelta = require("./apply_delta").applyDelta;
  5433. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5434. var Range = require("./range").Range;
  5435. var Anchor = require("./anchor").Anchor;
  5436. var Document = function(textOrLines) {
  5437. this.$lines = [""];
  5438. if (textOrLines.length === 0) {
  5439. this.$lines = [""];
  5440. } else if (Array.isArray(textOrLines)) {
  5441. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  5442. } else {
  5443. this.insert({row: 0, column:0}, textOrLines);
  5444. }
  5445. };
  5446. (function() {
  5447. oop.implement(this, EventEmitter);
  5448. this.setValue = function(text) {
  5449. var len = this.getLength() - 1;
  5450. this.remove(new Range(0, 0, len, this.getLine(len).length));
  5451. this.insert({row: 0, column: 0}, text);
  5452. };
  5453. this.getValue = function() {
  5454. return this.getAllLines().join(this.getNewLineCharacter());
  5455. };
  5456. this.createAnchor = function(row, column) {
  5457. return new Anchor(this, row, column);
  5458. };
  5459. if ("aaa".split(/a/).length === 0) {
  5460. this.$split = function(text) {
  5461. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5462. };
  5463. } else {
  5464. this.$split = function(text) {
  5465. return text.split(/\r\n|\r|\n/);
  5466. };
  5467. }
  5468. this.$detectNewLine = function(text) {
  5469. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5470. this.$autoNewLine = match ? match[1] : "\n";
  5471. this._signal("changeNewLineMode");
  5472. };
  5473. this.getNewLineCharacter = function() {
  5474. switch (this.$newLineMode) {
  5475. case "windows":
  5476. return "\r\n";
  5477. case "unix":
  5478. return "\n";
  5479. default:
  5480. return this.$autoNewLine || "\n";
  5481. }
  5482. };
  5483. this.$autoNewLine = "";
  5484. this.$newLineMode = "auto";
  5485. this.setNewLineMode = function(newLineMode) {
  5486. if (this.$newLineMode === newLineMode)
  5487. return;
  5488. this.$newLineMode = newLineMode;
  5489. this._signal("changeNewLineMode");
  5490. };
  5491. this.getNewLineMode = function() {
  5492. return this.$newLineMode;
  5493. };
  5494. this.isNewLine = function(text) {
  5495. return (text == "\r\n" || text == "\r" || text == "\n");
  5496. };
  5497. this.getLine = function(row) {
  5498. return this.$lines[row] || "";
  5499. };
  5500. this.getLines = function(firstRow, lastRow) {
  5501. return this.$lines.slice(firstRow, lastRow + 1);
  5502. };
  5503. this.getAllLines = function() {
  5504. return this.getLines(0, this.getLength());
  5505. };
  5506. this.getLength = function() {
  5507. return this.$lines.length;
  5508. };
  5509. this.getTextRange = function(range) {
  5510. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  5511. };
  5512. this.getLinesForRange = function(range) {
  5513. var lines;
  5514. if (range.start.row === range.end.row) {
  5515. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  5516. } else {
  5517. lines = this.getLines(range.start.row, range.end.row);
  5518. lines[0] = (lines[0] || "").substring(range.start.column);
  5519. var l = lines.length - 1;
  5520. if (range.end.row - range.start.row == l)
  5521. lines[l] = lines[l].substring(0, range.end.column);
  5522. }
  5523. return lines;
  5524. };
  5525. this.insertLines = function(row, lines) {
  5526. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  5527. return this.insertFullLines(row, lines);
  5528. };
  5529. this.removeLines = function(firstRow, lastRow) {
  5530. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  5531. return this.removeFullLines(firstRow, lastRow);
  5532. };
  5533. this.insertNewLine = function(position) {
  5534. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
  5535. return this.insertMergedLines(position, ["", ""]);
  5536. };
  5537. this.insert = function(position, text) {
  5538. if (this.getLength() <= 1)
  5539. this.$detectNewLine(text);
  5540. return this.insertMergedLines(position, this.$split(text));
  5541. };
  5542. this.insertInLine = function(position, text) {
  5543. var start = this.clippedPos(position.row, position.column);
  5544. var end = this.pos(position.row, position.column + text.length);
  5545. this.applyDelta({
  5546. start: start,
  5547. end: end,
  5548. action: "insert",
  5549. lines: [text]
  5550. }, true);
  5551. return this.clonePos(end);
  5552. };
  5553. this.clippedPos = function(row, column) {
  5554. var length = this.getLength();
  5555. if (row === undefined) {
  5556. row = length;
  5557. } else if (row < 0) {
  5558. row = 0;
  5559. } else if (row >= length) {
  5560. row = length - 1;
  5561. column = undefined;
  5562. }
  5563. var line = this.getLine(row);
  5564. if (column == undefined)
  5565. column = line.length;
  5566. column = Math.min(Math.max(column, 0), line.length);
  5567. return {row: row, column: column};
  5568. };
  5569. this.clonePos = function(pos) {
  5570. return {row: pos.row, column: pos.column};
  5571. };
  5572. this.pos = function(row, column) {
  5573. return {row: row, column: column};
  5574. };
  5575. this.$clipPosition = function(position) {
  5576. var length = this.getLength();
  5577. if (position.row >= length) {
  5578. position.row = Math.max(0, length - 1);
  5579. position.column = this.getLine(length - 1).length;
  5580. } else {
  5581. position.row = Math.max(0, position.row);
  5582. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  5583. }
  5584. return position;
  5585. };
  5586. this.insertFullLines = function(row, lines) {
  5587. row = Math.min(Math.max(row, 0), this.getLength());
  5588. var column = 0;
  5589. if (row < this.getLength()) {
  5590. lines = lines.concat([""]);
  5591. column = 0;
  5592. } else {
  5593. lines = [""].concat(lines);
  5594. row--;
  5595. column = this.$lines[row].length;
  5596. }
  5597. this.insertMergedLines({row: row, column: column}, lines);
  5598. };
  5599. this.insertMergedLines = function(position, lines) {
  5600. var start = this.clippedPos(position.row, position.column);
  5601. var end = {
  5602. row: start.row + lines.length - 1,
  5603. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  5604. };
  5605. this.applyDelta({
  5606. start: start,
  5607. end: end,
  5608. action: "insert",
  5609. lines: lines
  5610. });
  5611. return this.clonePos(end);
  5612. };
  5613. this.remove = function(range) {
  5614. var start = this.clippedPos(range.start.row, range.start.column);
  5615. var end = this.clippedPos(range.end.row, range.end.column);
  5616. this.applyDelta({
  5617. start: start,
  5618. end: end,
  5619. action: "remove",
  5620. lines: this.getLinesForRange({start: start, end: end})
  5621. });
  5622. return this.clonePos(start);
  5623. };
  5624. this.removeInLine = function(row, startColumn, endColumn) {
  5625. var start = this.clippedPos(row, startColumn);
  5626. var end = this.clippedPos(row, endColumn);
  5627. this.applyDelta({
  5628. start: start,
  5629. end: end,
  5630. action: "remove",
  5631. lines: this.getLinesForRange({start: start, end: end})
  5632. }, true);
  5633. return this.clonePos(start);
  5634. };
  5635. this.removeFullLines = function(firstRow, lastRow) {
  5636. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  5637. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  5638. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  5639. var deleteLastNewLine = lastRow < this.getLength() - 1;
  5640. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  5641. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  5642. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  5643. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  5644. var range = new Range(startRow, startCol, endRow, endCol);
  5645. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  5646. this.applyDelta({
  5647. start: range.start,
  5648. end: range.end,
  5649. action: "remove",
  5650. lines: this.getLinesForRange(range)
  5651. });
  5652. return deletedLines;
  5653. };
  5654. this.removeNewLine = function(row) {
  5655. if (row < this.getLength() - 1 && row >= 0) {
  5656. this.applyDelta({
  5657. start: this.pos(row, this.getLine(row).length),
  5658. end: this.pos(row + 1, 0),
  5659. action: "remove",
  5660. lines: ["", ""]
  5661. });
  5662. }
  5663. };
  5664. this.replace = function(range, text) {
  5665. if (!(range instanceof Range))
  5666. range = Range.fromPoints(range.start, range.end);
  5667. if (text.length === 0 && range.isEmpty())
  5668. return range.start;
  5669. if (text == this.getTextRange(range))
  5670. return range.end;
  5671. this.remove(range);
  5672. var end;
  5673. if (text) {
  5674. end = this.insert(range.start, text);
  5675. }
  5676. else {
  5677. end = range.start;
  5678. }
  5679. return end;
  5680. };
  5681. this.applyDeltas = function(deltas) {
  5682. for (var i=0; i<deltas.length; i++) {
  5683. this.applyDelta(deltas[i]);
  5684. }
  5685. };
  5686. this.revertDeltas = function(deltas) {
  5687. for (var i=deltas.length-1; i>=0; i--) {
  5688. this.revertDelta(deltas[i]);
  5689. }
  5690. };
  5691. this.applyDelta = function(delta, doNotValidate) {
  5692. var isInsert = delta.action == "insert";
  5693. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  5694. : !Range.comparePoints(delta.start, delta.end)) {
  5695. return;
  5696. }
  5697. if (isInsert && delta.lines.length > 20000)
  5698. this.$splitAndapplyLargeDelta(delta, 20000);
  5699. applyDelta(this.$lines, delta, doNotValidate);
  5700. this._signal("change", delta);
  5701. };
  5702. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  5703. var lines = delta.lines;
  5704. var l = lines.length;
  5705. var row = delta.start.row;
  5706. var column = delta.start.column;
  5707. var from = 0, to = 0;
  5708. do {
  5709. from = to;
  5710. to += MAX - 1;
  5711. var chunk = lines.slice(from, to);
  5712. if (to > l) {
  5713. delta.lines = chunk;
  5714. delta.start.row = row + from;
  5715. delta.start.column = column;
  5716. break;
  5717. }
  5718. chunk.push("");
  5719. this.applyDelta({
  5720. start: this.pos(row + from, column),
  5721. end: this.pos(row + to, column = 0),
  5722. action: delta.action,
  5723. lines: chunk
  5724. }, true);
  5725. } while(true);
  5726. };
  5727. this.revertDelta = function(delta) {
  5728. this.applyDelta({
  5729. start: this.clonePos(delta.start),
  5730. end: this.clonePos(delta.end),
  5731. action: (delta.action == "insert" ? "remove" : "insert"),
  5732. lines: delta.lines.slice()
  5733. });
  5734. };
  5735. this.indexToPosition = function(index, startRow) {
  5736. var lines = this.$lines || this.getAllLines();
  5737. var newlineLength = this.getNewLineCharacter().length;
  5738. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5739. index -= lines[i].length + newlineLength;
  5740. if (index < 0)
  5741. return {row: i, column: index + lines[i].length + newlineLength};
  5742. }
  5743. return {row: l-1, column: lines[l-1].length};
  5744. };
  5745. this.positionToIndex = function(pos, startRow) {
  5746. var lines = this.$lines || this.getAllLines();
  5747. var newlineLength = this.getNewLineCharacter().length;
  5748. var index = 0;
  5749. var row = Math.min(pos.row, lines.length);
  5750. for (var i = startRow || 0; i < row; ++i)
  5751. index += lines[i].length + newlineLength;
  5752. return index + pos.column;
  5753. };
  5754. }).call(Document.prototype);
  5755. exports.Document = Document;
  5756. });
  5757. define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5758. "use strict";
  5759. var oop = require("./lib/oop");
  5760. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5761. var BackgroundTokenizer = function(tokenizer, editor) {
  5762. this.running = false;
  5763. this.lines = [];
  5764. this.states = [];
  5765. this.currentLine = 0;
  5766. this.tokenizer = tokenizer;
  5767. var self = this;
  5768. this.$worker = function() {
  5769. if (!self.running) { return; }
  5770. var workerStart = new Date();
  5771. var currentLine = self.currentLine;
  5772. var endLine = -1;
  5773. var doc = self.doc;
  5774. var startLine = currentLine;
  5775. while (self.lines[currentLine])
  5776. currentLine++;
  5777. var len = doc.getLength();
  5778. var processedLines = 0;
  5779. self.running = false;
  5780. while (currentLine < len) {
  5781. self.$tokenizeRow(currentLine);
  5782. endLine = currentLine;
  5783. do {
  5784. currentLine++;
  5785. } while (self.lines[currentLine]);
  5786. processedLines ++;
  5787. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5788. self.running = setTimeout(self.$worker, 20);
  5789. break;
  5790. }
  5791. }
  5792. self.currentLine = currentLine;
  5793. if (startLine <= endLine)
  5794. self.fireUpdateEvent(startLine, endLine);
  5795. };
  5796. };
  5797. (function(){
  5798. oop.implement(this, EventEmitter);
  5799. this.setTokenizer = function(tokenizer) {
  5800. this.tokenizer = tokenizer;
  5801. this.lines = [];
  5802. this.states = [];
  5803. this.start(0);
  5804. };
  5805. this.setDocument = function(doc) {
  5806. this.doc = doc;
  5807. this.lines = [];
  5808. this.states = [];
  5809. this.stop();
  5810. };
  5811. this.fireUpdateEvent = function(firstRow, lastRow) {
  5812. var data = {
  5813. first: firstRow,
  5814. last: lastRow
  5815. };
  5816. this._signal("update", {data: data});
  5817. };
  5818. this.start = function(startRow) {
  5819. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5820. this.lines.splice(this.currentLine, this.lines.length);
  5821. this.states.splice(this.currentLine, this.states.length);
  5822. this.stop();
  5823. this.running = setTimeout(this.$worker, 700);
  5824. };
  5825. this.scheduleStart = function() {
  5826. if (!this.running)
  5827. this.running = setTimeout(this.$worker, 700);
  5828. }
  5829. this.$updateOnChange = function(delta) {
  5830. var startRow = delta.start.row;
  5831. var len = delta.end.row - startRow;
  5832. if (len === 0) {
  5833. this.lines[startRow] = null;
  5834. } else if (delta.action == "remove") {
  5835. this.lines.splice(startRow, len + 1, null);
  5836. this.states.splice(startRow, len + 1, null);
  5837. } else {
  5838. var args = Array(len + 1);
  5839. args.unshift(startRow, 1);
  5840. this.lines.splice.apply(this.lines, args);
  5841. this.states.splice.apply(this.states, args);
  5842. }
  5843. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5844. this.stop();
  5845. };
  5846. this.stop = function() {
  5847. if (this.running)
  5848. clearTimeout(this.running);
  5849. this.running = false;
  5850. };
  5851. this.getTokens = function(row) {
  5852. return this.lines[row] || this.$tokenizeRow(row);
  5853. };
  5854. this.getState = function(row) {
  5855. if (this.currentLine == row)
  5856. this.$tokenizeRow(row);
  5857. return this.states[row] || "start";
  5858. };
  5859. this.$tokenizeRow = function(row) {
  5860. var line = this.doc.getLine(row);
  5861. var state = this.states[row - 1];
  5862. var data = this.tokenizer.getLineTokens(line, state, row);
  5863. if (this.states[row] + "" !== data.state + "") {
  5864. this.states[row] = data.state;
  5865. this.lines[row + 1] = null;
  5866. if (this.currentLine > row + 1)
  5867. this.currentLine = row + 1;
  5868. } else if (this.currentLine == row) {
  5869. this.currentLine = row + 1;
  5870. }
  5871. return this.lines[row] = data.tokens;
  5872. };
  5873. }).call(BackgroundTokenizer.prototype);
  5874. exports.BackgroundTokenizer = BackgroundTokenizer;
  5875. });
  5876. define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5877. "use strict";
  5878. var lang = require("./lib/lang");
  5879. var oop = require("./lib/oop");
  5880. var Range = require("./range").Range;
  5881. var SearchHighlight = function(regExp, clazz, type) {
  5882. this.setRegexp(regExp);
  5883. this.clazz = clazz;
  5884. this.type = type || "text";
  5885. };
  5886. (function() {
  5887. this.MAX_RANGES = 500;
  5888. this.setRegexp = function(regExp) {
  5889. if (this.regExp+"" == regExp+"")
  5890. return;
  5891. this.regExp = regExp;
  5892. this.cache = [];
  5893. };
  5894. this.update = function(html, markerLayer, session, config) {
  5895. if (!this.regExp)
  5896. return;
  5897. var start = config.firstRow, end = config.lastRow;
  5898. for (var i = start; i <= end; i++) {
  5899. var ranges = this.cache[i];
  5900. if (ranges == null) {
  5901. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5902. if (ranges.length > this.MAX_RANGES)
  5903. ranges = ranges.slice(0, this.MAX_RANGES);
  5904. ranges = ranges.map(function(match) {
  5905. return new Range(i, match.offset, i, match.offset + match.length);
  5906. });
  5907. this.cache[i] = ranges.length ? ranges : "";
  5908. }
  5909. for (var j = ranges.length; j --; ) {
  5910. markerLayer.drawSingleLineMarker(
  5911. html, ranges[j].toScreenRange(session), this.clazz, config);
  5912. }
  5913. }
  5914. };
  5915. }).call(SearchHighlight.prototype);
  5916. exports.SearchHighlight = SearchHighlight;
  5917. });
  5918. define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5919. "use strict";
  5920. var Range = require("../range").Range;
  5921. function FoldLine(foldData, folds) {
  5922. this.foldData = foldData;
  5923. if (Array.isArray(folds)) {
  5924. this.folds = folds;
  5925. } else {
  5926. folds = this.folds = [ folds ];
  5927. }
  5928. var last = folds[folds.length - 1];
  5929. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5930. last.end.row, last.end.column);
  5931. this.start = this.range.start;
  5932. this.end = this.range.end;
  5933. this.folds.forEach(function(fold) {
  5934. fold.setFoldLine(this);
  5935. }, this);
  5936. }
  5937. (function() {
  5938. this.shiftRow = function(shift) {
  5939. this.start.row += shift;
  5940. this.end.row += shift;
  5941. this.folds.forEach(function(fold) {
  5942. fold.start.row += shift;
  5943. fold.end.row += shift;
  5944. });
  5945. };
  5946. this.addFold = function(fold) {
  5947. if (fold.sameRow) {
  5948. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5949. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5950. }
  5951. this.folds.push(fold);
  5952. this.folds.sort(function(a, b) {
  5953. return -a.range.compareEnd(b.start.row, b.start.column);
  5954. });
  5955. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5956. this.end.row = fold.end.row;
  5957. this.end.column = fold.end.column;
  5958. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5959. this.start.row = fold.start.row;
  5960. this.start.column = fold.start.column;
  5961. }
  5962. } else if (fold.start.row == this.end.row) {
  5963. this.folds.push(fold);
  5964. this.end.row = fold.end.row;
  5965. this.end.column = fold.end.column;
  5966. } else if (fold.end.row == this.start.row) {
  5967. this.folds.unshift(fold);
  5968. this.start.row = fold.start.row;
  5969. this.start.column = fold.start.column;
  5970. } else {
  5971. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5972. }
  5973. fold.foldLine = this;
  5974. };
  5975. this.containsRow = function(row) {
  5976. return row >= this.start.row && row <= this.end.row;
  5977. };
  5978. this.walk = function(callback, endRow, endColumn) {
  5979. var lastEnd = 0,
  5980. folds = this.folds,
  5981. fold,
  5982. cmp, stop, isNewRow = true;
  5983. if (endRow == null) {
  5984. endRow = this.end.row;
  5985. endColumn = this.end.column;
  5986. }
  5987. for (var i = 0; i < folds.length; i++) {
  5988. fold = folds[i];
  5989. cmp = fold.range.compareStart(endRow, endColumn);
  5990. if (cmp == -1) {
  5991. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5992. return;
  5993. }
  5994. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  5995. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  5996. if (stop || cmp === 0) {
  5997. return;
  5998. }
  5999. isNewRow = !fold.sameRow;
  6000. lastEnd = fold.end.column;
  6001. }
  6002. callback(null, endRow, endColumn, lastEnd, isNewRow);
  6003. };
  6004. this.getNextFoldTo = function(row, column) {
  6005. var fold, cmp;
  6006. for (var i = 0; i < this.folds.length; i++) {
  6007. fold = this.folds[i];
  6008. cmp = fold.range.compareEnd(row, column);
  6009. if (cmp == -1) {
  6010. return {
  6011. fold: fold,
  6012. kind: "after"
  6013. };
  6014. } else if (cmp === 0) {
  6015. return {
  6016. fold: fold,
  6017. kind: "inside"
  6018. };
  6019. }
  6020. }
  6021. return null;
  6022. };
  6023. this.addRemoveChars = function(row, column, len) {
  6024. var ret = this.getNextFoldTo(row, column),
  6025. fold, folds;
  6026. if (ret) {
  6027. fold = ret.fold;
  6028. if (ret.kind == "inside"
  6029. && fold.start.column != column
  6030. && fold.start.row != row)
  6031. {
  6032. window.console && window.console.log(row, column, fold);
  6033. } else if (fold.start.row == row) {
  6034. folds = this.folds;
  6035. var i = folds.indexOf(fold);
  6036. if (i === 0) {
  6037. this.start.column += len;
  6038. }
  6039. for (i; i < folds.length; i++) {
  6040. fold = folds[i];
  6041. fold.start.column += len;
  6042. if (!fold.sameRow) {
  6043. return;
  6044. }
  6045. fold.end.column += len;
  6046. }
  6047. this.end.column += len;
  6048. }
  6049. }
  6050. };
  6051. this.split = function(row, column) {
  6052. var pos = this.getNextFoldTo(row, column);
  6053. if (!pos || pos.kind == "inside")
  6054. return null;
  6055. var fold = pos.fold;
  6056. var folds = this.folds;
  6057. var foldData = this.foldData;
  6058. var i = folds.indexOf(fold);
  6059. var foldBefore = folds[i - 1];
  6060. this.end.row = foldBefore.end.row;
  6061. this.end.column = foldBefore.end.column;
  6062. folds = folds.splice(i, folds.length - i);
  6063. var newFoldLine = new FoldLine(foldData, folds);
  6064. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  6065. return newFoldLine;
  6066. };
  6067. this.merge = function(foldLineNext) {
  6068. var folds = foldLineNext.folds;
  6069. for (var i = 0; i < folds.length; i++) {
  6070. this.addFold(folds[i]);
  6071. }
  6072. var foldData = this.foldData;
  6073. foldData.splice(foldData.indexOf(foldLineNext), 1);
  6074. };
  6075. this.toString = function() {
  6076. var ret = [this.range.toString() + ": [" ];
  6077. this.folds.forEach(function(fold) {
  6078. ret.push(" " + fold.toString());
  6079. });
  6080. ret.push("]");
  6081. return ret.join("\n");
  6082. };
  6083. this.idxToPosition = function(idx) {
  6084. var lastFoldEndColumn = 0;
  6085. for (var i = 0; i < this.folds.length; i++) {
  6086. var fold = this.folds[i];
  6087. idx -= fold.start.column - lastFoldEndColumn;
  6088. if (idx < 0) {
  6089. return {
  6090. row: fold.start.row,
  6091. column: fold.start.column + idx
  6092. };
  6093. }
  6094. idx -= fold.placeholder.length;
  6095. if (idx < 0) {
  6096. return fold.start;
  6097. }
  6098. lastFoldEndColumn = fold.end.column;
  6099. }
  6100. return {
  6101. row: this.end.row,
  6102. column: this.end.column + idx
  6103. };
  6104. };
  6105. }).call(FoldLine.prototype);
  6106. exports.FoldLine = FoldLine;
  6107. });
  6108. define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  6109. "use strict";
  6110. var Range = require("./range").Range;
  6111. var comparePoints = Range.comparePoints;
  6112. var RangeList = function() {
  6113. this.ranges = [];
  6114. };
  6115. (function() {
  6116. this.comparePoints = comparePoints;
  6117. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6118. var list = this.ranges;
  6119. for (var i = startIndex || 0; i < list.length; i++) {
  6120. var range = list[i];
  6121. var cmpEnd = comparePoints(pos, range.end);
  6122. if (cmpEnd > 0)
  6123. continue;
  6124. var cmpStart = comparePoints(pos, range.start);
  6125. if (cmpEnd === 0)
  6126. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6127. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6128. return i;
  6129. return -i-1;
  6130. }
  6131. return -i - 1;
  6132. };
  6133. this.add = function(range) {
  6134. var excludeEdges = !range.isEmpty();
  6135. var startIndex = this.pointIndex(range.start, excludeEdges);
  6136. if (startIndex < 0)
  6137. startIndex = -startIndex - 1;
  6138. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6139. if (endIndex < 0)
  6140. endIndex = -endIndex - 1;
  6141. else
  6142. endIndex++;
  6143. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6144. };
  6145. this.addList = function(list) {
  6146. var removed = [];
  6147. for (var i = list.length; i--; ) {
  6148. removed.push.call(removed, this.add(list[i]));
  6149. }
  6150. return removed;
  6151. };
  6152. this.substractPoint = function(pos) {
  6153. var i = this.pointIndex(pos);
  6154. if (i >= 0)
  6155. return this.ranges.splice(i, 1);
  6156. };
  6157. this.merge = function() {
  6158. var removed = [];
  6159. var list = this.ranges;
  6160. list = list.sort(function(a, b) {
  6161. return comparePoints(a.start, b.start);
  6162. });
  6163. var next = list[0], range;
  6164. for (var i = 1; i < list.length; i++) {
  6165. range = next;
  6166. next = list[i];
  6167. var cmp = comparePoints(range.end, next.start);
  6168. if (cmp < 0)
  6169. continue;
  6170. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6171. continue;
  6172. if (comparePoints(range.end, next.end) < 0) {
  6173. range.end.row = next.end.row;
  6174. range.end.column = next.end.column;
  6175. }
  6176. list.splice(i, 1);
  6177. removed.push(next);
  6178. next = range;
  6179. i--;
  6180. }
  6181. this.ranges = list;
  6182. return removed;
  6183. };
  6184. this.contains = function(row, column) {
  6185. return this.pointIndex({row: row, column: column}) >= 0;
  6186. };
  6187. this.containsPoint = function(pos) {
  6188. return this.pointIndex(pos) >= 0;
  6189. };
  6190. this.rangeAtPoint = function(pos) {
  6191. var i = this.pointIndex(pos);
  6192. if (i >= 0)
  6193. return this.ranges[i];
  6194. };
  6195. this.clipRows = function(startRow, endRow) {
  6196. var list = this.ranges;
  6197. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6198. return [];
  6199. var startIndex = this.pointIndex({row: startRow, column: 0});
  6200. if (startIndex < 0)
  6201. startIndex = -startIndex - 1;
  6202. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6203. if (endIndex < 0)
  6204. endIndex = -endIndex - 1;
  6205. var clipped = [];
  6206. for (var i = startIndex; i < endIndex; i++) {
  6207. clipped.push(list[i]);
  6208. }
  6209. return clipped;
  6210. };
  6211. this.removeAll = function() {
  6212. return this.ranges.splice(0, this.ranges.length);
  6213. };
  6214. this.attach = function(session) {
  6215. if (this.session)
  6216. this.detach();
  6217. this.session = session;
  6218. this.onChange = this.$onChange.bind(this);
  6219. this.session.on('change', this.onChange);
  6220. };
  6221. this.detach = function() {
  6222. if (!this.session)
  6223. return;
  6224. this.session.removeListener('change', this.onChange);
  6225. this.session = null;
  6226. };
  6227. this.$onChange = function(delta) {
  6228. if (delta.action == "insert"){
  6229. var start = delta.start;
  6230. var end = delta.end;
  6231. } else {
  6232. var end = delta.start;
  6233. var start = delta.end;
  6234. }
  6235. var startRow = start.row;
  6236. var endRow = end.row;
  6237. var lineDif = endRow - startRow;
  6238. var colDiff = -start.column + end.column;
  6239. var ranges = this.ranges;
  6240. for (var i = 0, n = ranges.length; i < n; i++) {
  6241. var r = ranges[i];
  6242. if (r.end.row < startRow)
  6243. continue;
  6244. if (r.start.row > startRow)
  6245. break;
  6246. if (r.start.row == startRow && r.start.column >= start.column ) {
  6247. if (r.start.column == start.column && this.$insertRight) {
  6248. } else {
  6249. r.start.column += colDiff;
  6250. r.start.row += lineDif;
  6251. }
  6252. }
  6253. if (r.end.row == startRow && r.end.column >= start.column) {
  6254. if (r.end.column == start.column && this.$insertRight) {
  6255. continue;
  6256. }
  6257. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6258. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6259. r.end.column -= colDiff;
  6260. }
  6261. r.end.column += colDiff;
  6262. r.end.row += lineDif;
  6263. }
  6264. }
  6265. if (lineDif != 0 && i < n) {
  6266. for (; i < n; i++) {
  6267. var r = ranges[i];
  6268. r.start.row += lineDif;
  6269. r.end.row += lineDif;
  6270. }
  6271. }
  6272. };
  6273. }).call(RangeList.prototype);
  6274. exports.RangeList = RangeList;
  6275. });
  6276. define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6277. "use strict";
  6278. var Range = require("../range").Range;
  6279. var RangeList = require("../range_list").RangeList;
  6280. var oop = require("../lib/oop")
  6281. var Fold = exports.Fold = function(range, placeholder) {
  6282. this.foldLine = null;
  6283. this.placeholder = placeholder;
  6284. this.range = range;
  6285. this.start = range.start;
  6286. this.end = range.end;
  6287. this.sameRow = range.start.row == range.end.row;
  6288. this.subFolds = this.ranges = [];
  6289. };
  6290. oop.inherits(Fold, RangeList);
  6291. (function() {
  6292. this.toString = function() {
  6293. return '"' + this.placeholder + '" ' + this.range.toString();
  6294. };
  6295. this.setFoldLine = function(foldLine) {
  6296. this.foldLine = foldLine;
  6297. this.subFolds.forEach(function(fold) {
  6298. fold.setFoldLine(foldLine);
  6299. });
  6300. };
  6301. this.clone = function() {
  6302. var range = this.range.clone();
  6303. var fold = new Fold(range, this.placeholder);
  6304. this.subFolds.forEach(function(subFold) {
  6305. fold.subFolds.push(subFold.clone());
  6306. });
  6307. fold.collapseChildren = this.collapseChildren;
  6308. return fold;
  6309. };
  6310. this.addSubFold = function(fold) {
  6311. if (this.range.isEqual(fold))
  6312. return;
  6313. if (!this.range.containsRange(fold))
  6314. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6315. consumeRange(fold, this.start);
  6316. var row = fold.start.row, column = fold.start.column;
  6317. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6318. cmp = this.subFolds[i].range.compare(row, column);
  6319. if (cmp != 1)
  6320. break;
  6321. }
  6322. var afterStart = this.subFolds[i];
  6323. if (cmp == 0)
  6324. return afterStart.addSubFold(fold);
  6325. var row = fold.range.end.row, column = fold.range.end.column;
  6326. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6327. cmp = this.subFolds[j].range.compare(row, column);
  6328. if (cmp != 1)
  6329. break;
  6330. }
  6331. var afterEnd = this.subFolds[j];
  6332. if (cmp == 0)
  6333. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6334. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6335. fold.setFoldLine(this.foldLine);
  6336. return fold;
  6337. };
  6338. this.restoreRange = function(range) {
  6339. return restoreRange(range, this.start);
  6340. };
  6341. }).call(Fold.prototype);
  6342. function consumePoint(point, anchor) {
  6343. point.row -= anchor.row;
  6344. if (point.row == 0)
  6345. point.column -= anchor.column;
  6346. }
  6347. function consumeRange(range, anchor) {
  6348. consumePoint(range.start, anchor);
  6349. consumePoint(range.end, anchor);
  6350. }
  6351. function restorePoint(point, anchor) {
  6352. if (point.row == 0)
  6353. point.column += anchor.column;
  6354. point.row += anchor.row;
  6355. }
  6356. function restoreRange(range, anchor) {
  6357. restorePoint(range.start, anchor);
  6358. restorePoint(range.end, anchor);
  6359. }
  6360. });
  6361. 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) {
  6362. "use strict";
  6363. var Range = require("../range").Range;
  6364. var FoldLine = require("./fold_line").FoldLine;
  6365. var Fold = require("./fold").Fold;
  6366. var TokenIterator = require("../token_iterator").TokenIterator;
  6367. function Folding() {
  6368. this.getFoldAt = function(row, column, side) {
  6369. var foldLine = this.getFoldLine(row);
  6370. if (!foldLine)
  6371. return null;
  6372. var folds = foldLine.folds;
  6373. for (var i = 0; i < folds.length; i++) {
  6374. var fold = folds[i];
  6375. if (fold.range.contains(row, column)) {
  6376. if (side == 1 && fold.range.isEnd(row, column)) {
  6377. continue;
  6378. } else if (side == -1 && fold.range.isStart(row, column)) {
  6379. continue;
  6380. }
  6381. return fold;
  6382. }
  6383. }
  6384. };
  6385. this.getFoldsInRange = function(range) {
  6386. var start = range.start;
  6387. var end = range.end;
  6388. var foldLines = this.$foldData;
  6389. var foundFolds = [];
  6390. start.column += 1;
  6391. end.column -= 1;
  6392. for (var i = 0; i < foldLines.length; i++) {
  6393. var cmp = foldLines[i].range.compareRange(range);
  6394. if (cmp == 2) {
  6395. continue;
  6396. }
  6397. else if (cmp == -2) {
  6398. break;
  6399. }
  6400. var folds = foldLines[i].folds;
  6401. for (var j = 0; j < folds.length; j++) {
  6402. var fold = folds[j];
  6403. cmp = fold.range.compareRange(range);
  6404. if (cmp == -2) {
  6405. break;
  6406. } else if (cmp == 2) {
  6407. continue;
  6408. } else
  6409. if (cmp == 42) {
  6410. break;
  6411. }
  6412. foundFolds.push(fold);
  6413. }
  6414. }
  6415. start.column -= 1;
  6416. end.column += 1;
  6417. return foundFolds;
  6418. };
  6419. this.getFoldsInRangeList = function(ranges) {
  6420. if (Array.isArray(ranges)) {
  6421. var folds = [];
  6422. ranges.forEach(function(range) {
  6423. folds = folds.concat(this.getFoldsInRange(range));
  6424. }, this);
  6425. } else {
  6426. var folds = this.getFoldsInRange(ranges);
  6427. }
  6428. return folds;
  6429. };
  6430. this.getAllFolds = function() {
  6431. var folds = [];
  6432. var foldLines = this.$foldData;
  6433. for (var i = 0; i < foldLines.length; i++)
  6434. for (var j = 0; j < foldLines[i].folds.length; j++)
  6435. folds.push(foldLines[i].folds[j]);
  6436. return folds;
  6437. };
  6438. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6439. foldLine = foldLine || this.getFoldLine(row);
  6440. if (!foldLine)
  6441. return null;
  6442. var lastFold = {
  6443. end: { column: 0 }
  6444. };
  6445. var str, fold;
  6446. for (var i = 0; i < foldLine.folds.length; i++) {
  6447. fold = foldLine.folds[i];
  6448. var cmp = fold.range.compareEnd(row, column);
  6449. if (cmp == -1) {
  6450. str = this
  6451. .getLine(fold.start.row)
  6452. .substring(lastFold.end.column, fold.start.column);
  6453. break;
  6454. }
  6455. else if (cmp === 0) {
  6456. return null;
  6457. }
  6458. lastFold = fold;
  6459. }
  6460. if (!str)
  6461. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6462. if (trim == -1)
  6463. return str.substring(0, column - lastFold.end.column);
  6464. else if (trim == 1)
  6465. return str.substring(column - lastFold.end.column);
  6466. else
  6467. return str;
  6468. };
  6469. this.getFoldLine = function(docRow, startFoldLine) {
  6470. var foldData = this.$foldData;
  6471. var i = 0;
  6472. if (startFoldLine)
  6473. i = foldData.indexOf(startFoldLine);
  6474. if (i == -1)
  6475. i = 0;
  6476. for (i; i < foldData.length; i++) {
  6477. var foldLine = foldData[i];
  6478. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6479. return foldLine;
  6480. } else if (foldLine.end.row > docRow) {
  6481. return null;
  6482. }
  6483. }
  6484. return null;
  6485. };
  6486. this.getNextFoldLine = function(docRow, startFoldLine) {
  6487. var foldData = this.$foldData;
  6488. var i = 0;
  6489. if (startFoldLine)
  6490. i = foldData.indexOf(startFoldLine);
  6491. if (i == -1)
  6492. i = 0;
  6493. for (i; i < foldData.length; i++) {
  6494. var foldLine = foldData[i];
  6495. if (foldLine.end.row >= docRow) {
  6496. return foldLine;
  6497. }
  6498. }
  6499. return null;
  6500. };
  6501. this.getFoldedRowCount = function(first, last) {
  6502. var foldData = this.$foldData, rowCount = last-first+1;
  6503. for (var i = 0; i < foldData.length; i++) {
  6504. var foldLine = foldData[i],
  6505. end = foldLine.end.row,
  6506. start = foldLine.start.row;
  6507. if (end >= last) {
  6508. if (start < last) {
  6509. if (start >= first)
  6510. rowCount -= last-start;
  6511. else
  6512. rowCount = 0; // in one fold
  6513. }
  6514. break;
  6515. } else if (end >= first){
  6516. if (start >= first) // fold inside range
  6517. rowCount -= end-start;
  6518. else
  6519. rowCount -= end-first+1;
  6520. }
  6521. }
  6522. return rowCount;
  6523. };
  6524. this.$addFoldLine = function(foldLine) {
  6525. this.$foldData.push(foldLine);
  6526. this.$foldData.sort(function(a, b) {
  6527. return a.start.row - b.start.row;
  6528. });
  6529. return foldLine;
  6530. };
  6531. this.addFold = function(placeholder, range) {
  6532. var foldData = this.$foldData;
  6533. var added = false;
  6534. var fold;
  6535. if (placeholder instanceof Fold)
  6536. fold = placeholder;
  6537. else {
  6538. fold = new Fold(range, placeholder);
  6539. fold.collapseChildren = range.collapseChildren;
  6540. }
  6541. this.$clipRangeToDocument(fold.range);
  6542. var startRow = fold.start.row;
  6543. var startColumn = fold.start.column;
  6544. var endRow = fold.end.row;
  6545. var endColumn = fold.end.column;
  6546. if (!(startRow < endRow ||
  6547. startRow == endRow && startColumn <= endColumn - 2))
  6548. throw new Error("The range has to be at least 2 characters width");
  6549. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6550. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6551. if (startFold && endFold == startFold)
  6552. return startFold.addSubFold(fold);
  6553. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6554. this.removeFold(startFold);
  6555. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6556. this.removeFold(endFold);
  6557. var folds = this.getFoldsInRange(fold.range);
  6558. if (folds.length > 0) {
  6559. this.removeFolds(folds);
  6560. folds.forEach(function(subFold) {
  6561. fold.addSubFold(subFold);
  6562. });
  6563. }
  6564. for (var i = 0; i < foldData.length; i++) {
  6565. var foldLine = foldData[i];
  6566. if (endRow == foldLine.start.row) {
  6567. foldLine.addFold(fold);
  6568. added = true;
  6569. break;
  6570. } else if (startRow == foldLine.end.row) {
  6571. foldLine.addFold(fold);
  6572. added = true;
  6573. if (!fold.sameRow) {
  6574. var foldLineNext = foldData[i + 1];
  6575. if (foldLineNext && foldLineNext.start.row == endRow) {
  6576. foldLine.merge(foldLineNext);
  6577. break;
  6578. }
  6579. }
  6580. break;
  6581. } else if (endRow <= foldLine.start.row) {
  6582. break;
  6583. }
  6584. }
  6585. if (!added)
  6586. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6587. if (this.$useWrapMode)
  6588. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6589. else
  6590. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6591. this.$modified = true;
  6592. this._signal("changeFold", { data: fold, action: "add" });
  6593. return fold;
  6594. };
  6595. this.addFolds = function(folds) {
  6596. folds.forEach(function(fold) {
  6597. this.addFold(fold);
  6598. }, this);
  6599. };
  6600. this.removeFold = function(fold) {
  6601. var foldLine = fold.foldLine;
  6602. var startRow = foldLine.start.row;
  6603. var endRow = foldLine.end.row;
  6604. var foldLines = this.$foldData;
  6605. var folds = foldLine.folds;
  6606. if (folds.length == 1) {
  6607. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6608. } else
  6609. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6610. folds.pop();
  6611. foldLine.end.row = folds[folds.length - 1].end.row;
  6612. foldLine.end.column = folds[folds.length - 1].end.column;
  6613. } else
  6614. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6615. folds.shift();
  6616. foldLine.start.row = folds[0].start.row;
  6617. foldLine.start.column = folds[0].start.column;
  6618. } else
  6619. if (fold.sameRow) {
  6620. folds.splice(folds.indexOf(fold), 1);
  6621. } else
  6622. {
  6623. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6624. folds = newFoldLine.folds;
  6625. folds.shift();
  6626. newFoldLine.start.row = folds[0].start.row;
  6627. newFoldLine.start.column = folds[0].start.column;
  6628. }
  6629. if (!this.$updating) {
  6630. if (this.$useWrapMode)
  6631. this.$updateWrapData(startRow, endRow);
  6632. else
  6633. this.$updateRowLengthCache(startRow, endRow);
  6634. }
  6635. this.$modified = true;
  6636. this._signal("changeFold", { data: fold, action: "remove" });
  6637. };
  6638. this.removeFolds = function(folds) {
  6639. var cloneFolds = [];
  6640. for (var i = 0; i < folds.length; i++) {
  6641. cloneFolds.push(folds[i]);
  6642. }
  6643. cloneFolds.forEach(function(fold) {
  6644. this.removeFold(fold);
  6645. }, this);
  6646. this.$modified = true;
  6647. };
  6648. this.expandFold = function(fold) {
  6649. this.removeFold(fold);
  6650. fold.subFolds.forEach(function(subFold) {
  6651. fold.restoreRange(subFold);
  6652. this.addFold(subFold);
  6653. }, this);
  6654. if (fold.collapseChildren > 0) {
  6655. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6656. }
  6657. fold.subFolds = [];
  6658. };
  6659. this.expandFolds = function(folds) {
  6660. folds.forEach(function(fold) {
  6661. this.expandFold(fold);
  6662. }, this);
  6663. };
  6664. this.unfold = function(location, expandInner) {
  6665. var range, folds;
  6666. if (location == null) {
  6667. range = new Range(0, 0, this.getLength(), 0);
  6668. expandInner = true;
  6669. } else if (typeof location == "number")
  6670. range = new Range(location, 0, location, this.getLine(location).length);
  6671. else if ("row" in location)
  6672. range = Range.fromPoints(location, location);
  6673. else
  6674. range = location;
  6675. folds = this.getFoldsInRangeList(range);
  6676. if (expandInner) {
  6677. this.removeFolds(folds);
  6678. } else {
  6679. var subFolds = folds;
  6680. while (subFolds.length) {
  6681. this.expandFolds(subFolds);
  6682. subFolds = this.getFoldsInRangeList(range);
  6683. }
  6684. }
  6685. if (folds.length)
  6686. return folds;
  6687. };
  6688. this.isRowFolded = function(docRow, startFoldRow) {
  6689. return !!this.getFoldLine(docRow, startFoldRow);
  6690. };
  6691. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6692. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6693. return foldLine ? foldLine.end.row : docRow;
  6694. };
  6695. this.getRowFoldStart = function(docRow, startFoldRow) {
  6696. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6697. return foldLine ? foldLine.start.row : docRow;
  6698. };
  6699. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6700. if (startRow == null)
  6701. startRow = foldLine.start.row;
  6702. if (startColumn == null)
  6703. startColumn = 0;
  6704. if (endRow == null)
  6705. endRow = foldLine.end.row;
  6706. if (endColumn == null)
  6707. endColumn = this.getLine(endRow).length;
  6708. var doc = this.doc;
  6709. var textLine = "";
  6710. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6711. if (row < startRow)
  6712. return;
  6713. if (row == startRow) {
  6714. if (column < startColumn)
  6715. return;
  6716. lastColumn = Math.max(startColumn, lastColumn);
  6717. }
  6718. if (placeholder != null) {
  6719. textLine += placeholder;
  6720. } else {
  6721. textLine += doc.getLine(row).substring(lastColumn, column);
  6722. }
  6723. }, endRow, endColumn);
  6724. return textLine;
  6725. };
  6726. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6727. var foldLine = this.getFoldLine(row);
  6728. if (!foldLine) {
  6729. var line;
  6730. line = this.doc.getLine(row);
  6731. return line.substring(startColumn || 0, endColumn || line.length);
  6732. } else {
  6733. return this.getFoldDisplayLine(
  6734. foldLine, row, endColumn, startRow, startColumn);
  6735. }
  6736. };
  6737. this.$cloneFoldData = function() {
  6738. var fd = [];
  6739. fd = this.$foldData.map(function(foldLine) {
  6740. var folds = foldLine.folds.map(function(fold) {
  6741. return fold.clone();
  6742. });
  6743. return new FoldLine(fd, folds);
  6744. });
  6745. return fd;
  6746. };
  6747. this.toggleFold = function(tryToUnfold) {
  6748. var selection = this.selection;
  6749. var range = selection.getRange();
  6750. var fold;
  6751. var bracketPos;
  6752. if (range.isEmpty()) {
  6753. var cursor = range.start;
  6754. fold = this.getFoldAt(cursor.row, cursor.column);
  6755. if (fold) {
  6756. this.expandFold(fold);
  6757. return;
  6758. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6759. if (range.comparePoint(bracketPos) == 1) {
  6760. range.end = bracketPos;
  6761. } else {
  6762. range.start = bracketPos;
  6763. range.start.column++;
  6764. range.end.column--;
  6765. }
  6766. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6767. if (range.comparePoint(bracketPos) == 1)
  6768. range.end = bracketPos;
  6769. else
  6770. range.start = bracketPos;
  6771. range.start.column++;
  6772. } else {
  6773. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6774. }
  6775. } else {
  6776. var folds = this.getFoldsInRange(range);
  6777. if (tryToUnfold && folds.length) {
  6778. this.expandFolds(folds);
  6779. return;
  6780. } else if (folds.length == 1 ) {
  6781. fold = folds[0];
  6782. }
  6783. }
  6784. if (!fold)
  6785. fold = this.getFoldAt(range.start.row, range.start.column);
  6786. if (fold && fold.range.toString() == range.toString()) {
  6787. this.expandFold(fold);
  6788. return;
  6789. }
  6790. var placeholder = "...";
  6791. if (!range.isMultiLine()) {
  6792. placeholder = this.getTextRange(range);
  6793. if (placeholder.length < 4)
  6794. return;
  6795. placeholder = placeholder.trim().substring(0, 2) + "..";
  6796. }
  6797. this.addFold(placeholder, range);
  6798. };
  6799. this.getCommentFoldRange = function(row, column, dir) {
  6800. var iterator = new TokenIterator(this, row, column);
  6801. var token = iterator.getCurrentToken();
  6802. if (token && /^comment|string/.test(token.type)) {
  6803. var range = new Range();
  6804. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6805. if (dir != 1) {
  6806. do {
  6807. token = iterator.stepBackward();
  6808. } while (token && re.test(token.type));
  6809. iterator.stepForward();
  6810. }
  6811. range.start.row = iterator.getCurrentTokenRow();
  6812. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6813. iterator = new TokenIterator(this, row, column);
  6814. if (dir != -1) {
  6815. do {
  6816. token = iterator.stepForward();
  6817. } while (token && re.test(token.type));
  6818. token = iterator.stepBackward();
  6819. } else
  6820. token = iterator.getCurrentToken();
  6821. range.end.row = iterator.getCurrentTokenRow();
  6822. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6823. return range;
  6824. }
  6825. };
  6826. this.foldAll = function(startRow, endRow, depth) {
  6827. if (depth == undefined)
  6828. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6829. var foldWidgets = this.foldWidgets;
  6830. if (!foldWidgets)
  6831. return; // mode doesn't support folding
  6832. endRow = endRow || this.getLength();
  6833. startRow = startRow || 0;
  6834. for (var row = startRow; row < endRow; row++) {
  6835. if (foldWidgets[row] == null)
  6836. foldWidgets[row] = this.getFoldWidget(row);
  6837. if (foldWidgets[row] != "start")
  6838. continue;
  6839. var range = this.getFoldWidgetRange(row);
  6840. if (range && range.isMultiLine()
  6841. && range.end.row <= endRow
  6842. && range.start.row >= startRow
  6843. ) {
  6844. row = range.end.row;
  6845. try {
  6846. var fold = this.addFold("...", range);
  6847. if (fold)
  6848. fold.collapseChildren = depth;
  6849. } catch(e) {}
  6850. }
  6851. }
  6852. };
  6853. this.$foldStyles = {
  6854. "manual": 1,
  6855. "markbegin": 1,
  6856. "markbeginend": 1
  6857. };
  6858. this.$foldStyle = "markbegin";
  6859. this.setFoldStyle = function(style) {
  6860. if (!this.$foldStyles[style])
  6861. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6862. if (this.$foldStyle == style)
  6863. return;
  6864. this.$foldStyle = style;
  6865. if (style == "manual")
  6866. this.unfold();
  6867. var mode = this.$foldMode;
  6868. this.$setFolding(null);
  6869. this.$setFolding(mode);
  6870. };
  6871. this.$setFolding = function(foldMode) {
  6872. if (this.$foldMode == foldMode)
  6873. return;
  6874. this.$foldMode = foldMode;
  6875. this.off('change', this.$updateFoldWidgets);
  6876. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6877. this._signal("changeAnnotation");
  6878. if (!foldMode || this.$foldStyle == "manual") {
  6879. this.foldWidgets = null;
  6880. return;
  6881. }
  6882. this.foldWidgets = [];
  6883. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6884. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6885. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6886. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6887. this.on('change', this.$updateFoldWidgets);
  6888. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6889. };
  6890. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6891. var fw = this.foldWidgets;
  6892. if (!fw || (ignoreCurrent && fw[row]))
  6893. return {};
  6894. var i = row - 1, firstRange;
  6895. while (i >= 0) {
  6896. var c = fw[i];
  6897. if (c == null)
  6898. c = fw[i] = this.getFoldWidget(i);
  6899. if (c == "start") {
  6900. var range = this.getFoldWidgetRange(i);
  6901. if (!firstRange)
  6902. firstRange = range;
  6903. if (range && range.end.row >= row)
  6904. break;
  6905. }
  6906. i--;
  6907. }
  6908. return {
  6909. range: i !== -1 && range,
  6910. firstRange: firstRange
  6911. };
  6912. };
  6913. this.onFoldWidgetClick = function(row, e) {
  6914. e = e.domEvent;
  6915. var options = {
  6916. children: e.shiftKey,
  6917. all: e.ctrlKey || e.metaKey,
  6918. siblings: e.altKey
  6919. };
  6920. var range = this.$toggleFoldWidget(row, options);
  6921. if (!range) {
  6922. var el = (e.target || e.srcElement);
  6923. if (el && /ace_fold-widget/.test(el.className))
  6924. el.className += " ace_invalid";
  6925. }
  6926. };
  6927. this.$toggleFoldWidget = function(row, options) {
  6928. if (!this.getFoldWidget)
  6929. return;
  6930. var type = this.getFoldWidget(row);
  6931. var line = this.getLine(row);
  6932. var dir = type === "end" ? -1 : 1;
  6933. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6934. if (fold) {
  6935. if (options.children || options.all)
  6936. this.removeFold(fold);
  6937. else
  6938. this.expandFold(fold);
  6939. return;
  6940. }
  6941. var range = this.getFoldWidgetRange(row, true);
  6942. if (range && !range.isMultiLine()) {
  6943. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6944. if (fold && range.isEqual(fold.range)) {
  6945. this.removeFold(fold);
  6946. return;
  6947. }
  6948. }
  6949. if (options.siblings) {
  6950. var data = this.getParentFoldRangeData(row);
  6951. if (data.range) {
  6952. var startRow = data.range.start.row + 1;
  6953. var endRow = data.range.end.row;
  6954. }
  6955. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6956. } else if (options.children) {
  6957. endRow = range ? range.end.row : this.getLength();
  6958. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  6959. } else if (range) {
  6960. if (options.all)
  6961. range.collapseChildren = 10000;
  6962. this.addFold("...", range);
  6963. }
  6964. return range;
  6965. };
  6966. this.toggleFoldWidget = function(toggleParent) {
  6967. var row = this.selection.getCursor().row;
  6968. row = this.getRowFoldStart(row);
  6969. var range = this.$toggleFoldWidget(row, {});
  6970. if (range)
  6971. return;
  6972. var data = this.getParentFoldRangeData(row, true);
  6973. range = data.range || data.firstRange;
  6974. if (range) {
  6975. row = range.start.row;
  6976. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6977. if (fold) {
  6978. this.removeFold(fold);
  6979. } else {
  6980. this.addFold("...", range);
  6981. }
  6982. }
  6983. };
  6984. this.updateFoldWidgets = function(delta) {
  6985. var firstRow = delta.start.row;
  6986. var len = delta.end.row - firstRow;
  6987. if (len === 0) {
  6988. this.foldWidgets[firstRow] = null;
  6989. } else if (delta.action == 'remove') {
  6990. this.foldWidgets.splice(firstRow, len + 1, null);
  6991. } else {
  6992. var args = Array(len + 1);
  6993. args.unshift(firstRow, 1);
  6994. this.foldWidgets.splice.apply(this.foldWidgets, args);
  6995. }
  6996. };
  6997. this.tokenizerUpdateFoldWidgets = function(e) {
  6998. var rows = e.data;
  6999. if (rows.first != rows.last) {
  7000. if (this.foldWidgets.length > rows.first)
  7001. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  7002. }
  7003. };
  7004. }
  7005. exports.Folding = Folding;
  7006. });
  7007. define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  7008. "use strict";
  7009. var TokenIterator = require("../token_iterator").TokenIterator;
  7010. var Range = require("../range").Range;
  7011. function BracketMatch() {
  7012. this.findMatchingBracket = function(position, chr) {
  7013. if (position.column == 0) return null;
  7014. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  7015. if (charBeforeCursor == "") return null;
  7016. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  7017. if (!match)
  7018. return null;
  7019. if (match[1])
  7020. return this.$findClosingBracket(match[1], position);
  7021. else
  7022. return this.$findOpeningBracket(match[2], position);
  7023. };
  7024. this.getBracketRange = function(pos) {
  7025. var line = this.getLine(pos.row);
  7026. var before = true, range;
  7027. var chr = line.charAt(pos.column-1);
  7028. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7029. if (!match) {
  7030. chr = line.charAt(pos.column);
  7031. pos = {row: pos.row, column: pos.column + 1};
  7032. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7033. before = false;
  7034. }
  7035. if (!match)
  7036. return null;
  7037. if (match[1]) {
  7038. var bracketPos = this.$findClosingBracket(match[1], pos);
  7039. if (!bracketPos)
  7040. return null;
  7041. range = Range.fromPoints(pos, bracketPos);
  7042. if (!before) {
  7043. range.end.column++;
  7044. range.start.column--;
  7045. }
  7046. range.cursor = range.end;
  7047. } else {
  7048. var bracketPos = this.$findOpeningBracket(match[2], pos);
  7049. if (!bracketPos)
  7050. return null;
  7051. range = Range.fromPoints(bracketPos, pos);
  7052. if (!before) {
  7053. range.start.column++;
  7054. range.end.column--;
  7055. }
  7056. range.cursor = range.start;
  7057. }
  7058. return range;
  7059. };
  7060. this.$brackets = {
  7061. ")": "(",
  7062. "(": ")",
  7063. "]": "[",
  7064. "[": "]",
  7065. "{": "}",
  7066. "}": "{"
  7067. };
  7068. this.$findOpeningBracket = function(bracket, position, typeRe) {
  7069. var openBracket = this.$brackets[bracket];
  7070. var depth = 1;
  7071. var iterator = new TokenIterator(this, position.row, position.column);
  7072. var token = iterator.getCurrentToken();
  7073. if (!token)
  7074. token = iterator.stepForward();
  7075. if (!token)
  7076. return;
  7077. if (!typeRe){
  7078. typeRe = new RegExp(
  7079. "(\\.?" +
  7080. token.type.replace(".", "\\.").replace("rparen", ".paren")
  7081. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  7082. + ")+"
  7083. );
  7084. }
  7085. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  7086. var value = token.value;
  7087. while (true) {
  7088. while (valueIndex >= 0) {
  7089. var chr = value.charAt(valueIndex);
  7090. if (chr == openBracket) {
  7091. depth -= 1;
  7092. if (depth == 0) {
  7093. return {row: iterator.getCurrentTokenRow(),
  7094. column: valueIndex + iterator.getCurrentTokenColumn()};
  7095. }
  7096. }
  7097. else if (chr == bracket) {
  7098. depth += 1;
  7099. }
  7100. valueIndex -= 1;
  7101. }
  7102. do {
  7103. token = iterator.stepBackward();
  7104. } while (token && !typeRe.test(token.type));
  7105. if (token == null)
  7106. break;
  7107. value = token.value;
  7108. valueIndex = value.length - 1;
  7109. }
  7110. return null;
  7111. };
  7112. this.$findClosingBracket = function(bracket, position, typeRe) {
  7113. var closingBracket = this.$brackets[bracket];
  7114. var depth = 1;
  7115. var iterator = new TokenIterator(this, position.row, position.column);
  7116. var token = iterator.getCurrentToken();
  7117. if (!token)
  7118. token = iterator.stepForward();
  7119. if (!token)
  7120. return;
  7121. if (!typeRe){
  7122. typeRe = new RegExp(
  7123. "(\\.?" +
  7124. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7125. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  7126. + ")+"
  7127. );
  7128. }
  7129. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7130. while (true) {
  7131. var value = token.value;
  7132. var valueLength = value.length;
  7133. while (valueIndex < valueLength) {
  7134. var chr = value.charAt(valueIndex);
  7135. if (chr == closingBracket) {
  7136. depth -= 1;
  7137. if (depth == 0) {
  7138. return {row: iterator.getCurrentTokenRow(),
  7139. column: valueIndex + iterator.getCurrentTokenColumn()};
  7140. }
  7141. }
  7142. else if (chr == bracket) {
  7143. depth += 1;
  7144. }
  7145. valueIndex += 1;
  7146. }
  7147. do {
  7148. token = iterator.stepForward();
  7149. } while (token && !typeRe.test(token.type));
  7150. if (token == null)
  7151. break;
  7152. valueIndex = 0;
  7153. }
  7154. return null;
  7155. };
  7156. }
  7157. exports.BracketMatch = BracketMatch;
  7158. });
  7159. define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"], function(require, exports, module) {
  7160. "use strict";
  7161. var oop = require("./lib/oop");
  7162. var lang = require("./lib/lang");
  7163. var config = require("./config");
  7164. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7165. var Selection = require("./selection").Selection;
  7166. var TextMode = require("./mode/text").Mode;
  7167. var Range = require("./range").Range;
  7168. var Document = require("./document").Document;
  7169. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7170. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7171. var EditSession = function(text, mode) {
  7172. this.$breakpoints = [];
  7173. this.$decorations = [];
  7174. this.$frontMarkers = {};
  7175. this.$backMarkers = {};
  7176. this.$markerId = 1;
  7177. this.$undoSelect = true;
  7178. this.$foldData = [];
  7179. this.$foldData.toString = function() {
  7180. return this.join("\n");
  7181. };
  7182. this.on("changeFold", this.onChangeFold.bind(this));
  7183. this.$onChange = this.onChange.bind(this);
  7184. if (typeof text != "object" || !text.getLine)
  7185. text = new Document(text);
  7186. this.setDocument(text);
  7187. this.selection = new Selection(this);
  7188. config.resetOptions(this);
  7189. this.setMode(mode);
  7190. config._signal("session", this);
  7191. };
  7192. (function() {
  7193. oop.implement(this, EventEmitter);
  7194. this.setDocument = function(doc) {
  7195. if (this.doc)
  7196. this.doc.removeListener("change", this.$onChange);
  7197. this.doc = doc;
  7198. doc.on("change", this.$onChange);
  7199. if (this.bgTokenizer)
  7200. this.bgTokenizer.setDocument(this.getDocument());
  7201. this.resetCaches();
  7202. };
  7203. this.getDocument = function() {
  7204. return this.doc;
  7205. };
  7206. this.$resetRowCache = function(docRow) {
  7207. if (!docRow) {
  7208. this.$docRowCache = [];
  7209. this.$screenRowCache = [];
  7210. return;
  7211. }
  7212. var l = this.$docRowCache.length;
  7213. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7214. if (l > i) {
  7215. this.$docRowCache.splice(i, l);
  7216. this.$screenRowCache.splice(i, l);
  7217. }
  7218. };
  7219. this.$getRowCacheIndex = function(cacheArray, val) {
  7220. var low = 0;
  7221. var hi = cacheArray.length - 1;
  7222. while (low <= hi) {
  7223. var mid = (low + hi) >> 1;
  7224. var c = cacheArray[mid];
  7225. if (val > c)
  7226. low = mid + 1;
  7227. else if (val < c)
  7228. hi = mid - 1;
  7229. else
  7230. return mid;
  7231. }
  7232. return low -1;
  7233. };
  7234. this.resetCaches = function() {
  7235. this.$modified = true;
  7236. this.$wrapData = [];
  7237. this.$rowLengthCache = [];
  7238. this.$resetRowCache(0);
  7239. if (this.bgTokenizer)
  7240. this.bgTokenizer.start(0);
  7241. };
  7242. this.onChangeFold = function(e) {
  7243. var fold = e.data;
  7244. this.$resetRowCache(fold.start.row);
  7245. };
  7246. this.onChange = function(delta) {
  7247. this.$modified = true;
  7248. this.$resetRowCache(delta.start.row);
  7249. var removedFolds = this.$updateInternalDataOnChange(delta);
  7250. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7251. this.$deltasDoc.push(delta);
  7252. if (removedFolds && removedFolds.length != 0) {
  7253. this.$deltasFold.push({
  7254. action: "removeFolds",
  7255. folds: removedFolds
  7256. });
  7257. }
  7258. this.$informUndoManager.schedule();
  7259. }
  7260. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7261. this._signal("change", delta);
  7262. };
  7263. this.setValue = function(text) {
  7264. this.doc.setValue(text);
  7265. this.selection.moveTo(0, 0);
  7266. this.$resetRowCache(0);
  7267. this.$deltas = [];
  7268. this.$deltasDoc = [];
  7269. this.$deltasFold = [];
  7270. this.setUndoManager(this.$undoManager);
  7271. this.getUndoManager().reset();
  7272. };
  7273. this.getValue =
  7274. this.toString = function() {
  7275. return this.doc.getValue();
  7276. };
  7277. this.getSelection = function() {
  7278. return this.selection;
  7279. };
  7280. this.getState = function(row) {
  7281. return this.bgTokenizer.getState(row);
  7282. };
  7283. this.getTokens = function(row) {
  7284. return this.bgTokenizer.getTokens(row);
  7285. };
  7286. this.getTokenAt = function(row, column) {
  7287. var tokens = this.bgTokenizer.getTokens(row);
  7288. var token, c = 0;
  7289. if (column == null) {
  7290. i = tokens.length - 1;
  7291. c = this.getLine(row).length;
  7292. } else {
  7293. for (var i = 0; i < tokens.length; i++) {
  7294. c += tokens[i].value.length;
  7295. if (c >= column)
  7296. break;
  7297. }
  7298. }
  7299. token = tokens[i];
  7300. if (!token)
  7301. return null;
  7302. token.index = i;
  7303. token.start = c - token.value.length;
  7304. return token;
  7305. };
  7306. this.setUndoManager = function(undoManager) {
  7307. this.$undoManager = undoManager;
  7308. this.$deltas = [];
  7309. this.$deltasDoc = [];
  7310. this.$deltasFold = [];
  7311. if (this.$informUndoManager)
  7312. this.$informUndoManager.cancel();
  7313. if (undoManager) {
  7314. var self = this;
  7315. this.$syncInformUndoManager = function() {
  7316. self.$informUndoManager.cancel();
  7317. if (self.$deltasFold.length) {
  7318. self.$deltas.push({
  7319. group: "fold",
  7320. deltas: self.$deltasFold
  7321. });
  7322. self.$deltasFold = [];
  7323. }
  7324. if (self.$deltasDoc.length) {
  7325. self.$deltas.push({
  7326. group: "doc",
  7327. deltas: self.$deltasDoc
  7328. });
  7329. self.$deltasDoc = [];
  7330. }
  7331. if (self.$deltas.length > 0) {
  7332. undoManager.execute({
  7333. action: "aceupdate",
  7334. args: [self.$deltas, self],
  7335. merge: self.mergeUndoDeltas
  7336. });
  7337. }
  7338. self.mergeUndoDeltas = false;
  7339. self.$deltas = [];
  7340. };
  7341. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7342. }
  7343. };
  7344. this.markUndoGroup = function() {
  7345. if (this.$syncInformUndoManager)
  7346. this.$syncInformUndoManager();
  7347. };
  7348. this.$defaultUndoManager = {
  7349. undo: function() {},
  7350. redo: function() {},
  7351. reset: function() {}
  7352. };
  7353. this.getUndoManager = function() {
  7354. return this.$undoManager || this.$defaultUndoManager;
  7355. };
  7356. this.getTabString = function() {
  7357. if (this.getUseSoftTabs()) {
  7358. return lang.stringRepeat(" ", this.getTabSize());
  7359. } else {
  7360. return "\t";
  7361. }
  7362. };
  7363. this.setUseSoftTabs = function(val) {
  7364. this.setOption("useSoftTabs", val);
  7365. };
  7366. this.getUseSoftTabs = function() {
  7367. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7368. };
  7369. this.setTabSize = function(tabSize) {
  7370. this.setOption("tabSize", tabSize);
  7371. };
  7372. this.getTabSize = function() {
  7373. return this.$tabSize;
  7374. };
  7375. this.isTabStop = function(position) {
  7376. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7377. };
  7378. this.$overwrite = false;
  7379. this.setOverwrite = function(overwrite) {
  7380. this.setOption("overwrite", overwrite);
  7381. };
  7382. this.getOverwrite = function() {
  7383. return this.$overwrite;
  7384. };
  7385. this.toggleOverwrite = function() {
  7386. this.setOverwrite(!this.$overwrite);
  7387. };
  7388. this.addGutterDecoration = function(row, className) {
  7389. if (!this.$decorations[row])
  7390. this.$decorations[row] = "";
  7391. this.$decorations[row] += " " + className;
  7392. this._signal("changeBreakpoint", {});
  7393. };
  7394. this.removeGutterDecoration = function(row, className) {
  7395. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7396. this._signal("changeBreakpoint", {});
  7397. };
  7398. this.getBreakpoints = function() {
  7399. return this.$breakpoints;
  7400. };
  7401. this.setBreakpoints = function(rows) {
  7402. this.$breakpoints = [];
  7403. for (var i=0; i<rows.length; i++) {
  7404. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7405. }
  7406. this._signal("changeBreakpoint", {});
  7407. };
  7408. this.clearBreakpoints = function() {
  7409. this.$breakpoints = [];
  7410. this._signal("changeBreakpoint", {});
  7411. };
  7412. this.setBreakpoint = function(row, className) {
  7413. if (className === undefined)
  7414. className = "ace_breakpoint";
  7415. if (className)
  7416. this.$breakpoints[row] = className;
  7417. else
  7418. delete this.$breakpoints[row];
  7419. this._signal("changeBreakpoint", {});
  7420. };
  7421. this.clearBreakpoint = function(row) {
  7422. delete this.$breakpoints[row];
  7423. this._signal("changeBreakpoint", {});
  7424. };
  7425. this.addMarker = function(range, clazz, type, inFront) {
  7426. var id = this.$markerId++;
  7427. var marker = {
  7428. range : range,
  7429. type : type || "line",
  7430. renderer: typeof type == "function" ? type : null,
  7431. clazz : clazz,
  7432. inFront: !!inFront,
  7433. id: id
  7434. };
  7435. if (inFront) {
  7436. this.$frontMarkers[id] = marker;
  7437. this._signal("changeFrontMarker");
  7438. } else {
  7439. this.$backMarkers[id] = marker;
  7440. this._signal("changeBackMarker");
  7441. }
  7442. return id;
  7443. };
  7444. this.addDynamicMarker = function(marker, inFront) {
  7445. if (!marker.update)
  7446. return;
  7447. var id = this.$markerId++;
  7448. marker.id = id;
  7449. marker.inFront = !!inFront;
  7450. if (inFront) {
  7451. this.$frontMarkers[id] = marker;
  7452. this._signal("changeFrontMarker");
  7453. } else {
  7454. this.$backMarkers[id] = marker;
  7455. this._signal("changeBackMarker");
  7456. }
  7457. return marker;
  7458. };
  7459. this.removeMarker = function(markerId) {
  7460. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7461. if (!marker)
  7462. return;
  7463. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7464. if (marker) {
  7465. delete (markers[markerId]);
  7466. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7467. }
  7468. };
  7469. this.getMarkers = function(inFront) {
  7470. return inFront ? this.$frontMarkers : this.$backMarkers;
  7471. };
  7472. this.highlight = function(re) {
  7473. if (!this.$searchHighlight) {
  7474. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7475. this.$searchHighlight = this.addDynamicMarker(highlight);
  7476. }
  7477. this.$searchHighlight.setRegexp(re);
  7478. };
  7479. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7480. if (typeof endRow != "number") {
  7481. clazz = endRow;
  7482. endRow = startRow;
  7483. }
  7484. if (!clazz)
  7485. clazz = "ace_step";
  7486. var range = new Range(startRow, 0, endRow, Infinity);
  7487. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7488. return range;
  7489. };
  7490. this.setAnnotations = function(annotations) {
  7491. this.$annotations = annotations;
  7492. this._signal("changeAnnotation", {});
  7493. };
  7494. this.getAnnotations = function() {
  7495. return this.$annotations || [];
  7496. };
  7497. this.clearAnnotations = function() {
  7498. this.setAnnotations([]);
  7499. };
  7500. this.$detectNewLine = function(text) {
  7501. var match = text.match(/^.*?(\r?\n)/m);
  7502. if (match) {
  7503. this.$autoNewLine = match[1];
  7504. } else {
  7505. this.$autoNewLine = "\n";
  7506. }
  7507. };
  7508. this.getWordRange = function(row, column) {
  7509. var line = this.getLine(row);
  7510. var inToken = false;
  7511. if (column > 0)
  7512. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7513. if (!inToken)
  7514. inToken = !!line.charAt(column).match(this.tokenRe);
  7515. if (inToken)
  7516. var re = this.tokenRe;
  7517. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7518. var re = /\s/;
  7519. else
  7520. var re = this.nonTokenRe;
  7521. var start = column;
  7522. if (start > 0) {
  7523. do {
  7524. start--;
  7525. }
  7526. while (start >= 0 && line.charAt(start).match(re));
  7527. start++;
  7528. }
  7529. var end = column;
  7530. while (end < line.length && line.charAt(end).match(re)) {
  7531. end++;
  7532. }
  7533. return new Range(row, start, row, end);
  7534. };
  7535. this.getAWordRange = function(row, column) {
  7536. var wordRange = this.getWordRange(row, column);
  7537. var line = this.getLine(wordRange.end.row);
  7538. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7539. wordRange.end.column += 1;
  7540. }
  7541. return wordRange;
  7542. };
  7543. this.setNewLineMode = function(newLineMode) {
  7544. this.doc.setNewLineMode(newLineMode);
  7545. };
  7546. this.getNewLineMode = function() {
  7547. return this.doc.getNewLineMode();
  7548. };
  7549. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7550. this.getUseWorker = function() { return this.$useWorker; };
  7551. this.onReloadTokenizer = function(e) {
  7552. var rows = e.data;
  7553. this.bgTokenizer.start(rows.first);
  7554. this._signal("tokenizerUpdate", e);
  7555. };
  7556. this.$modes = {};
  7557. this.$mode = null;
  7558. this.$modeId = null;
  7559. this.setMode = function(mode, cb) {
  7560. if (mode && typeof mode === "object") {
  7561. if (mode.getTokenizer)
  7562. return this.$onChangeMode(mode);
  7563. var options = mode;
  7564. var path = options.path;
  7565. } else {
  7566. path = mode || "ace/mode/text";
  7567. }
  7568. if (!this.$modes["ace/mode/text"])
  7569. this.$modes["ace/mode/text"] = new TextMode();
  7570. if (this.$modes[path] && !options) {
  7571. this.$onChangeMode(this.$modes[path]);
  7572. cb && cb();
  7573. return;
  7574. }
  7575. this.$modeId = path;
  7576. config.loadModule(["mode", path], function(m) {
  7577. if (this.$modeId !== path)
  7578. return cb && cb();
  7579. if (this.$modes[path] && !options) {
  7580. this.$onChangeMode(this.$modes[path]);
  7581. } else if (m && m.Mode) {
  7582. m = new m.Mode(options);
  7583. if (!options) {
  7584. this.$modes[path] = m;
  7585. m.$id = path;
  7586. }
  7587. this.$onChangeMode(m);
  7588. }
  7589. cb && cb();
  7590. }.bind(this));
  7591. if (!this.$mode)
  7592. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7593. };
  7594. this.$onChangeMode = function(mode, $isPlaceholder) {
  7595. if (!$isPlaceholder)
  7596. this.$modeId = mode.$id;
  7597. if (this.$mode === mode)
  7598. return;
  7599. this.$mode = mode;
  7600. this.$stopWorker();
  7601. if (this.$useWorker)
  7602. this.$startWorker();
  7603. var tokenizer = mode.getTokenizer();
  7604. if(tokenizer.addEventListener !== undefined) {
  7605. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7606. tokenizer.addEventListener("update", onReloadTokenizer);
  7607. }
  7608. if (!this.bgTokenizer) {
  7609. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7610. var _self = this;
  7611. this.bgTokenizer.addEventListener("update", function(e) {
  7612. _self._signal("tokenizerUpdate", e);
  7613. });
  7614. } else {
  7615. this.bgTokenizer.setTokenizer(tokenizer);
  7616. }
  7617. this.bgTokenizer.setDocument(this.getDocument());
  7618. this.tokenRe = mode.tokenRe;
  7619. this.nonTokenRe = mode.nonTokenRe;
  7620. if (!$isPlaceholder) {
  7621. if (mode.attachToSession)
  7622. mode.attachToSession(this);
  7623. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7624. this.$setFolding(mode.foldingRules);
  7625. this.bgTokenizer.start(0);
  7626. this._emit("changeMode");
  7627. }
  7628. };
  7629. this.$stopWorker = function() {
  7630. if (this.$worker) {
  7631. this.$worker.terminate();
  7632. this.$worker = null;
  7633. }
  7634. };
  7635. this.$startWorker = function() {
  7636. try {
  7637. this.$worker = this.$mode.createWorker(this);
  7638. } catch (e) {
  7639. config.warn("Could not load worker", e);
  7640. this.$worker = null;
  7641. }
  7642. };
  7643. this.getMode = function() {
  7644. return this.$mode;
  7645. };
  7646. this.$scrollTop = 0;
  7647. this.setScrollTop = function(scrollTop) {
  7648. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7649. return;
  7650. this.$scrollTop = scrollTop;
  7651. this._signal("changeScrollTop", scrollTop);
  7652. };
  7653. this.getScrollTop = function() {
  7654. return this.$scrollTop;
  7655. };
  7656. this.$scrollLeft = 0;
  7657. this.setScrollLeft = function(scrollLeft) {
  7658. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7659. return;
  7660. this.$scrollLeft = scrollLeft;
  7661. this._signal("changeScrollLeft", scrollLeft);
  7662. };
  7663. this.getScrollLeft = function() {
  7664. return this.$scrollLeft;
  7665. };
  7666. this.getScreenWidth = function() {
  7667. this.$computeWidth();
  7668. if (this.lineWidgets)
  7669. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7670. return this.screenWidth;
  7671. };
  7672. this.getLineWidgetMaxWidth = function() {
  7673. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7674. var width = 0;
  7675. this.lineWidgets.forEach(function(w) {
  7676. if (w && w.screenWidth > width)
  7677. width = w.screenWidth;
  7678. });
  7679. return this.lineWidgetWidth = width;
  7680. };
  7681. this.$computeWidth = function(force) {
  7682. if (this.$modified || force) {
  7683. this.$modified = false;
  7684. if (this.$useWrapMode)
  7685. return this.screenWidth = this.$wrapLimit;
  7686. var lines = this.doc.getAllLines();
  7687. var cache = this.$rowLengthCache;
  7688. var longestScreenLine = 0;
  7689. var foldIndex = 0;
  7690. var foldLine = this.$foldData[foldIndex];
  7691. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7692. var len = lines.length;
  7693. for (var i = 0; i < len; i++) {
  7694. if (i > foldStart) {
  7695. i = foldLine.end.row + 1;
  7696. if (i >= len)
  7697. break;
  7698. foldLine = this.$foldData[foldIndex++];
  7699. foldStart = foldLine ? foldLine.start.row : Infinity;
  7700. }
  7701. if (cache[i] == null)
  7702. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7703. if (cache[i] > longestScreenLine)
  7704. longestScreenLine = cache[i];
  7705. }
  7706. this.screenWidth = longestScreenLine;
  7707. }
  7708. };
  7709. this.getLine = function(row) {
  7710. return this.doc.getLine(row);
  7711. };
  7712. this.getLines = function(firstRow, lastRow) {
  7713. return this.doc.getLines(firstRow, lastRow);
  7714. };
  7715. this.getLength = function() {
  7716. return this.doc.getLength();
  7717. };
  7718. this.getTextRange = function(range) {
  7719. return this.doc.getTextRange(range || this.selection.getRange());
  7720. };
  7721. this.insert = function(position, text) {
  7722. return this.doc.insert(position, text);
  7723. };
  7724. this.remove = function(range) {
  7725. return this.doc.remove(range);
  7726. };
  7727. this.removeFullLines = function(firstRow, lastRow){
  7728. return this.doc.removeFullLines(firstRow, lastRow);
  7729. };
  7730. this.undoChanges = function(deltas, dontSelect) {
  7731. if (!deltas.length)
  7732. return;
  7733. this.$fromUndo = true;
  7734. var lastUndoRange = null;
  7735. for (var i = deltas.length - 1; i != -1; i--) {
  7736. var delta = deltas[i];
  7737. if (delta.group == "doc") {
  7738. this.doc.revertDeltas(delta.deltas);
  7739. lastUndoRange =
  7740. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7741. } else {
  7742. delta.deltas.forEach(function(foldDelta) {
  7743. this.addFolds(foldDelta.folds);
  7744. }, this);
  7745. }
  7746. }
  7747. this.$fromUndo = false;
  7748. lastUndoRange &&
  7749. this.$undoSelect &&
  7750. !dontSelect &&
  7751. this.selection.setSelectionRange(lastUndoRange);
  7752. return lastUndoRange;
  7753. };
  7754. this.redoChanges = function(deltas, dontSelect) {
  7755. if (!deltas.length)
  7756. return;
  7757. this.$fromUndo = true;
  7758. var lastUndoRange = null;
  7759. for (var i = 0; i < deltas.length; i++) {
  7760. var delta = deltas[i];
  7761. if (delta.group == "doc") {
  7762. this.doc.applyDeltas(delta.deltas);
  7763. lastUndoRange =
  7764. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7765. }
  7766. }
  7767. this.$fromUndo = false;
  7768. lastUndoRange &&
  7769. this.$undoSelect &&
  7770. !dontSelect &&
  7771. this.selection.setSelectionRange(lastUndoRange);
  7772. return lastUndoRange;
  7773. };
  7774. this.setUndoSelect = function(enable) {
  7775. this.$undoSelect = enable;
  7776. };
  7777. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7778. function isInsert(delta) {
  7779. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  7780. }
  7781. var delta = deltas[0];
  7782. var range, point;
  7783. var lastDeltaIsInsert = false;
  7784. if (isInsert(delta)) {
  7785. range = Range.fromPoints(delta.start, delta.end);
  7786. lastDeltaIsInsert = true;
  7787. } else {
  7788. range = Range.fromPoints(delta.start, delta.start);
  7789. lastDeltaIsInsert = false;
  7790. }
  7791. for (var i = 1; i < deltas.length; i++) {
  7792. delta = deltas[i];
  7793. if (isInsert(delta)) {
  7794. point = delta.start;
  7795. if (range.compare(point.row, point.column) == -1) {
  7796. range.setStart(point);
  7797. }
  7798. point = delta.end;
  7799. if (range.compare(point.row, point.column) == 1) {
  7800. range.setEnd(point);
  7801. }
  7802. lastDeltaIsInsert = true;
  7803. } else {
  7804. point = delta.start;
  7805. if (range.compare(point.row, point.column) == -1) {
  7806. range = Range.fromPoints(delta.start, delta.start);
  7807. }
  7808. lastDeltaIsInsert = false;
  7809. }
  7810. }
  7811. if (lastUndoRange != null) {
  7812. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7813. lastUndoRange.start.column += range.end.column - range.start.column;
  7814. lastUndoRange.end.column += range.end.column - range.start.column;
  7815. }
  7816. var cmp = lastUndoRange.compareRange(range);
  7817. if (cmp == 1) {
  7818. range.setStart(lastUndoRange.start);
  7819. } else if (cmp == -1) {
  7820. range.setEnd(lastUndoRange.end);
  7821. }
  7822. }
  7823. return range;
  7824. };
  7825. this.replace = function(range, text) {
  7826. return this.doc.replace(range, text);
  7827. };
  7828. this.moveText = function(fromRange, toPosition, copy) {
  7829. var text = this.getTextRange(fromRange);
  7830. var folds = this.getFoldsInRange(fromRange);
  7831. var toRange = Range.fromPoints(toPosition, toPosition);
  7832. if (!copy) {
  7833. this.remove(fromRange);
  7834. var rowDiff = fromRange.start.row - fromRange.end.row;
  7835. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7836. if (collDiff) {
  7837. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7838. toRange.start.column += collDiff;
  7839. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7840. toRange.end.column += collDiff;
  7841. }
  7842. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7843. toRange.start.row += rowDiff;
  7844. toRange.end.row += rowDiff;
  7845. }
  7846. }
  7847. toRange.end = this.insert(toRange.start, text);
  7848. if (folds.length) {
  7849. var oldStart = fromRange.start;
  7850. var newStart = toRange.start;
  7851. var rowDiff = newStart.row - oldStart.row;
  7852. var collDiff = newStart.column - oldStart.column;
  7853. this.addFolds(folds.map(function(x) {
  7854. x = x.clone();
  7855. if (x.start.row == oldStart.row)
  7856. x.start.column += collDiff;
  7857. if (x.end.row == oldStart.row)
  7858. x.end.column += collDiff;
  7859. x.start.row += rowDiff;
  7860. x.end.row += rowDiff;
  7861. return x;
  7862. }));
  7863. }
  7864. return toRange;
  7865. };
  7866. this.indentRows = function(startRow, endRow, indentString) {
  7867. indentString = indentString.replace(/\t/g, this.getTabString());
  7868. for (var row=startRow; row<=endRow; row++)
  7869. this.doc.insertInLine({row: row, column: 0}, indentString);
  7870. };
  7871. this.outdentRows = function (range) {
  7872. var rowRange = range.collapseRows();
  7873. var deleteRange = new Range(0, 0, 0, 0);
  7874. var size = this.getTabSize();
  7875. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7876. var line = this.getLine(i);
  7877. deleteRange.start.row = i;
  7878. deleteRange.end.row = i;
  7879. for (var j = 0; j < size; ++j)
  7880. if (line.charAt(j) != ' ')
  7881. break;
  7882. if (j < size && line.charAt(j) == '\t') {
  7883. deleteRange.start.column = j;
  7884. deleteRange.end.column = j + 1;
  7885. } else {
  7886. deleteRange.start.column = 0;
  7887. deleteRange.end.column = j;
  7888. }
  7889. this.remove(deleteRange);
  7890. }
  7891. };
  7892. this.$moveLines = function(firstRow, lastRow, dir) {
  7893. firstRow = this.getRowFoldStart(firstRow);
  7894. lastRow = this.getRowFoldEnd(lastRow);
  7895. if (dir < 0) {
  7896. var row = this.getRowFoldStart(firstRow + dir);
  7897. if (row < 0) return 0;
  7898. var diff = row-firstRow;
  7899. } else if (dir > 0) {
  7900. var row = this.getRowFoldEnd(lastRow + dir);
  7901. if (row > this.doc.getLength()-1) return 0;
  7902. var diff = row-lastRow;
  7903. } else {
  7904. firstRow = this.$clipRowToDocument(firstRow);
  7905. lastRow = this.$clipRowToDocument(lastRow);
  7906. var diff = lastRow - firstRow + 1;
  7907. }
  7908. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7909. var folds = this.getFoldsInRange(range).map(function(x){
  7910. x = x.clone();
  7911. x.start.row += diff;
  7912. x.end.row += diff;
  7913. return x;
  7914. });
  7915. var lines = dir == 0
  7916. ? this.doc.getLines(firstRow, lastRow)
  7917. : this.doc.removeFullLines(firstRow, lastRow);
  7918. this.doc.insertFullLines(firstRow+diff, lines);
  7919. folds.length && this.addFolds(folds);
  7920. return diff;
  7921. };
  7922. this.moveLinesUp = function(firstRow, lastRow) {
  7923. return this.$moveLines(firstRow, lastRow, -1);
  7924. };
  7925. this.moveLinesDown = function(firstRow, lastRow) {
  7926. return this.$moveLines(firstRow, lastRow, 1);
  7927. };
  7928. this.duplicateLines = function(firstRow, lastRow) {
  7929. return this.$moveLines(firstRow, lastRow, 0);
  7930. };
  7931. this.$clipRowToDocument = function(row) {
  7932. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7933. };
  7934. this.$clipColumnToRow = function(row, column) {
  7935. if (column < 0)
  7936. return 0;
  7937. return Math.min(this.doc.getLine(row).length, column);
  7938. };
  7939. this.$clipPositionToDocument = function(row, column) {
  7940. column = Math.max(0, column);
  7941. if (row < 0) {
  7942. row = 0;
  7943. column = 0;
  7944. } else {
  7945. var len = this.doc.getLength();
  7946. if (row >= len) {
  7947. row = len - 1;
  7948. column = this.doc.getLine(len-1).length;
  7949. } else {
  7950. column = Math.min(this.doc.getLine(row).length, column);
  7951. }
  7952. }
  7953. return {
  7954. row: row,
  7955. column: column
  7956. };
  7957. };
  7958. this.$clipRangeToDocument = function(range) {
  7959. if (range.start.row < 0) {
  7960. range.start.row = 0;
  7961. range.start.column = 0;
  7962. } else {
  7963. range.start.column = this.$clipColumnToRow(
  7964. range.start.row,
  7965. range.start.column
  7966. );
  7967. }
  7968. var len = this.doc.getLength() - 1;
  7969. if (range.end.row > len) {
  7970. range.end.row = len;
  7971. range.end.column = this.doc.getLine(len).length;
  7972. } else {
  7973. range.end.column = this.$clipColumnToRow(
  7974. range.end.row,
  7975. range.end.column
  7976. );
  7977. }
  7978. return range;
  7979. };
  7980. this.$wrapLimit = 80;
  7981. this.$useWrapMode = false;
  7982. this.$wrapLimitRange = {
  7983. min : null,
  7984. max : null
  7985. };
  7986. this.setUseWrapMode = function(useWrapMode) {
  7987. if (useWrapMode != this.$useWrapMode) {
  7988. this.$useWrapMode = useWrapMode;
  7989. this.$modified = true;
  7990. this.$resetRowCache(0);
  7991. if (useWrapMode) {
  7992. var len = this.getLength();
  7993. this.$wrapData = Array(len);
  7994. this.$updateWrapData(0, len - 1);
  7995. }
  7996. this._signal("changeWrapMode");
  7997. }
  7998. };
  7999. this.getUseWrapMode = function() {
  8000. return this.$useWrapMode;
  8001. };
  8002. this.setWrapLimitRange = function(min, max) {
  8003. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  8004. this.$wrapLimitRange = { min: min, max: max };
  8005. this.$modified = true;
  8006. if (this.$useWrapMode)
  8007. this._signal("changeWrapMode");
  8008. }
  8009. };
  8010. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  8011. var limits = this.$wrapLimitRange;
  8012. if (limits.max < 0)
  8013. limits = {min: $printMargin, max: $printMargin};
  8014. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  8015. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  8016. this.$wrapLimit = wrapLimit;
  8017. this.$modified = true;
  8018. if (this.$useWrapMode) {
  8019. this.$updateWrapData(0, this.getLength() - 1);
  8020. this.$resetRowCache(0);
  8021. this._signal("changeWrapLimit");
  8022. }
  8023. return true;
  8024. }
  8025. return false;
  8026. };
  8027. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  8028. if (min)
  8029. wrapLimit = Math.max(min, wrapLimit);
  8030. if (max)
  8031. wrapLimit = Math.min(max, wrapLimit);
  8032. return wrapLimit;
  8033. };
  8034. this.getWrapLimit = function() {
  8035. return this.$wrapLimit;
  8036. };
  8037. this.setWrapLimit = function (limit) {
  8038. this.setWrapLimitRange(limit, limit);
  8039. };
  8040. this.getWrapLimitRange = function() {
  8041. return {
  8042. min : this.$wrapLimitRange.min,
  8043. max : this.$wrapLimitRange.max
  8044. };
  8045. };
  8046. this.$updateInternalDataOnChange = function(delta) {
  8047. var useWrapMode = this.$useWrapMode;
  8048. var action = delta.action;
  8049. var start = delta.start;
  8050. var end = delta.end;
  8051. var firstRow = start.row;
  8052. var lastRow = end.row;
  8053. var len = lastRow - firstRow;
  8054. var removedFolds = null;
  8055. this.$updating = true;
  8056. if (len != 0) {
  8057. if (action === "remove") {
  8058. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  8059. var foldLines = this.$foldData;
  8060. removedFolds = this.getFoldsInRange(delta);
  8061. this.removeFolds(removedFolds);
  8062. var foldLine = this.getFoldLine(end.row);
  8063. var idx = 0;
  8064. if (foldLine) {
  8065. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  8066. foldLine.shiftRow(-len);
  8067. var foldLineBefore = this.getFoldLine(firstRow);
  8068. if (foldLineBefore && foldLineBefore !== foldLine) {
  8069. foldLineBefore.merge(foldLine);
  8070. foldLine = foldLineBefore;
  8071. }
  8072. idx = foldLines.indexOf(foldLine) + 1;
  8073. }
  8074. for (idx; idx < foldLines.length; idx++) {
  8075. var foldLine = foldLines[idx];
  8076. if (foldLine.start.row >= end.row) {
  8077. foldLine.shiftRow(-len);
  8078. }
  8079. }
  8080. lastRow = firstRow;
  8081. } else {
  8082. var args = Array(len);
  8083. args.unshift(firstRow, 0);
  8084. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  8085. arr.splice.apply(arr, args);
  8086. var foldLines = this.$foldData;
  8087. var foldLine = this.getFoldLine(firstRow);
  8088. var idx = 0;
  8089. if (foldLine) {
  8090. var cmp = foldLine.range.compareInside(start.row, start.column);
  8091. if (cmp == 0) {
  8092. foldLine = foldLine.split(start.row, start.column);
  8093. if (foldLine) {
  8094. foldLine.shiftRow(len);
  8095. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  8096. }
  8097. } else
  8098. if (cmp == -1) {
  8099. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8100. foldLine.shiftRow(len);
  8101. }
  8102. idx = foldLines.indexOf(foldLine) + 1;
  8103. }
  8104. for (idx; idx < foldLines.length; idx++) {
  8105. var foldLine = foldLines[idx];
  8106. if (foldLine.start.row >= firstRow) {
  8107. foldLine.shiftRow(len);
  8108. }
  8109. }
  8110. }
  8111. } else {
  8112. len = Math.abs(delta.start.column - delta.end.column);
  8113. if (action === "remove") {
  8114. removedFolds = this.getFoldsInRange(delta);
  8115. this.removeFolds(removedFolds);
  8116. len = -len;
  8117. }
  8118. var foldLine = this.getFoldLine(firstRow);
  8119. if (foldLine) {
  8120. foldLine.addRemoveChars(firstRow, start.column, len);
  8121. }
  8122. }
  8123. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8124. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8125. }
  8126. this.$updating = false;
  8127. if (useWrapMode)
  8128. this.$updateWrapData(firstRow, lastRow);
  8129. else
  8130. this.$updateRowLengthCache(firstRow, lastRow);
  8131. return removedFolds;
  8132. };
  8133. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8134. this.$rowLengthCache[firstRow] = null;
  8135. this.$rowLengthCache[lastRow] = null;
  8136. };
  8137. this.$updateWrapData = function(firstRow, lastRow) {
  8138. var lines = this.doc.getAllLines();
  8139. var tabSize = this.getTabSize();
  8140. var wrapData = this.$wrapData;
  8141. var wrapLimit = this.$wrapLimit;
  8142. var tokens;
  8143. var foldLine;
  8144. var row = firstRow;
  8145. lastRow = Math.min(lastRow, lines.length - 1);
  8146. while (row <= lastRow) {
  8147. foldLine = this.getFoldLine(row, foldLine);
  8148. if (!foldLine) {
  8149. tokens = this.$getDisplayTokens(lines[row]);
  8150. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8151. row ++;
  8152. } else {
  8153. tokens = [];
  8154. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8155. var walkTokens;
  8156. if (placeholder != null) {
  8157. walkTokens = this.$getDisplayTokens(
  8158. placeholder, tokens.length);
  8159. walkTokens[0] = PLACEHOLDER_START;
  8160. for (var i = 1; i < walkTokens.length; i++) {
  8161. walkTokens[i] = PLACEHOLDER_BODY;
  8162. }
  8163. } else {
  8164. walkTokens = this.$getDisplayTokens(
  8165. lines[row].substring(lastColumn, column),
  8166. tokens.length);
  8167. }
  8168. tokens = tokens.concat(walkTokens);
  8169. }.bind(this),
  8170. foldLine.end.row,
  8171. lines[foldLine.end.row].length + 1
  8172. );
  8173. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8174. row = foldLine.end.row + 1;
  8175. }
  8176. }
  8177. };
  8178. var CHAR = 1,
  8179. CHAR_EXT = 2,
  8180. PLACEHOLDER_START = 3,
  8181. PLACEHOLDER_BODY = 4,
  8182. PUNCTUATION = 9,
  8183. SPACE = 10,
  8184. TAB = 11,
  8185. TAB_SPACE = 12;
  8186. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  8187. if (tokens.length == 0) {
  8188. return [];
  8189. }
  8190. var splits = [];
  8191. var displayLength = tokens.length;
  8192. var lastSplit = 0, lastDocSplit = 0;
  8193. var isCode = this.$wrapAsCode;
  8194. var indentedSoftWrap = this.$indentedSoftWrap;
  8195. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  8196. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  8197. function getWrapIndent() {
  8198. var indentation = 0;
  8199. if (maxIndent === 0)
  8200. return indentation;
  8201. if (indentedSoftWrap) {
  8202. for (var i = 0; i < tokens.length; i++) {
  8203. var token = tokens[i];
  8204. if (token == SPACE)
  8205. indentation += 1;
  8206. else if (token == TAB)
  8207. indentation += tabSize;
  8208. else if (token == TAB_SPACE)
  8209. continue;
  8210. else
  8211. break;
  8212. }
  8213. }
  8214. if (isCode && indentedSoftWrap !== false)
  8215. indentation += tabSize;
  8216. return Math.min(indentation, maxIndent);
  8217. }
  8218. function addSplit(screenPos) {
  8219. var displayed = tokens.slice(lastSplit, screenPos);
  8220. var len = displayed.length;
  8221. displayed.join("").
  8222. replace(/12/g, function() {
  8223. len -= 1;
  8224. }).
  8225. replace(/2/g, function() {
  8226. len -= 1;
  8227. });
  8228. if (!splits.length) {
  8229. indent = getWrapIndent();
  8230. splits.indent = indent;
  8231. }
  8232. lastDocSplit += len;
  8233. splits.push(lastDocSplit);
  8234. lastSplit = screenPos;
  8235. }
  8236. var indent = 0;
  8237. while (displayLength - lastSplit > wrapLimit - indent) {
  8238. var split = lastSplit + wrapLimit - indent;
  8239. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8240. addSplit(split);
  8241. continue;
  8242. }
  8243. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8244. for (split; split != lastSplit - 1; split--) {
  8245. if (tokens[split] == PLACEHOLDER_START) {
  8246. break;
  8247. }
  8248. }
  8249. if (split > lastSplit) {
  8250. addSplit(split);
  8251. continue;
  8252. }
  8253. split = lastSplit + wrapLimit;
  8254. for (split; split < tokens.length; split++) {
  8255. if (tokens[split] != PLACEHOLDER_BODY) {
  8256. break;
  8257. }
  8258. }
  8259. if (split == tokens.length) {
  8260. break; // Breaks the while-loop.
  8261. }
  8262. addSplit(split);
  8263. continue;
  8264. }
  8265. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  8266. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8267. split --;
  8268. }
  8269. if (isCode) {
  8270. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8271. split --;
  8272. }
  8273. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8274. split --;
  8275. }
  8276. } else {
  8277. while (split > minSplit && tokens[split] < SPACE) {
  8278. split --;
  8279. }
  8280. }
  8281. if (split > minSplit) {
  8282. addSplit(++split);
  8283. continue;
  8284. }
  8285. split = lastSplit + wrapLimit;
  8286. if (tokens[split] == CHAR_EXT)
  8287. split--;
  8288. addSplit(split - indent);
  8289. }
  8290. return splits;
  8291. };
  8292. this.$getDisplayTokens = function(str, offset) {
  8293. var arr = [];
  8294. var tabSize;
  8295. offset = offset || 0;
  8296. for (var i = 0; i < str.length; i++) {
  8297. var c = str.charCodeAt(i);
  8298. if (c == 9) {
  8299. tabSize = this.getScreenTabSize(arr.length + offset);
  8300. arr.push(TAB);
  8301. for (var n = 1; n < tabSize; n++) {
  8302. arr.push(TAB_SPACE);
  8303. }
  8304. }
  8305. else if (c == 32) {
  8306. arr.push(SPACE);
  8307. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8308. arr.push(PUNCTUATION);
  8309. }
  8310. else if (c >= 0x1100 && isFullWidth(c)) {
  8311. arr.push(CHAR, CHAR_EXT);
  8312. } else {
  8313. arr.push(CHAR);
  8314. }
  8315. }
  8316. return arr;
  8317. };
  8318. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8319. if (maxScreenColumn == 0)
  8320. return [0, 0];
  8321. if (maxScreenColumn == null)
  8322. maxScreenColumn = Infinity;
  8323. screenColumn = screenColumn || 0;
  8324. var c, column;
  8325. for (column = 0; column < str.length; column++) {
  8326. c = str.charCodeAt(column);
  8327. if (c == 9) {
  8328. screenColumn += this.getScreenTabSize(screenColumn);
  8329. }
  8330. else if (c >= 0x1100 && isFullWidth(c)) {
  8331. screenColumn += 2;
  8332. } else {
  8333. screenColumn += 1;
  8334. }
  8335. if (screenColumn > maxScreenColumn) {
  8336. break;
  8337. }
  8338. }
  8339. return [screenColumn, column];
  8340. };
  8341. this.lineWidgets = null;
  8342. this.getRowLength = function(row) {
  8343. if (this.lineWidgets)
  8344. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8345. else
  8346. h = 0
  8347. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8348. return 1 + h;
  8349. } else {
  8350. return this.$wrapData[row].length + 1 + h;
  8351. }
  8352. };
  8353. this.getRowLineCount = function(row) {
  8354. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8355. return 1;
  8356. } else {
  8357. return this.$wrapData[row].length + 1;
  8358. }
  8359. };
  8360. this.getRowWrapIndent = function(screenRow) {
  8361. if (this.$useWrapMode) {
  8362. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8363. var splits = this.$wrapData[pos.row];
  8364. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  8365. } else {
  8366. return 0;
  8367. }
  8368. }
  8369. this.getScreenLastRowColumn = function(screenRow) {
  8370. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8371. return this.documentToScreenColumn(pos.row, pos.column);
  8372. };
  8373. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8374. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8375. return this.getScreenLastRowColumn(screenRow);
  8376. };
  8377. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8378. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8379. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8380. };
  8381. this.getRowSplitData = function(row) {
  8382. if (!this.$useWrapMode) {
  8383. return undefined;
  8384. } else {
  8385. return this.$wrapData[row];
  8386. }
  8387. };
  8388. this.getScreenTabSize = function(screenColumn) {
  8389. return this.$tabSize - screenColumn % this.$tabSize;
  8390. };
  8391. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8392. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8393. };
  8394. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8395. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8396. };
  8397. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8398. if (screenRow < 0)
  8399. return {row: 0, column: 0};
  8400. var line;
  8401. var docRow = 0;
  8402. var docColumn = 0;
  8403. var column;
  8404. var row = 0;
  8405. var rowLength = 0;
  8406. var rowCache = this.$screenRowCache;
  8407. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8408. var l = rowCache.length;
  8409. if (l && i >= 0) {
  8410. var row = rowCache[i];
  8411. var docRow = this.$docRowCache[i];
  8412. var doCache = screenRow > rowCache[l - 1];
  8413. } else {
  8414. var doCache = !l;
  8415. }
  8416. var maxRow = this.getLength() - 1;
  8417. var foldLine = this.getNextFoldLine(docRow);
  8418. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8419. while (row <= screenRow) {
  8420. rowLength = this.getRowLength(docRow);
  8421. if (row + rowLength > screenRow || docRow >= maxRow) {
  8422. break;
  8423. } else {
  8424. row += rowLength;
  8425. docRow++;
  8426. if (docRow > foldStart) {
  8427. docRow = foldLine.end.row+1;
  8428. foldLine = this.getNextFoldLine(docRow, foldLine);
  8429. foldStart = foldLine ? foldLine.start.row : Infinity;
  8430. }
  8431. }
  8432. if (doCache) {
  8433. this.$docRowCache.push(docRow);
  8434. this.$screenRowCache.push(row);
  8435. }
  8436. }
  8437. if (foldLine && foldLine.start.row <= docRow) {
  8438. line = this.getFoldDisplayLine(foldLine);
  8439. docRow = foldLine.start.row;
  8440. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8441. return {
  8442. row: maxRow,
  8443. column: this.getLine(maxRow).length
  8444. };
  8445. } else {
  8446. line = this.getLine(docRow);
  8447. foldLine = null;
  8448. }
  8449. var wrapIndent = 0;
  8450. if (this.$useWrapMode) {
  8451. var splits = this.$wrapData[docRow];
  8452. if (splits) {
  8453. var splitIndex = Math.floor(screenRow - row);
  8454. column = splits[splitIndex];
  8455. if(splitIndex > 0 && splits.length) {
  8456. wrapIndent = splits.indent;
  8457. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8458. line = line.substring(docColumn);
  8459. }
  8460. }
  8461. }
  8462. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  8463. if (this.$useWrapMode && docColumn >= column)
  8464. docColumn = column - 1;
  8465. if (foldLine)
  8466. return foldLine.idxToPosition(docColumn);
  8467. return {row: docRow, column: docColumn};
  8468. };
  8469. this.documentToScreenPosition = function(docRow, docColumn) {
  8470. if (typeof docColumn === "undefined")
  8471. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8472. else
  8473. pos = this.$clipPositionToDocument(docRow, docColumn);
  8474. docRow = pos.row;
  8475. docColumn = pos.column;
  8476. var screenRow = 0;
  8477. var foldStartRow = null;
  8478. var fold = null;
  8479. fold = this.getFoldAt(docRow, docColumn, 1);
  8480. if (fold) {
  8481. docRow = fold.start.row;
  8482. docColumn = fold.start.column;
  8483. }
  8484. var rowEnd, row = 0;
  8485. var rowCache = this.$docRowCache;
  8486. var i = this.$getRowCacheIndex(rowCache, docRow);
  8487. var l = rowCache.length;
  8488. if (l && i >= 0) {
  8489. var row = rowCache[i];
  8490. var screenRow = this.$screenRowCache[i];
  8491. var doCache = docRow > rowCache[l - 1];
  8492. } else {
  8493. var doCache = !l;
  8494. }
  8495. var foldLine = this.getNextFoldLine(row);
  8496. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8497. while (row < docRow) {
  8498. if (row >= foldStart) {
  8499. rowEnd = foldLine.end.row + 1;
  8500. if (rowEnd > docRow)
  8501. break;
  8502. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8503. foldStart = foldLine ?foldLine.start.row :Infinity;
  8504. }
  8505. else {
  8506. rowEnd = row + 1;
  8507. }
  8508. screenRow += this.getRowLength(row);
  8509. row = rowEnd;
  8510. if (doCache) {
  8511. this.$docRowCache.push(row);
  8512. this.$screenRowCache.push(screenRow);
  8513. }
  8514. }
  8515. var textLine = "";
  8516. if (foldLine && row >= foldStart) {
  8517. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8518. foldStartRow = foldLine.start.row;
  8519. } else {
  8520. textLine = this.getLine(docRow).substring(0, docColumn);
  8521. foldStartRow = docRow;
  8522. }
  8523. var wrapIndent = 0;
  8524. if (this.$useWrapMode) {
  8525. var wrapRow = this.$wrapData[foldStartRow];
  8526. if (wrapRow) {
  8527. var screenRowOffset = 0;
  8528. while (textLine.length >= wrapRow[screenRowOffset]) {
  8529. screenRow ++;
  8530. screenRowOffset++;
  8531. }
  8532. textLine = textLine.substring(
  8533. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8534. );
  8535. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  8536. }
  8537. }
  8538. return {
  8539. row: screenRow,
  8540. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  8541. };
  8542. };
  8543. this.documentToScreenColumn = function(row, docColumn) {
  8544. return this.documentToScreenPosition(row, docColumn).column;
  8545. };
  8546. this.documentToScreenRow = function(docRow, docColumn) {
  8547. return this.documentToScreenPosition(docRow, docColumn).row;
  8548. };
  8549. this.getScreenLength = function() {
  8550. var screenRows = 0;
  8551. var fold = null;
  8552. if (!this.$useWrapMode) {
  8553. screenRows = this.getLength();
  8554. var foldData = this.$foldData;
  8555. for (var i = 0; i < foldData.length; i++) {
  8556. fold = foldData[i];
  8557. screenRows -= fold.end.row - fold.start.row;
  8558. }
  8559. } else {
  8560. var lastRow = this.$wrapData.length;
  8561. var row = 0, i = 0;
  8562. var fold = this.$foldData[i++];
  8563. var foldStart = fold ? fold.start.row :Infinity;
  8564. while (row < lastRow) {
  8565. var splits = this.$wrapData[row];
  8566. screenRows += splits ? splits.length + 1 : 1;
  8567. row ++;
  8568. if (row > foldStart) {
  8569. row = fold.end.row+1;
  8570. fold = this.$foldData[i++];
  8571. foldStart = fold ?fold.start.row :Infinity;
  8572. }
  8573. }
  8574. }
  8575. if (this.lineWidgets)
  8576. screenRows += this.$getWidgetScreenLength();
  8577. return screenRows;
  8578. };
  8579. this.$setFontMetrics = function(fm) {
  8580. if (!this.$enableVarChar) return;
  8581. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8582. if (maxScreenColumn === 0)
  8583. return [0, 0];
  8584. if (!maxScreenColumn)
  8585. maxScreenColumn = Infinity;
  8586. screenColumn = screenColumn || 0;
  8587. var c, column;
  8588. for (column = 0; column < str.length; column++) {
  8589. c = str.charAt(column);
  8590. if (c === "\t") {
  8591. screenColumn += this.getScreenTabSize(screenColumn);
  8592. } else {
  8593. screenColumn += fm.getCharacterWidth(c);
  8594. }
  8595. if (screenColumn > maxScreenColumn) {
  8596. break;
  8597. }
  8598. }
  8599. return [screenColumn, column];
  8600. };
  8601. };
  8602. this.destroy = function() {
  8603. if (this.bgTokenizer) {
  8604. this.bgTokenizer.setDocument(null);
  8605. this.bgTokenizer = null;
  8606. }
  8607. this.$stopWorker();
  8608. };
  8609. function isFullWidth(c) {
  8610. if (c < 0x1100)
  8611. return false;
  8612. return c >= 0x1100 && c <= 0x115F ||
  8613. c >= 0x11A3 && c <= 0x11A7 ||
  8614. c >= 0x11FA && c <= 0x11FF ||
  8615. c >= 0x2329 && c <= 0x232A ||
  8616. c >= 0x2E80 && c <= 0x2E99 ||
  8617. c >= 0x2E9B && c <= 0x2EF3 ||
  8618. c >= 0x2F00 && c <= 0x2FD5 ||
  8619. c >= 0x2FF0 && c <= 0x2FFB ||
  8620. c >= 0x3000 && c <= 0x303E ||
  8621. c >= 0x3041 && c <= 0x3096 ||
  8622. c >= 0x3099 && c <= 0x30FF ||
  8623. c >= 0x3105 && c <= 0x312D ||
  8624. c >= 0x3131 && c <= 0x318E ||
  8625. c >= 0x3190 && c <= 0x31BA ||
  8626. c >= 0x31C0 && c <= 0x31E3 ||
  8627. c >= 0x31F0 && c <= 0x321E ||
  8628. c >= 0x3220 && c <= 0x3247 ||
  8629. c >= 0x3250 && c <= 0x32FE ||
  8630. c >= 0x3300 && c <= 0x4DBF ||
  8631. c >= 0x4E00 && c <= 0xA48C ||
  8632. c >= 0xA490 && c <= 0xA4C6 ||
  8633. c >= 0xA960 && c <= 0xA97C ||
  8634. c >= 0xAC00 && c <= 0xD7A3 ||
  8635. c >= 0xD7B0 && c <= 0xD7C6 ||
  8636. c >= 0xD7CB && c <= 0xD7FB ||
  8637. c >= 0xF900 && c <= 0xFAFF ||
  8638. c >= 0xFE10 && c <= 0xFE19 ||
  8639. c >= 0xFE30 && c <= 0xFE52 ||
  8640. c >= 0xFE54 && c <= 0xFE66 ||
  8641. c >= 0xFE68 && c <= 0xFE6B ||
  8642. c >= 0xFF01 && c <= 0xFF60 ||
  8643. c >= 0xFFE0 && c <= 0xFFE6;
  8644. };
  8645. }).call(EditSession.prototype);
  8646. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8647. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8648. config.defineOptions(EditSession.prototype, "session", {
  8649. wrap: {
  8650. set: function(value) {
  8651. if (!value || value == "off")
  8652. value = false;
  8653. else if (value == "free")
  8654. value = true;
  8655. else if (value == "printMargin")
  8656. value = -1;
  8657. else if (typeof value == "string")
  8658. value = parseInt(value, 10) || false;
  8659. if (this.$wrap == value)
  8660. return;
  8661. this.$wrap = value;
  8662. if (!value) {
  8663. this.setUseWrapMode(false);
  8664. } else {
  8665. var col = typeof value == "number" ? value : null;
  8666. this.setWrapLimitRange(col, col);
  8667. this.setUseWrapMode(true);
  8668. }
  8669. },
  8670. get: function() {
  8671. if (this.getUseWrapMode()) {
  8672. if (this.$wrap == -1)
  8673. return "printMargin";
  8674. if (!this.getWrapLimitRange().min)
  8675. return "free";
  8676. return this.$wrap;
  8677. }
  8678. return "off";
  8679. },
  8680. handlesSet: true
  8681. },
  8682. wrapMethod: {
  8683. set: function(val) {
  8684. val = val == "auto"
  8685. ? this.$mode.type != "text"
  8686. : val != "text";
  8687. if (val != this.$wrapAsCode) {
  8688. this.$wrapAsCode = val;
  8689. if (this.$useWrapMode) {
  8690. this.$modified = true;
  8691. this.$resetRowCache(0);
  8692. this.$updateWrapData(0, this.getLength() - 1);
  8693. }
  8694. }
  8695. },
  8696. initialValue: "auto"
  8697. },
  8698. indentedSoftWrap: { initialValue: true },
  8699. firstLineNumber: {
  8700. set: function() {this._signal("changeBreakpoint");},
  8701. initialValue: 1
  8702. },
  8703. useWorker: {
  8704. set: function(useWorker) {
  8705. this.$useWorker = useWorker;
  8706. this.$stopWorker();
  8707. if (useWorker)
  8708. this.$startWorker();
  8709. },
  8710. initialValue: true
  8711. },
  8712. useSoftTabs: {initialValue: true},
  8713. tabSize: {
  8714. set: function(tabSize) {
  8715. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8716. this.$modified = true;
  8717. this.$rowLengthCache = [];
  8718. this.$tabSize = tabSize;
  8719. this._signal("changeTabSize");
  8720. },
  8721. initialValue: 4,
  8722. handlesSet: true
  8723. },
  8724. overwrite: {
  8725. set: function(val) {this._signal("changeOverwrite");},
  8726. initialValue: false
  8727. },
  8728. newLineMode: {
  8729. set: function(val) {this.doc.setNewLineMode(val)},
  8730. get: function() {return this.doc.getNewLineMode()},
  8731. handlesSet: true
  8732. },
  8733. mode: {
  8734. set: function(val) { this.setMode(val) },
  8735. get: function() { return this.$modeId }
  8736. }
  8737. });
  8738. exports.EditSession = EditSession;
  8739. });
  8740. define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8741. "use strict";
  8742. var lang = require("./lib/lang");
  8743. var oop = require("./lib/oop");
  8744. var Range = require("./range").Range;
  8745. var Search = function() {
  8746. this.$options = {};
  8747. };
  8748. (function() {
  8749. this.set = function(options) {
  8750. oop.mixin(this.$options, options);
  8751. return this;
  8752. };
  8753. this.getOptions = function() {
  8754. return lang.copyObject(this.$options);
  8755. };
  8756. this.setOptions = function(options) {
  8757. this.$options = options;
  8758. };
  8759. this.find = function(session) {
  8760. var options = this.$options;
  8761. var iterator = this.$matchIterator(session, options);
  8762. if (!iterator)
  8763. return false;
  8764. var firstRange = null;
  8765. iterator.forEach(function(range, row, offset) {
  8766. if (!range.start) {
  8767. var column = range.offset + (offset || 0);
  8768. firstRange = new Range(row, column, row, column + range.length);
  8769. if (!range.length && options.start && options.start.start
  8770. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8771. ) {
  8772. firstRange = null;
  8773. return false;
  8774. }
  8775. } else
  8776. firstRange = range;
  8777. return true;
  8778. });
  8779. return firstRange;
  8780. };
  8781. this.findAll = function(session) {
  8782. var options = this.$options;
  8783. if (!options.needle)
  8784. return [];
  8785. this.$assembleRegExp(options);
  8786. var range = options.range;
  8787. var lines = range
  8788. ? session.getLines(range.start.row, range.end.row)
  8789. : session.doc.getAllLines();
  8790. var ranges = [];
  8791. var re = options.re;
  8792. if (options.$isMultiLine) {
  8793. var len = re.length;
  8794. var maxRow = lines.length - len;
  8795. var prevRange;
  8796. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8797. for (var j = 0; j < len; j++)
  8798. if (lines[row + j].search(re[j]) == -1)
  8799. continue outer;
  8800. var startLine = lines[row];
  8801. var line = lines[row + len - 1];
  8802. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8803. var endIndex = line.match(re[len - 1])[0].length;
  8804. if (prevRange && prevRange.end.row === row &&
  8805. prevRange.end.column > startIndex
  8806. ) {
  8807. continue;
  8808. }
  8809. ranges.push(prevRange = new Range(
  8810. row, startIndex, row + len - 1, endIndex
  8811. ));
  8812. if (len > 2)
  8813. row = row + len - 2;
  8814. }
  8815. } else {
  8816. for (var i = 0; i < lines.length; i++) {
  8817. var matches = lang.getMatchOffsets(lines[i], re);
  8818. for (var j = 0; j < matches.length; j++) {
  8819. var match = matches[j];
  8820. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8821. }
  8822. }
  8823. }
  8824. if (range) {
  8825. var startColumn = range.start.column;
  8826. var endColumn = range.start.column;
  8827. var i = 0, j = ranges.length - 1;
  8828. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8829. i++;
  8830. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8831. j--;
  8832. ranges = ranges.slice(i, j + 1);
  8833. for (i = 0, j = ranges.length; i < j; i++) {
  8834. ranges[i].start.row += range.start.row;
  8835. ranges[i].end.row += range.start.row;
  8836. }
  8837. }
  8838. return ranges;
  8839. };
  8840. this.replace = function(input, replacement) {
  8841. var options = this.$options;
  8842. var re = this.$assembleRegExp(options);
  8843. if (options.$isMultiLine)
  8844. return replacement;
  8845. if (!re)
  8846. return;
  8847. var match = re.exec(input);
  8848. if (!match || match[0].length != input.length)
  8849. return null;
  8850. replacement = input.replace(re, replacement);
  8851. if (options.preserveCase) {
  8852. replacement = replacement.split("");
  8853. for (var i = Math.min(input.length, input.length); i--; ) {
  8854. var ch = input[i];
  8855. if (ch && ch.toLowerCase() != ch)
  8856. replacement[i] = replacement[i].toUpperCase();
  8857. else
  8858. replacement[i] = replacement[i].toLowerCase();
  8859. }
  8860. replacement = replacement.join("");
  8861. }
  8862. return replacement;
  8863. };
  8864. this.$matchIterator = function(session, options) {
  8865. var re = this.$assembleRegExp(options);
  8866. if (!re)
  8867. return false;
  8868. var callback;
  8869. if (options.$isMultiLine) {
  8870. var len = re.length;
  8871. var matchIterator = function(line, row, offset) {
  8872. var startIndex = line.search(re[0]);
  8873. if (startIndex == -1)
  8874. return;
  8875. for (var i = 1; i < len; i++) {
  8876. line = session.getLine(row + i);
  8877. if (line.search(re[i]) == -1)
  8878. return;
  8879. }
  8880. var endIndex = line.match(re[len - 1])[0].length;
  8881. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8882. if (re.offset == 1) {
  8883. range.start.row--;
  8884. range.start.column = Number.MAX_VALUE;
  8885. } else if (offset)
  8886. range.start.column += offset;
  8887. if (callback(range))
  8888. return true;
  8889. };
  8890. } else if (options.backwards) {
  8891. var matchIterator = function(line, row, startIndex) {
  8892. var matches = lang.getMatchOffsets(line, re);
  8893. for (var i = matches.length-1; i >= 0; i--)
  8894. if (callback(matches[i], row, startIndex))
  8895. return true;
  8896. };
  8897. } else {
  8898. var matchIterator = function(line, row, startIndex) {
  8899. var matches = lang.getMatchOffsets(line, re);
  8900. for (var i = 0; i < matches.length; i++)
  8901. if (callback(matches[i], row, startIndex))
  8902. return true;
  8903. };
  8904. }
  8905. var lineIterator = this.$lineIterator(session, options);
  8906. return {
  8907. forEach: function(_callback) {
  8908. callback = _callback;
  8909. lineIterator.forEach(matchIterator);
  8910. }
  8911. };
  8912. };
  8913. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8914. if (options.needle instanceof RegExp)
  8915. return options.re = options.needle;
  8916. var needle = options.needle;
  8917. if (!options.needle)
  8918. return options.re = false;
  8919. if (!options.regExp)
  8920. needle = lang.escapeRegExp(needle);
  8921. if (options.wholeWord)
  8922. needle = "\\b" + needle + "\\b";
  8923. var modifier = options.caseSensitive ? "gm" : "gmi";
  8924. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8925. if (options.$isMultiLine)
  8926. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8927. try {
  8928. var re = new RegExp(needle, modifier);
  8929. } catch(e) {
  8930. re = false;
  8931. }
  8932. return options.re = re;
  8933. };
  8934. this.$assembleMultilineRegExp = function(needle, modifier) {
  8935. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8936. var re = [];
  8937. for (var i = 0; i < parts.length; i++) try {
  8938. re.push(new RegExp(parts[i], modifier));
  8939. } catch(e) {
  8940. return false;
  8941. }
  8942. if (parts[0] == "") {
  8943. re.shift();
  8944. re.offset = 1;
  8945. } else {
  8946. re.offset = 0;
  8947. }
  8948. return re;
  8949. };
  8950. this.$lineIterator = function(session, options) {
  8951. var backwards = options.backwards == true;
  8952. var skipCurrent = options.skipCurrent != false;
  8953. var range = options.range;
  8954. var start = options.start;
  8955. if (!start)
  8956. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8957. if (start.start)
  8958. start = start[skipCurrent != backwards ? "end" : "start"];
  8959. var firstRow = range ? range.start.row : 0;
  8960. var lastRow = range ? range.end.row : session.getLength() - 1;
  8961. var forEach = backwards ? function(callback) {
  8962. var row = start.row;
  8963. var line = session.getLine(row).substring(0, start.column);
  8964. if (callback(line, row))
  8965. return;
  8966. for (row--; row >= firstRow; row--)
  8967. if (callback(session.getLine(row), row))
  8968. return;
  8969. if (options.wrap == false)
  8970. return;
  8971. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8972. if (callback(session.getLine(row), row))
  8973. return;
  8974. } : function(callback) {
  8975. var row = start.row;
  8976. var line = session.getLine(row).substr(start.column);
  8977. if (callback(line, row, start.column))
  8978. return;
  8979. for (row = row+1; row <= lastRow; row++)
  8980. if (callback(session.getLine(row), row))
  8981. return;
  8982. if (options.wrap == false)
  8983. return;
  8984. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8985. if (callback(session.getLine(row), row))
  8986. return;
  8987. };
  8988. return {forEach: forEach};
  8989. };
  8990. }).call(Search.prototype);
  8991. exports.Search = Search;
  8992. });
  8993. define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  8994. "use strict";
  8995. var keyUtil = require("../lib/keys");
  8996. var useragent = require("../lib/useragent");
  8997. var KEY_MODS = keyUtil.KEY_MODS;
  8998. function HashHandler(config, platform) {
  8999. this.platform = platform || (useragent.isMac ? "mac" : "win");
  9000. this.commands = {};
  9001. this.commandKeyBinding = {};
  9002. this.addCommands(config);
  9003. this.$singleCommand = true;
  9004. }
  9005. function MultiHashHandler(config, platform) {
  9006. HashHandler.call(this, config, platform);
  9007. this.$singleCommand = false;
  9008. }
  9009. MultiHashHandler.prototype = HashHandler.prototype;
  9010. (function() {
  9011. this.addCommand = function(command) {
  9012. if (this.commands[command.name])
  9013. this.removeCommand(command);
  9014. this.commands[command.name] = command;
  9015. if (command.bindKey)
  9016. this._buildKeyHash(command);
  9017. };
  9018. this.removeCommand = function(command, keepCommand) {
  9019. var name = command && (typeof command === 'string' ? command : command.name);
  9020. command = this.commands[name];
  9021. if (!keepCommand)
  9022. delete this.commands[name];
  9023. var ckb = this.commandKeyBinding;
  9024. for (var keyId in ckb) {
  9025. var cmdGroup = ckb[keyId];
  9026. if (cmdGroup == command) {
  9027. delete ckb[keyId];
  9028. } else if (Array.isArray(cmdGroup)) {
  9029. var i = cmdGroup.indexOf(command);
  9030. if (i != -1) {
  9031. cmdGroup.splice(i, 1);
  9032. if (cmdGroup.length == 1)
  9033. ckb[keyId] = cmdGroup[0];
  9034. }
  9035. }
  9036. }
  9037. };
  9038. this.bindKey = function(key, command, position) {
  9039. if (typeof key == "object") {
  9040. if (position == undefined)
  9041. position = key.position;
  9042. key = key[this.platform];
  9043. }
  9044. if (!key)
  9045. return;
  9046. if (typeof command == "function")
  9047. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  9048. key.split("|").forEach(function(keyPart) {
  9049. var chain = "";
  9050. if (keyPart.indexOf(" ") != -1) {
  9051. var parts = keyPart.split(/\s+/);
  9052. keyPart = parts.pop();
  9053. parts.forEach(function(keyPart) {
  9054. var binding = this.parseKeys(keyPart);
  9055. var id = KEY_MODS[binding.hashId] + binding.key;
  9056. chain += (chain ? " " : "") + id;
  9057. this._addCommandToBinding(chain, "chainKeys");
  9058. }, this);
  9059. chain += " ";
  9060. }
  9061. var binding = this.parseKeys(keyPart);
  9062. var id = KEY_MODS[binding.hashId] + binding.key;
  9063. this._addCommandToBinding(chain + id, command, position);
  9064. }, this);
  9065. };
  9066. function getPosition(command) {
  9067. return typeof command == "object" && command.bindKey
  9068. && command.bindKey.position || 0;
  9069. }
  9070. this._addCommandToBinding = function(keyId, command, position) {
  9071. var ckb = this.commandKeyBinding, i;
  9072. if (!command) {
  9073. delete ckb[keyId];
  9074. } else if (!ckb[keyId] || this.$singleCommand) {
  9075. ckb[keyId] = command;
  9076. } else {
  9077. if (!Array.isArray(ckb[keyId])) {
  9078. ckb[keyId] = [ckb[keyId]];
  9079. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  9080. ckb[keyId].splice(i, 1);
  9081. }
  9082. if (typeof position != "number") {
  9083. if (position || command.isDefault)
  9084. position = -100;
  9085. else
  9086. position = getPosition(command);
  9087. }
  9088. var commands = ckb[keyId];
  9089. for (i = 0; i < commands.length; i++) {
  9090. var other = commands[i];
  9091. var otherPos = getPosition(other);
  9092. if (otherPos > position)
  9093. break;
  9094. }
  9095. commands.splice(i, 0, command);
  9096. }
  9097. };
  9098. this.addCommands = function(commands) {
  9099. commands && Object.keys(commands).forEach(function(name) {
  9100. var command = commands[name];
  9101. if (!command)
  9102. return;
  9103. if (typeof command === "string")
  9104. return this.bindKey(command, name);
  9105. if (typeof command === "function")
  9106. command = { exec: command };
  9107. if (typeof command !== "object")
  9108. return;
  9109. if (!command.name)
  9110. command.name = name;
  9111. this.addCommand(command);
  9112. }, this);
  9113. };
  9114. this.removeCommands = function(commands) {
  9115. Object.keys(commands).forEach(function(name) {
  9116. this.removeCommand(commands[name]);
  9117. }, this);
  9118. };
  9119. this.bindKeys = function(keyList) {
  9120. Object.keys(keyList).forEach(function(key) {
  9121. this.bindKey(key, keyList[key]);
  9122. }, this);
  9123. };
  9124. this._buildKeyHash = function(command) {
  9125. this.bindKey(command.bindKey, command);
  9126. };
  9127. this.parseKeys = function(keys) {
  9128. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  9129. var key = parts.pop();
  9130. var keyCode = keyUtil[key];
  9131. if (keyUtil.FUNCTION_KEYS[keyCode])
  9132. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  9133. else if (!parts.length)
  9134. return {key: key, hashId: -1};
  9135. else if (parts.length == 1 && parts[0] == "shift")
  9136. return {key: key.toUpperCase(), hashId: -1};
  9137. var hashId = 0;
  9138. for (var i = parts.length; i--;) {
  9139. var modifier = keyUtil.KEY_MODS[parts[i]];
  9140. if (modifier == null) {
  9141. if (typeof console != "undefined")
  9142. console.error("invalid modifier " + parts[i] + " in " + keys);
  9143. return false;
  9144. }
  9145. hashId |= modifier;
  9146. }
  9147. return {key: key, hashId: hashId};
  9148. };
  9149. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9150. var key = KEY_MODS[hashId] + keyString;
  9151. return this.commandKeyBinding[key];
  9152. };
  9153. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9154. if (keyCode < 0) return;
  9155. var key = KEY_MODS[hashId] + keyString;
  9156. var command = this.commandKeyBinding[key];
  9157. if (data.$keyChain) {
  9158. data.$keyChain += " " + key;
  9159. command = this.commandKeyBinding[data.$keyChain] || command;
  9160. }
  9161. if (command) {
  9162. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  9163. data.$keyChain = data.$keyChain || key;
  9164. return {command: "null"};
  9165. }
  9166. }
  9167. if (data.$keyChain) {
  9168. if ((!hashId || hashId == 4) && keyString.length == 1)
  9169. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  9170. else if (hashId == -1 || keyCode > 0)
  9171. data.$keyChain = ""; // reset keyChain
  9172. }
  9173. return {command: command};
  9174. };
  9175. this.getStatusText = function(editor, data) {
  9176. return data.$keyChain || "";
  9177. };
  9178. }).call(HashHandler.prototype);
  9179. exports.HashHandler = HashHandler;
  9180. exports.MultiHashHandler = MultiHashHandler;
  9181. });
  9182. define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  9183. "use strict";
  9184. var oop = require("../lib/oop");
  9185. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  9186. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  9187. var CommandManager = function(platform, commands) {
  9188. MultiHashHandler.call(this, commands, platform);
  9189. this.byName = this.commands;
  9190. this.setDefaultHandler("exec", function(e) {
  9191. return e.command.exec(e.editor, e.args || {});
  9192. });
  9193. };
  9194. oop.inherits(CommandManager, MultiHashHandler);
  9195. (function() {
  9196. oop.implement(this, EventEmitter);
  9197. this.exec = function(command, editor, args) {
  9198. if (Array.isArray(command)) {
  9199. for (var i = command.length; i--; ) {
  9200. if (this.exec(command[i], editor, args)) return true;
  9201. }
  9202. return false;
  9203. }
  9204. if (typeof command === "string")
  9205. command = this.commands[command];
  9206. if (!command)
  9207. return false;
  9208. if (editor && editor.$readOnly && !command.readOnly)
  9209. return false;
  9210. var e = {editor: editor, command: command, args: args};
  9211. e.returnValue = this._emit("exec", e);
  9212. this._signal("afterExec", e);
  9213. return e.returnValue === false ? false : true;
  9214. };
  9215. this.toggleRecording = function(editor) {
  9216. if (this.$inReplay)
  9217. return;
  9218. editor && editor._emit("changeStatus");
  9219. if (this.recording) {
  9220. this.macro.pop();
  9221. this.removeEventListener("exec", this.$addCommandToMacro);
  9222. if (!this.macro.length)
  9223. this.macro = this.oldMacro;
  9224. return this.recording = false;
  9225. }
  9226. if (!this.$addCommandToMacro) {
  9227. this.$addCommandToMacro = function(e) {
  9228. this.macro.push([e.command, e.args]);
  9229. }.bind(this);
  9230. }
  9231. this.oldMacro = this.macro;
  9232. this.macro = [];
  9233. this.on("exec", this.$addCommandToMacro);
  9234. return this.recording = true;
  9235. };
  9236. this.replay = function(editor) {
  9237. if (this.$inReplay || !this.macro)
  9238. return;
  9239. if (this.recording)
  9240. return this.toggleRecording(editor);
  9241. try {
  9242. this.$inReplay = true;
  9243. this.macro.forEach(function(x) {
  9244. if (typeof x == "string")
  9245. this.exec(x, editor);
  9246. else
  9247. this.exec(x[0], editor, x[1]);
  9248. }, this);
  9249. } finally {
  9250. this.$inReplay = false;
  9251. }
  9252. };
  9253. this.trimMacro = function(m) {
  9254. return m.map(function(x){
  9255. if (typeof x[0] != "string")
  9256. x[0] = x[0].name;
  9257. if (!x[1])
  9258. x = x[0];
  9259. return x;
  9260. });
  9261. };
  9262. }).call(CommandManager.prototype);
  9263. exports.CommandManager = CommandManager;
  9264. });
  9265. define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9266. "use strict";
  9267. var lang = require("../lib/lang");
  9268. var config = require("../config");
  9269. var Range = require("../range").Range;
  9270. function bindKey(win, mac) {
  9271. return {win: win, mac: mac};
  9272. }
  9273. exports.commands = [{
  9274. name: "showSettingsMenu",
  9275. bindKey: bindKey("Ctrl-,", "Command-,"),
  9276. exec: function(editor) {
  9277. config.loadModule("ace/ext/settings_menu", function(module) {
  9278. module.init(editor);
  9279. editor.showSettingsMenu();
  9280. });
  9281. },
  9282. readOnly: true
  9283. }, {
  9284. name: "goToNextError",
  9285. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9286. exec: function(editor) {
  9287. config.loadModule("ace/ext/error_marker", function(module) {
  9288. module.showErrorMarker(editor, 1);
  9289. });
  9290. },
  9291. scrollIntoView: "animate",
  9292. readOnly: true
  9293. }, {
  9294. name: "goToPreviousError",
  9295. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9296. exec: function(editor) {
  9297. config.loadModule("ace/ext/error_marker", function(module) {
  9298. module.showErrorMarker(editor, -1);
  9299. });
  9300. },
  9301. scrollIntoView: "animate",
  9302. readOnly: true
  9303. }, {
  9304. name: "selectall",
  9305. bindKey: bindKey("Ctrl-A", "Command-A"),
  9306. exec: function(editor) { editor.selectAll(); },
  9307. readOnly: true
  9308. }, {
  9309. name: "centerselection",
  9310. bindKey: bindKey(null, "Ctrl-L"),
  9311. exec: function(editor) { editor.centerSelection(); },
  9312. readOnly: true
  9313. }, {
  9314. name: "gotoline",
  9315. bindKey: bindKey("Ctrl-L", "Command-L"),
  9316. exec: function(editor) {
  9317. var line = parseInt(prompt("Enter line number:"), 10);
  9318. if (!isNaN(line)) {
  9319. editor.gotoLine(line);
  9320. }
  9321. },
  9322. readOnly: true
  9323. }, {
  9324. name: "fold",
  9325. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9326. exec: function(editor) { editor.session.toggleFold(false); },
  9327. multiSelectAction: "forEach",
  9328. scrollIntoView: "center",
  9329. readOnly: true
  9330. }, {
  9331. name: "unfold",
  9332. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9333. exec: function(editor) { editor.session.toggleFold(true); },
  9334. multiSelectAction: "forEach",
  9335. scrollIntoView: "center",
  9336. readOnly: true
  9337. }, {
  9338. name: "toggleFoldWidget",
  9339. bindKey: bindKey("F2", "F2"),
  9340. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9341. multiSelectAction: "forEach",
  9342. scrollIntoView: "center",
  9343. readOnly: true
  9344. }, {
  9345. name: "toggleParentFoldWidget",
  9346. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9347. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9348. multiSelectAction: "forEach",
  9349. scrollIntoView: "center",
  9350. readOnly: true
  9351. }, {
  9352. name: "foldall",
  9353. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9354. exec: function(editor) { editor.session.foldAll(); },
  9355. scrollIntoView: "center",
  9356. readOnly: true
  9357. }, {
  9358. name: "foldOther",
  9359. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9360. exec: function(editor) {
  9361. editor.session.foldAll();
  9362. editor.session.unfold(editor.selection.getAllRanges());
  9363. },
  9364. scrollIntoView: "center",
  9365. readOnly: true
  9366. }, {
  9367. name: "unfoldall",
  9368. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9369. exec: function(editor) { editor.session.unfold(); },
  9370. scrollIntoView: "center",
  9371. readOnly: true
  9372. }, {
  9373. name: "findnext",
  9374. bindKey: bindKey("Ctrl-K", "Command-G"),
  9375. exec: function(editor) { editor.findNext(); },
  9376. multiSelectAction: "forEach",
  9377. scrollIntoView: "center",
  9378. readOnly: true
  9379. }, {
  9380. name: "findprevious",
  9381. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9382. exec: function(editor) { editor.findPrevious(); },
  9383. multiSelectAction: "forEach",
  9384. scrollIntoView: "center",
  9385. readOnly: true
  9386. }, {
  9387. name: "selectOrFindNext",
  9388. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9389. exec: function(editor) {
  9390. if (editor.selection.isEmpty())
  9391. editor.selection.selectWord();
  9392. else
  9393. editor.findNext();
  9394. },
  9395. readOnly: true
  9396. }, {
  9397. name: "selectOrFindPrevious",
  9398. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9399. exec: function(editor) {
  9400. if (editor.selection.isEmpty())
  9401. editor.selection.selectWord();
  9402. else
  9403. editor.findPrevious();
  9404. },
  9405. readOnly: true
  9406. }, {
  9407. name: "find",
  9408. bindKey: bindKey("Ctrl-F", "Command-F"),
  9409. exec: function(editor) {
  9410. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9411. },
  9412. readOnly: true
  9413. }, {
  9414. name: "overwrite",
  9415. bindKey: "Insert",
  9416. exec: function(editor) { editor.toggleOverwrite(); },
  9417. readOnly: true
  9418. }, {
  9419. name: "selecttostart",
  9420. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9421. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9422. multiSelectAction: "forEach",
  9423. readOnly: true,
  9424. scrollIntoView: "animate",
  9425. aceCommandGroup: "fileJump"
  9426. }, {
  9427. name: "gotostart",
  9428. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9429. exec: function(editor) { editor.navigateFileStart(); },
  9430. multiSelectAction: "forEach",
  9431. readOnly: true,
  9432. scrollIntoView: "animate",
  9433. aceCommandGroup: "fileJump"
  9434. }, {
  9435. name: "selectup",
  9436. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9437. exec: function(editor) { editor.getSelection().selectUp(); },
  9438. multiSelectAction: "forEach",
  9439. scrollIntoView: "cursor",
  9440. readOnly: true
  9441. }, {
  9442. name: "golineup",
  9443. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9444. exec: function(editor, args) { editor.navigateUp(args.times); },
  9445. multiSelectAction: "forEach",
  9446. scrollIntoView: "cursor",
  9447. readOnly: true
  9448. }, {
  9449. name: "selecttoend",
  9450. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9451. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9452. multiSelectAction: "forEach",
  9453. readOnly: true,
  9454. scrollIntoView: "animate",
  9455. aceCommandGroup: "fileJump"
  9456. }, {
  9457. name: "gotoend",
  9458. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9459. exec: function(editor) { editor.navigateFileEnd(); },
  9460. multiSelectAction: "forEach",
  9461. readOnly: true,
  9462. scrollIntoView: "animate",
  9463. aceCommandGroup: "fileJump"
  9464. }, {
  9465. name: "selectdown",
  9466. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9467. exec: function(editor) { editor.getSelection().selectDown(); },
  9468. multiSelectAction: "forEach",
  9469. scrollIntoView: "cursor",
  9470. readOnly: true
  9471. }, {
  9472. name: "golinedown",
  9473. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9474. exec: function(editor, args) { editor.navigateDown(args.times); },
  9475. multiSelectAction: "forEach",
  9476. scrollIntoView: "cursor",
  9477. readOnly: true
  9478. }, {
  9479. name: "selectwordleft",
  9480. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9481. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9482. multiSelectAction: "forEach",
  9483. scrollIntoView: "cursor",
  9484. readOnly: true
  9485. }, {
  9486. name: "gotowordleft",
  9487. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9488. exec: function(editor) { editor.navigateWordLeft(); },
  9489. multiSelectAction: "forEach",
  9490. scrollIntoView: "cursor",
  9491. readOnly: true
  9492. }, {
  9493. name: "selecttolinestart",
  9494. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9495. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9496. multiSelectAction: "forEach",
  9497. scrollIntoView: "cursor",
  9498. readOnly: true
  9499. }, {
  9500. name: "gotolinestart",
  9501. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9502. exec: function(editor) { editor.navigateLineStart(); },
  9503. multiSelectAction: "forEach",
  9504. scrollIntoView: "cursor",
  9505. readOnly: true
  9506. }, {
  9507. name: "selectleft",
  9508. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9509. exec: function(editor) { editor.getSelection().selectLeft(); },
  9510. multiSelectAction: "forEach",
  9511. scrollIntoView: "cursor",
  9512. readOnly: true
  9513. }, {
  9514. name: "gotoleft",
  9515. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9516. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9517. multiSelectAction: "forEach",
  9518. scrollIntoView: "cursor",
  9519. readOnly: true
  9520. }, {
  9521. name: "selectwordright",
  9522. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9523. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9524. multiSelectAction: "forEach",
  9525. scrollIntoView: "cursor",
  9526. readOnly: true
  9527. }, {
  9528. name: "gotowordright",
  9529. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9530. exec: function(editor) { editor.navigateWordRight(); },
  9531. multiSelectAction: "forEach",
  9532. scrollIntoView: "cursor",
  9533. readOnly: true
  9534. }, {
  9535. name: "selecttolineend",
  9536. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9537. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9538. multiSelectAction: "forEach",
  9539. scrollIntoView: "cursor",
  9540. readOnly: true
  9541. }, {
  9542. name: "gotolineend",
  9543. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9544. exec: function(editor) { editor.navigateLineEnd(); },
  9545. multiSelectAction: "forEach",
  9546. scrollIntoView: "cursor",
  9547. readOnly: true
  9548. }, {
  9549. name: "selectright",
  9550. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9551. exec: function(editor) { editor.getSelection().selectRight(); },
  9552. multiSelectAction: "forEach",
  9553. scrollIntoView: "cursor",
  9554. readOnly: true
  9555. }, {
  9556. name: "gotoright",
  9557. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9558. exec: function(editor, args) { editor.navigateRight(args.times); },
  9559. multiSelectAction: "forEach",
  9560. scrollIntoView: "cursor",
  9561. readOnly: true
  9562. }, {
  9563. name: "selectpagedown",
  9564. bindKey: "Shift-PageDown",
  9565. exec: function(editor) { editor.selectPageDown(); },
  9566. readOnly: true
  9567. }, {
  9568. name: "pagedown",
  9569. bindKey: bindKey(null, "Option-PageDown"),
  9570. exec: function(editor) { editor.scrollPageDown(); },
  9571. readOnly: true
  9572. }, {
  9573. name: "gotopagedown",
  9574. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9575. exec: function(editor) { editor.gotoPageDown(); },
  9576. readOnly: true
  9577. }, {
  9578. name: "selectpageup",
  9579. bindKey: "Shift-PageUp",
  9580. exec: function(editor) { editor.selectPageUp(); },
  9581. readOnly: true
  9582. }, {
  9583. name: "pageup",
  9584. bindKey: bindKey(null, "Option-PageUp"),
  9585. exec: function(editor) { editor.scrollPageUp(); },
  9586. readOnly: true
  9587. }, {
  9588. name: "gotopageup",
  9589. bindKey: "PageUp",
  9590. exec: function(editor) { editor.gotoPageUp(); },
  9591. readOnly: true
  9592. }, {
  9593. name: "scrollup",
  9594. bindKey: bindKey("Ctrl-Up", null),
  9595. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9596. readOnly: true
  9597. }, {
  9598. name: "scrolldown",
  9599. bindKey: bindKey("Ctrl-Down", null),
  9600. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9601. readOnly: true
  9602. }, {
  9603. name: "selectlinestart",
  9604. bindKey: "Shift-Home",
  9605. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9606. multiSelectAction: "forEach",
  9607. scrollIntoView: "cursor",
  9608. readOnly: true
  9609. }, {
  9610. name: "selectlineend",
  9611. bindKey: "Shift-End",
  9612. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9613. multiSelectAction: "forEach",
  9614. scrollIntoView: "cursor",
  9615. readOnly: true
  9616. }, {
  9617. name: "togglerecording",
  9618. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9619. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9620. readOnly: true
  9621. }, {
  9622. name: "replaymacro",
  9623. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9624. exec: function(editor) { editor.commands.replay(editor); },
  9625. readOnly: true
  9626. }, {
  9627. name: "jumptomatching",
  9628. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9629. exec: function(editor) { editor.jumpToMatching(); },
  9630. multiSelectAction: "forEach",
  9631. scrollIntoView: "animate",
  9632. readOnly: true
  9633. }, {
  9634. name: "selecttomatching",
  9635. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9636. exec: function(editor) { editor.jumpToMatching(true); },
  9637. multiSelectAction: "forEach",
  9638. scrollIntoView: "animate",
  9639. readOnly: true
  9640. }, {
  9641. name: "expandToMatching",
  9642. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9643. exec: function(editor) { editor.jumpToMatching(true, true); },
  9644. multiSelectAction: "forEach",
  9645. scrollIntoView: "animate",
  9646. readOnly: true
  9647. }, {
  9648. name: "passKeysToBrowser",
  9649. bindKey: bindKey(null, null),
  9650. exec: function() {},
  9651. passEvent: true,
  9652. readOnly: true
  9653. }, {
  9654. name: "copy",
  9655. exec: function(editor) {
  9656. },
  9657. readOnly: true
  9658. },
  9659. {
  9660. name: "cut",
  9661. exec: function(editor) {
  9662. var range = editor.getSelectionRange();
  9663. editor._emit("cut", range);
  9664. if (!editor.selection.isEmpty()) {
  9665. editor.session.remove(range);
  9666. editor.clearSelection();
  9667. }
  9668. },
  9669. scrollIntoView: "cursor",
  9670. multiSelectAction: "forEach"
  9671. }, {
  9672. name: "paste",
  9673. exec: function(editor, args) {
  9674. editor.$handlePaste(args);
  9675. },
  9676. scrollIntoView: "cursor"
  9677. }, {
  9678. name: "removeline",
  9679. bindKey: bindKey("Ctrl-D", "Command-D"),
  9680. exec: function(editor) { editor.removeLines(); },
  9681. scrollIntoView: "cursor",
  9682. multiSelectAction: "forEachLine"
  9683. }, {
  9684. name: "duplicateSelection",
  9685. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9686. exec: function(editor) { editor.duplicateSelection(); },
  9687. scrollIntoView: "cursor",
  9688. multiSelectAction: "forEach"
  9689. }, {
  9690. name: "sortlines",
  9691. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9692. exec: function(editor) { editor.sortLines(); },
  9693. scrollIntoView: "selection",
  9694. multiSelectAction: "forEachLine"
  9695. }, {
  9696. name: "togglecomment",
  9697. bindKey: bindKey("Ctrl-/", "Command-/"),
  9698. exec: function(editor) { editor.toggleCommentLines(); },
  9699. multiSelectAction: "forEachLine",
  9700. scrollIntoView: "selectionPart"
  9701. }, {
  9702. name: "toggleBlockComment",
  9703. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9704. exec: function(editor) { editor.toggleBlockComment(); },
  9705. multiSelectAction: "forEach",
  9706. scrollIntoView: "selectionPart"
  9707. }, {
  9708. name: "modifyNumberUp",
  9709. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9710. exec: function(editor) { editor.modifyNumber(1); },
  9711. scrollIntoView: "cursor",
  9712. multiSelectAction: "forEach"
  9713. }, {
  9714. name: "modifyNumberDown",
  9715. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9716. exec: function(editor) { editor.modifyNumber(-1); },
  9717. scrollIntoView: "cursor",
  9718. multiSelectAction: "forEach"
  9719. }, {
  9720. name: "replace",
  9721. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9722. exec: function(editor) {
  9723. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9724. }
  9725. }, {
  9726. name: "undo",
  9727. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9728. exec: function(editor) { editor.undo(); }
  9729. }, {
  9730. name: "redo",
  9731. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9732. exec: function(editor) { editor.redo(); }
  9733. }, {
  9734. name: "copylinesup",
  9735. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9736. exec: function(editor) { editor.copyLinesUp(); },
  9737. scrollIntoView: "cursor"
  9738. }, {
  9739. name: "movelinesup",
  9740. bindKey: bindKey("Alt-Up", "Option-Up"),
  9741. exec: function(editor) { editor.moveLinesUp(); },
  9742. scrollIntoView: "cursor"
  9743. }, {
  9744. name: "copylinesdown",
  9745. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9746. exec: function(editor) { editor.copyLinesDown(); },
  9747. scrollIntoView: "cursor"
  9748. }, {
  9749. name: "movelinesdown",
  9750. bindKey: bindKey("Alt-Down", "Option-Down"),
  9751. exec: function(editor) { editor.moveLinesDown(); },
  9752. scrollIntoView: "cursor"
  9753. }, {
  9754. name: "del",
  9755. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9756. exec: function(editor) { editor.remove("right"); },
  9757. multiSelectAction: "forEach",
  9758. scrollIntoView: "cursor"
  9759. }, {
  9760. name: "backspace",
  9761. bindKey: bindKey(
  9762. "Shift-Backspace|Backspace",
  9763. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9764. ),
  9765. exec: function(editor) { editor.remove("left"); },
  9766. multiSelectAction: "forEach",
  9767. scrollIntoView: "cursor"
  9768. }, {
  9769. name: "cut_or_delete",
  9770. bindKey: bindKey("Shift-Delete", null),
  9771. exec: function(editor) {
  9772. if (editor.selection.isEmpty()) {
  9773. editor.remove("left");
  9774. } else {
  9775. return false;
  9776. }
  9777. },
  9778. multiSelectAction: "forEach",
  9779. scrollIntoView: "cursor"
  9780. }, {
  9781. name: "removetolinestart",
  9782. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9783. exec: function(editor) { editor.removeToLineStart(); },
  9784. multiSelectAction: "forEach",
  9785. scrollIntoView: "cursor"
  9786. }, {
  9787. name: "removetolineend",
  9788. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9789. exec: function(editor) { editor.removeToLineEnd(); },
  9790. multiSelectAction: "forEach",
  9791. scrollIntoView: "cursor"
  9792. }, {
  9793. name: "removewordleft",
  9794. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9795. exec: function(editor) { editor.removeWordLeft(); },
  9796. multiSelectAction: "forEach",
  9797. scrollIntoView: "cursor"
  9798. }, {
  9799. name: "removewordright",
  9800. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9801. exec: function(editor) { editor.removeWordRight(); },
  9802. multiSelectAction: "forEach",
  9803. scrollIntoView: "cursor"
  9804. }, {
  9805. name: "outdent",
  9806. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9807. exec: function(editor) { editor.blockOutdent(); },
  9808. multiSelectAction: "forEach",
  9809. scrollIntoView: "selectionPart"
  9810. }, {
  9811. name: "indent",
  9812. bindKey: bindKey("Tab", "Tab"),
  9813. exec: function(editor) { editor.indent(); },
  9814. multiSelectAction: "forEach",
  9815. scrollIntoView: "selectionPart"
  9816. }, {
  9817. name: "blockoutdent",
  9818. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9819. exec: function(editor) { editor.blockOutdent(); },
  9820. multiSelectAction: "forEachLine",
  9821. scrollIntoView: "selectionPart"
  9822. }, {
  9823. name: "blockindent",
  9824. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9825. exec: function(editor) { editor.blockIndent(); },
  9826. multiSelectAction: "forEachLine",
  9827. scrollIntoView: "selectionPart"
  9828. }, {
  9829. name: "insertstring",
  9830. exec: function(editor, str) { editor.insert(str); },
  9831. multiSelectAction: "forEach",
  9832. scrollIntoView: "cursor"
  9833. }, {
  9834. name: "inserttext",
  9835. exec: function(editor, args) {
  9836. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9837. },
  9838. multiSelectAction: "forEach",
  9839. scrollIntoView: "cursor"
  9840. }, {
  9841. name: "splitline",
  9842. bindKey: bindKey(null, "Ctrl-O"),
  9843. exec: function(editor) { editor.splitLine(); },
  9844. multiSelectAction: "forEach",
  9845. scrollIntoView: "cursor"
  9846. }, {
  9847. name: "transposeletters",
  9848. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9849. exec: function(editor) { editor.transposeLetters(); },
  9850. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9851. scrollIntoView: "cursor"
  9852. }, {
  9853. name: "touppercase",
  9854. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9855. exec: function(editor) { editor.toUpperCase(); },
  9856. multiSelectAction: "forEach",
  9857. scrollIntoView: "cursor"
  9858. }, {
  9859. name: "tolowercase",
  9860. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9861. exec: function(editor) { editor.toLowerCase(); },
  9862. multiSelectAction: "forEach",
  9863. scrollIntoView: "cursor"
  9864. }, {
  9865. name: "expandtoline",
  9866. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9867. exec: function(editor) {
  9868. var range = editor.selection.getRange();
  9869. range.start.column = range.end.column = 0;
  9870. range.end.row++;
  9871. editor.selection.setRange(range, false);
  9872. },
  9873. multiSelectAction: "forEach",
  9874. scrollIntoView: "cursor",
  9875. readOnly: true
  9876. }, {
  9877. name: "joinlines",
  9878. bindKey: bindKey(null, null),
  9879. exec: function(editor) {
  9880. var isBackwards = editor.selection.isBackwards();
  9881. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9882. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9883. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9884. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9885. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9886. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9887. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9888. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9889. if (curLine.length !== 0) {
  9890. curLine = " " + curLine;
  9891. }
  9892. insertLine += curLine;
  9893. }
  9894. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9895. insertLine += editor.session.doc.getNewLineCharacter();
  9896. }
  9897. editor.clearSelection();
  9898. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9899. if (selectedCount > 0) {
  9900. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9901. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9902. } else {
  9903. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9904. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9905. }
  9906. },
  9907. multiSelectAction: "forEach",
  9908. readOnly: true
  9909. }, {
  9910. name: "invertSelection",
  9911. bindKey: bindKey(null, null),
  9912. exec: function(editor) {
  9913. var endRow = editor.session.doc.getLength() - 1;
  9914. var endCol = editor.session.doc.getLine(endRow).length;
  9915. var ranges = editor.selection.rangeList.ranges;
  9916. var newRanges = [];
  9917. if (ranges.length < 1) {
  9918. ranges = [editor.selection.getRange()];
  9919. }
  9920. for (var i = 0; i < ranges.length; i++) {
  9921. if (i == (ranges.length - 1)) {
  9922. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9923. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9924. }
  9925. }
  9926. if (i === 0) {
  9927. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9928. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9929. }
  9930. } else {
  9931. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9932. }
  9933. }
  9934. editor.exitMultiSelectMode();
  9935. editor.clearSelection();
  9936. for(var i = 0; i < newRanges.length; i++) {
  9937. editor.selection.addRange(newRanges[i], false);
  9938. }
  9939. },
  9940. readOnly: true,
  9941. scrollIntoView: "none"
  9942. }];
  9943. });
  9944. define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(require, exports, module) {
  9945. "use strict";
  9946. require("./lib/fixoldbrowsers");
  9947. var oop = require("./lib/oop");
  9948. var dom = require("./lib/dom");
  9949. var lang = require("./lib/lang");
  9950. var useragent = require("./lib/useragent");
  9951. var TextInput = require("./keyboard/textinput").TextInput;
  9952. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9953. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9954. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9955. var EditSession = require("./edit_session").EditSession;
  9956. var Search = require("./search").Search;
  9957. var Range = require("./range").Range;
  9958. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9959. var CommandManager = require("./commands/command_manager").CommandManager;
  9960. var defaultCommands = require("./commands/default_commands").commands;
  9961. var config = require("./config");
  9962. var TokenIterator = require("./token_iterator").TokenIterator;
  9963. var Editor = function(renderer, session) {
  9964. var container = renderer.getContainerElement();
  9965. this.container = container;
  9966. this.renderer = renderer;
  9967. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9968. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9969. this.renderer.textarea = this.textInput.getElement();
  9970. this.keyBinding = new KeyBinding(this);
  9971. this.$mouseHandler = new MouseHandler(this);
  9972. new FoldHandler(this);
  9973. this.$blockScrolling = 0;
  9974. this.$search = new Search().set({
  9975. wrap: true
  9976. });
  9977. this.$historyTracker = this.$historyTracker.bind(this);
  9978. this.commands.on("exec", this.$historyTracker);
  9979. this.$initOperationListeners();
  9980. this._$emitInputEvent = lang.delayedCall(function() {
  9981. this._signal("input", {});
  9982. if (this.session && this.session.bgTokenizer)
  9983. this.session.bgTokenizer.scheduleStart();
  9984. }.bind(this));
  9985. this.on("change", function(_, _self) {
  9986. _self._$emitInputEvent.schedule(31);
  9987. });
  9988. this.setSession(session || new EditSession(""));
  9989. config.resetOptions(this);
  9990. config._signal("editor", this);
  9991. };
  9992. (function(){
  9993. oop.implement(this, EventEmitter);
  9994. this.$initOperationListeners = function() {
  9995. function last(a) {return a[a.length - 1]}
  9996. this.selections = [];
  9997. this.commands.on("exec", this.startOperation.bind(this), true);
  9998. this.commands.on("afterExec", this.endOperation.bind(this), true);
  9999. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  10000. this.on("change", function() {
  10001. this.curOp || this.startOperation();
  10002. this.curOp.docChanged = true;
  10003. }.bind(this), true);
  10004. this.on("changeSelection", function() {
  10005. this.curOp || this.startOperation();
  10006. this.curOp.selectionChanged = true;
  10007. }.bind(this), true);
  10008. };
  10009. this.curOp = null;
  10010. this.prevOp = {};
  10011. this.startOperation = function(commadEvent) {
  10012. if (this.curOp) {
  10013. if (!commadEvent || this.curOp.command)
  10014. return;
  10015. this.prevOp = this.curOp;
  10016. }
  10017. if (!commadEvent) {
  10018. this.previousCommand = null;
  10019. commadEvent = {};
  10020. }
  10021. this.$opResetTimer.schedule();
  10022. this.curOp = {
  10023. command: commadEvent.command || {},
  10024. args: commadEvent.args,
  10025. scrollTop: this.renderer.scrollTop
  10026. };
  10027. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  10028. this.$blockScrolling++;
  10029. };
  10030. this.endOperation = function(e) {
  10031. if (this.curOp) {
  10032. if (e && e.returnValue === false)
  10033. return this.curOp = null;
  10034. this._signal("beforeEndOperation");
  10035. var command = this.curOp.command;
  10036. if (command.name && this.$blockScrolling > 0)
  10037. this.$blockScrolling--;
  10038. var scrollIntoView = command && command.scrollIntoView;
  10039. if (scrollIntoView) {
  10040. switch (scrollIntoView) {
  10041. case "center-animate":
  10042. scrollIntoView = "animate";
  10043. case "center":
  10044. this.renderer.scrollCursorIntoView(null, 0.5);
  10045. break;
  10046. case "animate":
  10047. case "cursor":
  10048. this.renderer.scrollCursorIntoView();
  10049. break;
  10050. case "selectionPart":
  10051. var range = this.selection.getRange();
  10052. var config = this.renderer.layerConfig;
  10053. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  10054. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  10055. }
  10056. break;
  10057. default:
  10058. break;
  10059. }
  10060. if (scrollIntoView == "animate")
  10061. this.renderer.animateScrolling(this.curOp.scrollTop);
  10062. }
  10063. this.prevOp = this.curOp;
  10064. this.curOp = null;
  10065. }
  10066. };
  10067. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  10068. this.$historyTracker = function(e) {
  10069. if (!this.$mergeUndoDeltas)
  10070. return;
  10071. var prev = this.prevOp;
  10072. var mergeableCommands = this.$mergeableCommands;
  10073. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  10074. if (e.command.name == "insertstring") {
  10075. var text = e.args;
  10076. if (this.mergeNextCommand === undefined)
  10077. this.mergeNextCommand = true;
  10078. shouldMerge = shouldMerge
  10079. && this.mergeNextCommand // previous command allows to coalesce with
  10080. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  10081. this.mergeNextCommand = true;
  10082. } else {
  10083. shouldMerge = shouldMerge
  10084. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  10085. }
  10086. if (
  10087. this.$mergeUndoDeltas != "always"
  10088. && Date.now() - this.sequenceStartTime > 2000
  10089. ) {
  10090. shouldMerge = false; // the sequence is too long
  10091. }
  10092. if (shouldMerge)
  10093. this.session.mergeUndoDeltas = true;
  10094. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  10095. this.sequenceStartTime = Date.now();
  10096. };
  10097. this.setKeyboardHandler = function(keyboardHandler, cb) {
  10098. if (keyboardHandler && typeof keyboardHandler === "string") {
  10099. this.$keybindingId = keyboardHandler;
  10100. var _self = this;
  10101. config.loadModule(["keybinding", keyboardHandler], function(module) {
  10102. if (_self.$keybindingId == keyboardHandler)
  10103. _self.keyBinding.setKeyboardHandler(module && module.handler);
  10104. cb && cb();
  10105. });
  10106. } else {
  10107. this.$keybindingId = null;
  10108. this.keyBinding.setKeyboardHandler(keyboardHandler);
  10109. cb && cb();
  10110. }
  10111. };
  10112. this.getKeyboardHandler = function() {
  10113. return this.keyBinding.getKeyboardHandler();
  10114. };
  10115. this.setSession = function(session) {
  10116. if (this.session == session)
  10117. return;
  10118. if (this.curOp) this.endOperation();
  10119. this.curOp = {};
  10120. var oldSession = this.session;
  10121. if (oldSession) {
  10122. this.session.removeEventListener("change", this.$onDocumentChange);
  10123. this.session.removeEventListener("changeMode", this.$onChangeMode);
  10124. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10125. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  10126. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10127. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  10128. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  10129. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10130. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  10131. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10132. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  10133. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  10134. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  10135. this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10136. var selection = this.session.getSelection();
  10137. selection.removeEventListener("changeCursor", this.$onCursorChange);
  10138. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  10139. }
  10140. this.session = session;
  10141. if (session) {
  10142. this.$onDocumentChange = this.onDocumentChange.bind(this);
  10143. session.addEventListener("change", this.$onDocumentChange);
  10144. this.renderer.setSession(session);
  10145. this.$onChangeMode = this.onChangeMode.bind(this);
  10146. session.addEventListener("changeMode", this.$onChangeMode);
  10147. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  10148. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10149. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  10150. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  10151. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  10152. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10153. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  10154. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  10155. this.$onChangeFold = this.onChangeFold.bind(this);
  10156. session.addEventListener("changeFold", this.$onChangeFold);
  10157. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  10158. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10159. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  10160. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  10161. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  10162. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10163. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  10164. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  10165. this.$onCursorChange = this.onCursorChange.bind(this);
  10166. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  10167. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  10168. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  10169. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  10170. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10171. this.selection = session.getSelection();
  10172. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  10173. this.$onSelectionChange = this.onSelectionChange.bind(this);
  10174. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  10175. this.onChangeMode();
  10176. this.$blockScrolling += 1;
  10177. this.onCursorChange();
  10178. this.$blockScrolling -= 1;
  10179. this.onScrollTopChange();
  10180. this.onScrollLeftChange();
  10181. this.onSelectionChange();
  10182. this.onChangeFrontMarker();
  10183. this.onChangeBackMarker();
  10184. this.onChangeBreakpoint();
  10185. this.onChangeAnnotation();
  10186. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  10187. this.renderer.updateFull();
  10188. } else {
  10189. this.selection = null;
  10190. this.renderer.setSession(session);
  10191. }
  10192. this._signal("changeSession", {
  10193. session: session,
  10194. oldSession: oldSession
  10195. });
  10196. this.curOp = null;
  10197. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  10198. session && session._signal("changeEditor", {editor: this});
  10199. };
  10200. this.getSession = function() {
  10201. return this.session;
  10202. };
  10203. this.setValue = function(val, cursorPos) {
  10204. this.session.doc.setValue(val);
  10205. if (!cursorPos)
  10206. this.selectAll();
  10207. else if (cursorPos == 1)
  10208. this.navigateFileEnd();
  10209. else if (cursorPos == -1)
  10210. this.navigateFileStart();
  10211. return val;
  10212. };
  10213. this.getValue = function() {
  10214. return this.session.getValue();
  10215. };
  10216. this.getSelection = function() {
  10217. return this.selection;
  10218. };
  10219. this.resize = function(force) {
  10220. this.renderer.onResize(force);
  10221. };
  10222. this.setTheme = function(theme, cb) {
  10223. this.renderer.setTheme(theme, cb);
  10224. };
  10225. this.getTheme = function() {
  10226. return this.renderer.getTheme();
  10227. };
  10228. this.setStyle = function(style) {
  10229. this.renderer.setStyle(style);
  10230. };
  10231. this.unsetStyle = function(style) {
  10232. this.renderer.unsetStyle(style);
  10233. };
  10234. this.getFontSize = function () {
  10235. return this.getOption("fontSize") ||
  10236. dom.computedStyle(this.container, "fontSize");
  10237. };
  10238. this.setFontSize = function(size) {
  10239. this.setOption("fontSize", size);
  10240. };
  10241. this.$highlightBrackets = function() {
  10242. if (this.session.$bracketHighlight) {
  10243. this.session.removeMarker(this.session.$bracketHighlight);
  10244. this.session.$bracketHighlight = null;
  10245. }
  10246. if (this.$highlightPending) {
  10247. return;
  10248. }
  10249. var self = this;
  10250. this.$highlightPending = true;
  10251. setTimeout(function() {
  10252. self.$highlightPending = false;
  10253. var session = self.session;
  10254. if (!session || !session.bgTokenizer) return;
  10255. var pos = session.findMatchingBracket(self.getCursorPosition());
  10256. if (pos) {
  10257. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10258. } else if (session.$mode.getMatching) {
  10259. var range = session.$mode.getMatching(self.session);
  10260. }
  10261. if (range)
  10262. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10263. }, 50);
  10264. };
  10265. this.$highlightTags = function() {
  10266. if (this.$highlightTagPending)
  10267. return;
  10268. var self = this;
  10269. this.$highlightTagPending = true;
  10270. setTimeout(function() {
  10271. self.$highlightTagPending = false;
  10272. var session = self.session;
  10273. if (!session || !session.bgTokenizer) return;
  10274. var pos = self.getCursorPosition();
  10275. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10276. var token = iterator.getCurrentToken();
  10277. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10278. session.removeMarker(session.$tagHighlight);
  10279. session.$tagHighlight = null;
  10280. return;
  10281. }
  10282. if (token.type.indexOf("tag-open") != -1) {
  10283. token = iterator.stepForward();
  10284. if (!token)
  10285. return;
  10286. }
  10287. var tag = token.value;
  10288. var depth = 0;
  10289. var prevToken = iterator.stepBackward();
  10290. if (prevToken.value == '<'){
  10291. do {
  10292. prevToken = token;
  10293. token = iterator.stepForward();
  10294. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10295. if (prevToken.value === '<'){
  10296. depth++;
  10297. } else if (prevToken.value === '</'){
  10298. depth--;
  10299. }
  10300. }
  10301. } while (token && depth >= 0);
  10302. } else {
  10303. do {
  10304. token = prevToken;
  10305. prevToken = iterator.stepBackward();
  10306. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10307. if (prevToken.value === '<') {
  10308. depth++;
  10309. } else if (prevToken.value === '</') {
  10310. depth--;
  10311. }
  10312. }
  10313. } while (prevToken && depth <= 0);
  10314. iterator.stepForward();
  10315. }
  10316. if (!token) {
  10317. session.removeMarker(session.$tagHighlight);
  10318. session.$tagHighlight = null;
  10319. return;
  10320. }
  10321. var row = iterator.getCurrentTokenRow();
  10322. var column = iterator.getCurrentTokenColumn();
  10323. var range = new Range(row, column, row, column+token.value.length);
  10324. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10325. session.removeMarker(session.$tagHighlight);
  10326. session.$tagHighlight = null;
  10327. }
  10328. if (range && !session.$tagHighlight)
  10329. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10330. }, 50);
  10331. };
  10332. this.focus = function() {
  10333. var _self = this;
  10334. setTimeout(function() {
  10335. _self.textInput.focus();
  10336. });
  10337. this.textInput.focus();
  10338. };
  10339. this.isFocused = function() {
  10340. return this.textInput.isFocused();
  10341. };
  10342. this.blur = function() {
  10343. this.textInput.blur();
  10344. };
  10345. this.onFocus = function(e) {
  10346. if (this.$isFocused)
  10347. return;
  10348. this.$isFocused = true;
  10349. this.renderer.showCursor();
  10350. this.renderer.visualizeFocus();
  10351. this._emit("focus", e);
  10352. };
  10353. this.onBlur = function(e) {
  10354. if (!this.$isFocused)
  10355. return;
  10356. this.$isFocused = false;
  10357. this.renderer.hideCursor();
  10358. this.renderer.visualizeBlur();
  10359. this._emit("blur", e);
  10360. };
  10361. this.$cursorChange = function() {
  10362. this.renderer.updateCursor();
  10363. };
  10364. this.onDocumentChange = function(delta) {
  10365. var wrap = this.session.$useWrapMode;
  10366. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  10367. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  10368. this._signal("change", delta);
  10369. this.$cursorChange();
  10370. this.$updateHighlightActiveLine();
  10371. };
  10372. this.onTokenizerUpdate = function(e) {
  10373. var rows = e.data;
  10374. this.renderer.updateLines(rows.first, rows.last);
  10375. };
  10376. this.onScrollTopChange = function() {
  10377. this.renderer.scrollToY(this.session.getScrollTop());
  10378. };
  10379. this.onScrollLeftChange = function() {
  10380. this.renderer.scrollToX(this.session.getScrollLeft());
  10381. };
  10382. this.onCursorChange = function() {
  10383. this.$cursorChange();
  10384. if (!this.$blockScrolling) {
  10385. config.warn("Automatically scrolling cursor into view after selection change",
  10386. "this will be disabled in the next version",
  10387. "set editor.$blockScrolling = Infinity to disable this message"
  10388. );
  10389. this.renderer.scrollCursorIntoView();
  10390. }
  10391. this.$highlightBrackets();
  10392. this.$highlightTags();
  10393. this.$updateHighlightActiveLine();
  10394. this._signal("changeSelection");
  10395. };
  10396. this.$updateHighlightActiveLine = function() {
  10397. var session = this.getSession();
  10398. var highlight;
  10399. if (this.$highlightActiveLine) {
  10400. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10401. highlight = this.getCursorPosition();
  10402. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10403. highlight = false;
  10404. }
  10405. if (session.$highlightLineMarker && !highlight) {
  10406. session.removeMarker(session.$highlightLineMarker.id);
  10407. session.$highlightLineMarker = null;
  10408. } else if (!session.$highlightLineMarker && highlight) {
  10409. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10410. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10411. session.$highlightLineMarker = range;
  10412. } else if (highlight) {
  10413. session.$highlightLineMarker.start.row = highlight.row;
  10414. session.$highlightLineMarker.end.row = highlight.row;
  10415. session.$highlightLineMarker.start.column = highlight.column;
  10416. session._signal("changeBackMarker");
  10417. }
  10418. };
  10419. this.onSelectionChange = function(e) {
  10420. var session = this.session;
  10421. if (session.$selectionMarker) {
  10422. session.removeMarker(session.$selectionMarker);
  10423. }
  10424. session.$selectionMarker = null;
  10425. if (!this.selection.isEmpty()) {
  10426. var range = this.selection.getRange();
  10427. var style = this.getSelectionStyle();
  10428. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10429. } else {
  10430. this.$updateHighlightActiveLine();
  10431. }
  10432. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10433. this.session.highlight(re);
  10434. this._signal("changeSelection");
  10435. };
  10436. this.$getSelectionHighLightRegexp = function() {
  10437. var session = this.session;
  10438. var selection = this.getSelectionRange();
  10439. if (selection.isEmpty() || selection.isMultiLine())
  10440. return;
  10441. var startOuter = selection.start.column - 1;
  10442. var endOuter = selection.end.column + 1;
  10443. var line = session.getLine(selection.start.row);
  10444. var lineCols = line.length;
  10445. var needle = line.substring(Math.max(startOuter, 0),
  10446. Math.min(endOuter, lineCols));
  10447. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10448. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10449. return;
  10450. needle = line.substring(selection.start.column, selection.end.column);
  10451. if (!/^[\w\d]+$/.test(needle))
  10452. return;
  10453. var re = this.$search.$assembleRegExp({
  10454. wholeWord: true,
  10455. caseSensitive: true,
  10456. needle: needle
  10457. });
  10458. return re;
  10459. };
  10460. this.onChangeFrontMarker = function() {
  10461. this.renderer.updateFrontMarkers();
  10462. };
  10463. this.onChangeBackMarker = function() {
  10464. this.renderer.updateBackMarkers();
  10465. };
  10466. this.onChangeBreakpoint = function() {
  10467. this.renderer.updateBreakpoints();
  10468. };
  10469. this.onChangeAnnotation = function() {
  10470. this.renderer.setAnnotations(this.session.getAnnotations());
  10471. };
  10472. this.onChangeMode = function(e) {
  10473. this.renderer.updateText();
  10474. this._emit("changeMode", e);
  10475. };
  10476. this.onChangeWrapLimit = function() {
  10477. this.renderer.updateFull();
  10478. };
  10479. this.onChangeWrapMode = function() {
  10480. this.renderer.onResize(true);
  10481. };
  10482. this.onChangeFold = function() {
  10483. this.$updateHighlightActiveLine();
  10484. this.renderer.updateFull();
  10485. };
  10486. this.getSelectedText = function() {
  10487. return this.session.getTextRange(this.getSelectionRange());
  10488. };
  10489. this.getCopyText = function() {
  10490. var text = this.getSelectedText();
  10491. this._signal("copy", text);
  10492. return text;
  10493. };
  10494. this.onCopy = function() {
  10495. this.commands.exec("copy", this);
  10496. };
  10497. this.onCut = function() {
  10498. this.commands.exec("cut", this);
  10499. };
  10500. this.onPaste = function(text, event) {
  10501. var e = {text: text, event: event};
  10502. this.commands.exec("paste", this, e);
  10503. };
  10504. this.$handlePaste = function(e) {
  10505. if (typeof e == "string")
  10506. e = {text: e};
  10507. this._signal("paste", e);
  10508. var text = e.text;
  10509. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10510. this.insert(text);
  10511. } else {
  10512. var lines = text.split(/\r\n|\r|\n/);
  10513. var ranges = this.selection.rangeList.ranges;
  10514. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10515. return this.commands.exec("insertstring", this, text);
  10516. for (var i = ranges.length; i--;) {
  10517. var range = ranges[i];
  10518. if (!range.isEmpty())
  10519. this.session.remove(range);
  10520. this.session.insert(range.start, lines[i]);
  10521. }
  10522. }
  10523. };
  10524. this.execCommand = function(command, args) {
  10525. return this.commands.exec(command, this, args);
  10526. };
  10527. this.insert = function(text, pasted) {
  10528. var session = this.session;
  10529. var mode = session.getMode();
  10530. var cursor = this.getCursorPosition();
  10531. if (this.getBehavioursEnabled() && !pasted) {
  10532. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10533. if (transform) {
  10534. if (text !== transform.text) {
  10535. this.session.mergeUndoDeltas = false;
  10536. this.$mergeNextCommand = false;
  10537. }
  10538. text = transform.text;
  10539. }
  10540. }
  10541. if (text == "\t")
  10542. text = this.session.getTabString();
  10543. if (!this.selection.isEmpty()) {
  10544. var range = this.getSelectionRange();
  10545. cursor = this.session.remove(range);
  10546. this.clearSelection();
  10547. }
  10548. else if (this.session.getOverwrite()) {
  10549. var range = new Range.fromPoints(cursor, cursor);
  10550. range.end.column += text.length;
  10551. this.session.remove(range);
  10552. }
  10553. if (text == "\n" || text == "\r\n") {
  10554. var line = session.getLine(cursor.row);
  10555. if (cursor.column > line.search(/\S|$/)) {
  10556. var d = line.substr(cursor.column).search(/\S|$/);
  10557. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10558. }
  10559. }
  10560. this.clearSelection();
  10561. var start = cursor.column;
  10562. var lineState = session.getState(cursor.row);
  10563. var line = session.getLine(cursor.row);
  10564. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10565. var end = session.insert(cursor, text);
  10566. if (transform && transform.selection) {
  10567. if (transform.selection.length == 2) { // Transform relative to the current column
  10568. this.selection.setSelectionRange(
  10569. new Range(cursor.row, start + transform.selection[0],
  10570. cursor.row, start + transform.selection[1]));
  10571. } else { // Transform relative to the current row.
  10572. this.selection.setSelectionRange(
  10573. new Range(cursor.row + transform.selection[0],
  10574. transform.selection[1],
  10575. cursor.row + transform.selection[2],
  10576. transform.selection[3]));
  10577. }
  10578. }
  10579. if (session.getDocument().isNewLine(text)) {
  10580. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10581. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10582. }
  10583. if (shouldOutdent)
  10584. mode.autoOutdent(lineState, session, cursor.row);
  10585. };
  10586. this.onTextInput = function(text) {
  10587. this.keyBinding.onTextInput(text);
  10588. };
  10589. this.onCommandKey = function(e, hashId, keyCode) {
  10590. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10591. };
  10592. this.setOverwrite = function(overwrite) {
  10593. this.session.setOverwrite(overwrite);
  10594. };
  10595. this.getOverwrite = function() {
  10596. return this.session.getOverwrite();
  10597. };
  10598. this.toggleOverwrite = function() {
  10599. this.session.toggleOverwrite();
  10600. };
  10601. this.setScrollSpeed = function(speed) {
  10602. this.setOption("scrollSpeed", speed);
  10603. };
  10604. this.getScrollSpeed = function() {
  10605. return this.getOption("scrollSpeed");
  10606. };
  10607. this.setDragDelay = function(dragDelay) {
  10608. this.setOption("dragDelay", dragDelay);
  10609. };
  10610. this.getDragDelay = function() {
  10611. return this.getOption("dragDelay");
  10612. };
  10613. this.setSelectionStyle = function(val) {
  10614. this.setOption("selectionStyle", val);
  10615. };
  10616. this.getSelectionStyle = function() {
  10617. return this.getOption("selectionStyle");
  10618. };
  10619. this.setHighlightActiveLine = function(shouldHighlight) {
  10620. this.setOption("highlightActiveLine", shouldHighlight);
  10621. };
  10622. this.getHighlightActiveLine = function() {
  10623. return this.getOption("highlightActiveLine");
  10624. };
  10625. this.setHighlightGutterLine = function(shouldHighlight) {
  10626. this.setOption("highlightGutterLine", shouldHighlight);
  10627. };
  10628. this.getHighlightGutterLine = function() {
  10629. return this.getOption("highlightGutterLine");
  10630. };
  10631. this.setHighlightSelectedWord = function(shouldHighlight) {
  10632. this.setOption("highlightSelectedWord", shouldHighlight);
  10633. };
  10634. this.getHighlightSelectedWord = function() {
  10635. return this.$highlightSelectedWord;
  10636. };
  10637. this.setAnimatedScroll = function(shouldAnimate){
  10638. this.renderer.setAnimatedScroll(shouldAnimate);
  10639. };
  10640. this.getAnimatedScroll = function(){
  10641. return this.renderer.getAnimatedScroll();
  10642. };
  10643. this.setShowInvisibles = function(showInvisibles) {
  10644. this.renderer.setShowInvisibles(showInvisibles);
  10645. };
  10646. this.getShowInvisibles = function() {
  10647. return this.renderer.getShowInvisibles();
  10648. };
  10649. this.setDisplayIndentGuides = function(display) {
  10650. this.renderer.setDisplayIndentGuides(display);
  10651. };
  10652. this.getDisplayIndentGuides = function() {
  10653. return this.renderer.getDisplayIndentGuides();
  10654. };
  10655. this.setShowPrintMargin = function(showPrintMargin) {
  10656. this.renderer.setShowPrintMargin(showPrintMargin);
  10657. };
  10658. this.getShowPrintMargin = function() {
  10659. return this.renderer.getShowPrintMargin();
  10660. };
  10661. this.setPrintMarginColumn = function(showPrintMargin) {
  10662. this.renderer.setPrintMarginColumn(showPrintMargin);
  10663. };
  10664. this.getPrintMarginColumn = function() {
  10665. return this.renderer.getPrintMarginColumn();
  10666. };
  10667. this.setReadOnly = function(readOnly) {
  10668. this.setOption("readOnly", readOnly);
  10669. };
  10670. this.getReadOnly = function() {
  10671. return this.getOption("readOnly");
  10672. };
  10673. this.setBehavioursEnabled = function (enabled) {
  10674. this.setOption("behavioursEnabled", enabled);
  10675. };
  10676. this.getBehavioursEnabled = function () {
  10677. return this.getOption("behavioursEnabled");
  10678. };
  10679. this.setWrapBehavioursEnabled = function (enabled) {
  10680. this.setOption("wrapBehavioursEnabled", enabled);
  10681. };
  10682. this.getWrapBehavioursEnabled = function () {
  10683. return this.getOption("wrapBehavioursEnabled");
  10684. };
  10685. this.setShowFoldWidgets = function(show) {
  10686. this.setOption("showFoldWidgets", show);
  10687. };
  10688. this.getShowFoldWidgets = function() {
  10689. return this.getOption("showFoldWidgets");
  10690. };
  10691. this.setFadeFoldWidgets = function(fade) {
  10692. this.setOption("fadeFoldWidgets", fade);
  10693. };
  10694. this.getFadeFoldWidgets = function() {
  10695. return this.getOption("fadeFoldWidgets");
  10696. };
  10697. this.remove = function(dir) {
  10698. if (this.selection.isEmpty()){
  10699. if (dir == "left")
  10700. this.selection.selectLeft();
  10701. else
  10702. this.selection.selectRight();
  10703. }
  10704. var range = this.getSelectionRange();
  10705. if (this.getBehavioursEnabled()) {
  10706. var session = this.session;
  10707. var state = session.getState(range.start.row);
  10708. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10709. if (range.end.column === 0) {
  10710. var text = session.getTextRange(range);
  10711. if (text[text.length - 1] == "\n") {
  10712. var line = session.getLine(range.end.row);
  10713. if (/^\s+$/.test(line)) {
  10714. range.end.column = line.length;
  10715. }
  10716. }
  10717. }
  10718. if (new_range)
  10719. range = new_range;
  10720. }
  10721. this.session.remove(range);
  10722. this.clearSelection();
  10723. };
  10724. this.removeWordRight = function() {
  10725. if (this.selection.isEmpty())
  10726. this.selection.selectWordRight();
  10727. this.session.remove(this.getSelectionRange());
  10728. this.clearSelection();
  10729. };
  10730. this.removeWordLeft = function() {
  10731. if (this.selection.isEmpty())
  10732. this.selection.selectWordLeft();
  10733. this.session.remove(this.getSelectionRange());
  10734. this.clearSelection();
  10735. };
  10736. this.removeToLineStart = function() {
  10737. if (this.selection.isEmpty())
  10738. this.selection.selectLineStart();
  10739. this.session.remove(this.getSelectionRange());
  10740. this.clearSelection();
  10741. };
  10742. this.removeToLineEnd = function() {
  10743. if (this.selection.isEmpty())
  10744. this.selection.selectLineEnd();
  10745. var range = this.getSelectionRange();
  10746. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10747. range.end.column = 0;
  10748. range.end.row++;
  10749. }
  10750. this.session.remove(range);
  10751. this.clearSelection();
  10752. };
  10753. this.splitLine = function() {
  10754. if (!this.selection.isEmpty()) {
  10755. this.session.remove(this.getSelectionRange());
  10756. this.clearSelection();
  10757. }
  10758. var cursor = this.getCursorPosition();
  10759. this.insert("\n");
  10760. this.moveCursorToPosition(cursor);
  10761. };
  10762. this.transposeLetters = function() {
  10763. if (!this.selection.isEmpty()) {
  10764. return;
  10765. }
  10766. var cursor = this.getCursorPosition();
  10767. var column = cursor.column;
  10768. if (column === 0)
  10769. return;
  10770. var line = this.session.getLine(cursor.row);
  10771. var swap, range;
  10772. if (column < line.length) {
  10773. swap = line.charAt(column) + line.charAt(column-1);
  10774. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10775. }
  10776. else {
  10777. swap = line.charAt(column-1) + line.charAt(column-2);
  10778. range = new Range(cursor.row, column-2, cursor.row, column);
  10779. }
  10780. this.session.replace(range, swap);
  10781. };
  10782. this.toLowerCase = function() {
  10783. var originalRange = this.getSelectionRange();
  10784. if (this.selection.isEmpty()) {
  10785. this.selection.selectWord();
  10786. }
  10787. var range = this.getSelectionRange();
  10788. var text = this.session.getTextRange(range);
  10789. this.session.replace(range, text.toLowerCase());
  10790. this.selection.setSelectionRange(originalRange);
  10791. };
  10792. this.toUpperCase = function() {
  10793. var originalRange = this.getSelectionRange();
  10794. if (this.selection.isEmpty()) {
  10795. this.selection.selectWord();
  10796. }
  10797. var range = this.getSelectionRange();
  10798. var text = this.session.getTextRange(range);
  10799. this.session.replace(range, text.toUpperCase());
  10800. this.selection.setSelectionRange(originalRange);
  10801. };
  10802. this.indent = function() {
  10803. var session = this.session;
  10804. var range = this.getSelectionRange();
  10805. if (range.start.row < range.end.row) {
  10806. var rows = this.$getSelectedRows();
  10807. session.indentRows(rows.first, rows.last, "\t");
  10808. return;
  10809. } else if (range.start.column < range.end.column) {
  10810. var text = session.getTextRange(range);
  10811. if (!/^\s+$/.test(text)) {
  10812. var rows = this.$getSelectedRows();
  10813. session.indentRows(rows.first, rows.last, "\t");
  10814. return;
  10815. }
  10816. }
  10817. var line = session.getLine(range.start.row);
  10818. var position = range.start;
  10819. var size = session.getTabSize();
  10820. var column = session.documentToScreenColumn(position.row, position.column);
  10821. if (this.session.getUseSoftTabs()) {
  10822. var count = (size - column % size);
  10823. var indentString = lang.stringRepeat(" ", count);
  10824. } else {
  10825. var count = column % size;
  10826. while (line[range.start.column] == " " && count) {
  10827. range.start.column--;
  10828. count--;
  10829. }
  10830. this.selection.setSelectionRange(range);
  10831. indentString = "\t";
  10832. }
  10833. return this.insert(indentString);
  10834. };
  10835. this.blockIndent = function() {
  10836. var rows = this.$getSelectedRows();
  10837. this.session.indentRows(rows.first, rows.last, "\t");
  10838. };
  10839. this.blockOutdent = function() {
  10840. var selection = this.session.getSelection();
  10841. this.session.outdentRows(selection.getRange());
  10842. };
  10843. this.sortLines = function() {
  10844. var rows = this.$getSelectedRows();
  10845. var session = this.session;
  10846. var lines = [];
  10847. for (i = rows.first; i <= rows.last; i++)
  10848. lines.push(session.getLine(i));
  10849. lines.sort(function(a, b) {
  10850. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10851. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10852. return 0;
  10853. });
  10854. var deleteRange = new Range(0, 0, 0, 0);
  10855. for (var i = rows.first; i <= rows.last; i++) {
  10856. var line = session.getLine(i);
  10857. deleteRange.start.row = i;
  10858. deleteRange.end.row = i;
  10859. deleteRange.end.column = line.length;
  10860. session.replace(deleteRange, lines[i-rows.first]);
  10861. }
  10862. };
  10863. this.toggleCommentLines = function() {
  10864. var state = this.session.getState(this.getCursorPosition().row);
  10865. var rows = this.$getSelectedRows();
  10866. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10867. };
  10868. this.toggleBlockComment = function() {
  10869. var cursor = this.getCursorPosition();
  10870. var state = this.session.getState(cursor.row);
  10871. var range = this.getSelectionRange();
  10872. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10873. };
  10874. this.getNumberAt = function(row, column) {
  10875. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10876. _numberRx.lastIndex = 0;
  10877. var s = this.session.getLine(row);
  10878. while (_numberRx.lastIndex < column) {
  10879. var m = _numberRx.exec(s);
  10880. if(m.index <= column && m.index+m[0].length >= column){
  10881. var number = {
  10882. value: m[0],
  10883. start: m.index,
  10884. end: m.index+m[0].length
  10885. };
  10886. return number;
  10887. }
  10888. }
  10889. return null;
  10890. };
  10891. this.modifyNumber = function(amount) {
  10892. var row = this.selection.getCursor().row;
  10893. var column = this.selection.getCursor().column;
  10894. var charRange = new Range(row, column-1, row, column);
  10895. var c = this.session.getTextRange(charRange);
  10896. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10897. var nr = this.getNumberAt(row, column);
  10898. if (nr) {
  10899. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10900. var decimals = nr.start + nr.value.length - fp;
  10901. var t = parseFloat(nr.value);
  10902. t *= Math.pow(10, decimals);
  10903. if(fp !== nr.end && column < fp){
  10904. amount *= Math.pow(10, nr.end - column - 1);
  10905. } else {
  10906. amount *= Math.pow(10, nr.end - column);
  10907. }
  10908. t += amount;
  10909. t /= Math.pow(10, decimals);
  10910. var nnr = t.toFixed(decimals);
  10911. var replaceRange = new Range(row, nr.start, row, nr.end);
  10912. this.session.replace(replaceRange, nnr);
  10913. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10914. }
  10915. }
  10916. };
  10917. this.removeLines = function() {
  10918. var rows = this.$getSelectedRows();
  10919. this.session.removeFullLines(rows.first, rows.last);
  10920. this.clearSelection();
  10921. };
  10922. this.duplicateSelection = function() {
  10923. var sel = this.selection;
  10924. var doc = this.session;
  10925. var range = sel.getRange();
  10926. var reverse = sel.isBackwards();
  10927. if (range.isEmpty()) {
  10928. var row = range.start.row;
  10929. doc.duplicateLines(row, row);
  10930. } else {
  10931. var point = reverse ? range.start : range.end;
  10932. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10933. range.start = point;
  10934. range.end = endPoint;
  10935. sel.setSelectionRange(range, reverse);
  10936. }
  10937. };
  10938. this.moveLinesDown = function() {
  10939. this.$moveLines(1, false);
  10940. };
  10941. this.moveLinesUp = function() {
  10942. this.$moveLines(-1, false);
  10943. };
  10944. this.moveText = function(range, toPosition, copy) {
  10945. return this.session.moveText(range, toPosition, copy);
  10946. };
  10947. this.copyLinesUp = function() {
  10948. this.$moveLines(-1, true);
  10949. };
  10950. this.copyLinesDown = function() {
  10951. this.$moveLines(1, true);
  10952. };
  10953. this.$moveLines = function(dir, copy) {
  10954. var rows, moved;
  10955. var selection = this.selection;
  10956. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10957. var range = selection.toOrientedRange();
  10958. rows = this.$getSelectedRows(range);
  10959. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10960. if (copy && dir == -1) moved = 0;
  10961. range.moveBy(moved, 0);
  10962. selection.fromOrientedRange(range);
  10963. } else {
  10964. var ranges = selection.rangeList.ranges;
  10965. selection.rangeList.detach(this.session);
  10966. this.inVirtualSelectionMode = true;
  10967. var diff = 0;
  10968. var totalDiff = 0;
  10969. var l = ranges.length;
  10970. for (var i = 0; i < l; i++) {
  10971. var rangeIndex = i;
  10972. ranges[i].moveBy(diff, 0);
  10973. rows = this.$getSelectedRows(ranges[i]);
  10974. var first = rows.first;
  10975. var last = rows.last;
  10976. while (++i < l) {
  10977. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10978. var subRows = this.$getSelectedRows(ranges[i]);
  10979. if (copy && subRows.first != last)
  10980. break;
  10981. else if (!copy && subRows.first > last + 1)
  10982. break;
  10983. last = subRows.last;
  10984. }
  10985. i--;
  10986. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10987. if (copy && dir == -1) rangeIndex = i + 1;
  10988. while (rangeIndex <= i) {
  10989. ranges[rangeIndex].moveBy(diff, 0);
  10990. rangeIndex++;
  10991. }
  10992. if (!copy) diff = 0;
  10993. totalDiff += diff;
  10994. }
  10995. selection.fromOrientedRange(selection.ranges[0]);
  10996. selection.rangeList.attach(this.session);
  10997. this.inVirtualSelectionMode = false;
  10998. }
  10999. };
  11000. this.$getSelectedRows = function(range) {
  11001. range = (range || this.getSelectionRange()).collapseRows();
  11002. return {
  11003. first: this.session.getRowFoldStart(range.start.row),
  11004. last: this.session.getRowFoldEnd(range.end.row)
  11005. };
  11006. };
  11007. this.onCompositionStart = function(text) {
  11008. this.renderer.showComposition(this.getCursorPosition());
  11009. };
  11010. this.onCompositionUpdate = function(text) {
  11011. this.renderer.setCompositionText(text);
  11012. };
  11013. this.onCompositionEnd = function() {
  11014. this.renderer.hideComposition();
  11015. };
  11016. this.getFirstVisibleRow = function() {
  11017. return this.renderer.getFirstVisibleRow();
  11018. };
  11019. this.getLastVisibleRow = function() {
  11020. return this.renderer.getLastVisibleRow();
  11021. };
  11022. this.isRowVisible = function(row) {
  11023. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  11024. };
  11025. this.isRowFullyVisible = function(row) {
  11026. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  11027. };
  11028. this.$getVisibleRowCount = function() {
  11029. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  11030. };
  11031. this.$moveByPage = function(dir, select) {
  11032. var renderer = this.renderer;
  11033. var config = this.renderer.layerConfig;
  11034. var rows = dir * Math.floor(config.height / config.lineHeight);
  11035. this.$blockScrolling++;
  11036. if (select === true) {
  11037. this.selection.$moveSelection(function(){
  11038. this.moveCursorBy(rows, 0);
  11039. });
  11040. } else if (select === false) {
  11041. this.selection.moveCursorBy(rows, 0);
  11042. this.selection.clearSelection();
  11043. }
  11044. this.$blockScrolling--;
  11045. var scrollTop = renderer.scrollTop;
  11046. renderer.scrollBy(0, rows * config.lineHeight);
  11047. if (select != null)
  11048. renderer.scrollCursorIntoView(null, 0.5);
  11049. renderer.animateScrolling(scrollTop);
  11050. };
  11051. this.selectPageDown = function() {
  11052. this.$moveByPage(1, true);
  11053. };
  11054. this.selectPageUp = function() {
  11055. this.$moveByPage(-1, true);
  11056. };
  11057. this.gotoPageDown = function() {
  11058. this.$moveByPage(1, false);
  11059. };
  11060. this.gotoPageUp = function() {
  11061. this.$moveByPage(-1, false);
  11062. };
  11063. this.scrollPageDown = function() {
  11064. this.$moveByPage(1);
  11065. };
  11066. this.scrollPageUp = function() {
  11067. this.$moveByPage(-1);
  11068. };
  11069. this.scrollToRow = function(row) {
  11070. this.renderer.scrollToRow(row);
  11071. };
  11072. this.scrollToLine = function(line, center, animate, callback) {
  11073. this.renderer.scrollToLine(line, center, animate, callback);
  11074. };
  11075. this.centerSelection = function() {
  11076. var range = this.getSelectionRange();
  11077. var pos = {
  11078. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  11079. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  11080. };
  11081. this.renderer.alignCursor(pos, 0.5);
  11082. };
  11083. this.getCursorPosition = function() {
  11084. return this.selection.getCursor();
  11085. };
  11086. this.getCursorPositionScreen = function() {
  11087. return this.session.documentToScreenPosition(this.getCursorPosition());
  11088. };
  11089. this.getSelectionRange = function() {
  11090. return this.selection.getRange();
  11091. };
  11092. this.selectAll = function() {
  11093. this.$blockScrolling += 1;
  11094. this.selection.selectAll();
  11095. this.$blockScrolling -= 1;
  11096. };
  11097. this.clearSelection = function() {
  11098. this.selection.clearSelection();
  11099. };
  11100. this.moveCursorTo = function(row, column) {
  11101. this.selection.moveCursorTo(row, column);
  11102. };
  11103. this.moveCursorToPosition = function(pos) {
  11104. this.selection.moveCursorToPosition(pos);
  11105. };
  11106. this.jumpToMatching = function(select, expand) {
  11107. var cursor = this.getCursorPosition();
  11108. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  11109. var prevToken = iterator.getCurrentToken();
  11110. var token = prevToken || iterator.stepForward();
  11111. if (!token) return;
  11112. var matchType;
  11113. var found = false;
  11114. var depth = {};
  11115. var i = cursor.column - token.start;
  11116. var bracketType;
  11117. var brackets = {
  11118. ")": "(",
  11119. "(": "(",
  11120. "]": "[",
  11121. "[": "[",
  11122. "{": "{",
  11123. "}": "{"
  11124. };
  11125. do {
  11126. if (token.value.match(/[{}()\[\]]/g)) {
  11127. for (; i < token.value.length && !found; i++) {
  11128. if (!brackets[token.value[i]]) {
  11129. continue;
  11130. }
  11131. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  11132. if (isNaN(depth[bracketType])) {
  11133. depth[bracketType] = 0;
  11134. }
  11135. switch (token.value[i]) {
  11136. case '(':
  11137. case '[':
  11138. case '{':
  11139. depth[bracketType]++;
  11140. break;
  11141. case ')':
  11142. case ']':
  11143. case '}':
  11144. depth[bracketType]--;
  11145. if (depth[bracketType] === -1) {
  11146. matchType = 'bracket';
  11147. found = true;
  11148. }
  11149. break;
  11150. }
  11151. }
  11152. }
  11153. else if (token && token.type.indexOf('tag-name') !== -1) {
  11154. if (isNaN(depth[token.value])) {
  11155. depth[token.value] = 0;
  11156. }
  11157. if (prevToken.value === '<') {
  11158. depth[token.value]++;
  11159. }
  11160. else if (prevToken.value === '</') {
  11161. depth[token.value]--;
  11162. }
  11163. if (depth[token.value] === -1) {
  11164. matchType = 'tag';
  11165. found = true;
  11166. }
  11167. }
  11168. if (!found) {
  11169. prevToken = token;
  11170. token = iterator.stepForward();
  11171. i = 0;
  11172. }
  11173. } while (token && !found);
  11174. if (!matchType)
  11175. return;
  11176. var range, pos;
  11177. if (matchType === 'bracket') {
  11178. range = this.session.getBracketRange(cursor);
  11179. if (!range) {
  11180. range = new Range(
  11181. iterator.getCurrentTokenRow(),
  11182. iterator.getCurrentTokenColumn() + i - 1,
  11183. iterator.getCurrentTokenRow(),
  11184. iterator.getCurrentTokenColumn() + i - 1
  11185. );
  11186. pos = range.start;
  11187. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11188. range = this.session.getBracketRange(pos);
  11189. }
  11190. }
  11191. else if (matchType === 'tag') {
  11192. if (token && token.type.indexOf('tag-name') !== -1)
  11193. var tag = token.value;
  11194. else
  11195. return;
  11196. range = new Range(
  11197. iterator.getCurrentTokenRow(),
  11198. iterator.getCurrentTokenColumn() - 2,
  11199. iterator.getCurrentTokenRow(),
  11200. iterator.getCurrentTokenColumn() - 2
  11201. );
  11202. if (range.compare(cursor.row, cursor.column) === 0) {
  11203. found = false;
  11204. do {
  11205. token = prevToken;
  11206. prevToken = iterator.stepBackward();
  11207. if (prevToken) {
  11208. if (prevToken.type.indexOf('tag-close') !== -1) {
  11209. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11210. }
  11211. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11212. if (prevToken.value === '<') {
  11213. depth[tag]++;
  11214. }
  11215. else if (prevToken.value === '</') {
  11216. depth[tag]--;
  11217. }
  11218. if (depth[tag] === 0)
  11219. found = true;
  11220. }
  11221. }
  11222. } while (prevToken && !found);
  11223. }
  11224. if (token && token.type.indexOf('tag-name')) {
  11225. pos = range.start;
  11226. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11227. pos = range.end;
  11228. }
  11229. }
  11230. pos = range && range.cursor || pos;
  11231. if (pos) {
  11232. if (select) {
  11233. if (range && expand) {
  11234. this.selection.setRange(range);
  11235. } else if (range && range.isEqual(this.getSelectionRange())) {
  11236. this.clearSelection();
  11237. } else {
  11238. this.selection.selectTo(pos.row, pos.column);
  11239. }
  11240. } else {
  11241. this.selection.moveTo(pos.row, pos.column);
  11242. }
  11243. }
  11244. };
  11245. this.gotoLine = function(lineNumber, column, animate) {
  11246. this.selection.clearSelection();
  11247. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11248. this.$blockScrolling += 1;
  11249. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11250. this.moveCursorTo(lineNumber - 1, column || 0);
  11251. this.$blockScrolling -= 1;
  11252. if (!this.isRowFullyVisible(lineNumber - 1))
  11253. this.scrollToLine(lineNumber - 1, true, animate);
  11254. };
  11255. this.navigateTo = function(row, column) {
  11256. this.selection.moveTo(row, column);
  11257. };
  11258. this.navigateUp = function(times) {
  11259. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11260. var selectionStart = this.selection.anchor.getPosition();
  11261. return this.moveCursorToPosition(selectionStart);
  11262. }
  11263. this.selection.clearSelection();
  11264. this.selection.moveCursorBy(-times || -1, 0);
  11265. };
  11266. this.navigateDown = function(times) {
  11267. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11268. var selectionEnd = this.selection.anchor.getPosition();
  11269. return this.moveCursorToPosition(selectionEnd);
  11270. }
  11271. this.selection.clearSelection();
  11272. this.selection.moveCursorBy(times || 1, 0);
  11273. };
  11274. this.navigateLeft = function(times) {
  11275. if (!this.selection.isEmpty()) {
  11276. var selectionStart = this.getSelectionRange().start;
  11277. this.moveCursorToPosition(selectionStart);
  11278. }
  11279. else {
  11280. times = times || 1;
  11281. while (times--) {
  11282. this.selection.moveCursorLeft();
  11283. }
  11284. }
  11285. this.clearSelection();
  11286. };
  11287. this.navigateRight = function(times) {
  11288. if (!this.selection.isEmpty()) {
  11289. var selectionEnd = this.getSelectionRange().end;
  11290. this.moveCursorToPosition(selectionEnd);
  11291. }
  11292. else {
  11293. times = times || 1;
  11294. while (times--) {
  11295. this.selection.moveCursorRight();
  11296. }
  11297. }
  11298. this.clearSelection();
  11299. };
  11300. this.navigateLineStart = function() {
  11301. this.selection.moveCursorLineStart();
  11302. this.clearSelection();
  11303. };
  11304. this.navigateLineEnd = function() {
  11305. this.selection.moveCursorLineEnd();
  11306. this.clearSelection();
  11307. };
  11308. this.navigateFileEnd = function() {
  11309. this.selection.moveCursorFileEnd();
  11310. this.clearSelection();
  11311. };
  11312. this.navigateFileStart = function() {
  11313. this.selection.moveCursorFileStart();
  11314. this.clearSelection();
  11315. };
  11316. this.navigateWordRight = function() {
  11317. this.selection.moveCursorWordRight();
  11318. this.clearSelection();
  11319. };
  11320. this.navigateWordLeft = function() {
  11321. this.selection.moveCursorWordLeft();
  11322. this.clearSelection();
  11323. };
  11324. this.replace = function(replacement, options) {
  11325. if (options)
  11326. this.$search.set(options);
  11327. var range = this.$search.find(this.session);
  11328. var replaced = 0;
  11329. if (!range)
  11330. return replaced;
  11331. if (this.$tryReplace(range, replacement)) {
  11332. replaced = 1;
  11333. }
  11334. if (range !== null) {
  11335. this.selection.setSelectionRange(range);
  11336. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11337. }
  11338. return replaced;
  11339. };
  11340. this.replaceAll = function(replacement, options) {
  11341. if (options) {
  11342. this.$search.set(options);
  11343. }
  11344. var ranges = this.$search.findAll(this.session);
  11345. var replaced = 0;
  11346. if (!ranges.length)
  11347. return replaced;
  11348. this.$blockScrolling += 1;
  11349. var selection = this.getSelectionRange();
  11350. this.selection.moveTo(0, 0);
  11351. for (var i = ranges.length - 1; i >= 0; --i) {
  11352. if(this.$tryReplace(ranges[i], replacement)) {
  11353. replaced++;
  11354. }
  11355. }
  11356. this.selection.setSelectionRange(selection);
  11357. this.$blockScrolling -= 1;
  11358. return replaced;
  11359. };
  11360. this.$tryReplace = function(range, replacement) {
  11361. var input = this.session.getTextRange(range);
  11362. replacement = this.$search.replace(input, replacement);
  11363. if (replacement !== null) {
  11364. range.end = this.session.replace(range, replacement);
  11365. return range;
  11366. } else {
  11367. return null;
  11368. }
  11369. };
  11370. this.getLastSearchOptions = function() {
  11371. return this.$search.getOptions();
  11372. };
  11373. this.find = function(needle, options, animate) {
  11374. if (!options)
  11375. options = {};
  11376. if (typeof needle == "string" || needle instanceof RegExp)
  11377. options.needle = needle;
  11378. else if (typeof needle == "object")
  11379. oop.mixin(options, needle);
  11380. var range = this.selection.getRange();
  11381. if (options.needle == null) {
  11382. needle = this.session.getTextRange(range)
  11383. || this.$search.$options.needle;
  11384. if (!needle) {
  11385. range = this.session.getWordRange(range.start.row, range.start.column);
  11386. needle = this.session.getTextRange(range);
  11387. }
  11388. this.$search.set({needle: needle});
  11389. }
  11390. this.$search.set(options);
  11391. if (!options.start)
  11392. this.$search.set({start: range});
  11393. var newRange = this.$search.find(this.session);
  11394. if (options.preventScroll)
  11395. return newRange;
  11396. if (newRange) {
  11397. this.revealRange(newRange, animate);
  11398. return newRange;
  11399. }
  11400. if (options.backwards)
  11401. range.start = range.end;
  11402. else
  11403. range.end = range.start;
  11404. this.selection.setRange(range);
  11405. };
  11406. this.findNext = function(options, animate) {
  11407. this.find({skipCurrent: true, backwards: false}, options, animate);
  11408. };
  11409. this.findPrevious = function(options, animate) {
  11410. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11411. };
  11412. this.revealRange = function(range, animate) {
  11413. this.$blockScrolling += 1;
  11414. this.session.unfold(range);
  11415. this.selection.setSelectionRange(range);
  11416. this.$blockScrolling -= 1;
  11417. var scrollTop = this.renderer.scrollTop;
  11418. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11419. if (animate !== false)
  11420. this.renderer.animateScrolling(scrollTop);
  11421. };
  11422. this.undo = function() {
  11423. this.$blockScrolling++;
  11424. this.session.getUndoManager().undo();
  11425. this.$blockScrolling--;
  11426. this.renderer.scrollCursorIntoView(null, 0.5);
  11427. };
  11428. this.redo = function() {
  11429. this.$blockScrolling++;
  11430. this.session.getUndoManager().redo();
  11431. this.$blockScrolling--;
  11432. this.renderer.scrollCursorIntoView(null, 0.5);
  11433. };
  11434. this.destroy = function() {
  11435. this.renderer.destroy();
  11436. this._signal("destroy", this);
  11437. if (this.session) {
  11438. this.session.destroy();
  11439. }
  11440. };
  11441. this.setAutoScrollEditorIntoView = function(enable) {
  11442. if (!enable)
  11443. return;
  11444. var rect;
  11445. var self = this;
  11446. var shouldScroll = false;
  11447. if (!this.$scrollAnchor)
  11448. this.$scrollAnchor = document.createElement("div");
  11449. var scrollAnchor = this.$scrollAnchor;
  11450. scrollAnchor.style.cssText = "position:absolute";
  11451. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11452. var onChangeSelection = this.on("changeSelection", function() {
  11453. shouldScroll = true;
  11454. });
  11455. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11456. if (shouldScroll)
  11457. rect = self.renderer.container.getBoundingClientRect();
  11458. });
  11459. var onAfterRender = this.renderer.on("afterRender", function() {
  11460. if (shouldScroll && rect && (self.isFocused()
  11461. || self.searchBox && self.searchBox.isFocused())
  11462. ) {
  11463. var renderer = self.renderer;
  11464. var pos = renderer.$cursorLayer.$pixelPos;
  11465. var config = renderer.layerConfig;
  11466. var top = pos.top - config.offset;
  11467. if (pos.top >= 0 && top + rect.top < 0) {
  11468. shouldScroll = true;
  11469. } else if (pos.top < config.height &&
  11470. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11471. shouldScroll = false;
  11472. } else {
  11473. shouldScroll = null;
  11474. }
  11475. if (shouldScroll != null) {
  11476. scrollAnchor.style.top = top + "px";
  11477. scrollAnchor.style.left = pos.left + "px";
  11478. scrollAnchor.style.height = config.lineHeight + "px";
  11479. scrollAnchor.scrollIntoView(shouldScroll);
  11480. }
  11481. shouldScroll = rect = null;
  11482. }
  11483. });
  11484. this.setAutoScrollEditorIntoView = function(enable) {
  11485. if (enable)
  11486. return;
  11487. delete this.setAutoScrollEditorIntoView;
  11488. this.removeEventListener("changeSelection", onChangeSelection);
  11489. this.renderer.removeEventListener("afterRender", onAfterRender);
  11490. this.renderer.removeEventListener("beforeRender", onBeforeRender);
  11491. };
  11492. };
  11493. this.$resetCursorStyle = function() {
  11494. var style = this.$cursorStyle || "ace";
  11495. var cursorLayer = this.renderer.$cursorLayer;
  11496. if (!cursorLayer)
  11497. return;
  11498. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11499. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11500. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11501. };
  11502. }).call(Editor.prototype);
  11503. config.defineOptions(Editor.prototype, "editor", {
  11504. selectionStyle: {
  11505. set: function(style) {
  11506. this.onSelectionChange();
  11507. this._signal("changeSelectionStyle", {data: style});
  11508. },
  11509. initialValue: "line"
  11510. },
  11511. highlightActiveLine: {
  11512. set: function() {this.$updateHighlightActiveLine();},
  11513. initialValue: true
  11514. },
  11515. highlightSelectedWord: {
  11516. set: function(shouldHighlight) {this.$onSelectionChange();},
  11517. initialValue: true
  11518. },
  11519. readOnly: {
  11520. set: function(readOnly) {
  11521. this.$resetCursorStyle();
  11522. },
  11523. initialValue: false
  11524. },
  11525. cursorStyle: {
  11526. set: function(val) { this.$resetCursorStyle(); },
  11527. values: ["ace", "slim", "smooth", "wide"],
  11528. initialValue: "ace"
  11529. },
  11530. mergeUndoDeltas: {
  11531. values: [false, true, "always"],
  11532. initialValue: true
  11533. },
  11534. behavioursEnabled: {initialValue: true},
  11535. wrapBehavioursEnabled: {initialValue: true},
  11536. autoScrollEditorIntoView: {
  11537. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11538. },
  11539. hScrollBarAlwaysVisible: "renderer",
  11540. vScrollBarAlwaysVisible: "renderer",
  11541. highlightGutterLine: "renderer",
  11542. animatedScroll: "renderer",
  11543. showInvisibles: "renderer",
  11544. showPrintMargin: "renderer",
  11545. printMarginColumn: "renderer",
  11546. printMargin: "renderer",
  11547. fadeFoldWidgets: "renderer",
  11548. showFoldWidgets: "renderer",
  11549. showLineNumbers: "renderer",
  11550. showGutter: "renderer",
  11551. displayIndentGuides: "renderer",
  11552. fontSize: "renderer",
  11553. fontFamily: "renderer",
  11554. maxLines: "renderer",
  11555. minLines: "renderer",
  11556. scrollPastEnd: "renderer",
  11557. fixedWidthGutter: "renderer",
  11558. theme: "renderer",
  11559. scrollSpeed: "$mouseHandler",
  11560. dragDelay: "$mouseHandler",
  11561. dragEnabled: "$mouseHandler",
  11562. focusTimout: "$mouseHandler",
  11563. tooltipFollowsMouse: "$mouseHandler",
  11564. firstLineNumber: "session",
  11565. overwrite: "session",
  11566. newLineMode: "session",
  11567. useWorker: "session",
  11568. useSoftTabs: "session",
  11569. tabSize: "session",
  11570. wrap: "session",
  11571. indentedSoftWrap: "session",
  11572. foldStyle: "session",
  11573. mode: "session"
  11574. });
  11575. exports.Editor = Editor;
  11576. });
  11577. define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11578. "use strict";
  11579. var UndoManager = function() {
  11580. this.reset();
  11581. };
  11582. (function() {
  11583. this.execute = function(options) {
  11584. var deltaSets = options.args[0];
  11585. this.$doc = options.args[1];
  11586. if (options.merge && this.hasUndo()){
  11587. this.dirtyCounter--;
  11588. deltaSets = this.$undoStack.pop().concat(deltaSets);
  11589. }
  11590. this.$undoStack.push(deltaSets);
  11591. this.$redoStack = [];
  11592. if (this.dirtyCounter < 0) {
  11593. this.dirtyCounter = NaN;
  11594. }
  11595. this.dirtyCounter++;
  11596. };
  11597. this.undo = function(dontSelect) {
  11598. var deltaSets = this.$undoStack.pop();
  11599. var undoSelectionRange = null;
  11600. if (deltaSets) {
  11601. undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
  11602. this.$redoStack.push(deltaSets);
  11603. this.dirtyCounter--;
  11604. }
  11605. return undoSelectionRange;
  11606. };
  11607. this.redo = function(dontSelect) {
  11608. var deltaSets = this.$redoStack.pop();
  11609. var redoSelectionRange = null;
  11610. if (deltaSets) {
  11611. redoSelectionRange =
  11612. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11613. this.$undoStack.push(deltaSets);
  11614. this.dirtyCounter++;
  11615. }
  11616. return redoSelectionRange;
  11617. };
  11618. this.reset = function() {
  11619. this.$undoStack = [];
  11620. this.$redoStack = [];
  11621. this.dirtyCounter = 0;
  11622. };
  11623. this.hasUndo = function() {
  11624. return this.$undoStack.length > 0;
  11625. };
  11626. this.hasRedo = function() {
  11627. return this.$redoStack.length > 0;
  11628. };
  11629. this.markClean = function() {
  11630. this.dirtyCounter = 0;
  11631. };
  11632. this.isClean = function() {
  11633. return this.dirtyCounter === 0;
  11634. };
  11635. this.$serializeDeltas = function(deltaSets) {
  11636. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  11637. };
  11638. this.$deserializeDeltas = function(deltaSets) {
  11639. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  11640. };
  11641. function $serializeDelta(delta){
  11642. return {
  11643. action: delta.action,
  11644. start: delta.start,
  11645. end: delta.end,
  11646. lines: delta.lines.length == 1 ? null : delta.lines,
  11647. text: delta.lines.length == 1 ? delta.lines[0] : null,
  11648. };
  11649. }
  11650. function $deserializeDelta(delta) {
  11651. return {
  11652. action: delta.action,
  11653. start: delta.start,
  11654. end: delta.end,
  11655. lines: delta.lines || [delta.text]
  11656. };
  11657. }
  11658. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  11659. var deltaSets_new = new Array(deltaSets_old.length);
  11660. for (var i = 0; i < deltaSets_old.length; i++) {
  11661. var deltaSet_old = deltaSets_old[i];
  11662. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  11663. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  11664. var delta_old = deltaSet_old.deltas[j];
  11665. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  11666. }
  11667. deltaSets_new[i] = deltaSet_new;
  11668. }
  11669. return deltaSets_new;
  11670. }
  11671. }).call(UndoManager.prototype);
  11672. exports.UndoManager = UndoManager;
  11673. });
  11674. define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
  11675. "use strict";
  11676. var dom = require("../lib/dom");
  11677. var oop = require("../lib/oop");
  11678. var lang = require("../lib/lang");
  11679. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11680. var Gutter = function(parentEl) {
  11681. this.element = dom.createElement("div");
  11682. this.element.className = "ace_layer ace_gutter-layer";
  11683. parentEl.appendChild(this.element);
  11684. this.setShowFoldWidgets(this.$showFoldWidgets);
  11685. this.gutterWidth = 0;
  11686. this.$annotations = [];
  11687. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11688. this.$cells = [];
  11689. };
  11690. (function() {
  11691. oop.implement(this, EventEmitter);
  11692. this.setSession = function(session) {
  11693. if (this.session)
  11694. this.session.removeEventListener("change", this.$updateAnnotations);
  11695. this.session = session;
  11696. if (session)
  11697. session.on("change", this.$updateAnnotations);
  11698. };
  11699. this.addGutterDecoration = function(row, className){
  11700. if (window.console)
  11701. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11702. this.session.addGutterDecoration(row, className);
  11703. };
  11704. this.removeGutterDecoration = function(row, className){
  11705. if (window.console)
  11706. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11707. this.session.removeGutterDecoration(row, className);
  11708. };
  11709. this.setAnnotations = function(annotations) {
  11710. this.$annotations = [];
  11711. for (var i = 0; i < annotations.length; i++) {
  11712. var annotation = annotations[i];
  11713. var row = annotation.row;
  11714. var rowInfo = this.$annotations[row];
  11715. if (!rowInfo)
  11716. rowInfo = this.$annotations[row] = {text: []};
  11717. var annoText = annotation.text;
  11718. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11719. if (rowInfo.text.indexOf(annoText) === -1)
  11720. rowInfo.text.push(annoText);
  11721. var type = annotation.type;
  11722. if (type == "error")
  11723. rowInfo.className = " ace_error";
  11724. else if (type == "warning" && rowInfo.className != " ace_error")
  11725. rowInfo.className = " ace_warning";
  11726. else if (type == "info" && (!rowInfo.className))
  11727. rowInfo.className = " ace_info";
  11728. }
  11729. };
  11730. this.$updateAnnotations = function (delta) {
  11731. if (!this.$annotations.length)
  11732. return;
  11733. var firstRow = delta.start.row;
  11734. var len = delta.end.row - firstRow;
  11735. if (len === 0) {
  11736. } else if (delta.action == 'remove') {
  11737. this.$annotations.splice(firstRow, len + 1, null);
  11738. } else {
  11739. var args = new Array(len + 1);
  11740. args.unshift(firstRow, 1);
  11741. this.$annotations.splice.apply(this.$annotations, args);
  11742. }
  11743. };
  11744. this.update = function(config) {
  11745. var session = this.session;
  11746. var firstRow = config.firstRow;
  11747. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11748. session.getLength() - 1);
  11749. var fold = session.getNextFoldLine(firstRow);
  11750. var foldStart = fold ? fold.start.row : Infinity;
  11751. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11752. var breakpoints = session.$breakpoints;
  11753. var decorations = session.$decorations;
  11754. var firstLineNumber = session.$firstLineNumber;
  11755. var lastLineNumber = 0;
  11756. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11757. var cell = null;
  11758. var index = -1;
  11759. var row = firstRow;
  11760. while (true) {
  11761. if (row > foldStart) {
  11762. row = fold.end.row + 1;
  11763. fold = session.getNextFoldLine(row, fold);
  11764. foldStart = fold ? fold.start.row : Infinity;
  11765. }
  11766. if (row > lastRow) {
  11767. while (this.$cells.length > index + 1) {
  11768. cell = this.$cells.pop();
  11769. this.element.removeChild(cell.element);
  11770. }
  11771. break;
  11772. }
  11773. cell = this.$cells[++index];
  11774. if (!cell) {
  11775. cell = {element: null, textNode: null, foldWidget: null};
  11776. cell.element = dom.createElement("div");
  11777. cell.textNode = document.createTextNode('');
  11778. cell.element.appendChild(cell.textNode);
  11779. this.element.appendChild(cell.element);
  11780. this.$cells[index] = cell;
  11781. }
  11782. var className = "ace_gutter-cell ";
  11783. if (breakpoints[row])
  11784. className += breakpoints[row];
  11785. if (decorations[row])
  11786. className += decorations[row];
  11787. if (this.$annotations[row])
  11788. className += this.$annotations[row].className;
  11789. if (cell.element.className != className)
  11790. cell.element.className = className;
  11791. var height = session.getRowLength(row) * config.lineHeight + "px";
  11792. if (height != cell.element.style.height)
  11793. cell.element.style.height = height;
  11794. if (foldWidgets) {
  11795. var c = foldWidgets[row];
  11796. if (c == null)
  11797. c = foldWidgets[row] = session.getFoldWidget(row);
  11798. }
  11799. if (c) {
  11800. if (!cell.foldWidget) {
  11801. cell.foldWidget = dom.createElement("span");
  11802. cell.element.appendChild(cell.foldWidget);
  11803. }
  11804. var className = "ace_fold-widget ace_" + c;
  11805. if (c == "start" && row == foldStart && row < fold.end.row)
  11806. className += " ace_closed";
  11807. else
  11808. className += " ace_open";
  11809. if (cell.foldWidget.className != className)
  11810. cell.foldWidget.className = className;
  11811. var height = config.lineHeight + "px";
  11812. if (cell.foldWidget.style.height != height)
  11813. cell.foldWidget.style.height = height;
  11814. } else {
  11815. if (cell.foldWidget) {
  11816. cell.element.removeChild(cell.foldWidget);
  11817. cell.foldWidget = null;
  11818. }
  11819. }
  11820. var text = lastLineNumber = gutterRenderer
  11821. ? gutterRenderer.getText(session, row)
  11822. : row + firstLineNumber;
  11823. if (text != cell.textNode.data)
  11824. cell.textNode.data = text;
  11825. row++;
  11826. }
  11827. this.element.style.height = config.minHeight + "px";
  11828. if (this.$fixedWidth || session.$useWrapMode)
  11829. lastLineNumber = session.getLength() + firstLineNumber;
  11830. var gutterWidth = gutterRenderer
  11831. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11832. : lastLineNumber.toString().length * config.characterWidth;
  11833. var padding = this.$padding || this.$computePadding();
  11834. gutterWidth += padding.left + padding.right;
  11835. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11836. this.gutterWidth = gutterWidth;
  11837. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11838. this._emit("changeGutterWidth", gutterWidth);
  11839. }
  11840. };
  11841. this.$fixedWidth = false;
  11842. this.$showLineNumbers = true;
  11843. this.$renderer = "";
  11844. this.setShowLineNumbers = function(show) {
  11845. this.$renderer = !show && {
  11846. getWidth: function() {return ""},
  11847. getText: function() {return ""}
  11848. };
  11849. };
  11850. this.getShowLineNumbers = function() {
  11851. return this.$showLineNumbers;
  11852. };
  11853. this.$showFoldWidgets = true;
  11854. this.setShowFoldWidgets = function(show) {
  11855. if (show)
  11856. dom.addCssClass(this.element, "ace_folding-enabled");
  11857. else
  11858. dom.removeCssClass(this.element, "ace_folding-enabled");
  11859. this.$showFoldWidgets = show;
  11860. this.$padding = null;
  11861. };
  11862. this.getShowFoldWidgets = function() {
  11863. return this.$showFoldWidgets;
  11864. };
  11865. this.$computePadding = function() {
  11866. if (!this.element.firstChild)
  11867. return {left: 0, right: 0};
  11868. var style = dom.computedStyle(this.element.firstChild);
  11869. this.$padding = {};
  11870. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11871. this.$padding.right = parseInt(style.paddingRight) || 0;
  11872. return this.$padding;
  11873. };
  11874. this.getRegion = function(point) {
  11875. var padding = this.$padding || this.$computePadding();
  11876. var rect = this.element.getBoundingClientRect();
  11877. if (point.x < padding.left + rect.left)
  11878. return "markers";
  11879. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11880. return "foldWidgets";
  11881. };
  11882. }).call(Gutter.prototype);
  11883. exports.Gutter = Gutter;
  11884. });
  11885. define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11886. "use strict";
  11887. var Range = require("../range").Range;
  11888. var dom = require("../lib/dom");
  11889. var Marker = function(parentEl) {
  11890. this.element = dom.createElement("div");
  11891. this.element.className = "ace_layer ace_marker-layer";
  11892. parentEl.appendChild(this.element);
  11893. };
  11894. (function() {
  11895. this.$padding = 0;
  11896. this.setPadding = function(padding) {
  11897. this.$padding = padding;
  11898. };
  11899. this.setSession = function(session) {
  11900. this.session = session;
  11901. };
  11902. this.setMarkers = function(markers) {
  11903. this.markers = markers;
  11904. };
  11905. this.update = function(config) {
  11906. var config = config || this.config;
  11907. if (!config)
  11908. return;
  11909. this.config = config;
  11910. var html = [];
  11911. for (var key in this.markers) {
  11912. var marker = this.markers[key];
  11913. if (!marker.range) {
  11914. marker.update(html, this, this.session, config);
  11915. continue;
  11916. }
  11917. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11918. if (range.isEmpty()) continue;
  11919. range = range.toScreenRange(this.session);
  11920. if (marker.renderer) {
  11921. var top = this.$getTop(range.start.row, config);
  11922. var left = this.$padding + range.start.column * config.characterWidth;
  11923. marker.renderer(html, range, left, top, config);
  11924. } else if (marker.type == "fullLine") {
  11925. this.drawFullLineMarker(html, range, marker.clazz, config);
  11926. } else if (marker.type == "screenLine") {
  11927. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11928. } else if (range.isMultiLine()) {
  11929. if (marker.type == "text")
  11930. this.drawTextMarker(html, range, marker.clazz, config);
  11931. else
  11932. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11933. } else {
  11934. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  11935. }
  11936. }
  11937. this.element.innerHTML = html.join("");
  11938. };
  11939. this.$getTop = function(row, layerConfig) {
  11940. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11941. };
  11942. function getBorderClass(tl, tr, br, bl) {
  11943. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  11944. }
  11945. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11946. var session = this.session;
  11947. var start = range.start.row;
  11948. var end = range.end.row;
  11949. var row = start;
  11950. var prev = 0;
  11951. var curr = 0;
  11952. var next = session.getScreenLastRowColumn(row);
  11953. var lineRange = new Range(row, range.start.column, row, curr);
  11954. for (; row <= end; row++) {
  11955. lineRange.start.row = lineRange.end.row = row;
  11956. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  11957. lineRange.end.column = next;
  11958. prev = curr;
  11959. curr = next;
  11960. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  11961. this.drawSingleLineMarker(stringBuilder, lineRange,
  11962. clazz + (row == start ? " ace_start" : "") + " ace_br"
  11963. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
  11964. layerConfig, row == end ? 0 : 1, extraStyle);
  11965. }
  11966. };
  11967. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11968. var padding = this.$padding;
  11969. var height = config.lineHeight;
  11970. var top = this.$getTop(range.start.row, config);
  11971. var left = padding + range.start.column * config.characterWidth;
  11972. extraStyle = extraStyle || "";
  11973. stringBuilder.push(
  11974. "<div class='", clazz, " ace_br1 ace_start' style='",
  11975. "height:", height, "px;",
  11976. "right:0;",
  11977. "top:", top, "px;",
  11978. "left:", left, "px;", extraStyle, "'></div>"
  11979. );
  11980. top = this.$getTop(range.end.row, config);
  11981. var width = range.end.column * config.characterWidth;
  11982. stringBuilder.push(
  11983. "<div class='", clazz, " ace_br12' style='",
  11984. "height:", height, "px;",
  11985. "width:", width, "px;",
  11986. "top:", top, "px;",
  11987. "left:", padding, "px;", extraStyle, "'></div>"
  11988. );
  11989. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  11990. if (height <= 0)
  11991. return;
  11992. top = this.$getTop(range.start.row + 1, config);
  11993. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  11994. stringBuilder.push(
  11995. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  11996. "height:", height, "px;",
  11997. "right:0;",
  11998. "top:", top, "px;",
  11999. "left:", padding, "px;", extraStyle, "'></div>"
  12000. );
  12001. };
  12002. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  12003. var height = config.lineHeight;
  12004. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  12005. var top = this.$getTop(range.start.row, config);
  12006. var left = this.$padding + range.start.column * config.characterWidth;
  12007. stringBuilder.push(
  12008. "<div class='", clazz, "' style='",
  12009. "height:", height, "px;",
  12010. "width:", width, "px;",
  12011. "top:", top, "px;",
  12012. "left:", left, "px;", extraStyle || "", "'></div>"
  12013. );
  12014. };
  12015. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12016. var top = this.$getTop(range.start.row, config);
  12017. var height = config.lineHeight;
  12018. if (range.start.row != range.end.row)
  12019. height += this.$getTop(range.end.row, config) - top;
  12020. stringBuilder.push(
  12021. "<div class='", clazz, "' style='",
  12022. "height:", height, "px;",
  12023. "top:", top, "px;",
  12024. "left:0;right:0;", extraStyle || "", "'></div>"
  12025. );
  12026. };
  12027. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12028. var top = this.$getTop(range.start.row, config);
  12029. var height = config.lineHeight;
  12030. stringBuilder.push(
  12031. "<div class='", clazz, "' style='",
  12032. "height:", height, "px;",
  12033. "top:", top, "px;",
  12034. "left:0;right:0;", extraStyle || "", "'></div>"
  12035. );
  12036. };
  12037. }).call(Marker.prototype);
  12038. exports.Marker = Marker;
  12039. });
  12040. 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) {
  12041. "use strict";
  12042. var oop = require("../lib/oop");
  12043. var dom = require("../lib/dom");
  12044. var lang = require("../lib/lang");
  12045. var useragent = require("../lib/useragent");
  12046. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12047. var Text = function(parentEl) {
  12048. this.element = dom.createElement("div");
  12049. this.element.className = "ace_layer ace_text-layer";
  12050. parentEl.appendChild(this.element);
  12051. this.$updateEolChar = this.$updateEolChar.bind(this);
  12052. };
  12053. (function() {
  12054. oop.implement(this, EventEmitter);
  12055. this.EOF_CHAR = "\xB6";
  12056. this.EOL_CHAR_LF = "\xAC";
  12057. this.EOL_CHAR_CRLF = "\xa4";
  12058. this.EOL_CHAR = this.EOL_CHAR_LF;
  12059. this.TAB_CHAR = "\u2014"; //"\u21E5";
  12060. this.SPACE_CHAR = "\xB7";
  12061. this.$padding = 0;
  12062. this.$updateEolChar = function() {
  12063. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  12064. ? this.EOL_CHAR_LF
  12065. : this.EOL_CHAR_CRLF;
  12066. if (this.EOL_CHAR != EOL_CHAR) {
  12067. this.EOL_CHAR = EOL_CHAR;
  12068. return true;
  12069. }
  12070. }
  12071. this.setPadding = function(padding) {
  12072. this.$padding = padding;
  12073. this.element.style.padding = "0 " + padding + "px";
  12074. };
  12075. this.getLineHeight = function() {
  12076. return this.$fontMetrics.$characterSize.height || 0;
  12077. };
  12078. this.getCharacterWidth = function() {
  12079. return this.$fontMetrics.$characterSize.width || 0;
  12080. };
  12081. this.$setFontMetrics = function(measure) {
  12082. this.$fontMetrics = measure;
  12083. this.$fontMetrics.on("changeCharacterSize", function(e) {
  12084. this._signal("changeCharacterSize", e);
  12085. }.bind(this));
  12086. this.$pollSizeChanges();
  12087. }
  12088. this.checkForSizeChanges = function() {
  12089. this.$fontMetrics.checkForSizeChanges();
  12090. };
  12091. this.$pollSizeChanges = function() {
  12092. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  12093. };
  12094. this.setSession = function(session) {
  12095. this.session = session;
  12096. if (session)
  12097. this.$computeTabString();
  12098. };
  12099. this.showInvisibles = false;
  12100. this.setShowInvisibles = function(showInvisibles) {
  12101. if (this.showInvisibles == showInvisibles)
  12102. return false;
  12103. this.showInvisibles = showInvisibles;
  12104. this.$computeTabString();
  12105. return true;
  12106. };
  12107. this.displayIndentGuides = true;
  12108. this.setDisplayIndentGuides = function(display) {
  12109. if (this.displayIndentGuides == display)
  12110. return false;
  12111. this.displayIndentGuides = display;
  12112. this.$computeTabString();
  12113. return true;
  12114. };
  12115. this.$tabStrings = [];
  12116. this.onChangeTabSize =
  12117. this.$computeTabString = function() {
  12118. var tabSize = this.session.getTabSize();
  12119. this.tabSize = tabSize;
  12120. var tabStr = this.$tabStrings = [0];
  12121. for (var i = 1; i < tabSize + 1; i++) {
  12122. if (this.showInvisibles) {
  12123. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  12124. + lang.stringRepeat(this.TAB_CHAR, i)
  12125. + "</span>");
  12126. } else {
  12127. tabStr.push(lang.stringRepeat(" ", i));
  12128. }
  12129. }
  12130. if (this.displayIndentGuides) {
  12131. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  12132. var className = "ace_indent-guide";
  12133. var spaceClass = "";
  12134. var tabClass = "";
  12135. if (this.showInvisibles) {
  12136. className += " ace_invisible";
  12137. spaceClass = " ace_invisible_space";
  12138. tabClass = " ace_invisible_tab";
  12139. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  12140. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  12141. } else{
  12142. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  12143. var tabContent = spaceContent;
  12144. }
  12145. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  12146. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  12147. }
  12148. };
  12149. this.updateLines = function(config, firstRow, lastRow) {
  12150. if (this.config.lastRow != config.lastRow ||
  12151. this.config.firstRow != config.firstRow) {
  12152. this.scrollLines(config);
  12153. }
  12154. this.config = config;
  12155. var first = Math.max(firstRow, config.firstRow);
  12156. var last = Math.min(lastRow, config.lastRow);
  12157. var lineElements = this.element.childNodes;
  12158. var lineElementsIdx = 0;
  12159. for (var row = config.firstRow; row < first; row++) {
  12160. var foldLine = this.session.getFoldLine(row);
  12161. if (foldLine) {
  12162. if (foldLine.containsRow(first)) {
  12163. first = foldLine.start.row;
  12164. break;
  12165. } else {
  12166. row = foldLine.end.row;
  12167. }
  12168. }
  12169. lineElementsIdx ++;
  12170. }
  12171. var row = first;
  12172. var foldLine = this.session.getNextFoldLine(row);
  12173. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12174. while (true) {
  12175. if (row > foldStart) {
  12176. row = foldLine.end.row+1;
  12177. foldLine = this.session.getNextFoldLine(row, foldLine);
  12178. foldStart = foldLine ? foldLine.start.row :Infinity;
  12179. }
  12180. if (row > last)
  12181. break;
  12182. var lineElement = lineElements[lineElementsIdx++];
  12183. if (lineElement) {
  12184. var html = [];
  12185. this.$renderLine(
  12186. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  12187. );
  12188. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12189. lineElement.innerHTML = html.join("");
  12190. }
  12191. row++;
  12192. }
  12193. };
  12194. this.scrollLines = function(config) {
  12195. var oldConfig = this.config;
  12196. this.config = config;
  12197. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  12198. return this.update(config);
  12199. if (config.lastRow < oldConfig.firstRow)
  12200. return this.update(config);
  12201. var el = this.element;
  12202. if (oldConfig.firstRow < config.firstRow)
  12203. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  12204. el.removeChild(el.firstChild);
  12205. if (oldConfig.lastRow > config.lastRow)
  12206. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  12207. el.removeChild(el.lastChild);
  12208. if (config.firstRow < oldConfig.firstRow) {
  12209. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  12210. if (el.firstChild)
  12211. el.insertBefore(fragment, el.firstChild);
  12212. else
  12213. el.appendChild(fragment);
  12214. }
  12215. if (config.lastRow > oldConfig.lastRow) {
  12216. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  12217. el.appendChild(fragment);
  12218. }
  12219. };
  12220. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  12221. var fragment = this.element.ownerDocument.createDocumentFragment();
  12222. var row = firstRow;
  12223. var foldLine = this.session.getNextFoldLine(row);
  12224. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12225. while (true) {
  12226. if (row > foldStart) {
  12227. row = foldLine.end.row+1;
  12228. foldLine = this.session.getNextFoldLine(row, foldLine);
  12229. foldStart = foldLine ? foldLine.start.row : Infinity;
  12230. }
  12231. if (row > lastRow)
  12232. break;
  12233. var container = dom.createElement("div");
  12234. var html = [];
  12235. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12236. container.innerHTML = html.join("");
  12237. if (this.$useLineGroups()) {
  12238. container.className = 'ace_line_group';
  12239. fragment.appendChild(container);
  12240. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12241. } else {
  12242. while(container.firstChild)
  12243. fragment.appendChild(container.firstChild);
  12244. }
  12245. row++;
  12246. }
  12247. return fragment;
  12248. };
  12249. this.update = function(config) {
  12250. this.config = config;
  12251. var html = [];
  12252. var firstRow = config.firstRow, lastRow = config.lastRow;
  12253. var row = firstRow;
  12254. var foldLine = this.session.getNextFoldLine(row);
  12255. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12256. while (true) {
  12257. if (row > foldStart) {
  12258. row = foldLine.end.row+1;
  12259. foldLine = this.session.getNextFoldLine(row, foldLine);
  12260. foldStart = foldLine ? foldLine.start.row :Infinity;
  12261. }
  12262. if (row > lastRow)
  12263. break;
  12264. if (this.$useLineGroups())
  12265. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12266. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12267. if (this.$useLineGroups())
  12268. html.push("</div>"); // end the line group
  12269. row++;
  12270. }
  12271. this.element.innerHTML = html.join("");
  12272. };
  12273. this.$textToken = {
  12274. "text": true,
  12275. "rparen": true,
  12276. "lparen": true
  12277. };
  12278. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12279. var self = this;
  12280. var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
  12281. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12282. if (a) {
  12283. return self.showInvisibles
  12284. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12285. : c;
  12286. } else if (c == "&") {
  12287. return "&#38;";
  12288. } else if (c == "<") {
  12289. return "&#60;";
  12290. } else if (c == ">") {
  12291. return "&#62;";
  12292. } else if (c == "\t") {
  12293. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12294. screenColumn += tabSize - 1;
  12295. return self.$tabStrings[tabSize];
  12296. } else if (c == "\u3000") {
  12297. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12298. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12299. screenColumn += 1;
  12300. return "<span class='" + classToUse + "' style='width:" +
  12301. (self.config.characterWidth * 2) +
  12302. "px'>" + space + "</span>";
  12303. } else if (b) {
  12304. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12305. } else {
  12306. screenColumn += 1;
  12307. return "<span class='ace_cjk' style='width:" +
  12308. (self.config.characterWidth * 2) +
  12309. "px'>" + c + "</span>";
  12310. }
  12311. };
  12312. var output = value.replace(replaceReg, replaceFunc);
  12313. if (!this.$textToken[token.type]) {
  12314. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12315. var style = "";
  12316. if (token.type == "fold")
  12317. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12318. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12319. }
  12320. else {
  12321. stringBuilder.push(output);
  12322. }
  12323. return screenColumn + value.length;
  12324. };
  12325. this.renderIndentGuide = function(stringBuilder, value, max) {
  12326. var cols = value.search(this.$indentGuideRe);
  12327. if (cols <= 0 || cols >= max)
  12328. return value;
  12329. if (value[0] == " ") {
  12330. cols -= cols % this.tabSize;
  12331. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12332. return value.substr(cols);
  12333. } else if (value[0] == "\t") {
  12334. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12335. return value.substr(cols);
  12336. }
  12337. return value;
  12338. };
  12339. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12340. var chars = 0;
  12341. var split = 0;
  12342. var splitChars = splits[0];
  12343. var screenColumn = 0;
  12344. for (var i = 0; i < tokens.length; i++) {
  12345. var token = tokens[i];
  12346. var value = token.value;
  12347. if (i == 0 && this.displayIndentGuides) {
  12348. chars = value.length;
  12349. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12350. if (!value)
  12351. continue;
  12352. chars -= value.length;
  12353. }
  12354. if (chars + value.length < splitChars) {
  12355. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12356. chars += value.length;
  12357. } else {
  12358. while (chars + value.length >= splitChars) {
  12359. screenColumn = this.$renderToken(
  12360. stringBuilder, screenColumn,
  12361. token, value.substring(0, splitChars - chars)
  12362. );
  12363. value = value.substring(splitChars - chars);
  12364. chars = splitChars;
  12365. if (!onlyContents) {
  12366. stringBuilder.push("</div>",
  12367. "<div class='ace_line' style='height:",
  12368. this.config.lineHeight, "px'>"
  12369. );
  12370. }
  12371. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  12372. split ++;
  12373. screenColumn = 0;
  12374. splitChars = splits[split] || Number.MAX_VALUE;
  12375. }
  12376. if (value.length != 0) {
  12377. chars += value.length;
  12378. screenColumn = this.$renderToken(
  12379. stringBuilder, screenColumn, token, value
  12380. );
  12381. }
  12382. }
  12383. }
  12384. };
  12385. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12386. var screenColumn = 0;
  12387. var token = tokens[0];
  12388. var value = token.value;
  12389. if (this.displayIndentGuides)
  12390. value = this.renderIndentGuide(stringBuilder, value);
  12391. if (value)
  12392. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12393. for (var i = 1; i < tokens.length; i++) {
  12394. token = tokens[i];
  12395. value = token.value;
  12396. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12397. }
  12398. };
  12399. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12400. if (!foldLine && foldLine != false)
  12401. foldLine = this.session.getFoldLine(row);
  12402. if (foldLine)
  12403. var tokens = this.$getFoldLineTokens(row, foldLine);
  12404. else
  12405. var tokens = this.session.getTokens(row);
  12406. if (!onlyContents) {
  12407. stringBuilder.push(
  12408. "<div class='ace_line' style='height:",
  12409. this.config.lineHeight * (
  12410. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12411. ), "px'>"
  12412. );
  12413. }
  12414. if (tokens.length) {
  12415. var splits = this.session.getRowSplitData(row);
  12416. if (splits && splits.length)
  12417. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12418. else
  12419. this.$renderSimpleLine(stringBuilder, tokens);
  12420. }
  12421. if (this.showInvisibles) {
  12422. if (foldLine)
  12423. row = foldLine.end.row
  12424. stringBuilder.push(
  12425. "<span class='ace_invisible ace_invisible_eol'>",
  12426. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12427. "</span>"
  12428. );
  12429. }
  12430. if (!onlyContents)
  12431. stringBuilder.push("</div>");
  12432. };
  12433. this.$getFoldLineTokens = function(row, foldLine) {
  12434. var session = this.session;
  12435. var renderTokens = [];
  12436. function addTokens(tokens, from, to) {
  12437. var idx = 0, col = 0;
  12438. while ((col + tokens[idx].value.length) < from) {
  12439. col += tokens[idx].value.length;
  12440. idx++;
  12441. if (idx == tokens.length)
  12442. return;
  12443. }
  12444. if (col != from) {
  12445. var value = tokens[idx].value.substring(from - col);
  12446. if (value.length > (to - from))
  12447. value = value.substring(0, to - from);
  12448. renderTokens.push({
  12449. type: tokens[idx].type,
  12450. value: value
  12451. });
  12452. col = from + value.length;
  12453. idx += 1;
  12454. }
  12455. while (col < to && idx < tokens.length) {
  12456. var value = tokens[idx].value;
  12457. if (value.length + col > to) {
  12458. renderTokens.push({
  12459. type: tokens[idx].type,
  12460. value: value.substring(0, to - col)
  12461. });
  12462. } else
  12463. renderTokens.push(tokens[idx]);
  12464. col += value.length;
  12465. idx += 1;
  12466. }
  12467. }
  12468. var tokens = session.getTokens(row);
  12469. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12470. if (placeholder != null) {
  12471. renderTokens.push({
  12472. type: "fold",
  12473. value: placeholder
  12474. });
  12475. } else {
  12476. if (isNewRow)
  12477. tokens = session.getTokens(row);
  12478. if (tokens.length)
  12479. addTokens(tokens, lastColumn, column);
  12480. }
  12481. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12482. return renderTokens;
  12483. };
  12484. this.$useLineGroups = function() {
  12485. return this.session.getUseWrapMode();
  12486. };
  12487. this.destroy = function() {
  12488. clearInterval(this.$pollSizeChangesTimer);
  12489. if (this.$measureNode)
  12490. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12491. delete this.$measureNode;
  12492. };
  12493. }).call(Text.prototype);
  12494. exports.Text = Text;
  12495. });
  12496. define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12497. "use strict";
  12498. var dom = require("../lib/dom");
  12499. var isIE8;
  12500. var Cursor = function(parentEl) {
  12501. this.element = dom.createElement("div");
  12502. this.element.className = "ace_layer ace_cursor-layer";
  12503. parentEl.appendChild(this.element);
  12504. if (isIE8 === undefined)
  12505. isIE8 = !("opacity" in this.element.style);
  12506. this.isVisible = false;
  12507. this.isBlinking = true;
  12508. this.blinkInterval = 1000;
  12509. this.smoothBlinking = false;
  12510. this.cursors = [];
  12511. this.cursor = this.addCursor();
  12512. dom.addCssClass(this.element, "ace_hidden-cursors");
  12513. this.$updateCursors = (isIE8
  12514. ? this.$updateVisibility
  12515. : this.$updateOpacity).bind(this);
  12516. };
  12517. (function() {
  12518. this.$updateVisibility = function(val) {
  12519. var cursors = this.cursors;
  12520. for (var i = cursors.length; i--; )
  12521. cursors[i].style.visibility = val ? "" : "hidden";
  12522. };
  12523. this.$updateOpacity = function(val) {
  12524. var cursors = this.cursors;
  12525. for (var i = cursors.length; i--; )
  12526. cursors[i].style.opacity = val ? "" : "0";
  12527. };
  12528. this.$padding = 0;
  12529. this.setPadding = function(padding) {
  12530. this.$padding = padding;
  12531. };
  12532. this.setSession = function(session) {
  12533. this.session = session;
  12534. };
  12535. this.setBlinking = function(blinking) {
  12536. if (blinking != this.isBlinking){
  12537. this.isBlinking = blinking;
  12538. this.restartTimer();
  12539. }
  12540. };
  12541. this.setBlinkInterval = function(blinkInterval) {
  12542. if (blinkInterval != this.blinkInterval){
  12543. this.blinkInterval = blinkInterval;
  12544. this.restartTimer();
  12545. }
  12546. };
  12547. this.setSmoothBlinking = function(smoothBlinking) {
  12548. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  12549. this.smoothBlinking = smoothBlinking;
  12550. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12551. this.$updateCursors(true);
  12552. this.$updateCursors = (this.$updateOpacity).bind(this);
  12553. this.restartTimer();
  12554. }
  12555. };
  12556. this.addCursor = function() {
  12557. var el = dom.createElement("div");
  12558. el.className = "ace_cursor";
  12559. this.element.appendChild(el);
  12560. this.cursors.push(el);
  12561. return el;
  12562. };
  12563. this.removeCursor = function() {
  12564. if (this.cursors.length > 1) {
  12565. var el = this.cursors.pop();
  12566. el.parentNode.removeChild(el);
  12567. return el;
  12568. }
  12569. };
  12570. this.hideCursor = function() {
  12571. this.isVisible = false;
  12572. dom.addCssClass(this.element, "ace_hidden-cursors");
  12573. this.restartTimer();
  12574. };
  12575. this.showCursor = function() {
  12576. this.isVisible = true;
  12577. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12578. this.restartTimer();
  12579. };
  12580. this.restartTimer = function() {
  12581. var update = this.$updateCursors;
  12582. clearInterval(this.intervalId);
  12583. clearTimeout(this.timeoutId);
  12584. if (this.smoothBlinking) {
  12585. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12586. }
  12587. update(true);
  12588. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12589. return;
  12590. if (this.smoothBlinking) {
  12591. setTimeout(function(){
  12592. dom.addCssClass(this.element, "ace_smooth-blinking");
  12593. }.bind(this));
  12594. }
  12595. var blink = function(){
  12596. this.timeoutId = setTimeout(function() {
  12597. update(false);
  12598. }, 0.6 * this.blinkInterval);
  12599. }.bind(this);
  12600. this.intervalId = setInterval(function() {
  12601. update(true);
  12602. blink();
  12603. }, this.blinkInterval);
  12604. blink();
  12605. };
  12606. this.getPixelPosition = function(position, onScreen) {
  12607. if (!this.config || !this.session)
  12608. return {left : 0, top : 0};
  12609. if (!position)
  12610. position = this.session.selection.getCursor();
  12611. var pos = this.session.documentToScreenPosition(position);
  12612. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12613. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12614. this.config.lineHeight;
  12615. return {left : cursorLeft, top : cursorTop};
  12616. };
  12617. this.update = function(config) {
  12618. this.config = config;
  12619. var selections = this.session.$selectionMarkers;
  12620. var i = 0, cursorIndex = 0;
  12621. if (selections === undefined || selections.length === 0){
  12622. selections = [{cursor: null}];
  12623. }
  12624. for (var i = 0, n = selections.length; i < n; i++) {
  12625. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12626. if ((pixelPos.top > config.height + config.offset ||
  12627. pixelPos.top < 0) && i > 1) {
  12628. continue;
  12629. }
  12630. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12631. if (!this.drawCursor) {
  12632. style.left = pixelPos.left + "px";
  12633. style.top = pixelPos.top + "px";
  12634. style.width = config.characterWidth + "px";
  12635. style.height = config.lineHeight + "px";
  12636. } else {
  12637. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12638. }
  12639. }
  12640. while (this.cursors.length > cursorIndex)
  12641. this.removeCursor();
  12642. var overwrite = this.session.getOverwrite();
  12643. this.$setOverwrite(overwrite);
  12644. this.$pixelPos = pixelPos;
  12645. this.restartTimer();
  12646. };
  12647. this.drawCursor = null;
  12648. this.$setOverwrite = function(overwrite) {
  12649. if (overwrite != this.overwrite) {
  12650. this.overwrite = overwrite;
  12651. if (overwrite)
  12652. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12653. else
  12654. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12655. }
  12656. };
  12657. this.destroy = function() {
  12658. clearInterval(this.intervalId);
  12659. clearTimeout(this.timeoutId);
  12660. };
  12661. }).call(Cursor.prototype);
  12662. exports.Cursor = Cursor;
  12663. });
  12664. define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12665. "use strict";
  12666. var oop = require("./lib/oop");
  12667. var dom = require("./lib/dom");
  12668. var event = require("./lib/event");
  12669. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12670. var ScrollBar = function(parent) {
  12671. this.element = dom.createElement("div");
  12672. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12673. this.inner = dom.createElement("div");
  12674. this.inner.className = "ace_scrollbar-inner";
  12675. this.element.appendChild(this.inner);
  12676. parent.appendChild(this.element);
  12677. this.setVisible(false);
  12678. this.skipEvent = false;
  12679. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12680. event.addListener(this.element, "mousedown", event.preventDefault);
  12681. };
  12682. (function() {
  12683. oop.implement(this, EventEmitter);
  12684. this.setVisible = function(isVisible) {
  12685. this.element.style.display = isVisible ? "" : "none";
  12686. this.isVisible = isVisible;
  12687. };
  12688. }).call(ScrollBar.prototype);
  12689. var VScrollBar = function(parent, renderer) {
  12690. ScrollBar.call(this, parent);
  12691. this.scrollTop = 0;
  12692. renderer.$scrollbarWidth =
  12693. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12694. this.inner.style.width =
  12695. this.element.style.width = (this.width || 15) + 5 + "px";
  12696. };
  12697. oop.inherits(VScrollBar, ScrollBar);
  12698. (function() {
  12699. this.classSuffix = '-v';
  12700. this.onScroll = function() {
  12701. if (!this.skipEvent) {
  12702. this.scrollTop = this.element.scrollTop;
  12703. this._emit("scroll", {data: this.scrollTop});
  12704. }
  12705. this.skipEvent = false;
  12706. };
  12707. this.getWidth = function() {
  12708. return this.isVisible ? this.width : 0;
  12709. };
  12710. this.setHeight = function(height) {
  12711. this.element.style.height = height + "px";
  12712. };
  12713. this.setInnerHeight = function(height) {
  12714. this.inner.style.height = height + "px";
  12715. };
  12716. this.setScrollHeight = function(height) {
  12717. this.inner.style.height = height + "px";
  12718. };
  12719. this.setScrollTop = function(scrollTop) {
  12720. if (this.scrollTop != scrollTop) {
  12721. this.skipEvent = true;
  12722. this.scrollTop = this.element.scrollTop = scrollTop;
  12723. }
  12724. };
  12725. }).call(VScrollBar.prototype);
  12726. var HScrollBar = function(parent, renderer) {
  12727. ScrollBar.call(this, parent);
  12728. this.scrollLeft = 0;
  12729. this.height = renderer.$scrollbarWidth;
  12730. this.inner.style.height =
  12731. this.element.style.height = (this.height || 15) + 5 + "px";
  12732. };
  12733. oop.inherits(HScrollBar, ScrollBar);
  12734. (function() {
  12735. this.classSuffix = '-h';
  12736. this.onScroll = function() {
  12737. if (!this.skipEvent) {
  12738. this.scrollLeft = this.element.scrollLeft;
  12739. this._emit("scroll", {data: this.scrollLeft});
  12740. }
  12741. this.skipEvent = false;
  12742. };
  12743. this.getHeight = function() {
  12744. return this.isVisible ? this.height : 0;
  12745. };
  12746. this.setWidth = function(width) {
  12747. this.element.style.width = width + "px";
  12748. };
  12749. this.setInnerWidth = function(width) {
  12750. this.inner.style.width = width + "px";
  12751. };
  12752. this.setScrollWidth = function(width) {
  12753. this.inner.style.width = width + "px";
  12754. };
  12755. this.setScrollLeft = function(scrollLeft) {
  12756. if (this.scrollLeft != scrollLeft) {
  12757. this.skipEvent = true;
  12758. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12759. }
  12760. };
  12761. }).call(HScrollBar.prototype);
  12762. exports.ScrollBar = VScrollBar; // backward compatibility
  12763. exports.ScrollBarV = VScrollBar; // backward compatibility
  12764. exports.ScrollBarH = HScrollBar; // backward compatibility
  12765. exports.VScrollBar = VScrollBar;
  12766. exports.HScrollBar = HScrollBar;
  12767. });
  12768. define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12769. "use strict";
  12770. var event = require("./lib/event");
  12771. var RenderLoop = function(onRender, win) {
  12772. this.onRender = onRender;
  12773. this.pending = false;
  12774. this.changes = 0;
  12775. this.window = win || window;
  12776. };
  12777. (function() {
  12778. this.schedule = function(change) {
  12779. this.changes = this.changes | change;
  12780. if (!this.pending && this.changes) {
  12781. this.pending = true;
  12782. var _self = this;
  12783. event.nextFrame(function() {
  12784. _self.pending = false;
  12785. var changes;
  12786. while (changes = _self.changes) {
  12787. _self.changes = 0;
  12788. _self.onRender(changes);
  12789. }
  12790. }, this.window);
  12791. }
  12792. };
  12793. }).call(RenderLoop.prototype);
  12794. exports.RenderLoop = RenderLoop;
  12795. });
  12796. define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
  12797. var oop = require("../lib/oop");
  12798. var dom = require("../lib/dom");
  12799. var lang = require("../lib/lang");
  12800. var useragent = require("../lib/useragent");
  12801. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12802. var CHAR_COUNT = 0;
  12803. var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
  12804. this.el = dom.createElement("div");
  12805. this.$setMeasureNodeStyles(this.el.style, true);
  12806. this.$main = dom.createElement("div");
  12807. this.$setMeasureNodeStyles(this.$main.style);
  12808. this.$measureNode = dom.createElement("div");
  12809. this.$setMeasureNodeStyles(this.$measureNode.style);
  12810. this.el.appendChild(this.$main);
  12811. this.el.appendChild(this.$measureNode);
  12812. parentEl.appendChild(this.el);
  12813. if (!CHAR_COUNT)
  12814. this.$testFractionalRect();
  12815. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12816. this.$characterSize = {width: 0, height: 0};
  12817. this.checkForSizeChanges();
  12818. };
  12819. (function() {
  12820. oop.implement(this, EventEmitter);
  12821. this.$characterSize = {width: 0, height: 0};
  12822. this.$testFractionalRect = function() {
  12823. var el = dom.createElement("div");
  12824. this.$setMeasureNodeStyles(el.style);
  12825. el.style.width = "0.2px";
  12826. document.documentElement.appendChild(el);
  12827. var w = el.getBoundingClientRect().width;
  12828. if (w > 0 && w < 1)
  12829. CHAR_COUNT = 50;
  12830. else
  12831. CHAR_COUNT = 100;
  12832. el.parentNode.removeChild(el);
  12833. };
  12834. this.$setMeasureNodeStyles = function(style, isRoot) {
  12835. style.width = style.height = "auto";
  12836. style.left = style.top = "0px";
  12837. style.visibility = "hidden";
  12838. style.position = "absolute";
  12839. style.whiteSpace = "pre";
  12840. if (useragent.isIE < 8) {
  12841. style["font-family"] = "inherit";
  12842. } else {
  12843. style.font = "inherit";
  12844. }
  12845. style.overflow = isRoot ? "hidden" : "visible";
  12846. };
  12847. this.checkForSizeChanges = function() {
  12848. var size = this.$measureSizes();
  12849. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12850. this.$measureNode.style.fontWeight = "bold";
  12851. var boldSize = this.$measureSizes();
  12852. this.$measureNode.style.fontWeight = "";
  12853. this.$characterSize = size;
  12854. this.charSizes = Object.create(null);
  12855. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12856. this._emit("changeCharacterSize", {data: size});
  12857. }
  12858. };
  12859. this.$pollSizeChanges = function() {
  12860. if (this.$pollSizeChangesTimer)
  12861. return this.$pollSizeChangesTimer;
  12862. var self = this;
  12863. return this.$pollSizeChangesTimer = setInterval(function() {
  12864. self.checkForSizeChanges();
  12865. }, 500);
  12866. };
  12867. this.setPolling = function(val) {
  12868. if (val) {
  12869. this.$pollSizeChanges();
  12870. } else if (this.$pollSizeChangesTimer) {
  12871. clearInterval(this.$pollSizeChangesTimer);
  12872. this.$pollSizeChangesTimer = 0;
  12873. }
  12874. };
  12875. this.$measureSizes = function() {
  12876. if (CHAR_COUNT === 50) {
  12877. var rect = null;
  12878. try {
  12879. rect = this.$measureNode.getBoundingClientRect();
  12880. } catch(e) {
  12881. rect = {width: 0, height:0 };
  12882. };
  12883. var size = {
  12884. height: rect.height,
  12885. width: rect.width / CHAR_COUNT
  12886. };
  12887. } else {
  12888. var size = {
  12889. height: this.$measureNode.clientHeight,
  12890. width: this.$measureNode.clientWidth / CHAR_COUNT
  12891. };
  12892. }
  12893. if (size.width === 0 || size.height === 0)
  12894. return null;
  12895. return size;
  12896. };
  12897. this.$measureCharWidth = function(ch) {
  12898. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12899. var rect = this.$main.getBoundingClientRect();
  12900. return rect.width / CHAR_COUNT;
  12901. };
  12902. this.getCharacterWidth = function(ch) {
  12903. var w = this.charSizes[ch];
  12904. if (w === undefined) {
  12905. w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12906. }
  12907. return w;
  12908. };
  12909. this.destroy = function() {
  12910. clearInterval(this.$pollSizeChangesTimer);
  12911. if (this.el && this.el.parentNode)
  12912. this.el.parentNode.removeChild(this.el);
  12913. };
  12914. }).call(FontMetrics.prototype);
  12915. });
  12916. define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"], function(require, exports, module) {
  12917. "use strict";
  12918. var oop = require("./lib/oop");
  12919. var dom = require("./lib/dom");
  12920. var config = require("./config");
  12921. var useragent = require("./lib/useragent");
  12922. var GutterLayer = require("./layer/gutter").Gutter;
  12923. var MarkerLayer = require("./layer/marker").Marker;
  12924. var TextLayer = require("./layer/text").Text;
  12925. var CursorLayer = require("./layer/cursor").Cursor;
  12926. var HScrollBar = require("./scrollbar").HScrollBar;
  12927. var VScrollBar = require("./scrollbar").VScrollBar;
  12928. var RenderLoop = require("./renderloop").RenderLoop;
  12929. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12930. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12931. var editorCss = ".ace_editor {\
  12932. position: relative;\
  12933. overflow: hidden;\
  12934. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12935. direction: ltr;\
  12936. }\
  12937. .ace_scroller {\
  12938. position: absolute;\
  12939. overflow: hidden;\
  12940. top: 0;\
  12941. bottom: 0;\
  12942. background-color: inherit;\
  12943. -ms-user-select: none;\
  12944. -moz-user-select: none;\
  12945. -webkit-user-select: none;\
  12946. user-select: none;\
  12947. cursor: text;\
  12948. }\
  12949. .ace_content {\
  12950. position: absolute;\
  12951. -moz-box-sizing: border-box;\
  12952. -webkit-box-sizing: border-box;\
  12953. box-sizing: border-box;\
  12954. min-width: 100%;\
  12955. }\
  12956. .ace_dragging .ace_scroller:before{\
  12957. position: absolute;\
  12958. top: 0;\
  12959. left: 0;\
  12960. right: 0;\
  12961. bottom: 0;\
  12962. content: '';\
  12963. background: rgba(250, 250, 250, 0.01);\
  12964. z-index: 1000;\
  12965. }\
  12966. .ace_dragging.ace_dark .ace_scroller:before{\
  12967. background: rgba(0, 0, 0, 0.01);\
  12968. }\
  12969. .ace_selecting, .ace_selecting * {\
  12970. cursor: text !important;\
  12971. }\
  12972. .ace_gutter {\
  12973. position: absolute;\
  12974. overflow : hidden;\
  12975. width: auto;\
  12976. top: 0;\
  12977. bottom: 0;\
  12978. left: 0;\
  12979. cursor: default;\
  12980. z-index: 4;\
  12981. -ms-user-select: none;\
  12982. -moz-user-select: none;\
  12983. -webkit-user-select: none;\
  12984. user-select: none;\
  12985. }\
  12986. .ace_gutter-active-line {\
  12987. position: absolute;\
  12988. left: 0;\
  12989. right: 0;\
  12990. }\
  12991. .ace_scroller.ace_scroll-left {\
  12992. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  12993. }\
  12994. .ace_gutter-cell {\
  12995. padding-left: 19px;\
  12996. padding-right: 6px;\
  12997. background-repeat: no-repeat;\
  12998. }\
  12999. .ace_gutter-cell.ace_error {\
  13000. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\
  13001. background-repeat: no-repeat;\
  13002. background-position: 2px center;\
  13003. }\
  13004. .ace_gutter-cell.ace_warning {\
  13005. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\
  13006. background-position: 2px center;\
  13007. }\
  13008. .ace_gutter-cell.ace_info {\
  13009. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  13010. background-position: 2px center;\
  13011. }\
  13012. .ace_dark .ace_gutter-cell.ace_info {\
  13013. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  13014. }\
  13015. .ace_scrollbar {\
  13016. position: absolute;\
  13017. right: 0;\
  13018. bottom: 0;\
  13019. z-index: 6;\
  13020. }\
  13021. .ace_scrollbar-inner {\
  13022. position: absolute;\
  13023. cursor: text;\
  13024. left: 0;\
  13025. top: 0;\
  13026. }\
  13027. .ace_scrollbar-v{\
  13028. overflow-x: hidden;\
  13029. overflow-y: scroll;\
  13030. top: 0;\
  13031. }\
  13032. .ace_scrollbar-h {\
  13033. overflow-x: scroll;\
  13034. overflow-y: hidden;\
  13035. left: 0;\
  13036. }\
  13037. .ace_print-margin {\
  13038. position: absolute;\
  13039. height: 100%;\
  13040. }\
  13041. .ace_text-input {\
  13042. position: absolute;\
  13043. z-index: 0;\
  13044. width: 0.5em;\
  13045. height: 1em;\
  13046. opacity: 0;\
  13047. background: transparent;\
  13048. -moz-appearance: none;\
  13049. appearance: none;\
  13050. border: none;\
  13051. resize: none;\
  13052. outline: none;\
  13053. overflow: hidden;\
  13054. font: inherit;\
  13055. padding: 0 1px;\
  13056. margin: 0 -1px;\
  13057. text-indent: -1em;\
  13058. -ms-user-select: text;\
  13059. -moz-user-select: text;\
  13060. -webkit-user-select: text;\
  13061. user-select: text;\
  13062. white-space: pre!important;\
  13063. }\
  13064. .ace_text-input.ace_composition {\
  13065. background: inherit;\
  13066. color: inherit;\
  13067. z-index: 1000;\
  13068. opacity: 1;\
  13069. text-indent: 0;\
  13070. }\
  13071. .ace_layer {\
  13072. z-index: 1;\
  13073. position: absolute;\
  13074. overflow: hidden;\
  13075. word-wrap: normal;\
  13076. white-space: pre;\
  13077. height: 100%;\
  13078. width: 100%;\
  13079. -moz-box-sizing: border-box;\
  13080. -webkit-box-sizing: border-box;\
  13081. box-sizing: border-box;\
  13082. pointer-events: none;\
  13083. }\
  13084. .ace_gutter-layer {\
  13085. position: relative;\
  13086. width: auto;\
  13087. text-align: right;\
  13088. pointer-events: auto;\
  13089. }\
  13090. .ace_text-layer {\
  13091. font: inherit !important;\
  13092. }\
  13093. .ace_cjk {\
  13094. display: inline-block;\
  13095. text-align: center;\
  13096. }\
  13097. .ace_cursor-layer {\
  13098. z-index: 4;\
  13099. }\
  13100. .ace_cursor {\
  13101. z-index: 4;\
  13102. position: absolute;\
  13103. -moz-box-sizing: border-box;\
  13104. -webkit-box-sizing: border-box;\
  13105. box-sizing: border-box;\
  13106. border-left: 2px solid;\
  13107. transform: translatez(0);\
  13108. }\
  13109. .ace_slim-cursors .ace_cursor {\
  13110. border-left-width: 1px;\
  13111. }\
  13112. .ace_overwrite-cursors .ace_cursor {\
  13113. border-left-width: 0;\
  13114. border-bottom: 1px solid;\
  13115. }\
  13116. .ace_hidden-cursors .ace_cursor {\
  13117. opacity: 0.2;\
  13118. }\
  13119. .ace_smooth-blinking .ace_cursor {\
  13120. -webkit-transition: opacity 0.18s;\
  13121. transition: opacity 0.18s;\
  13122. }\
  13123. .ace_editor.ace_multiselect .ace_cursor {\
  13124. border-left-width: 1px;\
  13125. }\
  13126. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  13127. position: absolute;\
  13128. z-index: 3;\
  13129. }\
  13130. .ace_marker-layer .ace_selection {\
  13131. position: absolute;\
  13132. z-index: 5;\
  13133. }\
  13134. .ace_marker-layer .ace_bracket {\
  13135. position: absolute;\
  13136. z-index: 6;\
  13137. }\
  13138. .ace_marker-layer .ace_active-line {\
  13139. position: absolute;\
  13140. z-index: 2;\
  13141. }\
  13142. .ace_marker-layer .ace_selected-word {\
  13143. position: absolute;\
  13144. z-index: 4;\
  13145. -moz-box-sizing: border-box;\
  13146. -webkit-box-sizing: border-box;\
  13147. box-sizing: border-box;\
  13148. }\
  13149. .ace_line .ace_fold {\
  13150. -moz-box-sizing: border-box;\
  13151. -webkit-box-sizing: border-box;\
  13152. box-sizing: border-box;\
  13153. display: inline-block;\
  13154. height: 11px;\
  13155. margin-top: -2px;\
  13156. vertical-align: middle;\
  13157. background-image:\
  13158. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13159. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  13160. background-repeat: no-repeat, repeat-x;\
  13161. background-position: center center, top left;\
  13162. color: transparent;\
  13163. border: 1px solid black;\
  13164. border-radius: 2px;\
  13165. cursor: pointer;\
  13166. pointer-events: auto;\
  13167. }\
  13168. .ace_dark .ace_fold {\
  13169. }\
  13170. .ace_fold:hover{\
  13171. background-image:\
  13172. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13173. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  13174. }\
  13175. .ace_tooltip {\
  13176. background-color: #FFF;\
  13177. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  13178. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  13179. border: 1px solid gray;\
  13180. border-radius: 1px;\
  13181. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  13182. color: black;\
  13183. max-width: 100%;\
  13184. padding: 3px 4px;\
  13185. position: fixed;\
  13186. z-index: 999999;\
  13187. -moz-box-sizing: border-box;\
  13188. -webkit-box-sizing: border-box;\
  13189. box-sizing: border-box;\
  13190. cursor: default;\
  13191. white-space: pre;\
  13192. word-wrap: break-word;\
  13193. line-height: normal;\
  13194. font-style: normal;\
  13195. font-weight: normal;\
  13196. letter-spacing: normal;\
  13197. pointer-events: none;\
  13198. }\
  13199. .ace_folding-enabled > .ace_gutter-cell {\
  13200. padding-right: 13px;\
  13201. }\
  13202. .ace_fold-widget {\
  13203. -moz-box-sizing: border-box;\
  13204. -webkit-box-sizing: border-box;\
  13205. box-sizing: border-box;\
  13206. margin: 0 -12px 0 1px;\
  13207. display: none;\
  13208. width: 11px;\
  13209. vertical-align: top;\
  13210. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  13211. background-repeat: no-repeat;\
  13212. background-position: center;\
  13213. border-radius: 3px;\
  13214. border: 1px solid transparent;\
  13215. cursor: pointer;\
  13216. }\
  13217. .ace_folding-enabled .ace_fold-widget {\
  13218. display: inline-block; \
  13219. }\
  13220. .ace_fold-widget.ace_end {\
  13221. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  13222. }\
  13223. .ace_fold-widget.ace_closed {\
  13224. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  13225. }\
  13226. .ace_fold-widget:hover {\
  13227. border: 1px solid rgba(0, 0, 0, 0.3);\
  13228. background-color: rgba(255, 255, 255, 0.2);\
  13229. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  13230. }\
  13231. .ace_fold-widget:active {\
  13232. border: 1px solid rgba(0, 0, 0, 0.4);\
  13233. background-color: rgba(0, 0, 0, 0.05);\
  13234. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  13235. }\
  13236. .ace_dark .ace_fold-widget {\
  13237. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  13238. }\
  13239. .ace_dark .ace_fold-widget.ace_end {\
  13240. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  13241. }\
  13242. .ace_dark .ace_fold-widget.ace_closed {\
  13243. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  13244. }\
  13245. .ace_dark .ace_fold-widget:hover {\
  13246. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13247. background-color: rgba(255, 255, 255, 0.1);\
  13248. }\
  13249. .ace_dark .ace_fold-widget:active {\
  13250. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13251. }\
  13252. .ace_fold-widget.ace_invalid {\
  13253. background-color: #FFB4B4;\
  13254. border-color: #DE5555;\
  13255. }\
  13256. .ace_fade-fold-widgets .ace_fold-widget {\
  13257. -webkit-transition: opacity 0.4s ease 0.05s;\
  13258. transition: opacity 0.4s ease 0.05s;\
  13259. opacity: 0;\
  13260. }\
  13261. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13262. -webkit-transition: opacity 0.05s ease 0.05s;\
  13263. transition: opacity 0.05s ease 0.05s;\
  13264. opacity:1;\
  13265. }\
  13266. .ace_underline {\
  13267. text-decoration: underline;\
  13268. }\
  13269. .ace_bold {\
  13270. font-weight: bold;\
  13271. }\
  13272. .ace_nobold .ace_bold {\
  13273. font-weight: normal;\
  13274. }\
  13275. .ace_italic {\
  13276. font-style: italic;\
  13277. }\
  13278. .ace_error-marker {\
  13279. background-color: rgba(255, 0, 0,0.2);\
  13280. position: absolute;\
  13281. z-index: 9;\
  13282. }\
  13283. .ace_highlight-marker {\
  13284. background-color: rgba(255, 255, 0,0.2);\
  13285. position: absolute;\
  13286. z-index: 8;\
  13287. }\
  13288. .ace_br1 {border-top-left-radius : 3px;}\
  13289. .ace_br2 {border-top-right-radius : 3px;}\
  13290. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  13291. .ace_br4 {border-bottom-right-radius: 3px;}\
  13292. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  13293. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  13294. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  13295. .ace_br8 {border-bottom-left-radius : 3px;}\
  13296. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  13297. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  13298. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13299. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13300. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13301. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13302. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13303. ";
  13304. dom.importCssString(editorCss, "ace_editor.css");
  13305. var VirtualRenderer = function(container, theme) {
  13306. var _self = this;
  13307. this.container = container || dom.createElement("div");
  13308. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13309. dom.addCssClass(this.container, "ace_editor");
  13310. this.setTheme(theme);
  13311. this.$gutter = dom.createElement("div");
  13312. this.$gutter.className = "ace_gutter";
  13313. this.container.appendChild(this.$gutter);
  13314. this.scroller = dom.createElement("div");
  13315. this.scroller.className = "ace_scroller";
  13316. this.container.appendChild(this.scroller);
  13317. this.content = dom.createElement("div");
  13318. this.content.className = "ace_content";
  13319. this.scroller.appendChild(this.content);
  13320. this.$gutterLayer = new GutterLayer(this.$gutter);
  13321. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13322. this.$markerBack = new MarkerLayer(this.content);
  13323. var textLayer = this.$textLayer = new TextLayer(this.content);
  13324. this.canvas = textLayer.element;
  13325. this.$markerFront = new MarkerLayer(this.content);
  13326. this.$cursorLayer = new CursorLayer(this.content);
  13327. this.$horizScroll = false;
  13328. this.$vScroll = false;
  13329. this.scrollBar =
  13330. this.scrollBarV = new VScrollBar(this.container, this);
  13331. this.scrollBarH = new HScrollBar(this.container, this);
  13332. this.scrollBarV.addEventListener("scroll", function(e) {
  13333. if (!_self.$scrollAnimation)
  13334. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13335. });
  13336. this.scrollBarH.addEventListener("scroll", function(e) {
  13337. if (!_self.$scrollAnimation)
  13338. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13339. });
  13340. this.scrollTop = 0;
  13341. this.scrollLeft = 0;
  13342. this.cursorPos = {
  13343. row : 0,
  13344. column : 0
  13345. };
  13346. this.$fontMetrics = new FontMetrics(this.container, 500);
  13347. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13348. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13349. _self.updateCharacterSize();
  13350. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13351. _self._signal("changeCharacterSize", e);
  13352. });
  13353. this.$size = {
  13354. width: 0,
  13355. height: 0,
  13356. scrollerHeight: 0,
  13357. scrollerWidth: 0,
  13358. $dirty: true
  13359. };
  13360. this.layerConfig = {
  13361. width : 1,
  13362. padding : 0,
  13363. firstRow : 0,
  13364. firstRowScreen: 0,
  13365. lastRow : 0,
  13366. lineHeight : 0,
  13367. characterWidth : 0,
  13368. minHeight : 1,
  13369. maxHeight : 1,
  13370. offset : 0,
  13371. height : 1,
  13372. gutterOffset: 1
  13373. };
  13374. this.scrollMargin = {
  13375. left: 0,
  13376. right: 0,
  13377. top: 0,
  13378. bottom: 0,
  13379. v: 0,
  13380. h: 0
  13381. };
  13382. this.$loop = new RenderLoop(
  13383. this.$renderChanges.bind(this),
  13384. this.container.ownerDocument.defaultView
  13385. );
  13386. this.$loop.schedule(this.CHANGE_FULL);
  13387. this.updateCharacterSize();
  13388. this.setPadding(4);
  13389. config.resetOptions(this);
  13390. config._emit("renderer", this);
  13391. };
  13392. (function() {
  13393. this.CHANGE_CURSOR = 1;
  13394. this.CHANGE_MARKER = 2;
  13395. this.CHANGE_GUTTER = 4;
  13396. this.CHANGE_SCROLL = 8;
  13397. this.CHANGE_LINES = 16;
  13398. this.CHANGE_TEXT = 32;
  13399. this.CHANGE_SIZE = 64;
  13400. this.CHANGE_MARKER_BACK = 128;
  13401. this.CHANGE_MARKER_FRONT = 256;
  13402. this.CHANGE_FULL = 512;
  13403. this.CHANGE_H_SCROLL = 1024;
  13404. oop.implement(this, EventEmitter);
  13405. this.updateCharacterSize = function() {
  13406. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13407. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13408. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13409. }
  13410. this.layerConfig.characterWidth =
  13411. this.characterWidth = this.$textLayer.getCharacterWidth();
  13412. this.layerConfig.lineHeight =
  13413. this.lineHeight = this.$textLayer.getLineHeight();
  13414. this.$updatePrintMargin();
  13415. };
  13416. this.setSession = function(session) {
  13417. if (this.session)
  13418. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13419. this.session = session;
  13420. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13421. session.setScrollTop(-this.scrollMargin.top);
  13422. this.$cursorLayer.setSession(session);
  13423. this.$markerBack.setSession(session);
  13424. this.$markerFront.setSession(session);
  13425. this.$gutterLayer.setSession(session);
  13426. this.$textLayer.setSession(session);
  13427. if (!session)
  13428. return;
  13429. this.$loop.schedule(this.CHANGE_FULL);
  13430. this.session.$setFontMetrics(this.$fontMetrics);
  13431. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13432. this.onChangeNewLineMode()
  13433. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13434. };
  13435. this.updateLines = function(firstRow, lastRow, force) {
  13436. if (lastRow === undefined)
  13437. lastRow = Infinity;
  13438. if (!this.$changedLines) {
  13439. this.$changedLines = {
  13440. firstRow: firstRow,
  13441. lastRow: lastRow
  13442. };
  13443. }
  13444. else {
  13445. if (this.$changedLines.firstRow > firstRow)
  13446. this.$changedLines.firstRow = firstRow;
  13447. if (this.$changedLines.lastRow < lastRow)
  13448. this.$changedLines.lastRow = lastRow;
  13449. }
  13450. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13451. if (force)
  13452. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13453. else
  13454. return;
  13455. }
  13456. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13457. return;
  13458. this.$loop.schedule(this.CHANGE_LINES);
  13459. };
  13460. this.onChangeNewLineMode = function() {
  13461. this.$loop.schedule(this.CHANGE_TEXT);
  13462. this.$textLayer.$updateEolChar();
  13463. };
  13464. this.onChangeTabSize = function() {
  13465. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13466. this.$textLayer.onChangeTabSize();
  13467. };
  13468. this.updateText = function() {
  13469. this.$loop.schedule(this.CHANGE_TEXT);
  13470. };
  13471. this.updateFull = function(force) {
  13472. if (force)
  13473. this.$renderChanges(this.CHANGE_FULL, true);
  13474. else
  13475. this.$loop.schedule(this.CHANGE_FULL);
  13476. };
  13477. this.updateFontSize = function() {
  13478. this.$textLayer.checkForSizeChanges();
  13479. };
  13480. this.$changes = 0;
  13481. this.$updateSizeAsync = function() {
  13482. if (this.$loop.pending)
  13483. this.$size.$dirty = true;
  13484. else
  13485. this.onResize();
  13486. };
  13487. this.onResize = function(force, gutterWidth, width, height) {
  13488. if (this.resizing > 2)
  13489. return;
  13490. else if (this.resizing > 0)
  13491. this.resizing++;
  13492. else
  13493. this.resizing = force ? 1 : 0;
  13494. var el = this.container;
  13495. if (!height)
  13496. height = el.clientHeight || el.scrollHeight;
  13497. if (!width)
  13498. width = el.clientWidth || el.scrollWidth;
  13499. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13500. if (!this.$size.scrollerHeight || (!width && !height))
  13501. return this.resizing = 0;
  13502. if (force)
  13503. this.$gutterLayer.$padding = null;
  13504. if (force)
  13505. this.$renderChanges(changes | this.$changes, true);
  13506. else
  13507. this.$loop.schedule(changes | this.$changes);
  13508. if (this.resizing)
  13509. this.resizing = 0;
  13510. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13511. };
  13512. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13513. height -= (this.$extraHeight || 0);
  13514. var changes = 0;
  13515. var size = this.$size;
  13516. var oldSize = {
  13517. width: size.width,
  13518. height: size.height,
  13519. scrollerHeight: size.scrollerHeight,
  13520. scrollerWidth: size.scrollerWidth
  13521. };
  13522. if (height && (force || size.height != height)) {
  13523. size.height = height;
  13524. changes |= this.CHANGE_SIZE;
  13525. size.scrollerHeight = size.height;
  13526. if (this.$horizScroll)
  13527. size.scrollerHeight -= this.scrollBarH.getHeight();
  13528. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13529. changes = changes | this.CHANGE_SCROLL;
  13530. }
  13531. if (width && (force || size.width != width)) {
  13532. changes |= this.CHANGE_SIZE;
  13533. size.width = width;
  13534. if (gutterWidth == null)
  13535. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13536. this.gutterWidth = gutterWidth;
  13537. this.scrollBarH.element.style.left =
  13538. this.scroller.style.left = gutterWidth + "px";
  13539. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13540. this.scrollBarH.element.style.right =
  13541. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13542. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13543. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13544. changes |= this.CHANGE_FULL;
  13545. }
  13546. size.$dirty = !width || !height;
  13547. if (changes)
  13548. this._signal("resize", oldSize);
  13549. return changes;
  13550. };
  13551. this.onGutterResize = function() {
  13552. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13553. if (gutterWidth != this.gutterWidth)
  13554. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13555. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13556. this.$loop.schedule(this.CHANGE_FULL);
  13557. } else if (this.$size.$dirty) {
  13558. this.$loop.schedule(this.CHANGE_FULL);
  13559. } else {
  13560. this.$computeLayerConfig();
  13561. this.$loop.schedule(this.CHANGE_MARKER);
  13562. }
  13563. };
  13564. this.adjustWrapLimit = function() {
  13565. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13566. var limit = Math.floor(availableWidth / this.characterWidth);
  13567. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13568. };
  13569. this.setAnimatedScroll = function(shouldAnimate){
  13570. this.setOption("animatedScroll", shouldAnimate);
  13571. };
  13572. this.getAnimatedScroll = function() {
  13573. return this.$animatedScroll;
  13574. };
  13575. this.setShowInvisibles = function(showInvisibles) {
  13576. this.setOption("showInvisibles", showInvisibles);
  13577. };
  13578. this.getShowInvisibles = function() {
  13579. return this.getOption("showInvisibles");
  13580. };
  13581. this.getDisplayIndentGuides = function() {
  13582. return this.getOption("displayIndentGuides");
  13583. };
  13584. this.setDisplayIndentGuides = function(display) {
  13585. this.setOption("displayIndentGuides", display);
  13586. };
  13587. this.setShowPrintMargin = function(showPrintMargin) {
  13588. this.setOption("showPrintMargin", showPrintMargin);
  13589. };
  13590. this.getShowPrintMargin = function() {
  13591. return this.getOption("showPrintMargin");
  13592. };
  13593. this.setPrintMarginColumn = function(showPrintMargin) {
  13594. this.setOption("printMarginColumn", showPrintMargin);
  13595. };
  13596. this.getPrintMarginColumn = function() {
  13597. return this.getOption("printMarginColumn");
  13598. };
  13599. this.getShowGutter = function(){
  13600. return this.getOption("showGutter");
  13601. };
  13602. this.setShowGutter = function(show){
  13603. return this.setOption("showGutter", show);
  13604. };
  13605. this.getFadeFoldWidgets = function(){
  13606. return this.getOption("fadeFoldWidgets")
  13607. };
  13608. this.setFadeFoldWidgets = function(show) {
  13609. this.setOption("fadeFoldWidgets", show);
  13610. };
  13611. this.setHighlightGutterLine = function(shouldHighlight) {
  13612. this.setOption("highlightGutterLine", shouldHighlight);
  13613. };
  13614. this.getHighlightGutterLine = function() {
  13615. return this.getOption("highlightGutterLine");
  13616. };
  13617. this.$updateGutterLineHighlight = function() {
  13618. var pos = this.$cursorLayer.$pixelPos;
  13619. var height = this.layerConfig.lineHeight;
  13620. if (this.session.getUseWrapMode()) {
  13621. var cursor = this.session.selection.getCursor();
  13622. cursor.column = 0;
  13623. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13624. height *= this.session.getRowLength(cursor.row);
  13625. }
  13626. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13627. this.$gutterLineHighlight.style.height = height + "px";
  13628. };
  13629. this.$updatePrintMargin = function() {
  13630. if (!this.$showPrintMargin && !this.$printMarginEl)
  13631. return;
  13632. if (!this.$printMarginEl) {
  13633. var containerEl = dom.createElement("div");
  13634. containerEl.className = "ace_layer ace_print-margin-layer";
  13635. this.$printMarginEl = dom.createElement("div");
  13636. this.$printMarginEl.className = "ace_print-margin";
  13637. containerEl.appendChild(this.$printMarginEl);
  13638. this.content.insertBefore(containerEl, this.content.firstChild);
  13639. }
  13640. var style = this.$printMarginEl.style;
  13641. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13642. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13643. if (this.session && this.session.$wrap == -1)
  13644. this.adjustWrapLimit();
  13645. };
  13646. this.getContainerElement = function() {
  13647. return this.container;
  13648. };
  13649. this.getMouseEventTarget = function() {
  13650. return this.scroller;
  13651. };
  13652. this.getTextAreaContainer = function() {
  13653. return this.container;
  13654. };
  13655. this.$moveTextAreaToCursor = function() {
  13656. if (!this.$keepTextAreaAtCursor)
  13657. return;
  13658. var config = this.layerConfig;
  13659. var posTop = this.$cursorLayer.$pixelPos.top;
  13660. var posLeft = this.$cursorLayer.$pixelPos.left;
  13661. posTop -= config.offset;
  13662. var style = this.textarea.style;
  13663. var h = this.lineHeight;
  13664. if (posTop < 0 || posTop > config.height - h) {
  13665. style.top = style.left = "0";
  13666. return;
  13667. }
  13668. var w = this.characterWidth;
  13669. if (this.$composition) {
  13670. var val = this.textarea.value.replace(/^\x01+/, "");
  13671. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13672. h += 2;
  13673. }
  13674. posLeft -= this.scrollLeft;
  13675. if (posLeft > this.$size.scrollerWidth - w)
  13676. posLeft = this.$size.scrollerWidth - w;
  13677. posLeft += this.gutterWidth;
  13678. style.height = h + "px";
  13679. style.width = w + "px";
  13680. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13681. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13682. };
  13683. this.getFirstVisibleRow = function() {
  13684. return this.layerConfig.firstRow;
  13685. };
  13686. this.getFirstFullyVisibleRow = function() {
  13687. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13688. };
  13689. this.getLastFullyVisibleRow = function() {
  13690. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  13691. return this.layerConfig.firstRow - 1 + flint;
  13692. };
  13693. this.getLastVisibleRow = function() {
  13694. return this.layerConfig.lastRow;
  13695. };
  13696. this.$padding = null;
  13697. this.setPadding = function(padding) {
  13698. this.$padding = padding;
  13699. this.$textLayer.setPadding(padding);
  13700. this.$cursorLayer.setPadding(padding);
  13701. this.$markerFront.setPadding(padding);
  13702. this.$markerBack.setPadding(padding);
  13703. this.$loop.schedule(this.CHANGE_FULL);
  13704. this.$updatePrintMargin();
  13705. };
  13706. this.setScrollMargin = function(top, bottom, left, right) {
  13707. var sm = this.scrollMargin;
  13708. sm.top = top|0;
  13709. sm.bottom = bottom|0;
  13710. sm.right = right|0;
  13711. sm.left = left|0;
  13712. sm.v = sm.top + sm.bottom;
  13713. sm.h = sm.left + sm.right;
  13714. if (sm.top && this.scrollTop <= 0 && this.session)
  13715. this.session.setScrollTop(-sm.top);
  13716. this.updateFull();
  13717. };
  13718. this.getHScrollBarAlwaysVisible = function() {
  13719. return this.$hScrollBarAlwaysVisible;
  13720. };
  13721. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13722. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13723. };
  13724. this.getVScrollBarAlwaysVisible = function() {
  13725. return this.$vScrollBarAlwaysVisible;
  13726. };
  13727. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13728. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13729. };
  13730. this.$updateScrollBarV = function() {
  13731. var scrollHeight = this.layerConfig.maxHeight;
  13732. var scrollerHeight = this.$size.scrollerHeight;
  13733. if (!this.$maxLines && this.$scrollPastEnd) {
  13734. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13735. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13736. scrollHeight = this.scrollTop + scrollerHeight;
  13737. this.scrollBarV.scrollTop = null;
  13738. }
  13739. }
  13740. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13741. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13742. };
  13743. this.$updateScrollBarH = function() {
  13744. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13745. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13746. };
  13747. this.$frozen = false;
  13748. this.freeze = function() {
  13749. this.$frozen = true;
  13750. };
  13751. this.unfreeze = function() {
  13752. this.$frozen = false;
  13753. };
  13754. this.$renderChanges = function(changes, force) {
  13755. if (this.$changes) {
  13756. changes |= this.$changes;
  13757. this.$changes = 0;
  13758. }
  13759. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13760. this.$changes |= changes;
  13761. return;
  13762. }
  13763. if (this.$size.$dirty) {
  13764. this.$changes |= changes;
  13765. return this.onResize(true);
  13766. }
  13767. if (!this.lineHeight) {
  13768. this.$textLayer.checkForSizeChanges();
  13769. }
  13770. this._signal("beforeRender");
  13771. var config = this.layerConfig;
  13772. if (changes & this.CHANGE_FULL ||
  13773. changes & this.CHANGE_SIZE ||
  13774. changes & this.CHANGE_TEXT ||
  13775. changes & this.CHANGE_LINES ||
  13776. changes & this.CHANGE_SCROLL ||
  13777. changes & this.CHANGE_H_SCROLL
  13778. ) {
  13779. changes |= this.$computeLayerConfig();
  13780. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13781. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13782. if (st > 0) {
  13783. this.scrollTop = st;
  13784. changes = changes | this.CHANGE_SCROLL;
  13785. changes |= this.$computeLayerConfig();
  13786. }
  13787. }
  13788. config = this.layerConfig;
  13789. this.$updateScrollBarV();
  13790. if (changes & this.CHANGE_H_SCROLL)
  13791. this.$updateScrollBarH();
  13792. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13793. this.content.style.marginTop = (-config.offset) + "px";
  13794. this.content.style.width = config.width + 2 * this.$padding + "px";
  13795. this.content.style.height = config.minHeight + "px";
  13796. }
  13797. if (changes & this.CHANGE_H_SCROLL) {
  13798. this.content.style.marginLeft = -this.scrollLeft + "px";
  13799. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13800. }
  13801. if (changes & this.CHANGE_FULL) {
  13802. this.$textLayer.update(config);
  13803. if (this.$showGutter)
  13804. this.$gutterLayer.update(config);
  13805. this.$markerBack.update(config);
  13806. this.$markerFront.update(config);
  13807. this.$cursorLayer.update(config);
  13808. this.$moveTextAreaToCursor();
  13809. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13810. this._signal("afterRender");
  13811. return;
  13812. }
  13813. if (changes & this.CHANGE_SCROLL) {
  13814. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13815. this.$textLayer.update(config);
  13816. else
  13817. this.$textLayer.scrollLines(config);
  13818. if (this.$showGutter)
  13819. this.$gutterLayer.update(config);
  13820. this.$markerBack.update(config);
  13821. this.$markerFront.update(config);
  13822. this.$cursorLayer.update(config);
  13823. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13824. this.$moveTextAreaToCursor();
  13825. this._signal("afterRender");
  13826. return;
  13827. }
  13828. if (changes & this.CHANGE_TEXT) {
  13829. this.$textLayer.update(config);
  13830. if (this.$showGutter)
  13831. this.$gutterLayer.update(config);
  13832. }
  13833. else if (changes & this.CHANGE_LINES) {
  13834. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13835. this.$gutterLayer.update(config);
  13836. }
  13837. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13838. if (this.$showGutter)
  13839. this.$gutterLayer.update(config);
  13840. }
  13841. if (changes & this.CHANGE_CURSOR) {
  13842. this.$cursorLayer.update(config);
  13843. this.$moveTextAreaToCursor();
  13844. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13845. }
  13846. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13847. this.$markerFront.update(config);
  13848. }
  13849. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13850. this.$markerBack.update(config);
  13851. }
  13852. this._signal("afterRender");
  13853. };
  13854. this.$autosize = function() {
  13855. var height = this.session.getScreenLength() * this.lineHeight;
  13856. var maxHeight = this.$maxLines * this.lineHeight;
  13857. var desiredHeight = Math.max(
  13858. (this.$minLines||1) * this.lineHeight,
  13859. Math.min(maxHeight, height)
  13860. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13861. if (this.$horizScroll)
  13862. desiredHeight += this.scrollBarH.getHeight();
  13863. var vScroll = height > maxHeight;
  13864. if (desiredHeight != this.desiredHeight ||
  13865. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13866. if (vScroll != this.$vScroll) {
  13867. this.$vScroll = vScroll;
  13868. this.scrollBarV.setVisible(vScroll);
  13869. }
  13870. var w = this.container.clientWidth;
  13871. this.container.style.height = desiredHeight + "px";
  13872. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13873. this.desiredHeight = desiredHeight;
  13874. this._signal("autosize");
  13875. }
  13876. };
  13877. this.$computeLayerConfig = function() {
  13878. var session = this.session;
  13879. var size = this.$size;
  13880. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13881. var screenLines = this.session.getScreenLength();
  13882. var maxHeight = screenLines * this.lineHeight;
  13883. var longestLine = this.$getLongestLine();
  13884. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13885. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13886. var hScrollChanged = this.$horizScroll !== horizScroll;
  13887. if (hScrollChanged) {
  13888. this.$horizScroll = horizScroll;
  13889. this.scrollBarH.setVisible(horizScroll);
  13890. }
  13891. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  13892. if (this.$maxLines && this.lineHeight > 1)
  13893. this.$autosize();
  13894. var offset = this.scrollTop % this.lineHeight;
  13895. var minHeight = size.scrollerHeight + this.lineHeight;
  13896. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13897. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13898. : 0;
  13899. maxHeight += scrollPastEnd;
  13900. var sm = this.scrollMargin;
  13901. this.session.setScrollTop(Math.max(-sm.top,
  13902. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  13903. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  13904. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  13905. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13906. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  13907. var vScrollChanged = vScrollBefore !== vScroll;
  13908. if (vScrollChanged) {
  13909. this.$vScroll = vScroll;
  13910. this.scrollBarV.setVisible(vScroll);
  13911. }
  13912. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13913. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13914. var lastRow = firstRow + lineCount;
  13915. var firstRowScreen, firstRowHeight;
  13916. var lineHeight = this.lineHeight;
  13917. firstRow = session.screenToDocumentRow(firstRow, 0);
  13918. var foldLine = session.getFoldLine(firstRow);
  13919. if (foldLine) {
  13920. firstRow = foldLine.start.row;
  13921. }
  13922. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13923. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13924. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13925. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13926. firstRowHeight;
  13927. offset = this.scrollTop - firstRowScreen * lineHeight;
  13928. var changes = 0;
  13929. if (this.layerConfig.width != longestLine)
  13930. changes = this.CHANGE_H_SCROLL;
  13931. if (hScrollChanged || vScrollChanged) {
  13932. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13933. this._signal("scrollbarVisibilityChanged");
  13934. if (vScrollChanged)
  13935. longestLine = this.$getLongestLine();
  13936. }
  13937. this.layerConfig = {
  13938. width : longestLine,
  13939. padding : this.$padding,
  13940. firstRow : firstRow,
  13941. firstRowScreen: firstRowScreen,
  13942. lastRow : lastRow,
  13943. lineHeight : lineHeight,
  13944. characterWidth : this.characterWidth,
  13945. minHeight : minHeight,
  13946. maxHeight : maxHeight,
  13947. offset : offset,
  13948. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13949. height : this.$size.scrollerHeight
  13950. };
  13951. return changes;
  13952. };
  13953. this.$updateLines = function() {
  13954. var firstRow = this.$changedLines.firstRow;
  13955. var lastRow = this.$changedLines.lastRow;
  13956. this.$changedLines = null;
  13957. var layerConfig = this.layerConfig;
  13958. if (firstRow > layerConfig.lastRow + 1) { return; }
  13959. if (lastRow < layerConfig.firstRow) { return; }
  13960. if (lastRow === Infinity) {
  13961. if (this.$showGutter)
  13962. this.$gutterLayer.update(layerConfig);
  13963. this.$textLayer.update(layerConfig);
  13964. return;
  13965. }
  13966. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13967. return true;
  13968. };
  13969. this.$getLongestLine = function() {
  13970. var charCount = this.session.getScreenWidth();
  13971. if (this.showInvisibles && !this.session.$useWrapMode)
  13972. charCount += 1;
  13973. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13974. };
  13975. this.updateFrontMarkers = function() {
  13976. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13977. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13978. };
  13979. this.updateBackMarkers = function() {
  13980. this.$markerBack.setMarkers(this.session.getMarkers());
  13981. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  13982. };
  13983. this.addGutterDecoration = function(row, className){
  13984. this.$gutterLayer.addGutterDecoration(row, className);
  13985. };
  13986. this.removeGutterDecoration = function(row, className){
  13987. this.$gutterLayer.removeGutterDecoration(row, className);
  13988. };
  13989. this.updateBreakpoints = function(rows) {
  13990. this.$loop.schedule(this.CHANGE_GUTTER);
  13991. };
  13992. this.setAnnotations = function(annotations) {
  13993. this.$gutterLayer.setAnnotations(annotations);
  13994. this.$loop.schedule(this.CHANGE_GUTTER);
  13995. };
  13996. this.updateCursor = function() {
  13997. this.$loop.schedule(this.CHANGE_CURSOR);
  13998. };
  13999. this.hideCursor = function() {
  14000. this.$cursorLayer.hideCursor();
  14001. };
  14002. this.showCursor = function() {
  14003. this.$cursorLayer.showCursor();
  14004. };
  14005. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  14006. this.scrollCursorIntoView(anchor, offset);
  14007. this.scrollCursorIntoView(lead, offset);
  14008. };
  14009. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  14010. if (this.$size.scrollerHeight === 0)
  14011. return;
  14012. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14013. var left = pos.left;
  14014. var top = pos.top;
  14015. var topMargin = $viewMargin && $viewMargin.top || 0;
  14016. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  14017. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  14018. if (scrollTop + topMargin > top) {
  14019. if (offset)
  14020. top -= offset * this.$size.scrollerHeight;
  14021. if (top === 0)
  14022. top = -this.scrollMargin.top;
  14023. this.session.setScrollTop(top);
  14024. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  14025. if (offset)
  14026. top += offset * this.$size.scrollerHeight;
  14027. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  14028. }
  14029. var scrollLeft = this.scrollLeft;
  14030. if (scrollLeft > left) {
  14031. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  14032. left = -this.scrollMargin.left;
  14033. this.session.setScrollLeft(left);
  14034. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  14035. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  14036. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  14037. this.session.setScrollLeft(0);
  14038. }
  14039. };
  14040. this.getScrollTop = function() {
  14041. return this.session.getScrollTop();
  14042. };
  14043. this.getScrollLeft = function() {
  14044. return this.session.getScrollLeft();
  14045. };
  14046. this.getScrollTopRow = function() {
  14047. return this.scrollTop / this.lineHeight;
  14048. };
  14049. this.getScrollBottomRow = function() {
  14050. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  14051. };
  14052. this.scrollToRow = function(row) {
  14053. this.session.setScrollTop(row * this.lineHeight);
  14054. };
  14055. this.alignCursor = function(cursor, alignment) {
  14056. if (typeof cursor == "number")
  14057. cursor = {row: cursor, column: 0};
  14058. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14059. var h = this.$size.scrollerHeight - this.lineHeight;
  14060. var offset = pos.top - h * (alignment || 0);
  14061. this.session.setScrollTop(offset);
  14062. return offset;
  14063. };
  14064. this.STEPS = 8;
  14065. this.$calcSteps = function(fromValue, toValue){
  14066. var i = 0;
  14067. var l = this.STEPS;
  14068. var steps = [];
  14069. var func = function(t, x_min, dx) {
  14070. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  14071. };
  14072. for (i = 0; i < l; ++i)
  14073. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  14074. return steps;
  14075. };
  14076. this.scrollToLine = function(line, center, animate, callback) {
  14077. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  14078. var offset = pos.top;
  14079. if (center)
  14080. offset -= this.$size.scrollerHeight / 2;
  14081. var initialScroll = this.scrollTop;
  14082. this.session.setScrollTop(offset);
  14083. if (animate !== false)
  14084. this.animateScrolling(initialScroll, callback);
  14085. };
  14086. this.animateScrolling = function(fromValue, callback) {
  14087. var toValue = this.scrollTop;
  14088. if (!this.$animatedScroll)
  14089. return;
  14090. var _self = this;
  14091. if (fromValue == toValue)
  14092. return;
  14093. if (this.$scrollAnimation) {
  14094. var oldSteps = this.$scrollAnimation.steps;
  14095. if (oldSteps.length) {
  14096. fromValue = oldSteps[0];
  14097. if (fromValue == toValue)
  14098. return;
  14099. }
  14100. }
  14101. var steps = _self.$calcSteps(fromValue, toValue);
  14102. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  14103. clearInterval(this.$timer);
  14104. _self.session.setScrollTop(steps.shift());
  14105. _self.session.$scrollTop = toValue;
  14106. this.$timer = setInterval(function() {
  14107. if (steps.length) {
  14108. _self.session.setScrollTop(steps.shift());
  14109. _self.session.$scrollTop = toValue;
  14110. } else if (toValue != null) {
  14111. _self.session.$scrollTop = -1;
  14112. _self.session.setScrollTop(toValue);
  14113. toValue = null;
  14114. } else {
  14115. _self.$timer = clearInterval(_self.$timer);
  14116. _self.$scrollAnimation = null;
  14117. callback && callback();
  14118. }
  14119. }, 10);
  14120. };
  14121. this.scrollToY = function(scrollTop) {
  14122. if (this.scrollTop !== scrollTop) {
  14123. this.$loop.schedule(this.CHANGE_SCROLL);
  14124. this.scrollTop = scrollTop;
  14125. }
  14126. };
  14127. this.scrollToX = function(scrollLeft) {
  14128. if (this.scrollLeft !== scrollLeft)
  14129. this.scrollLeft = scrollLeft;
  14130. this.$loop.schedule(this.CHANGE_H_SCROLL);
  14131. };
  14132. this.scrollTo = function(x, y) {
  14133. this.session.setScrollTop(y);
  14134. this.session.setScrollLeft(y);
  14135. };
  14136. this.scrollBy = function(deltaX, deltaY) {
  14137. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  14138. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  14139. };
  14140. this.isScrollableBy = function(deltaX, deltaY) {
  14141. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  14142. return true;
  14143. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  14144. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  14145. return true;
  14146. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  14147. return true;
  14148. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  14149. - this.layerConfig.width < -1 + this.scrollMargin.right)
  14150. return true;
  14151. };
  14152. this.pixelToScreenCoordinates = function(x, y) {
  14153. var canvasPos = this.scroller.getBoundingClientRect();
  14154. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  14155. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  14156. var col = Math.round(offset);
  14157. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  14158. };
  14159. this.screenToTextCoordinates = function(x, y) {
  14160. var canvasPos = this.scroller.getBoundingClientRect();
  14161. var col = Math.round(
  14162. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  14163. );
  14164. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  14165. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  14166. };
  14167. this.textToScreenCoordinates = function(row, column) {
  14168. var canvasPos = this.scroller.getBoundingClientRect();
  14169. var pos = this.session.documentToScreenPosition(row, column);
  14170. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  14171. var y = pos.row * this.lineHeight;
  14172. return {
  14173. pageX: canvasPos.left + x - this.scrollLeft,
  14174. pageY: canvasPos.top + y - this.scrollTop
  14175. };
  14176. };
  14177. this.visualizeFocus = function() {
  14178. dom.addCssClass(this.container, "ace_focus");
  14179. };
  14180. this.visualizeBlur = function() {
  14181. dom.removeCssClass(this.container, "ace_focus");
  14182. };
  14183. this.showComposition = function(position) {
  14184. if (!this.$composition)
  14185. this.$composition = {
  14186. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  14187. cssText: this.textarea.style.cssText
  14188. };
  14189. this.$keepTextAreaAtCursor = true;
  14190. dom.addCssClass(this.textarea, "ace_composition");
  14191. this.textarea.style.cssText = "";
  14192. this.$moveTextAreaToCursor();
  14193. };
  14194. this.setCompositionText = function(text) {
  14195. this.$moveTextAreaToCursor();
  14196. };
  14197. this.hideComposition = function() {
  14198. if (!this.$composition)
  14199. return;
  14200. dom.removeCssClass(this.textarea, "ace_composition");
  14201. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  14202. this.textarea.style.cssText = this.$composition.cssText;
  14203. this.$composition = null;
  14204. };
  14205. this.setTheme = function(theme, cb) {
  14206. var _self = this;
  14207. this.$themeId = theme;
  14208. _self._dispatchEvent('themeChange',{theme:theme});
  14209. if (!theme || typeof theme == "string") {
  14210. var moduleName = theme || this.$options.theme.initialValue;
  14211. config.loadModule(["theme", moduleName], afterLoad);
  14212. } else {
  14213. afterLoad(theme);
  14214. }
  14215. function afterLoad(module) {
  14216. if (_self.$themeId != theme)
  14217. return cb && cb();
  14218. if (!module.cssClass)
  14219. return;
  14220. dom.importCssString(
  14221. module.cssText,
  14222. module.cssClass,
  14223. _self.container.ownerDocument
  14224. );
  14225. if (_self.theme)
  14226. dom.removeCssClass(_self.container, _self.theme.cssClass);
  14227. var padding = "padding" in module ? module.padding
  14228. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  14229. if (_self.$padding && padding != _self.$padding)
  14230. _self.setPadding(padding);
  14231. _self.$theme = module.cssClass;
  14232. _self.theme = module;
  14233. dom.addCssClass(_self.container, module.cssClass);
  14234. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  14235. if (_self.$size) {
  14236. _self.$size.width = 0;
  14237. _self.$updateSizeAsync();
  14238. }
  14239. _self._dispatchEvent('themeLoaded', {theme:module});
  14240. cb && cb();
  14241. }
  14242. };
  14243. this.getTheme = function() {
  14244. return this.$themeId;
  14245. };
  14246. this.setStyle = function(style, include) {
  14247. dom.setCssClass(this.container, style, include !== false);
  14248. };
  14249. this.unsetStyle = function(style) {
  14250. dom.removeCssClass(this.container, style);
  14251. };
  14252. this.setCursorStyle = function(style) {
  14253. if (this.scroller.style.cursor != style)
  14254. this.scroller.style.cursor = style;
  14255. };
  14256. this.setMouseCursor = function(cursorStyle) {
  14257. this.scroller.style.cursor = cursorStyle;
  14258. };
  14259. this.destroy = function() {
  14260. this.$textLayer.destroy();
  14261. this.$cursorLayer.destroy();
  14262. };
  14263. }).call(VirtualRenderer.prototype);
  14264. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  14265. animatedScroll: {initialValue: false},
  14266. showInvisibles: {
  14267. set: function(value) {
  14268. if (this.$textLayer.setShowInvisibles(value))
  14269. this.$loop.schedule(this.CHANGE_TEXT);
  14270. },
  14271. initialValue: false
  14272. },
  14273. showPrintMargin: {
  14274. set: function() { this.$updatePrintMargin(); },
  14275. initialValue: true
  14276. },
  14277. printMarginColumn: {
  14278. set: function() { this.$updatePrintMargin(); },
  14279. initialValue: 80
  14280. },
  14281. printMargin: {
  14282. set: function(val) {
  14283. if (typeof val == "number")
  14284. this.$printMarginColumn = val;
  14285. this.$showPrintMargin = !!val;
  14286. this.$updatePrintMargin();
  14287. },
  14288. get: function() {
  14289. return this.$showPrintMargin && this.$printMarginColumn;
  14290. }
  14291. },
  14292. showGutter: {
  14293. set: function(show){
  14294. this.$gutter.style.display = show ? "block" : "none";
  14295. this.$loop.schedule(this.CHANGE_FULL);
  14296. this.onGutterResize();
  14297. },
  14298. initialValue: true
  14299. },
  14300. fadeFoldWidgets: {
  14301. set: function(show) {
  14302. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14303. },
  14304. initialValue: false
  14305. },
  14306. showFoldWidgets: {
  14307. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14308. initialValue: true
  14309. },
  14310. showLineNumbers: {
  14311. set: function(show) {
  14312. this.$gutterLayer.setShowLineNumbers(show);
  14313. this.$loop.schedule(this.CHANGE_GUTTER);
  14314. },
  14315. initialValue: true
  14316. },
  14317. displayIndentGuides: {
  14318. set: function(show) {
  14319. if (this.$textLayer.setDisplayIndentGuides(show))
  14320. this.$loop.schedule(this.CHANGE_TEXT);
  14321. },
  14322. initialValue: true
  14323. },
  14324. highlightGutterLine: {
  14325. set: function(shouldHighlight) {
  14326. if (!this.$gutterLineHighlight) {
  14327. this.$gutterLineHighlight = dom.createElement("div");
  14328. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14329. this.$gutter.appendChild(this.$gutterLineHighlight);
  14330. return;
  14331. }
  14332. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14333. if (this.$cursorLayer.$pixelPos)
  14334. this.$updateGutterLineHighlight();
  14335. },
  14336. initialValue: false,
  14337. value: true
  14338. },
  14339. hScrollBarAlwaysVisible: {
  14340. set: function(val) {
  14341. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14342. this.$loop.schedule(this.CHANGE_SCROLL);
  14343. },
  14344. initialValue: false
  14345. },
  14346. vScrollBarAlwaysVisible: {
  14347. set: function(val) {
  14348. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14349. this.$loop.schedule(this.CHANGE_SCROLL);
  14350. },
  14351. initialValue: false
  14352. },
  14353. fontSize: {
  14354. set: function(size) {
  14355. if (typeof size == "number")
  14356. size = size + "px";
  14357. this.container.style.fontSize = size;
  14358. this.updateFontSize();
  14359. },
  14360. initialValue: 12
  14361. },
  14362. fontFamily: {
  14363. set: function(name) {
  14364. this.container.style.fontFamily = name;
  14365. this.updateFontSize();
  14366. }
  14367. },
  14368. maxLines: {
  14369. set: function(val) {
  14370. this.updateFull();
  14371. }
  14372. },
  14373. minLines: {
  14374. set: function(val) {
  14375. this.updateFull();
  14376. }
  14377. },
  14378. scrollPastEnd: {
  14379. set: function(val) {
  14380. val = +val || 0;
  14381. if (this.$scrollPastEnd == val)
  14382. return;
  14383. this.$scrollPastEnd = val;
  14384. this.$loop.schedule(this.CHANGE_SCROLL);
  14385. },
  14386. initialValue: 0,
  14387. handlesSet: true
  14388. },
  14389. fixedWidthGutter: {
  14390. set: function(val) {
  14391. this.$gutterLayer.$fixedWidth = !!val;
  14392. this.$loop.schedule(this.CHANGE_GUTTER);
  14393. }
  14394. },
  14395. theme: {
  14396. set: function(val) { this.setTheme(val) },
  14397. get: function() { return this.$themeId || this.theme; },
  14398. initialValue: "./theme/textmate",
  14399. handlesSet: true
  14400. }
  14401. });
  14402. exports.VirtualRenderer = VirtualRenderer;
  14403. });
  14404. define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
  14405. "use strict";
  14406. var oop = require("../lib/oop");
  14407. var net = require("../lib/net");
  14408. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14409. var config = require("../config");
  14410. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14411. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14412. this.changeListener = this.changeListener.bind(this);
  14413. this.onMessage = this.onMessage.bind(this);
  14414. if (require.nameToUrl && !require.toUrl)
  14415. require.toUrl = require.nameToUrl;
  14416. if (config.get("packaged") || !require.toUrl) {
  14417. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14418. } else {
  14419. var normalizePath = this.$normalizePath;
  14420. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14421. var tlns = {};
  14422. topLevelNamespaces.forEach(function(ns) {
  14423. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14424. });
  14425. }
  14426. try {
  14427. this.$worker = new Worker(workerUrl);
  14428. } catch(e) {
  14429. if (e instanceof window.DOMException) {
  14430. var blob = this.$workerBlob(workerUrl);
  14431. var URL = window.URL || window.webkitURL;
  14432. var blobURL = URL.createObjectURL(blob);
  14433. this.$worker = new Worker(blobURL);
  14434. URL.revokeObjectURL(blobURL);
  14435. } else {
  14436. throw e;
  14437. }
  14438. }
  14439. this.$worker.postMessage({
  14440. init : true,
  14441. tlns : tlns,
  14442. module : mod,
  14443. classname : classname
  14444. });
  14445. this.callbackId = 1;
  14446. this.callbacks = {};
  14447. this.$worker.onmessage = this.onMessage;
  14448. };
  14449. (function(){
  14450. oop.implement(this, EventEmitter);
  14451. this.onMessage = function(e) {
  14452. var msg = e.data;
  14453. switch(msg.type) {
  14454. case "event":
  14455. this._signal(msg.name, {data: msg.data});
  14456. break;
  14457. case "call":
  14458. var callback = this.callbacks[msg.id];
  14459. if (callback) {
  14460. callback(msg.data);
  14461. delete this.callbacks[msg.id];
  14462. }
  14463. break;
  14464. case "error":
  14465. this.reportError(msg.data);
  14466. break;
  14467. case "log":
  14468. window.console && console.log && console.log.apply(console, msg.data);
  14469. break;
  14470. }
  14471. };
  14472. this.reportError = function(err) {
  14473. window.console && console.error && console.error(err);
  14474. };
  14475. this.$normalizePath = function(path) {
  14476. return net.qualifyURL(path);
  14477. };
  14478. this.terminate = function() {
  14479. this._signal("terminate", {});
  14480. this.deltaQueue = null;
  14481. this.$worker.terminate();
  14482. this.$worker = null;
  14483. if (this.$doc)
  14484. this.$doc.off("change", this.changeListener);
  14485. this.$doc = null;
  14486. };
  14487. this.send = function(cmd, args) {
  14488. this.$worker.postMessage({command: cmd, args: args});
  14489. };
  14490. this.call = function(cmd, args, callback) {
  14491. if (callback) {
  14492. var id = this.callbackId++;
  14493. this.callbacks[id] = callback;
  14494. args.push(id);
  14495. }
  14496. this.send(cmd, args);
  14497. };
  14498. this.emit = function(event, data) {
  14499. try {
  14500. this.$worker.postMessage({event: event, data: {data: data.data}});
  14501. }
  14502. catch(ex) {
  14503. console.error(ex.stack);
  14504. }
  14505. };
  14506. this.attachToDocument = function(doc) {
  14507. if(this.$doc)
  14508. this.terminate();
  14509. this.$doc = doc;
  14510. this.call("setValue", [doc.getValue()]);
  14511. doc.on("change", this.changeListener);
  14512. };
  14513. this.changeListener = function(delta) {
  14514. if (!this.deltaQueue) {
  14515. this.deltaQueue = [];
  14516. setTimeout(this.$sendDeltaQueue, 0);
  14517. }
  14518. if (delta.action == "insert")
  14519. this.deltaQueue.push(delta.start, delta.lines);
  14520. else
  14521. this.deltaQueue.push(delta.start, delta.end);
  14522. };
  14523. this.$sendDeltaQueue = function() {
  14524. var q = this.deltaQueue;
  14525. if (!q) return;
  14526. this.deltaQueue = null;
  14527. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  14528. this.call("setValue", [this.$doc.getValue()]);
  14529. } else
  14530. this.emit("change", {data: q});
  14531. };
  14532. this.$workerBlob = function(workerUrl) {
  14533. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14534. try {
  14535. return new Blob([script], {"type": "application/javascript"});
  14536. } catch (e) { // Backwards-compatibility
  14537. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14538. var blobBuilder = new BlobBuilder();
  14539. blobBuilder.append(script);
  14540. return blobBuilder.getBlob("application/javascript");
  14541. }
  14542. };
  14543. }).call(WorkerClient.prototype);
  14544. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14545. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14546. this.changeListener = this.changeListener.bind(this);
  14547. this.callbackId = 1;
  14548. this.callbacks = {};
  14549. this.messageBuffer = [];
  14550. var main = null;
  14551. var emitSync = false;
  14552. var sender = Object.create(EventEmitter);
  14553. var _self = this;
  14554. this.$worker = {};
  14555. this.$worker.terminate = function() {};
  14556. this.$worker.postMessage = function(e) {
  14557. _self.messageBuffer.push(e);
  14558. if (main) {
  14559. if (emitSync)
  14560. setTimeout(processNext);
  14561. else
  14562. processNext();
  14563. }
  14564. };
  14565. this.setEmitSync = function(val) { emitSync = val };
  14566. var processNext = function() {
  14567. var msg = _self.messageBuffer.shift();
  14568. if (msg.command)
  14569. main[msg.command].apply(main, msg.args);
  14570. else if (msg.event)
  14571. sender._signal(msg.event, msg.data);
  14572. };
  14573. sender.postMessage = function(msg) {
  14574. _self.onMessage({data: msg});
  14575. };
  14576. sender.callback = function(data, callbackId) {
  14577. this.postMessage({type: "call", id: callbackId, data: data});
  14578. };
  14579. sender.emit = function(name, data) {
  14580. this.postMessage({type: "event", name: name, data: data});
  14581. };
  14582. config.loadModule(["worker", mod], function(Main) {
  14583. main = new Main[classname](sender);
  14584. while (_self.messageBuffer.length)
  14585. processNext();
  14586. });
  14587. };
  14588. UIWorkerClient.prototype = WorkerClient.prototype;
  14589. exports.UIWorkerClient = UIWorkerClient;
  14590. exports.WorkerClient = WorkerClient;
  14591. });
  14592. define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14593. "use strict";
  14594. var Range = require("./range").Range;
  14595. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14596. var oop = require("./lib/oop");
  14597. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14598. var _self = this;
  14599. this.length = length;
  14600. this.session = session;
  14601. this.doc = session.getDocument();
  14602. this.mainClass = mainClass;
  14603. this.othersClass = othersClass;
  14604. this.$onUpdate = this.onUpdate.bind(this);
  14605. this.doc.on("change", this.$onUpdate);
  14606. this.$others = others;
  14607. this.$onCursorChange = function() {
  14608. setTimeout(function() {
  14609. _self.onCursorChange();
  14610. });
  14611. };
  14612. this.$pos = pos;
  14613. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14614. this.$undoStackDepth = undoStack.length;
  14615. this.setup();
  14616. session.selection.on("changeCursor", this.$onCursorChange);
  14617. };
  14618. (function() {
  14619. oop.implement(this, EventEmitter);
  14620. this.setup = function() {
  14621. var _self = this;
  14622. var doc = this.doc;
  14623. var session = this.session;
  14624. this.selectionBefore = session.selection.toJSON();
  14625. if (session.selection.inMultiSelectMode)
  14626. session.selection.toSingleRange();
  14627. this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
  14628. var pos = this.pos;
  14629. pos.$insertRight = true;
  14630. pos.detach();
  14631. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14632. this.others = [];
  14633. this.$others.forEach(function(other) {
  14634. var anchor = doc.createAnchor(other.row, other.column);
  14635. anchor.$insertRight = true;
  14636. anchor.detach();
  14637. _self.others.push(anchor);
  14638. });
  14639. session.setUndoSelect(false);
  14640. };
  14641. this.showOtherMarkers = function() {
  14642. if (this.othersActive) return;
  14643. var session = this.session;
  14644. var _self = this;
  14645. this.othersActive = true;
  14646. this.others.forEach(function(anchor) {
  14647. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14648. });
  14649. };
  14650. this.hideOtherMarkers = function() {
  14651. if (!this.othersActive) return;
  14652. this.othersActive = false;
  14653. for (var i = 0; i < this.others.length; i++) {
  14654. this.session.removeMarker(this.others[i].markerId);
  14655. }
  14656. };
  14657. this.onUpdate = function(delta) {
  14658. if (this.$updating)
  14659. return this.updateAnchors(delta);
  14660. var range = delta;
  14661. if (range.start.row !== range.end.row) return;
  14662. if (range.start.row !== this.pos.row) return;
  14663. this.$updating = true;
  14664. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14665. var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
  14666. var distanceFromStart = range.start.column - this.pos.column;
  14667. this.updateAnchors(delta);
  14668. if (inMainRange)
  14669. this.length += lengthDiff;
  14670. if (inMainRange && !this.session.$fromUndo) {
  14671. if (delta.action === 'insert') {
  14672. for (var i = this.others.length - 1; i >= 0; i--) {
  14673. var otherPos = this.others[i];
  14674. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14675. this.doc.insertMergedLines(newPos, delta.lines);
  14676. }
  14677. } else if (delta.action === 'remove') {
  14678. for (var i = this.others.length - 1; i >= 0; i--) {
  14679. var otherPos = this.others[i];
  14680. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14681. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14682. }
  14683. }
  14684. }
  14685. this.$updating = false;
  14686. this.updateMarkers();
  14687. };
  14688. this.updateAnchors = function(delta) {
  14689. this.pos.onChange(delta);
  14690. for (var i = this.others.length; i--;)
  14691. this.others[i].onChange(delta);
  14692. this.updateMarkers();
  14693. };
  14694. this.updateMarkers = function() {
  14695. if (this.$updating)
  14696. return;
  14697. var _self = this;
  14698. var session = this.session;
  14699. var updateMarker = function(pos, className) {
  14700. session.removeMarker(pos.markerId);
  14701. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
  14702. };
  14703. updateMarker(this.pos, this.mainClass);
  14704. for (var i = this.others.length; i--;)
  14705. updateMarker(this.others[i], this.othersClass);
  14706. };
  14707. this.onCursorChange = function(event) {
  14708. if (this.$updating || !this.session) return;
  14709. var pos = this.session.selection.getCursor();
  14710. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14711. this.showOtherMarkers();
  14712. this._emit("cursorEnter", event);
  14713. } else {
  14714. this.hideOtherMarkers();
  14715. this._emit("cursorLeave", event);
  14716. }
  14717. };
  14718. this.detach = function() {
  14719. this.session.removeMarker(this.pos && this.pos.markerId);
  14720. this.hideOtherMarkers();
  14721. this.doc.removeEventListener("change", this.$onUpdate);
  14722. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14723. this.session.setUndoSelect(true);
  14724. this.session = null;
  14725. };
  14726. this.cancel = function() {
  14727. if (this.$undoStackDepth === -1)
  14728. return;
  14729. var undoManager = this.session.getUndoManager();
  14730. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14731. for (var i = 0; i < undosRequired; i++) {
  14732. undoManager.undo(true);
  14733. }
  14734. if (this.selectionBefore)
  14735. this.session.selection.fromJSON(this.selectionBefore);
  14736. };
  14737. }).call(PlaceHolder.prototype);
  14738. exports.PlaceHolder = PlaceHolder;
  14739. });
  14740. define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14741. var event = require("../lib/event");
  14742. var useragent = require("../lib/useragent");
  14743. function isSamePoint(p1, p2) {
  14744. return p1.row == p2.row && p1.column == p2.column;
  14745. }
  14746. function onMouseDown(e) {
  14747. var ev = e.domEvent;
  14748. var alt = ev.altKey;
  14749. var shift = ev.shiftKey;
  14750. var ctrl = ev.ctrlKey;
  14751. var accel = e.getAccelKey();
  14752. var button = e.getButton();
  14753. if (ctrl && useragent.isMac)
  14754. button = ev.button;
  14755. if (e.editor.inMultiSelectMode && button == 2) {
  14756. e.editor.textInput.onContextMenu(e.domEvent);
  14757. return;
  14758. }
  14759. if (!ctrl && !alt && !accel) {
  14760. if (button === 0 && e.editor.inMultiSelectMode)
  14761. e.editor.exitMultiSelectMode();
  14762. return;
  14763. }
  14764. if (button !== 0)
  14765. return;
  14766. var editor = e.editor;
  14767. var selection = editor.selection;
  14768. var isMultiSelect = editor.inMultiSelectMode;
  14769. var pos = e.getDocumentPosition();
  14770. var cursor = selection.getCursor();
  14771. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14772. var mouseX = e.x, mouseY = e.y;
  14773. var onMouseSelection = function(e) {
  14774. mouseX = e.clientX;
  14775. mouseY = e.clientY;
  14776. };
  14777. var session = editor.session;
  14778. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14779. var screenCursor = screenAnchor;
  14780. var selectionMode;
  14781. if (editor.$mouseHandler.$enableJumpToDef) {
  14782. if (ctrl && alt || accel && alt)
  14783. selectionMode = shift ? "block" : "add";
  14784. else if (alt && editor.$blockSelectEnabled)
  14785. selectionMode = "block";
  14786. } else {
  14787. if (accel && !alt) {
  14788. selectionMode = "add";
  14789. if (!isMultiSelect && shift)
  14790. return;
  14791. } else if (alt && editor.$blockSelectEnabled) {
  14792. selectionMode = "block";
  14793. }
  14794. }
  14795. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14796. editor.$mouseHandler.cancelContextMenu();
  14797. }
  14798. if (selectionMode == "add") {
  14799. if (!isMultiSelect && inSelection)
  14800. return; // dragging
  14801. if (!isMultiSelect) {
  14802. var range = selection.toOrientedRange();
  14803. editor.addSelectionMarker(range);
  14804. }
  14805. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14806. editor.$blockScrolling++;
  14807. editor.inVirtualSelectionMode = true;
  14808. if (shift) {
  14809. oldRange = null;
  14810. range = selection.ranges[0] || range;
  14811. editor.removeSelectionMarker(range);
  14812. }
  14813. editor.once("mouseup", function() {
  14814. var tmpSel = selection.toOrientedRange();
  14815. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14816. selection.substractPoint(tmpSel.cursor);
  14817. else {
  14818. if (shift) {
  14819. selection.substractPoint(range.cursor);
  14820. } else if (range) {
  14821. editor.removeSelectionMarker(range);
  14822. selection.addRange(range);
  14823. }
  14824. selection.addRange(tmpSel);
  14825. }
  14826. editor.$blockScrolling--;
  14827. editor.inVirtualSelectionMode = false;
  14828. });
  14829. } else if (selectionMode == "block") {
  14830. e.stop();
  14831. editor.inVirtualSelectionMode = true;
  14832. var initialRange;
  14833. var rectSel = [];
  14834. var blockSelect = function() {
  14835. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14836. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14837. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14838. return;
  14839. screenCursor = newCursor;
  14840. editor.$blockScrolling++;
  14841. editor.selection.moveToPosition(cursor);
  14842. editor.renderer.scrollCursorIntoView();
  14843. editor.removeSelectionMarkers(rectSel);
  14844. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14845. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14846. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14847. rectSel.forEach(editor.addSelectionMarker, editor);
  14848. editor.updateSelectionMarkers();
  14849. editor.$blockScrolling--;
  14850. };
  14851. editor.$blockScrolling++;
  14852. if (isMultiSelect && !accel) {
  14853. selection.toSingleRange();
  14854. } else if (!isMultiSelect && accel) {
  14855. initialRange = selection.toOrientedRange();
  14856. editor.addSelectionMarker(initialRange);
  14857. }
  14858. if (shift)
  14859. screenAnchor = session.documentToScreenPosition(selection.lead);
  14860. else
  14861. selection.moveToPosition(pos);
  14862. editor.$blockScrolling--;
  14863. screenCursor = {row: -1, column: -1};
  14864. var onMouseSelectionEnd = function(e) {
  14865. clearInterval(timerId);
  14866. editor.removeSelectionMarkers(rectSel);
  14867. if (!rectSel.length)
  14868. rectSel = [selection.toOrientedRange()];
  14869. editor.$blockScrolling++;
  14870. if (initialRange) {
  14871. editor.removeSelectionMarker(initialRange);
  14872. selection.toSingleRange(initialRange);
  14873. }
  14874. for (var i = 0; i < rectSel.length; i++)
  14875. selection.addRange(rectSel[i]);
  14876. editor.inVirtualSelectionMode = false;
  14877. editor.$mouseHandler.$clickSelection = null;
  14878. editor.$blockScrolling--;
  14879. };
  14880. var onSelectionInterval = blockSelect;
  14881. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14882. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14883. return e.preventDefault();
  14884. }
  14885. }
  14886. exports.onMouseDown = onMouseDown;
  14887. });
  14888. define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14889. exports.defaultCommands = [{
  14890. name: "addCursorAbove",
  14891. exec: function(editor) { editor.selectMoreLines(-1); },
  14892. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14893. scrollIntoView: "cursor",
  14894. readOnly: true
  14895. }, {
  14896. name: "addCursorBelow",
  14897. exec: function(editor) { editor.selectMoreLines(1); },
  14898. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14899. scrollIntoView: "cursor",
  14900. readOnly: true
  14901. }, {
  14902. name: "addCursorAboveSkipCurrent",
  14903. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14904. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14905. scrollIntoView: "cursor",
  14906. readOnly: true
  14907. }, {
  14908. name: "addCursorBelowSkipCurrent",
  14909. exec: function(editor) { editor.selectMoreLines(1, true); },
  14910. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14911. scrollIntoView: "cursor",
  14912. readOnly: true
  14913. }, {
  14914. name: "selectMoreBefore",
  14915. exec: function(editor) { editor.selectMore(-1); },
  14916. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14917. scrollIntoView: "cursor",
  14918. readOnly: true
  14919. }, {
  14920. name: "selectMoreAfter",
  14921. exec: function(editor) { editor.selectMore(1); },
  14922. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14923. scrollIntoView: "cursor",
  14924. readOnly: true
  14925. }, {
  14926. name: "selectNextBefore",
  14927. exec: function(editor) { editor.selectMore(-1, true); },
  14928. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14929. scrollIntoView: "cursor",
  14930. readOnly: true
  14931. }, {
  14932. name: "selectNextAfter",
  14933. exec: function(editor) { editor.selectMore(1, true); },
  14934. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14935. scrollIntoView: "cursor",
  14936. readOnly: true
  14937. }, {
  14938. name: "splitIntoLines",
  14939. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14940. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14941. readOnly: true
  14942. }, {
  14943. name: "alignCursors",
  14944. exec: function(editor) { editor.alignCursors(); },
  14945. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14946. scrollIntoView: "cursor"
  14947. }, {
  14948. name: "findAll",
  14949. exec: function(editor) { editor.findAll(); },
  14950. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14951. scrollIntoView: "cursor",
  14952. readOnly: true
  14953. }];
  14954. exports.multiSelectCommands = [{
  14955. name: "singleSelection",
  14956. bindKey: "esc",
  14957. exec: function(editor) { editor.exitMultiSelectMode(); },
  14958. scrollIntoView: "cursor",
  14959. readOnly: true,
  14960. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14961. }];
  14962. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14963. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14964. });
  14965. define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"], function(require, exports, module) {
  14966. var RangeList = require("./range_list").RangeList;
  14967. var Range = require("./range").Range;
  14968. var Selection = require("./selection").Selection;
  14969. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14970. var event = require("./lib/event");
  14971. var lang = require("./lib/lang");
  14972. var commands = require("./commands/multi_select_commands");
  14973. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14974. var Search = require("./search").Search;
  14975. var search = new Search();
  14976. function find(session, needle, dir) {
  14977. search.$options.wrap = true;
  14978. search.$options.needle = needle;
  14979. search.$options.backwards = dir == -1;
  14980. return search.find(session);
  14981. }
  14982. var EditSession = require("./edit_session").EditSession;
  14983. (function() {
  14984. this.getSelectionMarkers = function() {
  14985. return this.$selectionMarkers;
  14986. };
  14987. }).call(EditSession.prototype);
  14988. (function() {
  14989. this.ranges = null;
  14990. this.rangeList = null;
  14991. this.addRange = function(range, $blockChangeEvents) {
  14992. if (!range)
  14993. return;
  14994. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  14995. var oldRange = this.toOrientedRange();
  14996. this.rangeList.add(oldRange);
  14997. this.rangeList.add(range);
  14998. if (this.rangeList.ranges.length != 2) {
  14999. this.rangeList.removeAll();
  15000. return $blockChangeEvents || this.fromOrientedRange(range);
  15001. }
  15002. this.rangeList.removeAll();
  15003. this.rangeList.add(oldRange);
  15004. this.$onAddRange(oldRange);
  15005. }
  15006. if (!range.cursor)
  15007. range.cursor = range.end;
  15008. var removed = this.rangeList.add(range);
  15009. this.$onAddRange(range);
  15010. if (removed.length)
  15011. this.$onRemoveRange(removed);
  15012. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  15013. this._signal("multiSelect");
  15014. this.inMultiSelectMode = true;
  15015. this.session.$undoSelect = false;
  15016. this.rangeList.attach(this.session);
  15017. }
  15018. return $blockChangeEvents || this.fromOrientedRange(range);
  15019. };
  15020. this.toSingleRange = function(range) {
  15021. range = range || this.ranges[0];
  15022. var removed = this.rangeList.removeAll();
  15023. if (removed.length)
  15024. this.$onRemoveRange(removed);
  15025. range && this.fromOrientedRange(range);
  15026. };
  15027. this.substractPoint = function(pos) {
  15028. var removed = this.rangeList.substractPoint(pos);
  15029. if (removed) {
  15030. this.$onRemoveRange(removed);
  15031. return removed[0];
  15032. }
  15033. };
  15034. this.mergeOverlappingRanges = function() {
  15035. var removed = this.rangeList.merge();
  15036. if (removed.length)
  15037. this.$onRemoveRange(removed);
  15038. else if(this.ranges[0])
  15039. this.fromOrientedRange(this.ranges[0]);
  15040. };
  15041. this.$onAddRange = function(range) {
  15042. this.rangeCount = this.rangeList.ranges.length;
  15043. this.ranges.unshift(range);
  15044. this._signal("addRange", {range: range});
  15045. };
  15046. this.$onRemoveRange = function(removed) {
  15047. this.rangeCount = this.rangeList.ranges.length;
  15048. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  15049. var lastRange = this.rangeList.ranges.pop();
  15050. removed.push(lastRange);
  15051. this.rangeCount = 0;
  15052. }
  15053. for (var i = removed.length; i--; ) {
  15054. var index = this.ranges.indexOf(removed[i]);
  15055. this.ranges.splice(index, 1);
  15056. }
  15057. this._signal("removeRange", {ranges: removed});
  15058. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  15059. this.inMultiSelectMode = false;
  15060. this._signal("singleSelect");
  15061. this.session.$undoSelect = true;
  15062. this.rangeList.detach(this.session);
  15063. }
  15064. lastRange = lastRange || this.ranges[0];
  15065. if (lastRange && !lastRange.isEqual(this.getRange()))
  15066. this.fromOrientedRange(lastRange);
  15067. };
  15068. this.$initRangeList = function() {
  15069. if (this.rangeList)
  15070. return;
  15071. this.rangeList = new RangeList();
  15072. this.ranges = [];
  15073. this.rangeCount = 0;
  15074. };
  15075. this.getAllRanges = function() {
  15076. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  15077. };
  15078. this.splitIntoLines = function () {
  15079. if (this.rangeCount > 1) {
  15080. var ranges = this.rangeList.ranges;
  15081. var lastRange = ranges[ranges.length - 1];
  15082. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15083. this.toSingleRange();
  15084. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15085. } else {
  15086. var range = this.getRange();
  15087. var isBackwards = this.isBackwards();
  15088. var startRow = range.start.row;
  15089. var endRow = range.end.row;
  15090. if (startRow == endRow) {
  15091. if (isBackwards)
  15092. var start = range.end, end = range.start;
  15093. else
  15094. var start = range.start, end = range.end;
  15095. this.addRange(Range.fromPoints(end, end));
  15096. this.addRange(Range.fromPoints(start, start));
  15097. return;
  15098. }
  15099. var rectSel = [];
  15100. var r = this.getLineRange(startRow, true);
  15101. r.start.column = range.start.column;
  15102. rectSel.push(r);
  15103. for (var i = startRow + 1; i < endRow; i++)
  15104. rectSel.push(this.getLineRange(i, true));
  15105. r = this.getLineRange(endRow, true);
  15106. r.end.column = range.end.column;
  15107. rectSel.push(r);
  15108. rectSel.forEach(this.addRange, this);
  15109. }
  15110. };
  15111. this.toggleBlockSelection = function () {
  15112. if (this.rangeCount > 1) {
  15113. var ranges = this.rangeList.ranges;
  15114. var lastRange = ranges[ranges.length - 1];
  15115. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15116. this.toSingleRange();
  15117. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15118. } else {
  15119. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  15120. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  15121. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  15122. rectSel.forEach(this.addRange, this);
  15123. }
  15124. };
  15125. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  15126. var rectSel = [];
  15127. var xBackwards = screenCursor.column < screenAnchor.column;
  15128. if (xBackwards) {
  15129. var startColumn = screenCursor.column;
  15130. var endColumn = screenAnchor.column;
  15131. } else {
  15132. var startColumn = screenAnchor.column;
  15133. var endColumn = screenCursor.column;
  15134. }
  15135. var yBackwards = screenCursor.row < screenAnchor.row;
  15136. if (yBackwards) {
  15137. var startRow = screenCursor.row;
  15138. var endRow = screenAnchor.row;
  15139. } else {
  15140. var startRow = screenAnchor.row;
  15141. var endRow = screenCursor.row;
  15142. }
  15143. if (startColumn < 0)
  15144. startColumn = 0;
  15145. if (startRow < 0)
  15146. startRow = 0;
  15147. if (startRow == endRow)
  15148. includeEmptyLines = true;
  15149. for (var row = startRow; row <= endRow; row++) {
  15150. var range = Range.fromPoints(
  15151. this.session.screenToDocumentPosition(row, startColumn),
  15152. this.session.screenToDocumentPosition(row, endColumn)
  15153. );
  15154. if (range.isEmpty()) {
  15155. if (docEnd && isSamePoint(range.end, docEnd))
  15156. break;
  15157. var docEnd = range.end;
  15158. }
  15159. range.cursor = xBackwards ? range.start : range.end;
  15160. rectSel.push(range);
  15161. }
  15162. if (yBackwards)
  15163. rectSel.reverse();
  15164. if (!includeEmptyLines) {
  15165. var end = rectSel.length - 1;
  15166. while (rectSel[end].isEmpty() && end > 0)
  15167. end--;
  15168. if (end > 0) {
  15169. var start = 0;
  15170. while (rectSel[start].isEmpty())
  15171. start++;
  15172. }
  15173. for (var i = end; i >= start; i--) {
  15174. if (rectSel[i].isEmpty())
  15175. rectSel.splice(i, 1);
  15176. }
  15177. }
  15178. return rectSel;
  15179. };
  15180. }).call(Selection.prototype);
  15181. var Editor = require("./editor").Editor;
  15182. (function() {
  15183. this.updateSelectionMarkers = function() {
  15184. this.renderer.updateCursor();
  15185. this.renderer.updateBackMarkers();
  15186. };
  15187. this.addSelectionMarker = function(orientedRange) {
  15188. if (!orientedRange.cursor)
  15189. orientedRange.cursor = orientedRange.end;
  15190. var style = this.getSelectionStyle();
  15191. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  15192. this.session.$selectionMarkers.push(orientedRange);
  15193. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15194. return orientedRange;
  15195. };
  15196. this.removeSelectionMarker = function(range) {
  15197. if (!range.marker)
  15198. return;
  15199. this.session.removeMarker(range.marker);
  15200. var index = this.session.$selectionMarkers.indexOf(range);
  15201. if (index != -1)
  15202. this.session.$selectionMarkers.splice(index, 1);
  15203. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15204. };
  15205. this.removeSelectionMarkers = function(ranges) {
  15206. var markerList = this.session.$selectionMarkers;
  15207. for (var i = ranges.length; i--; ) {
  15208. var range = ranges[i];
  15209. if (!range.marker)
  15210. continue;
  15211. this.session.removeMarker(range.marker);
  15212. var index = markerList.indexOf(range);
  15213. if (index != -1)
  15214. markerList.splice(index, 1);
  15215. }
  15216. this.session.selectionMarkerCount = markerList.length;
  15217. };
  15218. this.$onAddRange = function(e) {
  15219. this.addSelectionMarker(e.range);
  15220. this.renderer.updateCursor();
  15221. this.renderer.updateBackMarkers();
  15222. };
  15223. this.$onRemoveRange = function(e) {
  15224. this.removeSelectionMarkers(e.ranges);
  15225. this.renderer.updateCursor();
  15226. this.renderer.updateBackMarkers();
  15227. };
  15228. this.$onMultiSelect = function(e) {
  15229. if (this.inMultiSelectMode)
  15230. return;
  15231. this.inMultiSelectMode = true;
  15232. this.setStyle("ace_multiselect");
  15233. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  15234. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  15235. this.renderer.updateCursor();
  15236. this.renderer.updateBackMarkers();
  15237. };
  15238. this.$onSingleSelect = function(e) {
  15239. if (this.session.multiSelect.inVirtualMode)
  15240. return;
  15241. this.inMultiSelectMode = false;
  15242. this.unsetStyle("ace_multiselect");
  15243. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  15244. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  15245. this.renderer.updateCursor();
  15246. this.renderer.updateBackMarkers();
  15247. this._emit("changeSelection");
  15248. };
  15249. this.$onMultiSelectExec = function(e) {
  15250. var command = e.command;
  15251. var editor = e.editor;
  15252. if (!editor.multiSelect)
  15253. return;
  15254. if (!command.multiSelectAction) {
  15255. var result = command.exec(editor, e.args || {});
  15256. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15257. editor.multiSelect.mergeOverlappingRanges();
  15258. } else if (command.multiSelectAction == "forEach") {
  15259. result = editor.forEachSelection(command, e.args);
  15260. } else if (command.multiSelectAction == "forEachLine") {
  15261. result = editor.forEachSelection(command, e.args, true);
  15262. } else if (command.multiSelectAction == "single") {
  15263. editor.exitMultiSelectMode();
  15264. result = command.exec(editor, e.args || {});
  15265. } else {
  15266. result = command.multiSelectAction(editor, e.args || {});
  15267. }
  15268. return result;
  15269. };
  15270. this.forEachSelection = function(cmd, args, options) {
  15271. if (this.inVirtualSelectionMode)
  15272. return;
  15273. var keepOrder = options && options.keepOrder;
  15274. var $byLines = options == true || options && options.$byLines
  15275. var session = this.session;
  15276. var selection = this.selection;
  15277. var rangeList = selection.rangeList;
  15278. var ranges = (keepOrder ? selection : rangeList).ranges;
  15279. var result;
  15280. if (!ranges.length)
  15281. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15282. var reg = selection._eventRegistry;
  15283. selection._eventRegistry = {};
  15284. var tmpSel = new Selection(session);
  15285. this.inVirtualSelectionMode = true;
  15286. for (var i = ranges.length; i--;) {
  15287. if ($byLines) {
  15288. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15289. i--;
  15290. }
  15291. tmpSel.fromOrientedRange(ranges[i]);
  15292. tmpSel.index = i;
  15293. this.selection = session.selection = tmpSel;
  15294. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15295. if (!result && cmdResult !== undefined)
  15296. result = cmdResult;
  15297. tmpSel.toOrientedRange(ranges[i]);
  15298. }
  15299. tmpSel.detach();
  15300. this.selection = session.selection = selection;
  15301. this.inVirtualSelectionMode = false;
  15302. selection._eventRegistry = reg;
  15303. selection.mergeOverlappingRanges();
  15304. var anim = this.renderer.$scrollAnimation;
  15305. this.onCursorChange();
  15306. this.onSelectionChange();
  15307. if (anim && anim.from == anim.to)
  15308. this.renderer.animateScrolling(anim.from);
  15309. return result;
  15310. };
  15311. this.exitMultiSelectMode = function() {
  15312. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15313. return;
  15314. this.multiSelect.toSingleRange();
  15315. };
  15316. this.getSelectedText = function() {
  15317. var text = "";
  15318. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15319. var ranges = this.multiSelect.rangeList.ranges;
  15320. var buf = [];
  15321. for (var i = 0; i < ranges.length; i++) {
  15322. buf.push(this.session.getTextRange(ranges[i]));
  15323. }
  15324. var nl = this.session.getDocument().getNewLineCharacter();
  15325. text = buf.join(nl);
  15326. if (text.length == (buf.length - 1) * nl.length)
  15327. text = "";
  15328. } else if (!this.selection.isEmpty()) {
  15329. text = this.session.getTextRange(this.getSelectionRange());
  15330. }
  15331. return text;
  15332. };
  15333. this.$checkMultiselectChange = function(e, anchor) {
  15334. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15335. var range = this.multiSelect.ranges[0];
  15336. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15337. return;
  15338. var pos = anchor == this.multiSelect.anchor
  15339. ? range.cursor == range.start ? range.end : range.start
  15340. : range.cursor;
  15341. if (pos.row != anchor.row
  15342. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15343. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15344. }
  15345. };
  15346. this.findAll = function(needle, options, additive) {
  15347. options = options || {};
  15348. options.needle = needle || options.needle;
  15349. if (options.needle == undefined) {
  15350. var range = this.selection.isEmpty()
  15351. ? this.selection.getWordRange()
  15352. : this.selection.getRange();
  15353. options.needle = this.session.getTextRange(range);
  15354. }
  15355. this.$search.set(options);
  15356. var ranges = this.$search.findAll(this.session);
  15357. if (!ranges.length)
  15358. return 0;
  15359. this.$blockScrolling += 1;
  15360. var selection = this.multiSelect;
  15361. if (!additive)
  15362. selection.toSingleRange(ranges[0]);
  15363. for (var i = ranges.length; i--; )
  15364. selection.addRange(ranges[i], true);
  15365. if (range && selection.rangeList.rangeAtPoint(range.start))
  15366. selection.addRange(range, true);
  15367. this.$blockScrolling -= 1;
  15368. return ranges.length;
  15369. };
  15370. this.selectMoreLines = function(dir, skip) {
  15371. var range = this.selection.toOrientedRange();
  15372. var isBackwards = range.cursor == range.end;
  15373. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15374. if (this.selection.$desiredColumn)
  15375. screenLead.column = this.selection.$desiredColumn;
  15376. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15377. if (!range.isEmpty()) {
  15378. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15379. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15380. } else {
  15381. var anchor = lead;
  15382. }
  15383. if (isBackwards) {
  15384. var newRange = Range.fromPoints(lead, anchor);
  15385. newRange.cursor = newRange.start;
  15386. } else {
  15387. var newRange = Range.fromPoints(anchor, lead);
  15388. newRange.cursor = newRange.end;
  15389. }
  15390. newRange.desiredColumn = screenLead.column;
  15391. if (!this.selection.inMultiSelectMode) {
  15392. this.selection.addRange(range);
  15393. } else {
  15394. if (skip)
  15395. var toRemove = range.cursor;
  15396. }
  15397. this.selection.addRange(newRange);
  15398. if (toRemove)
  15399. this.selection.substractPoint(toRemove);
  15400. };
  15401. this.transposeSelections = function(dir) {
  15402. var session = this.session;
  15403. var sel = session.multiSelect;
  15404. var all = sel.ranges;
  15405. for (var i = all.length; i--; ) {
  15406. var range = all[i];
  15407. if (range.isEmpty()) {
  15408. var tmp = session.getWordRange(range.start.row, range.start.column);
  15409. range.start.row = tmp.start.row;
  15410. range.start.column = tmp.start.column;
  15411. range.end.row = tmp.end.row;
  15412. range.end.column = tmp.end.column;
  15413. }
  15414. }
  15415. sel.mergeOverlappingRanges();
  15416. var words = [];
  15417. for (var i = all.length; i--; ) {
  15418. var range = all[i];
  15419. words.unshift(session.getTextRange(range));
  15420. }
  15421. if (dir < 0)
  15422. words.unshift(words.pop());
  15423. else
  15424. words.push(words.shift());
  15425. for (var i = all.length; i--; ) {
  15426. var range = all[i];
  15427. var tmp = range.clone();
  15428. session.replace(range, words[i]);
  15429. range.start.row = tmp.start.row;
  15430. range.start.column = tmp.start.column;
  15431. }
  15432. };
  15433. this.selectMore = function(dir, skip, stopAtFirst) {
  15434. var session = this.session;
  15435. var sel = session.multiSelect;
  15436. var range = sel.toOrientedRange();
  15437. if (range.isEmpty()) {
  15438. range = session.getWordRange(range.start.row, range.start.column);
  15439. range.cursor = dir == -1 ? range.start : range.end;
  15440. this.multiSelect.addRange(range);
  15441. if (stopAtFirst)
  15442. return;
  15443. }
  15444. var needle = session.getTextRange(range);
  15445. var newRange = find(session, needle, dir);
  15446. if (newRange) {
  15447. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15448. this.$blockScrolling += 1;
  15449. this.session.unfold(newRange);
  15450. this.multiSelect.addRange(newRange);
  15451. this.$blockScrolling -= 1;
  15452. this.renderer.scrollCursorIntoView(null, 0.5);
  15453. }
  15454. if (skip)
  15455. this.multiSelect.substractPoint(range.cursor);
  15456. };
  15457. this.alignCursors = function() {
  15458. var session = this.session;
  15459. var sel = session.multiSelect;
  15460. var ranges = sel.ranges;
  15461. var row = -1;
  15462. var sameRowRanges = ranges.filter(function(r) {
  15463. if (r.cursor.row == row)
  15464. return true;
  15465. row = r.cursor.row;
  15466. });
  15467. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15468. var range = this.selection.getRange();
  15469. var fr = range.start.row, lr = range.end.row;
  15470. var guessRange = fr == lr;
  15471. if (guessRange) {
  15472. var max = this.session.getLength();
  15473. var line;
  15474. do {
  15475. line = this.session.getLine(lr);
  15476. } while (/[=:]/.test(line) && ++lr < max);
  15477. do {
  15478. line = this.session.getLine(fr);
  15479. } while (/[=:]/.test(line) && --fr > 0);
  15480. if (fr < 0) fr = 0;
  15481. if (lr >= max) lr = max - 1;
  15482. }
  15483. var lines = this.session.removeFullLines(fr, lr);
  15484. lines = this.$reAlignText(lines, guessRange);
  15485. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15486. if (!guessRange) {
  15487. range.start.column = 0;
  15488. range.end.column = lines[lines.length - 1].length;
  15489. }
  15490. this.selection.setRange(range);
  15491. } else {
  15492. sameRowRanges.forEach(function(r) {
  15493. sel.substractPoint(r.cursor);
  15494. });
  15495. var maxCol = 0;
  15496. var minSpace = Infinity;
  15497. var spaceOffsets = ranges.map(function(r) {
  15498. var p = r.cursor;
  15499. var line = session.getLine(p.row);
  15500. var spaceOffset = line.substr(p.column).search(/\S/g);
  15501. if (spaceOffset == -1)
  15502. spaceOffset = 0;
  15503. if (p.column > maxCol)
  15504. maxCol = p.column;
  15505. if (spaceOffset < minSpace)
  15506. minSpace = spaceOffset;
  15507. return spaceOffset;
  15508. });
  15509. ranges.forEach(function(r, i) {
  15510. var p = r.cursor;
  15511. var l = maxCol - p.column;
  15512. var d = spaceOffsets[i] - minSpace;
  15513. if (l > d)
  15514. session.insert(p, lang.stringRepeat(" ", l - d));
  15515. else
  15516. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15517. r.start.column = r.end.column = maxCol;
  15518. r.start.row = r.end.row = p.row;
  15519. r.cursor = r.end;
  15520. });
  15521. sel.fromOrientedRange(ranges[0]);
  15522. this.renderer.updateCursor();
  15523. this.renderer.updateBackMarkers();
  15524. }
  15525. };
  15526. this.$reAlignText = function(lines, forceLeft) {
  15527. var isLeftAligned = true, isRightAligned = true;
  15528. var startW, textW, endW;
  15529. return lines.map(function(line) {
  15530. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15531. if (!m)
  15532. return [line];
  15533. if (startW == null) {
  15534. startW = m[1].length;
  15535. textW = m[2].length;
  15536. endW = m[3].length;
  15537. return m;
  15538. }
  15539. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15540. isRightAligned = false;
  15541. if (startW != m[1].length)
  15542. isLeftAligned = false;
  15543. if (startW > m[1].length)
  15544. startW = m[1].length;
  15545. if (textW < m[2].length)
  15546. textW = m[2].length;
  15547. if (endW > m[3].length)
  15548. endW = m[3].length;
  15549. return m;
  15550. }).map(forceLeft ? alignLeft :
  15551. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15552. function spaces(n) {
  15553. return lang.stringRepeat(" ", n);
  15554. }
  15555. function alignLeft(m) {
  15556. return !m[2] ? m[0] : spaces(startW) + m[2]
  15557. + spaces(textW - m[2].length + endW)
  15558. + m[4].replace(/^([=:])\s+/, "$1 ");
  15559. }
  15560. function alignRight(m) {
  15561. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15562. + spaces(endW, " ")
  15563. + m[4].replace(/^([=:])\s+/, "$1 ");
  15564. }
  15565. function unAlign(m) {
  15566. return !m[2] ? m[0] : spaces(startW) + m[2]
  15567. + spaces(endW)
  15568. + m[4].replace(/^([=:])\s+/, "$1 ");
  15569. }
  15570. };
  15571. }).call(Editor.prototype);
  15572. function isSamePoint(p1, p2) {
  15573. return p1.row == p2.row && p1.column == p2.column;
  15574. }
  15575. exports.onSessionChange = function(e) {
  15576. var session = e.session;
  15577. if (session && !session.multiSelect) {
  15578. session.$selectionMarkers = [];
  15579. session.selection.$initRangeList();
  15580. session.multiSelect = session.selection;
  15581. }
  15582. this.multiSelect = session && session.multiSelect;
  15583. var oldSession = e.oldSession;
  15584. if (oldSession) {
  15585. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15586. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15587. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15588. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15589. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15590. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15591. }
  15592. if (session) {
  15593. session.multiSelect.on("addRange", this.$onAddRange);
  15594. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15595. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15596. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15597. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15598. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15599. }
  15600. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15601. if (session.selection.inMultiSelectMode)
  15602. this.$onMultiSelect();
  15603. else
  15604. this.$onSingleSelect();
  15605. }
  15606. };
  15607. function MultiSelect(editor) {
  15608. if (editor.$multiselectOnSessionChange)
  15609. return;
  15610. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15611. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15612. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15613. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15614. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15615. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15616. editor.$multiselectOnSessionChange(editor);
  15617. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15618. editor.on("mousedown", onMouseDown);
  15619. editor.commands.addCommands(commands.defaultCommands);
  15620. addAltCursorListeners(editor);
  15621. }
  15622. function addAltCursorListeners(editor){
  15623. var el = editor.textInput.getElement();
  15624. var altCursor = false;
  15625. event.addListener(el, "keydown", function(e) {
  15626. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  15627. if (editor.$blockSelectEnabled && altDown) {
  15628. if (!altCursor) {
  15629. editor.renderer.setMouseCursor("crosshair");
  15630. altCursor = true;
  15631. }
  15632. } else if (altCursor) {
  15633. reset();
  15634. }
  15635. });
  15636. event.addListener(el, "keyup", reset);
  15637. event.addListener(el, "blur", reset);
  15638. function reset(e) {
  15639. if (altCursor) {
  15640. editor.renderer.setMouseCursor("");
  15641. altCursor = false;
  15642. }
  15643. }
  15644. }
  15645. exports.MultiSelect = MultiSelect;
  15646. require("./config").defineOptions(Editor.prototype, "editor", {
  15647. enableMultiselect: {
  15648. set: function(val) {
  15649. MultiSelect(this);
  15650. if (val) {
  15651. this.on("changeSession", this.$multiselectOnSessionChange);
  15652. this.on("mousedown", onMouseDown);
  15653. } else {
  15654. this.off("changeSession", this.$multiselectOnSessionChange);
  15655. this.off("mousedown", onMouseDown);
  15656. }
  15657. },
  15658. value: true
  15659. },
  15660. enableBlockSelect: {
  15661. set: function(val) {
  15662. this.$blockSelectEnabled = val;
  15663. },
  15664. value: true
  15665. }
  15666. });
  15667. });
  15668. define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15669. "use strict";
  15670. var Range = require("../../range").Range;
  15671. var FoldMode = exports.FoldMode = function() {};
  15672. (function() {
  15673. this.foldingStartMarker = null;
  15674. this.foldingStopMarker = null;
  15675. this.getFoldWidget = function(session, foldStyle, row) {
  15676. var line = session.getLine(row);
  15677. if (this.foldingStartMarker.test(line))
  15678. return "start";
  15679. if (foldStyle == "markbeginend"
  15680. && this.foldingStopMarker
  15681. && this.foldingStopMarker.test(line))
  15682. return "end";
  15683. return "";
  15684. };
  15685. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15686. return null;
  15687. };
  15688. this.indentationBlock = function(session, row, column) {
  15689. var re = /\S/;
  15690. var line = session.getLine(row);
  15691. var startLevel = line.search(re);
  15692. if (startLevel == -1)
  15693. return;
  15694. var startColumn = column || line.length;
  15695. var maxRow = session.getLength();
  15696. var startRow = row;
  15697. var endRow = row;
  15698. while (++row < maxRow) {
  15699. var level = session.getLine(row).search(re);
  15700. if (level == -1)
  15701. continue;
  15702. if (level <= startLevel)
  15703. break;
  15704. endRow = row;
  15705. }
  15706. if (endRow > startRow) {
  15707. var endColumn = session.getLine(endRow).length;
  15708. return new Range(startRow, startColumn, endRow, endColumn);
  15709. }
  15710. };
  15711. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15712. var start = {row: row, column: column + 1};
  15713. var end = session.$findClosingBracket(bracket, start, typeRe);
  15714. if (!end)
  15715. return;
  15716. var fw = session.foldWidgets[end.row];
  15717. if (fw == null)
  15718. fw = session.getFoldWidget(end.row);
  15719. if (fw == "start" && end.row > start.row) {
  15720. end.row --;
  15721. end.column = session.getLine(end.row).length;
  15722. }
  15723. return Range.fromPoints(start, end);
  15724. };
  15725. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15726. var end = {row: row, column: column};
  15727. var start = session.$findOpeningBracket(bracket, end);
  15728. if (!start)
  15729. return;
  15730. start.column++;
  15731. end.column--;
  15732. return Range.fromPoints(start, end);
  15733. };
  15734. }).call(FoldMode.prototype);
  15735. });
  15736. define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15737. "use strict";
  15738. exports.isDark = false;
  15739. exports.cssClass = "ace-tm";
  15740. exports.cssText = ".ace-tm .ace_gutter {\
  15741. background: #f0f0f0;\
  15742. color: #333;\
  15743. }\
  15744. .ace-tm .ace_print-margin {\
  15745. width: 1px;\
  15746. background: #e8e8e8;\
  15747. }\
  15748. .ace-tm .ace_fold {\
  15749. background-color: #6B72E6;\
  15750. }\
  15751. .ace-tm {\
  15752. background-color: #FFFFFF;\
  15753. color: black;\
  15754. }\
  15755. .ace-tm .ace_cursor {\
  15756. color: black;\
  15757. }\
  15758. .ace-tm .ace_invisible {\
  15759. color: rgb(191, 191, 191);\
  15760. }\
  15761. .ace-tm .ace_storage,\
  15762. .ace-tm .ace_keyword {\
  15763. color: blue;\
  15764. }\
  15765. .ace-tm .ace_constant {\
  15766. color: rgb(197, 6, 11);\
  15767. }\
  15768. .ace-tm .ace_constant.ace_buildin {\
  15769. color: rgb(88, 72, 246);\
  15770. }\
  15771. .ace-tm .ace_constant.ace_language {\
  15772. color: rgb(88, 92, 246);\
  15773. }\
  15774. .ace-tm .ace_constant.ace_library {\
  15775. color: rgb(6, 150, 14);\
  15776. }\
  15777. .ace-tm .ace_invalid {\
  15778. background-color: rgba(255, 0, 0, 0.1);\
  15779. color: red;\
  15780. }\
  15781. .ace-tm .ace_support.ace_function {\
  15782. color: rgb(60, 76, 114);\
  15783. }\
  15784. .ace-tm .ace_support.ace_constant {\
  15785. color: rgb(6, 150, 14);\
  15786. }\
  15787. .ace-tm .ace_support.ace_type,\
  15788. .ace-tm .ace_support.ace_class {\
  15789. color: rgb(109, 121, 222);\
  15790. }\
  15791. .ace-tm .ace_keyword.ace_operator {\
  15792. color: rgb(104, 118, 135);\
  15793. }\
  15794. .ace-tm .ace_string {\
  15795. color: rgb(3, 106, 7);\
  15796. }\
  15797. .ace-tm .ace_comment {\
  15798. color: rgb(76, 136, 107);\
  15799. }\
  15800. .ace-tm .ace_comment.ace_doc {\
  15801. color: rgb(0, 102, 255);\
  15802. }\
  15803. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15804. color: rgb(128, 159, 191);\
  15805. }\
  15806. .ace-tm .ace_constant.ace_numeric {\
  15807. color: rgb(0, 0, 205);\
  15808. }\
  15809. .ace-tm .ace_variable {\
  15810. color: rgb(49, 132, 149);\
  15811. }\
  15812. .ace-tm .ace_xml-pe {\
  15813. color: rgb(104, 104, 91);\
  15814. }\
  15815. .ace-tm .ace_entity.ace_name.ace_function {\
  15816. color: #0000A2;\
  15817. }\
  15818. .ace-tm .ace_heading {\
  15819. color: rgb(12, 7, 255);\
  15820. }\
  15821. .ace-tm .ace_list {\
  15822. color:rgb(185, 6, 144);\
  15823. }\
  15824. .ace-tm .ace_meta.ace_tag {\
  15825. color:rgb(0, 22, 142);\
  15826. }\
  15827. .ace-tm .ace_string.ace_regex {\
  15828. color: rgb(255, 0, 0)\
  15829. }\
  15830. .ace-tm .ace_marker-layer .ace_selection {\
  15831. background: rgb(181, 213, 255);\
  15832. }\
  15833. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15834. box-shadow: 0 0 3px 0px white;\
  15835. }\
  15836. .ace-tm .ace_marker-layer .ace_step {\
  15837. background: rgb(252, 255, 0);\
  15838. }\
  15839. .ace-tm .ace_marker-layer .ace_stack {\
  15840. background: rgb(164, 229, 101);\
  15841. }\
  15842. .ace-tm .ace_marker-layer .ace_bracket {\
  15843. margin: -1px 0 0 -1px;\
  15844. border: 1px solid rgb(192, 192, 192);\
  15845. }\
  15846. .ace-tm .ace_marker-layer .ace_active-line {\
  15847. background: rgba(0, 0, 0, 0.07);\
  15848. }\
  15849. .ace-tm .ace_gutter-active-line {\
  15850. background-color : #dcdcdc;\
  15851. }\
  15852. .ace-tm .ace_marker-layer .ace_selected-word {\
  15853. background: rgb(250, 250, 255);\
  15854. border: 1px solid rgb(200, 200, 250);\
  15855. }\
  15856. .ace-tm .ace_indent-guide {\
  15857. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15858. }\
  15859. ";
  15860. var dom = require("../lib/dom");
  15861. dom.importCssString(exports.cssText, exports.cssClass);
  15862. });
  15863. define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15864. "use strict";
  15865. var oop = require("./lib/oop");
  15866. var dom = require("./lib/dom");
  15867. var Range = require("./range").Range;
  15868. function LineWidgets(session) {
  15869. this.session = session;
  15870. this.session.widgetManager = this;
  15871. this.session.getRowLength = this.getRowLength;
  15872. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15873. this.updateOnChange = this.updateOnChange.bind(this);
  15874. this.renderWidgets = this.renderWidgets.bind(this);
  15875. this.measureWidgets = this.measureWidgets.bind(this);
  15876. this.session._changedWidgets = [];
  15877. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15878. this.session.on("change", this.updateOnChange);
  15879. this.session.on("changeFold", this.updateOnFold);
  15880. this.session.on("changeEditor", this.$onChangeEditor);
  15881. }
  15882. (function() {
  15883. this.getRowLength = function(row) {
  15884. var h;
  15885. if (this.lineWidgets)
  15886. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15887. else
  15888. h = 0;
  15889. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15890. return 1 + h;
  15891. } else {
  15892. return this.$wrapData[row].length + 1 + h;
  15893. }
  15894. };
  15895. this.$getWidgetScreenLength = function() {
  15896. var screenRows = 0;
  15897. this.lineWidgets.forEach(function(w){
  15898. if (w && w.rowCount && !w.hidden)
  15899. screenRows += w.rowCount;
  15900. });
  15901. return screenRows;
  15902. };
  15903. this.$onChangeEditor = function(e) {
  15904. this.attach(e.editor);
  15905. };
  15906. this.attach = function(editor) {
  15907. if (editor && editor.widgetManager && editor.widgetManager != this)
  15908. editor.widgetManager.detach();
  15909. if (this.editor == editor)
  15910. return;
  15911. this.detach();
  15912. this.editor = editor;
  15913. if (editor) {
  15914. editor.widgetManager = this;
  15915. editor.renderer.on("beforeRender", this.measureWidgets);
  15916. editor.renderer.on("afterRender", this.renderWidgets);
  15917. }
  15918. };
  15919. this.detach = function(e) {
  15920. var editor = this.editor;
  15921. if (!editor)
  15922. return;
  15923. this.editor = null;
  15924. editor.widgetManager = null;
  15925. editor.renderer.off("beforeRender", this.measureWidgets);
  15926. editor.renderer.off("afterRender", this.renderWidgets);
  15927. var lineWidgets = this.session.lineWidgets;
  15928. lineWidgets && lineWidgets.forEach(function(w) {
  15929. if (w && w.el && w.el.parentNode) {
  15930. w._inDocument = false;
  15931. w.el.parentNode.removeChild(w.el);
  15932. }
  15933. });
  15934. };
  15935. this.updateOnFold = function(e, session) {
  15936. var lineWidgets = session.lineWidgets;
  15937. if (!lineWidgets || !e.action)
  15938. return;
  15939. var fold = e.data;
  15940. var start = fold.start.row;
  15941. var end = fold.end.row;
  15942. var hide = e.action == "add";
  15943. for (var i = start + 1; i < end; i++) {
  15944. if (lineWidgets[i])
  15945. lineWidgets[i].hidden = hide;
  15946. }
  15947. if (lineWidgets[end]) {
  15948. if (hide) {
  15949. if (!lineWidgets[start])
  15950. lineWidgets[start] = lineWidgets[end];
  15951. else
  15952. lineWidgets[end].hidden = hide;
  15953. } else {
  15954. if (lineWidgets[start] == lineWidgets[end])
  15955. lineWidgets[start] = undefined;
  15956. lineWidgets[end].hidden = hide;
  15957. }
  15958. }
  15959. };
  15960. this.updateOnChange = function(delta) {
  15961. var lineWidgets = this.session.lineWidgets;
  15962. if (!lineWidgets) return;
  15963. var startRow = delta.start.row;
  15964. var len = delta.end.row - startRow;
  15965. if (len === 0) {
  15966. } else if (delta.action == 'remove') {
  15967. var removed = lineWidgets.splice(startRow + 1, len);
  15968. removed.forEach(function(w) {
  15969. w && this.removeLineWidget(w);
  15970. }, this);
  15971. this.$updateRows();
  15972. } else {
  15973. var args = new Array(len);
  15974. args.unshift(startRow, 0);
  15975. lineWidgets.splice.apply(lineWidgets, args);
  15976. this.$updateRows();
  15977. }
  15978. };
  15979. this.$updateRows = function() {
  15980. var lineWidgets = this.session.lineWidgets;
  15981. if (!lineWidgets) return;
  15982. var noWidgets = true;
  15983. lineWidgets.forEach(function(w, i) {
  15984. if (w) {
  15985. noWidgets = false;
  15986. w.row = i;
  15987. while (w.$oldWidget) {
  15988. w.$oldWidget.row = i;
  15989. w = w.$oldWidget;
  15990. }
  15991. }
  15992. });
  15993. if (noWidgets)
  15994. this.session.lineWidgets = null;
  15995. };
  15996. this.addLineWidget = function(w) {
  15997. if (!this.session.lineWidgets)
  15998. this.session.lineWidgets = new Array(this.session.getLength());
  15999. var old = this.session.lineWidgets[w.row];
  16000. if (old) {
  16001. w.$oldWidget = old;
  16002. if (old.el && old.el.parentNode) {
  16003. old.el.parentNode.removeChild(old.el);
  16004. old._inDocument = false;
  16005. }
  16006. }
  16007. this.session.lineWidgets[w.row] = w;
  16008. w.session = this.session;
  16009. var renderer = this.editor.renderer;
  16010. if (w.html && !w.el) {
  16011. w.el = dom.createElement("div");
  16012. w.el.innerHTML = w.html;
  16013. }
  16014. if (w.el) {
  16015. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  16016. w.el.style.position = "absolute";
  16017. w.el.style.zIndex = 5;
  16018. renderer.container.appendChild(w.el);
  16019. w._inDocument = true;
  16020. }
  16021. if (!w.coverGutter) {
  16022. w.el.style.zIndex = 3;
  16023. }
  16024. if (!w.pixelHeight) {
  16025. w.pixelHeight = w.el.offsetHeight;
  16026. }
  16027. if (w.rowCount == null) {
  16028. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  16029. }
  16030. var fold = this.session.getFoldAt(w.row, 0);
  16031. w.$fold = fold;
  16032. if (fold) {
  16033. var lineWidgets = this.session.lineWidgets;
  16034. if (w.row == fold.end.row && !lineWidgets[fold.start.row])
  16035. lineWidgets[fold.start.row] = w;
  16036. else
  16037. w.hidden = true;
  16038. }
  16039. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16040. this.$updateRows();
  16041. this.renderWidgets(null, renderer);
  16042. this.onWidgetChanged(w);
  16043. return w;
  16044. };
  16045. this.removeLineWidget = function(w) {
  16046. w._inDocument = false;
  16047. w.session = null;
  16048. if (w.el && w.el.parentNode)
  16049. w.el.parentNode.removeChild(w.el);
  16050. if (w.editor && w.editor.destroy) try {
  16051. w.editor.destroy();
  16052. } catch(e){}
  16053. if (this.session.lineWidgets) {
  16054. var w1 = this.session.lineWidgets[w.row]
  16055. if (w1 == w) {
  16056. this.session.lineWidgets[w.row] = w.$oldWidget;
  16057. if (w.$oldWidget)
  16058. this.onWidgetChanged(w.$oldWidget);
  16059. } else {
  16060. while (w1) {
  16061. if (w1.$oldWidget == w) {
  16062. w1.$oldWidget = w.$oldWidget;
  16063. break;
  16064. }
  16065. w1 = w1.$oldWidget;
  16066. }
  16067. }
  16068. }
  16069. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16070. this.$updateRows();
  16071. };
  16072. this.getWidgetsAtRow = function(row) {
  16073. var lineWidgets = this.session.lineWidgets;
  16074. var w = lineWidgets && lineWidgets[row];
  16075. var list = [];
  16076. while (w) {
  16077. list.push(w);
  16078. w = w.$oldWidget;
  16079. }
  16080. return list;
  16081. };
  16082. this.onWidgetChanged = function(w) {
  16083. this.session._changedWidgets.push(w);
  16084. this.editor && this.editor.renderer.updateFull();
  16085. };
  16086. this.measureWidgets = function(e, renderer) {
  16087. var changedWidgets = this.session._changedWidgets;
  16088. var config = renderer.layerConfig;
  16089. if (!changedWidgets || !changedWidgets.length) return;
  16090. var min = Infinity;
  16091. for (var i = 0; i < changedWidgets.length; i++) {
  16092. var w = changedWidgets[i];
  16093. if (!w || !w.el) continue;
  16094. if (w.session != this.session) continue;
  16095. if (!w._inDocument) {
  16096. if (this.session.lineWidgets[w.row] != w)
  16097. continue;
  16098. w._inDocument = true;
  16099. renderer.container.appendChild(w.el);
  16100. }
  16101. w.h = w.el.offsetHeight;
  16102. if (!w.fixedWidth) {
  16103. w.w = w.el.offsetWidth;
  16104. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  16105. }
  16106. var rowCount = w.h / config.lineHeight;
  16107. if (w.coverLine) {
  16108. rowCount -= this.session.getRowLineCount(w.row);
  16109. if (rowCount < 0)
  16110. rowCount = 0;
  16111. }
  16112. if (w.rowCount != rowCount) {
  16113. w.rowCount = rowCount;
  16114. if (w.row < min)
  16115. min = w.row;
  16116. }
  16117. }
  16118. if (min != Infinity) {
  16119. this.session._emit("changeFold", {data:{start:{row: min}}});
  16120. this.session.lineWidgetWidth = null;
  16121. }
  16122. this.session._changedWidgets = [];
  16123. };
  16124. this.renderWidgets = function(e, renderer) {
  16125. var config = renderer.layerConfig;
  16126. var lineWidgets = this.session.lineWidgets;
  16127. if (!lineWidgets)
  16128. return;
  16129. var first = Math.min(this.firstRow, config.firstRow);
  16130. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  16131. while (first > 0 && !lineWidgets[first])
  16132. first--;
  16133. this.firstRow = config.firstRow;
  16134. this.lastRow = config.lastRow;
  16135. renderer.$cursorLayer.config = config;
  16136. for (var i = first; i <= last; i++) {
  16137. var w = lineWidgets[i];
  16138. if (!w || !w.el) continue;
  16139. if (w.hidden) {
  16140. w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
  16141. continue;
  16142. }
  16143. if (!w._inDocument) {
  16144. w._inDocument = true;
  16145. renderer.container.appendChild(w.el);
  16146. }
  16147. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  16148. if (!w.coverLine)
  16149. top += config.lineHeight * this.session.getRowLineCount(w.row);
  16150. w.el.style.top = top - config.offset + "px";
  16151. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  16152. if (!w.fixedWidth)
  16153. left -= renderer.scrollLeft;
  16154. w.el.style.left = left + "px";
  16155. if (w.fullWidth && w.screenWidth) {
  16156. w.el.style.minWidth = config.width + 2 * config.padding + "px";
  16157. }
  16158. if (w.fixedWidth) {
  16159. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  16160. } else {
  16161. w.el.style.right = "";
  16162. }
  16163. }
  16164. };
  16165. }).call(LineWidgets.prototype);
  16166. exports.LineWidgets = LineWidgets;
  16167. });
  16168. define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  16169. "use strict";
  16170. var LineWidgets = require("../line_widgets").LineWidgets;
  16171. var dom = require("../lib/dom");
  16172. var Range = require("../range").Range;
  16173. function binarySearch(array, needle, comparator) {
  16174. var first = 0;
  16175. var last = array.length - 1;
  16176. while (first <= last) {
  16177. var mid = (first + last) >> 1;
  16178. var c = comparator(needle, array[mid]);
  16179. if (c > 0)
  16180. first = mid + 1;
  16181. else if (c < 0)
  16182. last = mid - 1;
  16183. else
  16184. return mid;
  16185. }
  16186. return -(first + 1);
  16187. }
  16188. function findAnnotations(session, row, dir) {
  16189. var annotations = session.getAnnotations().sort(Range.comparePoints);
  16190. if (!annotations.length)
  16191. return;
  16192. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  16193. if (i < 0)
  16194. i = -i - 1;
  16195. if (i >= annotations.length)
  16196. i = dir > 0 ? 0 : annotations.length - 1;
  16197. else if (i === 0 && dir < 0)
  16198. i = annotations.length - 1;
  16199. var annotation = annotations[i];
  16200. if (!annotation || !dir)
  16201. return;
  16202. if (annotation.row === row) {
  16203. do {
  16204. annotation = annotations[i += dir];
  16205. } while (annotation && annotation.row === row);
  16206. if (!annotation)
  16207. return annotations.slice();
  16208. }
  16209. var matched = [];
  16210. row = annotation.row;
  16211. do {
  16212. matched[dir < 0 ? "unshift" : "push"](annotation);
  16213. annotation = annotations[i += dir];
  16214. } while (annotation && annotation.row == row);
  16215. return matched.length && matched;
  16216. }
  16217. exports.showErrorMarker = function(editor, dir) {
  16218. var session = editor.session;
  16219. if (!session.widgetManager) {
  16220. session.widgetManager = new LineWidgets(session);
  16221. session.widgetManager.attach(editor);
  16222. }
  16223. var pos = editor.getCursorPosition();
  16224. var row = pos.row;
  16225. var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
  16226. return w.type == "errorMarker";
  16227. })[0];
  16228. if (oldWidget) {
  16229. oldWidget.destroy();
  16230. } else {
  16231. row -= dir;
  16232. }
  16233. var annotations = findAnnotations(session, row, dir);
  16234. var gutterAnno;
  16235. if (annotations) {
  16236. var annotation = annotations[0];
  16237. pos.column = (annotation.pos && typeof annotation.column != "number"
  16238. ? annotation.pos.sc
  16239. : annotation.column) || 0;
  16240. pos.row = annotation.row;
  16241. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  16242. } else if (oldWidget) {
  16243. return;
  16244. } else {
  16245. gutterAnno = {
  16246. text: ["Looks good!"],
  16247. className: "ace_ok"
  16248. };
  16249. }
  16250. editor.session.unfold(pos.row);
  16251. editor.selection.moveToPosition(pos);
  16252. var w = {
  16253. row: pos.row,
  16254. fixedWidth: true,
  16255. coverGutter: true,
  16256. el: dom.createElement("div"),
  16257. type: "errorMarker"
  16258. };
  16259. var el = w.el.appendChild(dom.createElement("div"));
  16260. var arrow = w.el.appendChild(dom.createElement("div"));
  16261. arrow.className = "error_widget_arrow " + gutterAnno.className;
  16262. var left = editor.renderer.$cursorLayer
  16263. .getPixelPosition(pos).left;
  16264. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  16265. w.el.className = "error_widget_wrapper";
  16266. el.className = "error_widget " + gutterAnno.className;
  16267. el.innerHTML = gutterAnno.text.join("<br>");
  16268. el.appendChild(dom.createElement("div"));
  16269. var kb = function(_, hashId, keyString) {
  16270. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  16271. w.destroy();
  16272. return {command: "null"};
  16273. }
  16274. };
  16275. w.destroy = function() {
  16276. if (editor.$mouseHandler.isMousePressed)
  16277. return;
  16278. editor.keyBinding.removeKeyboardHandler(kb);
  16279. session.widgetManager.removeLineWidget(w);
  16280. editor.off("changeSelection", w.destroy);
  16281. editor.off("changeSession", w.destroy);
  16282. editor.off("mouseup", w.destroy);
  16283. editor.off("change", w.destroy);
  16284. };
  16285. editor.keyBinding.addKeyboardHandler(kb);
  16286. editor.on("changeSelection", w.destroy);
  16287. editor.on("changeSession", w.destroy);
  16288. editor.on("mouseup", w.destroy);
  16289. editor.on("change", w.destroy);
  16290. editor.session.widgetManager.addLineWidget(w);
  16291. w.el.onmousedown = editor.focus.bind(editor);
  16292. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  16293. };
  16294. dom.importCssString("\
  16295. .error_widget_wrapper {\
  16296. background: inherit;\
  16297. color: inherit;\
  16298. border:none\
  16299. }\
  16300. .error_widget {\
  16301. border-top: solid 2px;\
  16302. border-bottom: solid 2px;\
  16303. margin: 5px 0;\
  16304. padding: 10px 40px;\
  16305. white-space: pre-wrap;\
  16306. }\
  16307. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  16308. border-color: #ff5a5a\
  16309. }\
  16310. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  16311. border-color: #F1D817\
  16312. }\
  16313. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  16314. border-color: #5a5a5a\
  16315. }\
  16316. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  16317. border-color: #5aaa5a\
  16318. }\
  16319. .error_widget_arrow {\
  16320. position: absolute;\
  16321. border: solid 5px;\
  16322. border-top-color: transparent!important;\
  16323. border-right-color: transparent!important;\
  16324. border-left-color: transparent!important;\
  16325. top: -5px;\
  16326. }\
  16327. ", "");
  16328. });
  16329. define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"], function(require, exports, module) {
  16330. "use strict";
  16331. require("./lib/fixoldbrowsers");
  16332. var dom = require("./lib/dom");
  16333. var event = require("./lib/event");
  16334. var Editor = require("./editor").Editor;
  16335. var EditSession = require("./edit_session").EditSession;
  16336. var UndoManager = require("./undomanager").UndoManager;
  16337. var Renderer = require("./virtual_renderer").VirtualRenderer;
  16338. require("./worker/worker_client");
  16339. require("./keyboard/hash_handler");
  16340. require("./placeholder");
  16341. require("./multi_select");
  16342. require("./mode/folding/fold_mode");
  16343. require("./theme/textmate");
  16344. require("./ext/error_marker");
  16345. exports.config = require("./config");
  16346. exports.require = require;
  16347. exports.edit = function(el) {
  16348. if (typeof(el) == "string") {
  16349. var _id = el;
  16350. el = document.getElementById(_id);
  16351. if (!el)
  16352. throw new Error("ace.edit can't find div #" + _id);
  16353. }
  16354. if (el && el.env && el.env.editor instanceof Editor)
  16355. return el.env.editor;
  16356. var value = "";
  16357. if (el && /input|textarea/i.test(el.tagName)) {
  16358. var oldNode = el;
  16359. value = oldNode.value;
  16360. el = dom.createElement("pre");
  16361. oldNode.parentNode.replaceChild(el, oldNode);
  16362. } else if (el) {
  16363. value = dom.getInnerText(el);
  16364. el.innerHTML = '';
  16365. }
  16366. var doc = exports.createEditSession(value);
  16367. var editor = new Editor(new Renderer(el));
  16368. editor.setSession(doc);
  16369. var env = {
  16370. document: doc,
  16371. editor: editor,
  16372. onResize: editor.resize.bind(editor, null)
  16373. };
  16374. if (oldNode) env.textarea = oldNode;
  16375. event.addListener(window, "resize", env.onResize);
  16376. editor.on("destroy", function() {
  16377. event.removeListener(window, "resize", env.onResize);
  16378. env.editor.container.env = null; // prevent memory leak on old ie
  16379. });
  16380. editor.container.env = editor.env = env;
  16381. return editor;
  16382. };
  16383. exports.createEditSession = function(text, mode) {
  16384. var doc = new EditSession(text, mode);
  16385. doc.setUndoManager(new UndoManager());
  16386. return doc;
  16387. }
  16388. exports.EditSession = EditSession;
  16389. exports.UndoManager = UndoManager;
  16390. exports.version = "1.2.2";
  16391. });
  16392. (function() {
  16393. window.require(["ace/ace"], function(a) {
  16394. a && a.config.init(true);
  16395. if (!window.ace)
  16396. window.ace = a;
  16397. for (var key in a) if (a.hasOwnProperty(key))
  16398. window.ace[key] = a[key];
  16399. });
  16400. })();