ace.js 626 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /**
  31. * Define a module along with a payload
  32. * @param module a name for the payload
  33. * @param payload a function to call with (require, exports, module) params
  34. */
  35. (function() {
  36. var ACE_NAMESPACE = "ace";
  37. var global = (function() { return this; })();
  38. if (!global && typeof window != "undefined") global = window; // strict mode
  39. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  40. return;
  41. var define = function(module, deps, payload) {
  42. if (typeof module !== "string") {
  43. if (define.original)
  44. define.original.apply(this, arguments);
  45. else {
  46. console.error("dropping module because define wasn\'t a string.");
  47. console.trace();
  48. }
  49. return;
  50. }
  51. if (arguments.length == 2)
  52. payload = deps;
  53. if (!define.modules[module]) {
  54. define.payloads[module] = payload;
  55. define.modules[module] = null;
  56. }
  57. };
  58. define.modules = {};
  59. define.payloads = {};
  60. /**
  61. * Get at functionality ace.define()ed using the function above
  62. */
  63. var _require = function(parentId, module, callback) {
  64. if (typeof module === "string") {
  65. var payload = lookup(parentId, module);
  66. if (payload != undefined) {
  67. callback && callback();
  68. return payload;
  69. }
  70. } else if (Object.prototype.toString.call(module) === "[object Array]") {
  71. var params = [];
  72. for (var i = 0, l = module.length; i < l; ++i) {
  73. var dep = lookup(parentId, module[i]);
  74. if (dep == undefined && require.original)
  75. return;
  76. params.push(dep);
  77. }
  78. return callback && callback.apply(null, params) || true;
  79. }
  80. };
  81. var require = function(module, callback) {
  82. var packagedModule = _require("", module, callback);
  83. if (packagedModule == undefined && require.original)
  84. return require.original.apply(this, arguments);
  85. return packagedModule;
  86. };
  87. var normalizeModule = function(parentId, moduleName) {
  88. // normalize plugin requires
  89. if (moduleName.indexOf("!") !== -1) {
  90. var chunks = moduleName.split("!");
  91. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  92. }
  93. // normalize relative requires
  94. if (moduleName.charAt(0) == ".") {
  95. var base = parentId.split("/").slice(0, -1).join("/");
  96. moduleName = base + "/" + moduleName;
  97. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  98. var previous = moduleName;
  99. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  100. }
  101. }
  102. return moduleName;
  103. };
  104. /**
  105. * Internal function to lookup moduleNames and resolve them by calling the
  106. * definition function if needed.
  107. */
  108. var lookup = function(parentId, moduleName) {
  109. moduleName = normalizeModule(parentId, moduleName);
  110. var module = define.modules[moduleName];
  111. if (!module) {
  112. module = define.payloads[moduleName];
  113. if (typeof module === 'function') {
  114. var exports = {};
  115. var mod = {
  116. id: moduleName,
  117. uri: '',
  118. exports: exports,
  119. packaged: true
  120. };
  121. var req = function(module, callback) {
  122. return _require(moduleName, module, callback);
  123. };
  124. var returnValue = module(req, exports, mod);
  125. exports = returnValue || mod.exports;
  126. define.modules[moduleName] = exports;
  127. delete define.payloads[moduleName];
  128. }
  129. module = define.modules[moduleName] = exports || module;
  130. }
  131. return module;
  132. };
  133. function exportAce(ns) {
  134. var root = global;
  135. if (ns) {
  136. if (!global[ns])
  137. global[ns] = {};
  138. root = global[ns];
  139. }
  140. if (!root.define || !root.define.packaged) {
  141. define.original = root.define;
  142. root.define = define;
  143. root.define.packaged = true;
  144. }
  145. if (!root.require || !root.require.packaged) {
  146. require.original = root.require;
  147. root.require = require;
  148. root.require.packaged = true;
  149. }
  150. }
  151. exportAce(ACE_NAMESPACE);
  152. })();
  153. ace.define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  154. "use strict";
  155. var real = {
  156. exec: RegExp.prototype.exec,
  157. test: RegExp.prototype.test,
  158. match: String.prototype.match,
  159. replace: String.prototype.replace,
  160. split: String.prototype.split
  161. },
  162. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  163. compliantLastIndexIncrement = function () {
  164. var x = /^/g;
  165. real.test.call(x, "");
  166. return !x.lastIndex;
  167. }();
  168. if (compliantLastIndexIncrement && compliantExecNpcg)
  169. return;
  170. RegExp.prototype.exec = function (str) {
  171. var match = real.exec.apply(this, arguments),
  172. name, r2;
  173. if ( typeof(str) == 'string' && match) {
  174. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  175. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  176. real.replace.call(str.slice(match.index), r2, function () {
  177. for (var i = 1; i < arguments.length - 2; i++) {
  178. if (arguments[i] === undefined)
  179. match[i] = undefined;
  180. }
  181. });
  182. }
  183. if (this._xregexp && this._xregexp.captureNames) {
  184. for (var i = 1; i < match.length; i++) {
  185. name = this._xregexp.captureNames[i - 1];
  186. if (name)
  187. match[name] = match[i];
  188. }
  189. }
  190. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  191. this.lastIndex--;
  192. }
  193. return match;
  194. };
  195. if (!compliantLastIndexIncrement) {
  196. RegExp.prototype.test = function (str) {
  197. var match = real.exec.call(this, str);
  198. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  199. this.lastIndex--;
  200. return !!match;
  201. };
  202. }
  203. function getNativeFlags (regex) {
  204. return (regex.global ? "g" : "") +
  205. (regex.ignoreCase ? "i" : "") +
  206. (regex.multiline ? "m" : "") +
  207. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  208. (regex.sticky ? "y" : "");
  209. }
  210. function indexOf (array, item, from) {
  211. if (Array.prototype.indexOf) // Use the native array method if available
  212. return array.indexOf(item, from);
  213. for (var i = from || 0; i < array.length; i++) {
  214. if (array[i] === item)
  215. return i;
  216. }
  217. return -1;
  218. }
  219. });
  220. ace.define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  221. function Empty() {}
  222. if (!Function.prototype.bind) {
  223. Function.prototype.bind = function bind(that) { // .length is 1
  224. var target = this;
  225. if (typeof target != "function") {
  226. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  227. }
  228. var args = slice.call(arguments, 1); // for normal call
  229. var bound = function () {
  230. if (this instanceof bound) {
  231. var result = target.apply(
  232. this,
  233. args.concat(slice.call(arguments))
  234. );
  235. if (Object(result) === result) {
  236. return result;
  237. }
  238. return this;
  239. } else {
  240. return target.apply(
  241. that,
  242. args.concat(slice.call(arguments))
  243. );
  244. }
  245. };
  246. if(target.prototype) {
  247. Empty.prototype = target.prototype;
  248. bound.prototype = new Empty();
  249. Empty.prototype = null;
  250. }
  251. return bound;
  252. };
  253. }
  254. var call = Function.prototype.call;
  255. var prototypeOfArray = Array.prototype;
  256. var prototypeOfObject = Object.prototype;
  257. var slice = prototypeOfArray.slice;
  258. var _toString = call.bind(prototypeOfObject.toString);
  259. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  260. var defineGetter;
  261. var defineSetter;
  262. var lookupGetter;
  263. var lookupSetter;
  264. var supportsAccessors;
  265. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  266. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  267. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  268. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  269. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  270. }
  271. if ([1,2].splice(0).length != 2) {
  272. if(function() { // test IE < 9 to splice bug - see issue #138
  273. function makeArray(l) {
  274. var a = new Array(l+2);
  275. a[0] = a[1] = 0;
  276. return a;
  277. }
  278. var array = [], lengthBefore;
  279. array.splice.apply(array, makeArray(20));
  280. array.splice.apply(array, makeArray(26));
  281. lengthBefore = array.length; //46
  282. array.splice(5, 0, "XXX"); // add one element
  283. lengthBefore + 1 == array.length
  284. if (lengthBefore + 1 == array.length) {
  285. return true;// has right splice implementation without bugs
  286. }
  287. }()) {//IE 6/7
  288. var array_splice = Array.prototype.splice;
  289. Array.prototype.splice = function(start, deleteCount) {
  290. if (!arguments.length) {
  291. return [];
  292. } else {
  293. return array_splice.apply(this, [
  294. start === void 0 ? 0 : start,
  295. deleteCount === void 0 ? (this.length - start) : deleteCount
  296. ].concat(slice.call(arguments, 2)))
  297. }
  298. };
  299. } else {//IE8
  300. Array.prototype.splice = function(pos, removeCount){
  301. var length = this.length;
  302. if (pos > 0) {
  303. if (pos > length)
  304. pos = length;
  305. } else if (pos == void 0) {
  306. pos = 0;
  307. } else if (pos < 0) {
  308. pos = Math.max(length + pos, 0);
  309. }
  310. if (!(pos+removeCount < length))
  311. removeCount = length - pos;
  312. var removed = this.slice(pos, pos+removeCount);
  313. var insert = slice.call(arguments, 2);
  314. var add = insert.length;
  315. if (pos === length) {
  316. if (add) {
  317. this.push.apply(this, insert);
  318. }
  319. } else {
  320. var remove = Math.min(removeCount, length - pos);
  321. var tailOldPos = pos + remove;
  322. var tailNewPos = tailOldPos + add - remove;
  323. var tailCount = length - tailOldPos;
  324. var lengthAfterRemove = length - remove;
  325. if (tailNewPos < tailOldPos) { // case A
  326. for (var i = 0; i < tailCount; ++i) {
  327. this[tailNewPos+i] = this[tailOldPos+i];
  328. }
  329. } else if (tailNewPos > tailOldPos) { // case B
  330. for (i = tailCount; i--; ) {
  331. this[tailNewPos+i] = this[tailOldPos+i];
  332. }
  333. } // else, add == remove (nothing to do)
  334. if (add && pos === lengthAfterRemove) {
  335. this.length = lengthAfterRemove; // truncate array
  336. this.push.apply(this, insert);
  337. } else {
  338. this.length = lengthAfterRemove + add; // reserves space
  339. for (i = 0; i < add; ++i) {
  340. this[pos+i] = insert[i];
  341. }
  342. }
  343. }
  344. return removed;
  345. };
  346. }
  347. }
  348. if (!Array.isArray) {
  349. Array.isArray = function isArray(obj) {
  350. return _toString(obj) == "[object Array]";
  351. };
  352. }
  353. var boxedString = Object("a"),
  354. splitString = boxedString[0] != "a" || !(0 in boxedString);
  355. if (!Array.prototype.forEach) {
  356. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. thisp = arguments[1],
  362. i = -1,
  363. length = self.length >>> 0;
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(); // TODO message
  366. }
  367. while (++i < length) {
  368. if (i in self) {
  369. fun.call(thisp, self[i], i, object);
  370. }
  371. }
  372. };
  373. }
  374. if (!Array.prototype.map) {
  375. Array.prototype.map = function map(fun /*, thisp*/) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = Array(length),
  382. thisp = arguments[1];
  383. if (_toString(fun) != "[object Function]") {
  384. throw new TypeError(fun + " is not a function");
  385. }
  386. for (var i = 0; i < length; i++) {
  387. if (i in self)
  388. result[i] = fun.call(thisp, self[i], i, object);
  389. }
  390. return result;
  391. };
  392. }
  393. if (!Array.prototype.filter) {
  394. Array.prototype.filter = function filter(fun /*, thisp */) {
  395. var object = toObject(this),
  396. self = splitString && _toString(this) == "[object String]" ?
  397. this.split("") :
  398. object,
  399. length = self.length >>> 0,
  400. result = [],
  401. value,
  402. thisp = arguments[1];
  403. if (_toString(fun) != "[object Function]") {
  404. throw new TypeError(fun + " is not a function");
  405. }
  406. for (var i = 0; i < length; i++) {
  407. if (i in self) {
  408. value = self[i];
  409. if (fun.call(thisp, value, i, object)) {
  410. result.push(value);
  411. }
  412. }
  413. }
  414. return result;
  415. };
  416. }
  417. if (!Array.prototype.every) {
  418. Array.prototype.every = function every(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && !fun.call(thisp, self[i], i, object)) {
  430. return false;
  431. }
  432. }
  433. return true;
  434. };
  435. }
  436. if (!Array.prototype.some) {
  437. Array.prototype.some = function some(fun /*, thisp */) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0,
  443. thisp = arguments[1];
  444. if (_toString(fun) != "[object Function]") {
  445. throw new TypeError(fun + " is not a function");
  446. }
  447. for (var i = 0; i < length; i++) {
  448. if (i in self && fun.call(thisp, self[i], i, object)) {
  449. return true;
  450. }
  451. }
  452. return false;
  453. };
  454. }
  455. if (!Array.prototype.reduce) {
  456. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  457. var object = toObject(this),
  458. self = splitString && _toString(this) == "[object String]" ?
  459. this.split("") :
  460. object,
  461. length = self.length >>> 0;
  462. if (_toString(fun) != "[object Function]") {
  463. throw new TypeError(fun + " is not a function");
  464. }
  465. if (!length && arguments.length == 1) {
  466. throw new TypeError("reduce of empty array with no initial value");
  467. }
  468. var i = 0;
  469. var result;
  470. if (arguments.length >= 2) {
  471. result = arguments[1];
  472. } else {
  473. do {
  474. if (i in self) {
  475. result = self[i++];
  476. break;
  477. }
  478. if (++i >= length) {
  479. throw new TypeError("reduce of empty array with no initial value");
  480. }
  481. } while (true);
  482. }
  483. for (; i < length; i++) {
  484. if (i in self) {
  485. result = fun.call(void 0, result, self[i], i, object);
  486. }
  487. }
  488. return result;
  489. };
  490. }
  491. if (!Array.prototype.reduceRight) {
  492. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  493. var object = toObject(this),
  494. self = splitString && _toString(this) == "[object String]" ?
  495. this.split("") :
  496. object,
  497. length = self.length >>> 0;
  498. if (_toString(fun) != "[object Function]") {
  499. throw new TypeError(fun + " is not a function");
  500. }
  501. if (!length && arguments.length == 1) {
  502. throw new TypeError("reduceRight of empty array with no initial value");
  503. }
  504. var result, i = length - 1;
  505. if (arguments.length >= 2) {
  506. result = arguments[1];
  507. } else {
  508. do {
  509. if (i in self) {
  510. result = self[i--];
  511. break;
  512. }
  513. if (--i < 0) {
  514. throw new TypeError("reduceRight of empty array with no initial value");
  515. }
  516. } while (true);
  517. }
  518. do {
  519. if (i in this) {
  520. result = fun.call(void 0, result, self[i], i, object);
  521. }
  522. } while (i--);
  523. return result;
  524. };
  525. }
  526. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  527. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  528. var self = splitString && _toString(this) == "[object String]" ?
  529. this.split("") :
  530. toObject(this),
  531. length = self.length >>> 0;
  532. if (!length) {
  533. return -1;
  534. }
  535. var i = 0;
  536. if (arguments.length > 1) {
  537. i = toInteger(arguments[1]);
  538. }
  539. i = i >= 0 ? i : Math.max(0, length + i);
  540. for (; i < length; i++) {
  541. if (i in self && self[i] === sought) {
  542. return i;
  543. }
  544. }
  545. return -1;
  546. };
  547. }
  548. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  549. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  550. var self = splitString && _toString(this) == "[object String]" ?
  551. this.split("") :
  552. toObject(this),
  553. length = self.length >>> 0;
  554. if (!length) {
  555. return -1;
  556. }
  557. var i = length - 1;
  558. if (arguments.length > 1) {
  559. i = Math.min(i, toInteger(arguments[1]));
  560. }
  561. i = i >= 0 ? i : length - Math.abs(i);
  562. for (; i >= 0; i--) {
  563. if (i in self && sought === self[i]) {
  564. return i;
  565. }
  566. }
  567. return -1;
  568. };
  569. }
  570. if (!Object.getPrototypeOf) {
  571. Object.getPrototypeOf = function getPrototypeOf(object) {
  572. return object.__proto__ || (
  573. object.constructor ?
  574. object.constructor.prototype :
  575. prototypeOfObject
  576. );
  577. };
  578. }
  579. if (!Object.getOwnPropertyDescriptor) {
  580. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  581. "non-object: ";
  582. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  583. if ((typeof object != "object" && typeof object != "function") || object === null)
  584. throw new TypeError(ERR_NON_OBJECT + object);
  585. if (!owns(object, property))
  586. return;
  587. var descriptor, getter, setter;
  588. descriptor = { enumerable: true, configurable: true };
  589. if (supportsAccessors) {
  590. var prototype = object.__proto__;
  591. object.__proto__ = prototypeOfObject;
  592. var getter = lookupGetter(object, property);
  593. var setter = lookupSetter(object, property);
  594. object.__proto__ = prototype;
  595. if (getter || setter) {
  596. if (getter) descriptor.get = getter;
  597. if (setter) descriptor.set = setter;
  598. return descriptor;
  599. }
  600. }
  601. descriptor.value = object[property];
  602. return descriptor;
  603. };
  604. }
  605. if (!Object.getOwnPropertyNames) {
  606. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  607. return Object.keys(object);
  608. };
  609. }
  610. if (!Object.create) {
  611. var createEmpty;
  612. if (Object.prototype.__proto__ === null) {
  613. createEmpty = function () {
  614. return { "__proto__": null };
  615. };
  616. } else {
  617. createEmpty = function () {
  618. var empty = {};
  619. for (var i in empty)
  620. empty[i] = null;
  621. empty.constructor =
  622. empty.hasOwnProperty =
  623. empty.propertyIsEnumerable =
  624. empty.isPrototypeOf =
  625. empty.toLocaleString =
  626. empty.toString =
  627. empty.valueOf =
  628. empty.__proto__ = null;
  629. return empty;
  630. }
  631. }
  632. Object.create = function create(prototype, properties) {
  633. var object;
  634. if (prototype === null) {
  635. object = createEmpty();
  636. } else {
  637. if (typeof prototype != "object")
  638. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  639. var Type = function () {};
  640. Type.prototype = prototype;
  641. object = new Type();
  642. object.__proto__ = prototype;
  643. }
  644. if (properties !== void 0)
  645. Object.defineProperties(object, properties);
  646. return object;
  647. };
  648. }
  649. function doesDefinePropertyWork(object) {
  650. try {
  651. Object.defineProperty(object, "sentinel", {});
  652. return "sentinel" in object;
  653. } catch (exception) {
  654. }
  655. }
  656. if (Object.defineProperty) {
  657. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  658. var definePropertyWorksOnDom = typeof document == "undefined" ||
  659. doesDefinePropertyWork(document.createElement("div"));
  660. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  661. var definePropertyFallback = Object.defineProperty;
  662. }
  663. }
  664. if (!Object.defineProperty || definePropertyFallback) {
  665. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  666. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  667. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  668. "on this javascript engine";
  669. Object.defineProperty = function defineProperty(object, property, descriptor) {
  670. if ((typeof object != "object" && typeof object != "function") || object === null)
  671. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  672. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  673. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  674. if (definePropertyFallback) {
  675. try {
  676. return definePropertyFallback.call(Object, object, property, descriptor);
  677. } catch (exception) {
  678. }
  679. }
  680. if (owns(descriptor, "value")) {
  681. if (supportsAccessors && (lookupGetter(object, property) ||
  682. lookupSetter(object, property)))
  683. {
  684. var prototype = object.__proto__;
  685. object.__proto__ = prototypeOfObject;
  686. delete object[property];
  687. object[property] = descriptor.value;
  688. object.__proto__ = prototype;
  689. } else {
  690. object[property] = descriptor.value;
  691. }
  692. } else {
  693. if (!supportsAccessors)
  694. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  695. if (owns(descriptor, "get"))
  696. defineGetter(object, property, descriptor.get);
  697. if (owns(descriptor, "set"))
  698. defineSetter(object, property, descriptor.set);
  699. }
  700. return object;
  701. };
  702. }
  703. if (!Object.defineProperties) {
  704. Object.defineProperties = function defineProperties(object, properties) {
  705. for (var property in properties) {
  706. if (owns(properties, property))
  707. Object.defineProperty(object, property, properties[property]);
  708. }
  709. return object;
  710. };
  711. }
  712. if (!Object.seal) {
  713. Object.seal = function seal(object) {
  714. return object;
  715. };
  716. }
  717. if (!Object.freeze) {
  718. Object.freeze = function freeze(object) {
  719. return object;
  720. };
  721. }
  722. try {
  723. Object.freeze(function () {});
  724. } catch (exception) {
  725. Object.freeze = (function freeze(freezeObject) {
  726. return function freeze(object) {
  727. if (typeof object == "function") {
  728. return object;
  729. } else {
  730. return freezeObject(object);
  731. }
  732. };
  733. })(Object.freeze);
  734. }
  735. if (!Object.preventExtensions) {
  736. Object.preventExtensions = function preventExtensions(object) {
  737. return object;
  738. };
  739. }
  740. if (!Object.isSealed) {
  741. Object.isSealed = function isSealed(object) {
  742. return false;
  743. };
  744. }
  745. if (!Object.isFrozen) {
  746. Object.isFrozen = function isFrozen(object) {
  747. return false;
  748. };
  749. }
  750. if (!Object.isExtensible) {
  751. Object.isExtensible = function isExtensible(object) {
  752. if (Object(object) === object) {
  753. throw new TypeError(); // TODO message
  754. }
  755. var name = '';
  756. while (owns(object, name)) {
  757. name += '?';
  758. }
  759. object[name] = true;
  760. var returnValue = owns(object, name);
  761. delete object[name];
  762. return returnValue;
  763. };
  764. }
  765. if (!Object.keys) {
  766. var hasDontEnumBug = true,
  767. dontEnums = [
  768. "toString",
  769. "toLocaleString",
  770. "valueOf",
  771. "hasOwnProperty",
  772. "isPrototypeOf",
  773. "propertyIsEnumerable",
  774. "constructor"
  775. ],
  776. dontEnumsLength = dontEnums.length;
  777. for (var key in {"toString": null}) {
  778. hasDontEnumBug = false;
  779. }
  780. Object.keys = function keys(object) {
  781. if (
  782. (typeof object != "object" && typeof object != "function") ||
  783. object === null
  784. ) {
  785. throw new TypeError("Object.keys called on a non-object");
  786. }
  787. var keys = [];
  788. for (var name in object) {
  789. if (owns(object, name)) {
  790. keys.push(name);
  791. }
  792. }
  793. if (hasDontEnumBug) {
  794. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  795. var dontEnum = dontEnums[i];
  796. if (owns(object, dontEnum)) {
  797. keys.push(dontEnum);
  798. }
  799. }
  800. }
  801. return keys;
  802. };
  803. }
  804. if (!Date.now) {
  805. Date.now = function now() {
  806. return new Date().getTime();
  807. };
  808. }
  809. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  810. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  811. "\u2029\uFEFF";
  812. if (!String.prototype.trim || ws.trim()) {
  813. ws = "[" + ws + "]";
  814. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  815. trimEndRegexp = new RegExp(ws + ws + "*$");
  816. String.prototype.trim = function trim() {
  817. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  818. };
  819. }
  820. function toInteger(n) {
  821. n = +n;
  822. if (n !== n) { // isNaN
  823. n = 0;
  824. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  825. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  826. }
  827. return n;
  828. }
  829. function isPrimitive(input) {
  830. var type = typeof input;
  831. return (
  832. input === null ||
  833. type === "undefined" ||
  834. type === "boolean" ||
  835. type === "number" ||
  836. type === "string"
  837. );
  838. }
  839. function toPrimitive(input) {
  840. var val, valueOf, toString;
  841. if (isPrimitive(input)) {
  842. return input;
  843. }
  844. valueOf = input.valueOf;
  845. if (typeof valueOf === "function") {
  846. val = valueOf.call(input);
  847. if (isPrimitive(val)) {
  848. return val;
  849. }
  850. }
  851. toString = input.toString;
  852. if (typeof toString === "function") {
  853. val = toString.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. throw new TypeError();
  859. }
  860. var toObject = function (o) {
  861. if (o == null) { // this matches both null and undefined
  862. throw new TypeError("can't convert "+o+" to object");
  863. }
  864. return Object(o);
  865. };
  866. });
  867. ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  868. "use strict";
  869. require("./regexp");
  870. require("./es5-shim");
  871. });
  872. ace.define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  873. "use strict";
  874. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  875. exports.getDocumentHead = function(doc) {
  876. if (!doc)
  877. doc = document;
  878. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  879. }
  880. exports.createElement = function(tag, ns) {
  881. return document.createElementNS ?
  882. document.createElementNS(ns || XHTML_NS, tag) :
  883. document.createElement(tag);
  884. };
  885. exports.hasCssClass = function(el, name) {
  886. var classes = (el.className || "").split(/\s+/g);
  887. return classes.indexOf(name) !== -1;
  888. };
  889. exports.addCssClass = function(el, name) {
  890. if (!exports.hasCssClass(el, name)) {
  891. el.className += " " + name;
  892. }
  893. };
  894. exports.removeCssClass = function(el, name) {
  895. var classes = el.className.split(/\s+/g);
  896. while (true) {
  897. var index = classes.indexOf(name);
  898. if (index == -1) {
  899. break;
  900. }
  901. classes.splice(index, 1);
  902. }
  903. el.className = classes.join(" ");
  904. };
  905. exports.toggleCssClass = function(el, name) {
  906. var classes = el.className.split(/\s+/g), add = true;
  907. while (true) {
  908. var index = classes.indexOf(name);
  909. if (index == -1) {
  910. break;
  911. }
  912. add = false;
  913. classes.splice(index, 1);
  914. }
  915. if(add)
  916. classes.push(name);
  917. el.className = classes.join(" ");
  918. return add;
  919. };
  920. exports.setCssClass = function(node, className, include) {
  921. if (include) {
  922. exports.addCssClass(node, className);
  923. } else {
  924. exports.removeCssClass(node, className);
  925. }
  926. };
  927. exports.hasCssString = function(id, doc) {
  928. var index = 0, sheets;
  929. doc = doc || document;
  930. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  931. while (index < sheets.length)
  932. if (sheets[index++].owningElement.id === id) return true;
  933. } else if ((sheets = doc.getElementsByTagName("style"))) {
  934. while (index < sheets.length)
  935. if (sheets[index++].id === id) return true;
  936. }
  937. return false;
  938. };
  939. exports.importCssString = function importCssString(cssText, id, doc) {
  940. doc = doc || document;
  941. if (id && exports.hasCssString(id, doc))
  942. return null;
  943. var style;
  944. if (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 = doc.createElementNS
  953. ? doc.createElementNS(XHTML_NS, "style")
  954. : doc.createElement("style");
  955. style.appendChild(doc.createTextNode(cssText));
  956. if (id)
  957. style.id = id;
  958. exports.getDocumentHead(doc).appendChild(style);
  959. }
  960. };
  961. exports.importCssStylsheet = function(uri, doc) {
  962. if (doc.createStyleSheet) {
  963. doc.createStyleSheet(uri);
  964. } else {
  965. var link = exports.createElement('link');
  966. link.rel = 'stylesheet';
  967. link.href = uri;
  968. exports.getDocumentHead(doc).appendChild(link);
  969. }
  970. };
  971. exports.getInnerWidth = function(element) {
  972. return (
  973. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  974. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  975. element.clientWidth
  976. );
  977. };
  978. exports.getInnerHeight = function(element) {
  979. return (
  980. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  981. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  982. element.clientHeight
  983. );
  984. };
  985. exports.scrollbarWidth = function(document) {
  986. var inner = exports.createElement("ace_inner");
  987. inner.style.width = "100%";
  988. inner.style.minWidth = "0px";
  989. inner.style.height = "200px";
  990. inner.style.display = "block";
  991. var outer = exports.createElement("ace_outer");
  992. var style = outer.style;
  993. style.position = "absolute";
  994. style.left = "-10000px";
  995. style.overflow = "hidden";
  996. style.width = "200px";
  997. style.minWidth = "0px";
  998. style.height = "150px";
  999. style.display = "block";
  1000. outer.appendChild(inner);
  1001. var body = document.documentElement;
  1002. body.appendChild(outer);
  1003. var noScrollbar = inner.offsetWidth;
  1004. style.overflow = "scroll";
  1005. var withScrollbar = inner.offsetWidth;
  1006. if (noScrollbar == withScrollbar) {
  1007. withScrollbar = outer.clientWidth;
  1008. }
  1009. body.removeChild(outer);
  1010. return noScrollbar-withScrollbar;
  1011. };
  1012. if (typeof document == "undefined") {
  1013. exports.importCssString = function() {};
  1014. return;
  1015. }
  1016. if (window.pageYOffset !== undefined) {
  1017. exports.getPageScrollTop = function() {
  1018. return window.pageYOffset;
  1019. };
  1020. exports.getPageScrollLeft = function() {
  1021. return window.pageXOffset;
  1022. };
  1023. }
  1024. else {
  1025. exports.getPageScrollTop = function() {
  1026. return document.body.scrollTop;
  1027. };
  1028. exports.getPageScrollLeft = function() {
  1029. return document.body.scrollLeft;
  1030. };
  1031. }
  1032. if (window.getComputedStyle)
  1033. exports.computedStyle = function(element, style) {
  1034. if (style)
  1035. return (window.getComputedStyle(element, "") || {})[style] || "";
  1036. return window.getComputedStyle(element, "") || {};
  1037. };
  1038. else
  1039. exports.computedStyle = function(element, style) {
  1040. if (style)
  1041. return element.currentStyle[style];
  1042. return element.currentStyle;
  1043. };
  1044. exports.setInnerHtml = function(el, innerHtml) {
  1045. var element = el.cloneNode(false);//document.createElement("div");
  1046. element.innerHTML = innerHtml;
  1047. el.parentNode.replaceChild(element, el);
  1048. return element;
  1049. };
  1050. if ("textContent" in document.documentElement) {
  1051. exports.setInnerText = function(el, innerText) {
  1052. el.textContent = innerText;
  1053. };
  1054. exports.getInnerText = function(el) {
  1055. return el.textContent;
  1056. };
  1057. }
  1058. else {
  1059. exports.setInnerText = function(el, innerText) {
  1060. el.innerText = innerText;
  1061. };
  1062. exports.getInnerText = function(el) {
  1063. return el.innerText;
  1064. };
  1065. }
  1066. exports.getParentWindow = function(document) {
  1067. return document.defaultView || document.parentWindow;
  1068. };
  1069. });
  1070. ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1071. "use strict";
  1072. exports.inherits = function(ctor, superCtor) {
  1073. ctor.super_ = superCtor;
  1074. ctor.prototype = Object.create(superCtor.prototype, {
  1075. constructor: {
  1076. value: ctor,
  1077. enumerable: false,
  1078. writable: true,
  1079. configurable: true
  1080. }
  1081. });
  1082. };
  1083. exports.mixin = function(obj, mixin) {
  1084. for (var key in mixin) {
  1085. obj[key] = mixin[key];
  1086. }
  1087. return obj;
  1088. };
  1089. exports.implement = function(proto, mixin) {
  1090. exports.mixin(proto, mixin);
  1091. };
  1092. });
  1093. ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1094. "use strict";
  1095. require("./fixoldbrowsers");
  1096. var oop = require("./oop");
  1097. var Keys = (function() {
  1098. var ret = {
  1099. MODIFIER_KEYS: {
  1100. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1101. },
  1102. KEY_MODS: {
  1103. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1104. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1105. },
  1106. FUNCTION_KEYS : {
  1107. 8 : "Backspace",
  1108. 9 : "Tab",
  1109. 13 : "Return",
  1110. 19 : "Pause",
  1111. 27 : "Esc",
  1112. 32 : "Space",
  1113. 33 : "PageUp",
  1114. 34 : "PageDown",
  1115. 35 : "End",
  1116. 36 : "Home",
  1117. 37 : "Left",
  1118. 38 : "Up",
  1119. 39 : "Right",
  1120. 40 : "Down",
  1121. 44 : "Print",
  1122. 45 : "Insert",
  1123. 46 : "Delete",
  1124. 96 : "Numpad0",
  1125. 97 : "Numpad1",
  1126. 98 : "Numpad2",
  1127. 99 : "Numpad3",
  1128. 100: "Numpad4",
  1129. 101: "Numpad5",
  1130. 102: "Numpad6",
  1131. 103: "Numpad7",
  1132. 104: "Numpad8",
  1133. 105: "Numpad9",
  1134. '-13': "NumpadEnter",
  1135. 112: "F1",
  1136. 113: "F2",
  1137. 114: "F3",
  1138. 115: "F4",
  1139. 116: "F5",
  1140. 117: "F6",
  1141. 118: "F7",
  1142. 119: "F8",
  1143. 120: "F9",
  1144. 121: "F10",
  1145. 122: "F11",
  1146. 123: "F12",
  1147. 144: "Numlock",
  1148. 145: "Scrolllock"
  1149. },
  1150. PRINTABLE_KEYS: {
  1151. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1152. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1153. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1154. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1155. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1156. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1157. 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
  1158. 219: '[', 220: '\\',221: ']', 222: '\''
  1159. }
  1160. };
  1161. var name, i;
  1162. for (i in ret.FUNCTION_KEYS) {
  1163. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1164. ret[name] = parseInt(i, 10);
  1165. }
  1166. for (i in ret.PRINTABLE_KEYS) {
  1167. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1168. ret[name] = parseInt(i, 10);
  1169. }
  1170. oop.mixin(ret, ret.MODIFIER_KEYS);
  1171. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1172. oop.mixin(ret, ret.FUNCTION_KEYS);
  1173. ret.enter = ret["return"];
  1174. ret.escape = ret.esc;
  1175. ret.del = ret["delete"];
  1176. ret[173] = '-';
  1177. (function() {
  1178. var mods = ["cmd", "ctrl", "alt", "shift"];
  1179. for (var i = Math.pow(2, mods.length); i--;) {
  1180. ret.KEY_MODS[i] = mods.filter(function(x) {
  1181. return i & ret.KEY_MODS[x];
  1182. }).join("-") + "-";
  1183. }
  1184. })();
  1185. ret.KEY_MODS[0] = "";
  1186. ret.KEY_MODS[-1] = "input-";
  1187. return ret;
  1188. })();
  1189. oop.mixin(exports, Keys);
  1190. exports.keyCodeToString = function(keyCode) {
  1191. var keyString = Keys[keyCode];
  1192. if (typeof keyString != "string")
  1193. keyString = String.fromCharCode(keyCode);
  1194. return keyString.toLowerCase();
  1195. };
  1196. });
  1197. ace.define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1198. "use strict";
  1199. exports.OS = {
  1200. LINUX: "LINUX",
  1201. MAC: "MAC",
  1202. WINDOWS: "WINDOWS"
  1203. };
  1204. exports.getOS = function() {
  1205. if (exports.isMac) {
  1206. return exports.OS.MAC;
  1207. } else if (exports.isLinux) {
  1208. return exports.OS.LINUX;
  1209. } else {
  1210. return exports.OS.WINDOWS;
  1211. }
  1212. };
  1213. if (typeof navigator != "object")
  1214. return;
  1215. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1216. var ua = navigator.userAgent;
  1217. exports.isWin = (os == "win");
  1218. exports.isMac = (os == "mac");
  1219. exports.isLinux = (os == "linux");
  1220. exports.isIE =
  1221. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1222. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1223. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1224. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1225. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1226. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1227. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1228. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1229. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1230. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1231. exports.isIPad = ua.indexOf("iPad") >= 0;
  1232. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1233. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1234. });
  1235. ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1236. "use strict";
  1237. var keys = require("./keys");
  1238. var useragent = require("./useragent");
  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[91] || pressedKeys[92])
  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. var pressedKeys = null;
  1470. var ts = 0;
  1471. exports.addCommandKeyListener = function(el, callback) {
  1472. var addListener = exports.addListener;
  1473. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1474. var lastKeyDownKeyCode = null;
  1475. addListener(el, "keydown", function(e) {
  1476. lastKeyDownKeyCode = e.keyCode;
  1477. });
  1478. addListener(el, "keypress", function(e) {
  1479. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1480. });
  1481. } else {
  1482. var lastDefaultPrevented = null;
  1483. addListener(el, "keydown", function(e) {
  1484. pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
  1485. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1486. lastDefaultPrevented = e.defaultPrevented;
  1487. return result;
  1488. });
  1489. addListener(el, "keypress", function(e) {
  1490. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1491. exports.stopEvent(e);
  1492. lastDefaultPrevented = null;
  1493. }
  1494. });
  1495. addListener(el, "keyup", function(e) {
  1496. pressedKeys[e.keyCode] = null;
  1497. });
  1498. if (!pressedKeys) {
  1499. resetPressedKeys();
  1500. addListener(window, "focus", resetPressedKeys);
  1501. }
  1502. }
  1503. };
  1504. function resetPressedKeys(e) {
  1505. pressedKeys = Object.create(null);
  1506. }
  1507. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1508. var postMessageId = 1;
  1509. exports.nextTick = function(callback, win) {
  1510. win = win || window;
  1511. var messageName = "zero-timeout-message-" + postMessageId;
  1512. exports.addListener(win, "message", function listener(e) {
  1513. if (e.data == messageName) {
  1514. exports.stopPropagation(e);
  1515. exports.removeListener(win, "message", listener);
  1516. callback();
  1517. }
  1518. });
  1519. win.postMessage(messageName, "*");
  1520. };
  1521. }
  1522. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1523. || window.mozRequestAnimationFrame
  1524. || window.webkitRequestAnimationFrame
  1525. || window.msRequestAnimationFrame
  1526. || window.oRequestAnimationFrame);
  1527. if (exports.nextFrame)
  1528. exports.nextFrame = exports.nextFrame.bind(window);
  1529. else
  1530. exports.nextFrame = function(callback) {
  1531. setTimeout(callback, 17);
  1532. };
  1533. });
  1534. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1535. "use strict";
  1536. exports.last = function(a) {
  1537. return a[a.length - 1];
  1538. };
  1539. exports.stringReverse = function(string) {
  1540. return string.split("").reverse().join("");
  1541. };
  1542. exports.stringRepeat = function (string, count) {
  1543. var result = '';
  1544. while (count > 0) {
  1545. if (count & 1)
  1546. result += string;
  1547. if (count >>= 1)
  1548. string += string;
  1549. }
  1550. return result;
  1551. };
  1552. var trimBeginRegexp = /^\s\s*/;
  1553. var trimEndRegexp = /\s\s*$/;
  1554. exports.stringTrimLeft = function (string) {
  1555. return string.replace(trimBeginRegexp, '');
  1556. };
  1557. exports.stringTrimRight = function (string) {
  1558. return string.replace(trimEndRegexp, '');
  1559. };
  1560. exports.copyObject = function(obj) {
  1561. var copy = {};
  1562. for (var key in obj) {
  1563. copy[key] = obj[key];
  1564. }
  1565. return copy;
  1566. };
  1567. exports.copyArray = function(array){
  1568. var copy = [];
  1569. for (var i=0, l=array.length; i<l; i++) {
  1570. if (array[i] && typeof array[i] == "object")
  1571. copy[i] = this.copyObject( array[i] );
  1572. else
  1573. copy[i] = array[i];
  1574. }
  1575. return copy;
  1576. };
  1577. exports.deepCopy = function deepCopy(obj) {
  1578. if (typeof obj !== "object" || !obj)
  1579. return obj;
  1580. var copy;
  1581. if (Array.isArray(obj)) {
  1582. copy = [];
  1583. for (var key = 0; key < obj.length; key++) {
  1584. copy[key] = deepCopy(obj[key]);
  1585. }
  1586. return copy;
  1587. }
  1588. var cons = obj.constructor;
  1589. if (cons === RegExp)
  1590. return obj;
  1591. copy = cons();
  1592. for (var key in obj) {
  1593. copy[key] = deepCopy(obj[key]);
  1594. }
  1595. return copy;
  1596. };
  1597. exports.arrayToMap = function(arr) {
  1598. var map = {};
  1599. for (var i=0; i<arr.length; i++) {
  1600. map[arr[i]] = 1;
  1601. }
  1602. return map;
  1603. };
  1604. exports.createMap = function(props) {
  1605. var map = Object.create(null);
  1606. for (var i in props) {
  1607. map[i] = props[i];
  1608. }
  1609. return map;
  1610. };
  1611. exports.arrayRemove = function(array, value) {
  1612. for (var i = 0; i <= array.length; i++) {
  1613. if (value === array[i]) {
  1614. array.splice(i, 1);
  1615. }
  1616. }
  1617. };
  1618. exports.escapeRegExp = function(str) {
  1619. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1620. };
  1621. exports.escapeHTML = function(str) {
  1622. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1623. };
  1624. exports.getMatchOffsets = function(string, regExp) {
  1625. var matches = [];
  1626. string.replace(regExp, function(str) {
  1627. matches.push({
  1628. offset: arguments[arguments.length-2],
  1629. length: str.length
  1630. });
  1631. });
  1632. return matches;
  1633. };
  1634. exports.deferredCall = function(fcn) {
  1635. var timer = null;
  1636. var callback = function() {
  1637. timer = null;
  1638. fcn();
  1639. };
  1640. var deferred = function(timeout) {
  1641. deferred.cancel();
  1642. timer = setTimeout(callback, timeout || 0);
  1643. return deferred;
  1644. };
  1645. deferred.schedule = deferred;
  1646. deferred.call = function() {
  1647. this.cancel();
  1648. fcn();
  1649. return deferred;
  1650. };
  1651. deferred.cancel = function() {
  1652. clearTimeout(timer);
  1653. timer = null;
  1654. return deferred;
  1655. };
  1656. deferred.isPending = function() {
  1657. return timer;
  1658. };
  1659. return deferred;
  1660. };
  1661. exports.delayedCall = function(fcn, defaultTimeout) {
  1662. var timer = null;
  1663. var callback = function() {
  1664. timer = null;
  1665. fcn();
  1666. };
  1667. var _self = function(timeout) {
  1668. if (timer == null)
  1669. timer = setTimeout(callback, timeout || defaultTimeout);
  1670. };
  1671. _self.delay = function(timeout) {
  1672. timer && clearTimeout(timer);
  1673. timer = setTimeout(callback, timeout || defaultTimeout);
  1674. };
  1675. _self.schedule = _self;
  1676. _self.call = function() {
  1677. this.cancel();
  1678. fcn();
  1679. };
  1680. _self.cancel = function() {
  1681. timer && clearTimeout(timer);
  1682. timer = null;
  1683. };
  1684. _self.isPending = function() {
  1685. return timer;
  1686. };
  1687. return _self;
  1688. };
  1689. });
  1690. ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1691. "use strict";
  1692. var event = require("../lib/event");
  1693. var useragent = require("../lib/useragent");
  1694. var dom = require("../lib/dom");
  1695. var lang = require("../lib/lang");
  1696. var BROKEN_SETDATA = useragent.isChrome < 18;
  1697. var USE_IE_MIME_TYPE = useragent.isIE;
  1698. var TextInput = function(parentNode, host) {
  1699. var text = dom.createElement("textarea");
  1700. text.className = "ace_text-input";
  1701. if (useragent.isTouchPad)
  1702. text.setAttribute("x-palm-disable-auto-cap", true);
  1703. text.setAttribute("wrap", "off");
  1704. text.setAttribute("autocorrect", "off");
  1705. text.setAttribute("autocapitalize", "off");
  1706. text.setAttribute("spellcheck", false);
  1707. text.style.opacity = "0";
  1708. if (useragent.isOldIE) text.style.top = "-1000px";
  1709. parentNode.insertBefore(text, parentNode.firstChild);
  1710. var PLACEHOLDER = "\x01\x01";
  1711. var copied = false;
  1712. var pasted = false;
  1713. var inComposition = false;
  1714. var tempStyle = '';
  1715. var isSelectionEmpty = true;
  1716. try { var isFocused = document.activeElement === text; } catch(e) {}
  1717. event.addListener(text, "blur", function(e) {
  1718. host.onBlur(e);
  1719. isFocused = false;
  1720. });
  1721. event.addListener(text, "focus", function(e) {
  1722. isFocused = true;
  1723. host.onFocus(e);
  1724. resetSelection();
  1725. });
  1726. this.focus = function() {
  1727. if (tempStyle) return text.focus();
  1728. var top = text.style.top;
  1729. text.style.position = "fixed";
  1730. text.style.top = "-1000px";
  1731. text.focus();
  1732. setTimeout(function() {
  1733. text.style.position = "";
  1734. if (text.style.top == "-1000px")
  1735. text.style.top = top;
  1736. }, 0);
  1737. };
  1738. this.blur = function() {
  1739. text.blur();
  1740. };
  1741. this.isFocused = function() {
  1742. return isFocused;
  1743. };
  1744. var syncSelection = lang.delayedCall(function() {
  1745. isFocused && resetSelection(isSelectionEmpty);
  1746. });
  1747. var syncValue = lang.delayedCall(function() {
  1748. if (!inComposition) {
  1749. text.value = PLACEHOLDER;
  1750. isFocused && resetSelection();
  1751. }
  1752. });
  1753. function resetSelection(isEmpty) {
  1754. if (inComposition)
  1755. return;
  1756. inComposition = true;
  1757. if (inputHandler) {
  1758. selectionStart = 0;
  1759. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1760. } else {
  1761. var selectionStart = isEmpty ? 2 : 1;
  1762. var selectionEnd = 2;
  1763. }
  1764. try {
  1765. text.setSelectionRange(selectionStart, selectionEnd);
  1766. } catch(e){}
  1767. inComposition = false;
  1768. }
  1769. function resetValue() {
  1770. if (inComposition)
  1771. return;
  1772. text.value = PLACEHOLDER;
  1773. if (useragent.isWebKit)
  1774. syncValue.schedule();
  1775. }
  1776. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1777. if (host.selection.isEmpty() != isSelectionEmpty) {
  1778. isSelectionEmpty = !isSelectionEmpty;
  1779. syncSelection.schedule();
  1780. }
  1781. });
  1782. resetValue();
  1783. if (isFocused)
  1784. host.onFocus();
  1785. var isAllSelected = function(text) {
  1786. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1787. };
  1788. if (!text.setSelectionRange && text.createTextRange) {
  1789. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1790. var range = this.createTextRange();
  1791. range.collapse(true);
  1792. range.moveStart('character', selectionStart);
  1793. range.moveEnd('character', selectionEnd);
  1794. range.select();
  1795. };
  1796. isAllSelected = function(text) {
  1797. try {
  1798. var range = text.ownerDocument.selection.createRange();
  1799. }catch(e) {}
  1800. if (!range || range.parentElement() != text) return false;
  1801. return range.text == text.value;
  1802. }
  1803. }
  1804. if (useragent.isOldIE) {
  1805. var inPropertyChange = false;
  1806. var onPropertyChange = function(e){
  1807. if (inPropertyChange)
  1808. return;
  1809. var data = text.value;
  1810. if (inComposition || !data || data == PLACEHOLDER)
  1811. return;
  1812. if (e && data == PLACEHOLDER[0])
  1813. return syncProperty.schedule();
  1814. sendText(data);
  1815. inPropertyChange = true;
  1816. resetValue();
  1817. inPropertyChange = false;
  1818. };
  1819. var syncProperty = lang.delayedCall(onPropertyChange);
  1820. event.addListener(text, "propertychange", onPropertyChange);
  1821. var keytable = { 13:1, 27:1 };
  1822. event.addListener(text, "keyup", function (e) {
  1823. if (inComposition && (!text.value || keytable[e.keyCode]))
  1824. setTimeout(onCompositionEnd, 0);
  1825. if ((text.value.charCodeAt(0)||0) < 129) {
  1826. return syncProperty.call();
  1827. }
  1828. inComposition ? onCompositionUpdate() : onCompositionStart();
  1829. });
  1830. event.addListener(text, "keydown", function (e) {
  1831. syncProperty.schedule(50);
  1832. });
  1833. }
  1834. var onSelect = function(e) {
  1835. if (copied) {
  1836. copied = false;
  1837. } else if (isAllSelected(text)) {
  1838. host.selectAll();
  1839. resetSelection();
  1840. } else if (inputHandler) {
  1841. resetSelection(host.selection.isEmpty());
  1842. }
  1843. };
  1844. var inputHandler = null;
  1845. this.setInputHandler = function(cb) {inputHandler = cb};
  1846. this.getInputHandler = function() {return inputHandler};
  1847. var afterContextMenu = false;
  1848. var sendText = function(data) {
  1849. if (inputHandler) {
  1850. data = inputHandler(data);
  1851. inputHandler = null;
  1852. }
  1853. if (pasted) {
  1854. resetSelection();
  1855. if (data)
  1856. host.onPaste(data);
  1857. pasted = false;
  1858. } else if (data == PLACEHOLDER.charAt(0)) {
  1859. if (afterContextMenu)
  1860. host.execCommand("del", {source: "ace"});
  1861. else // some versions of android do not fire keydown when pressing backspace
  1862. host.execCommand("backspace", {source: "ace"});
  1863. } else {
  1864. if (data.substring(0, 2) == PLACEHOLDER)
  1865. data = data.substr(2);
  1866. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1867. data = data.substr(1);
  1868. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1869. data = data.slice(0, -1);
  1870. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1871. data = data.slice(0, -1);
  1872. if (data)
  1873. host.onTextInput(data);
  1874. }
  1875. if (afterContextMenu)
  1876. afterContextMenu = false;
  1877. };
  1878. var onInput = function(e) {
  1879. if (inComposition)
  1880. return;
  1881. var data = text.value;
  1882. sendText(data);
  1883. resetValue();
  1884. };
  1885. var handleClipboardData = function(e, data) {
  1886. var clipboardData = e.clipboardData || window.clipboardData;
  1887. if (!clipboardData || BROKEN_SETDATA)
  1888. return;
  1889. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1890. if (data) {
  1891. return clipboardData.setData(mime, data) !== false;
  1892. } else {
  1893. return clipboardData.getData(mime);
  1894. }
  1895. };
  1896. var doCopy = function(e, isCut) {
  1897. var data = host.getCopyText();
  1898. if (!data)
  1899. return event.preventDefault(e);
  1900. if (handleClipboardData(e, data)) {
  1901. isCut ? host.onCut() : host.onCopy();
  1902. event.preventDefault(e);
  1903. } else {
  1904. copied = true;
  1905. text.value = data;
  1906. text.select();
  1907. setTimeout(function(){
  1908. copied = false;
  1909. resetValue();
  1910. resetSelection();
  1911. isCut ? host.onCut() : host.onCopy();
  1912. });
  1913. }
  1914. };
  1915. var onCut = function(e) {
  1916. doCopy(e, true);
  1917. };
  1918. var onCopy = function(e) {
  1919. doCopy(e, false);
  1920. };
  1921. var onPaste = function(e) {
  1922. var data = handleClipboardData(e);
  1923. if (typeof data == "string") {
  1924. if (data)
  1925. host.onPaste(data, e);
  1926. if (useragent.isIE)
  1927. setTimeout(resetSelection);
  1928. event.preventDefault(e);
  1929. }
  1930. else {
  1931. text.value = "";
  1932. pasted = true;
  1933. }
  1934. };
  1935. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1936. event.addListener(text, "select", onSelect);
  1937. event.addListener(text, "input", onInput);
  1938. event.addListener(text, "cut", onCut);
  1939. event.addListener(text, "copy", onCopy);
  1940. event.addListener(text, "paste", onPaste);
  1941. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1942. event.addListener(parentNode, "keydown", function(e) {
  1943. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1944. return;
  1945. switch (e.keyCode) {
  1946. case 67:
  1947. onCopy(e);
  1948. break;
  1949. case 86:
  1950. onPaste(e);
  1951. break;
  1952. case 88:
  1953. onCut(e);
  1954. break;
  1955. }
  1956. });
  1957. }
  1958. var onCompositionStart = function(e) {
  1959. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1960. return;
  1961. inComposition = {};
  1962. host.onCompositionStart();
  1963. setTimeout(onCompositionUpdate, 0);
  1964. host.on("mousedown", onCompositionEnd);
  1965. if (!host.selection.isEmpty()) {
  1966. host.insert("");
  1967. host.session.markUndoGroup();
  1968. host.selection.clearSelection();
  1969. }
  1970. host.session.markUndoGroup();
  1971. };
  1972. var onCompositionUpdate = function() {
  1973. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1974. return;
  1975. var val = text.value.replace(/\x01/g, "");
  1976. if (inComposition.lastValue === val) return;
  1977. host.onCompositionUpdate(val);
  1978. if (inComposition.lastValue)
  1979. host.undo();
  1980. inComposition.lastValue = val;
  1981. if (inComposition.lastValue) {
  1982. var r = host.selection.getRange();
  1983. host.insert(inComposition.lastValue);
  1984. host.session.markUndoGroup();
  1985. inComposition.range = host.selection.getRange();
  1986. host.selection.setRange(r);
  1987. host.selection.clearSelection();
  1988. }
  1989. };
  1990. var onCompositionEnd = function(e) {
  1991. if (!host.onCompositionEnd || host.$readOnly) return;
  1992. var c = inComposition;
  1993. inComposition = false;
  1994. var timer = setTimeout(function() {
  1995. timer = null;
  1996. var str = text.value.replace(/\x01/g, "");
  1997. if (inComposition)
  1998. return;
  1999. else if (str == c.lastValue)
  2000. resetValue();
  2001. else if (!c.lastValue && str) {
  2002. resetValue();
  2003. sendText(str);
  2004. }
  2005. });
  2006. inputHandler = function compositionInputHandler(str) {
  2007. if (timer)
  2008. clearTimeout(timer);
  2009. str = str.replace(/\x01/g, "");
  2010. if (str == c.lastValue)
  2011. return "";
  2012. if (c.lastValue && timer)
  2013. host.undo();
  2014. return str;
  2015. };
  2016. host.onCompositionEnd();
  2017. host.removeListener("mousedown", onCompositionEnd);
  2018. if (e.type == "compositionend" && c.range) {
  2019. host.selection.setRange(c.range);
  2020. }
  2021. };
  2022. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2023. event.addListener(text, "compositionstart", onCompositionStart);
  2024. if (useragent.isGecko) {
  2025. event.addListener(text, "text", function(){syncComposition.schedule()});
  2026. } else {
  2027. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2028. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2029. }
  2030. event.addListener(text, "compositionend", onCompositionEnd);
  2031. this.getElement = function() {
  2032. return text;
  2033. };
  2034. this.setReadOnly = function(readOnly) {
  2035. text.readOnly = readOnly;
  2036. };
  2037. this.onContextMenu = function(e) {
  2038. afterContextMenu = true;
  2039. resetSelection(host.selection.isEmpty());
  2040. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2041. this.moveToMouse(e, true);
  2042. };
  2043. this.moveToMouse = function(e, bringToFront) {
  2044. if (!bringToFront && useragent.isOldIE)
  2045. return;
  2046. if (!tempStyle)
  2047. tempStyle = text.style.cssText;
  2048. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2049. + "height:" + text.style.height + ";"
  2050. + (useragent.isIE ? "opacity:0.1;" : "");
  2051. var rect = host.container.getBoundingClientRect();
  2052. var style = dom.computedStyle(host.container);
  2053. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2054. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2055. var maxTop = rect.bottom - top - text.clientHeight -2;
  2056. var move = function(e) {
  2057. text.style.left = e.clientX - left - 2 + "px";
  2058. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2059. };
  2060. move(e);
  2061. if (e.type != "mousedown")
  2062. return;
  2063. if (host.renderer.$keepTextAreaAtCursor)
  2064. host.renderer.$keepTextAreaAtCursor = null;
  2065. if (useragent.isWin && !useragent.isOldIE)
  2066. event.capture(host.container, move, onContextMenuClose);
  2067. };
  2068. this.onContextMenuClose = onContextMenuClose;
  2069. var closeTimeout;
  2070. function onContextMenuClose() {
  2071. clearTimeout(closeTimeout);
  2072. closeTimeout = setTimeout(function () {
  2073. if (tempStyle) {
  2074. text.style.cssText = tempStyle;
  2075. tempStyle = '';
  2076. }
  2077. if (host.renderer.$keepTextAreaAtCursor == null) {
  2078. host.renderer.$keepTextAreaAtCursor = true;
  2079. host.renderer.$moveTextAreaToCursor();
  2080. }
  2081. }, useragent.isOldIE ? 200 : 0);
  2082. }
  2083. var onContextMenu = function(e) {
  2084. host.textInput.onContextMenu(e);
  2085. onContextMenuClose();
  2086. };
  2087. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2088. event.addListener(text, "contextmenu", onContextMenu);
  2089. };
  2090. exports.TextInput = TextInput;
  2091. });
  2092. ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2093. "use strict";
  2094. var dom = require("../lib/dom");
  2095. var event = require("../lib/event");
  2096. var useragent = require("../lib/useragent");
  2097. var DRAG_OFFSET = 0; // pixels
  2098. function DefaultHandlers(mouseHandler) {
  2099. mouseHandler.$clickSelection = null;
  2100. var editor = mouseHandler.editor;
  2101. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2102. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2103. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2104. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2105. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2106. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2107. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2108. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2109. exports.forEach(function(x) {
  2110. mouseHandler[x] = this[x];
  2111. }, this);
  2112. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2113. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2114. }
  2115. (function() {
  2116. this.onMouseDown = function(ev) {
  2117. var inSelection = ev.inSelection();
  2118. var pos = ev.getDocumentPosition();
  2119. this.mousedownEvent = ev;
  2120. var editor = this.editor;
  2121. var button = ev.getButton();
  2122. if (button !== 0) {
  2123. var selectionRange = editor.getSelectionRange();
  2124. var selectionEmpty = selectionRange.isEmpty();
  2125. editor.$blockScrolling++;
  2126. if (selectionEmpty)
  2127. editor.selection.moveToPosition(pos);
  2128. editor.$blockScrolling--;
  2129. editor.textInput.onContextMenu(ev.domEvent);
  2130. return; // stopping event here breaks contextmenu on ff mac
  2131. }
  2132. this.mousedownEvent.time = Date.now();
  2133. if (inSelection && !editor.isFocused()) {
  2134. editor.focus();
  2135. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2136. this.setState("focusWait");
  2137. this.captureMouse(ev);
  2138. return;
  2139. }
  2140. }
  2141. this.captureMouse(ev);
  2142. this.startSelect(pos, ev.domEvent._clicks > 1);
  2143. return ev.preventDefault();
  2144. };
  2145. this.startSelect = function(pos, waitForClickSelection) {
  2146. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2147. var editor = this.editor;
  2148. editor.$blockScrolling++;
  2149. if (this.mousedownEvent.getShiftKey())
  2150. editor.selection.selectToPosition(pos);
  2151. else if (!waitForClickSelection)
  2152. editor.selection.moveToPosition(pos);
  2153. if (!waitForClickSelection)
  2154. this.select();
  2155. if (editor.renderer.scroller.setCapture) {
  2156. editor.renderer.scroller.setCapture();
  2157. }
  2158. editor.setStyle("ace_selecting");
  2159. this.setState("select");
  2160. editor.$blockScrolling--;
  2161. };
  2162. this.select = function() {
  2163. var anchor, editor = this.editor;
  2164. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2165. editor.$blockScrolling++;
  2166. if (this.$clickSelection) {
  2167. var cmp = this.$clickSelection.comparePoint(cursor);
  2168. if (cmp == -1) {
  2169. anchor = this.$clickSelection.end;
  2170. } else if (cmp == 1) {
  2171. anchor = this.$clickSelection.start;
  2172. } else {
  2173. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2174. cursor = orientedRange.cursor;
  2175. anchor = orientedRange.anchor;
  2176. }
  2177. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2178. }
  2179. editor.selection.selectToPosition(cursor);
  2180. editor.$blockScrolling--;
  2181. editor.renderer.scrollCursorIntoView();
  2182. };
  2183. this.extendSelectionBy = function(unitName) {
  2184. var anchor, editor = this.editor;
  2185. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2186. var range = editor.selection[unitName](cursor.row, cursor.column);
  2187. editor.$blockScrolling++;
  2188. if (this.$clickSelection) {
  2189. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2190. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2191. if (cmpStart == -1 && cmpEnd <= 0) {
  2192. anchor = this.$clickSelection.end;
  2193. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2194. cursor = range.start;
  2195. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2196. anchor = this.$clickSelection.start;
  2197. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2198. cursor = range.end;
  2199. } else if (cmpStart == -1 && cmpEnd == 1) {
  2200. cursor = range.end;
  2201. anchor = range.start;
  2202. } else {
  2203. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2204. cursor = orientedRange.cursor;
  2205. anchor = orientedRange.anchor;
  2206. }
  2207. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2208. }
  2209. editor.selection.selectToPosition(cursor);
  2210. editor.$blockScrolling--;
  2211. editor.renderer.scrollCursorIntoView();
  2212. };
  2213. this.selectEnd =
  2214. this.selectAllEnd =
  2215. this.selectByWordsEnd =
  2216. this.selectByLinesEnd = function() {
  2217. this.$clickSelection = null;
  2218. this.editor.unsetStyle("ace_selecting");
  2219. if (this.editor.renderer.scroller.releaseCapture) {
  2220. this.editor.renderer.scroller.releaseCapture();
  2221. }
  2222. };
  2223. this.focusWait = function() {
  2224. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2225. var time = Date.now();
  2226. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2227. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2228. };
  2229. this.onDoubleClick = function(ev) {
  2230. var pos = ev.getDocumentPosition();
  2231. var editor = this.editor;
  2232. var session = editor.session;
  2233. var range = session.getBracketRange(pos);
  2234. if (range) {
  2235. if (range.isEmpty()) {
  2236. range.start.column--;
  2237. range.end.column++;
  2238. }
  2239. this.setState("select");
  2240. } else {
  2241. range = editor.selection.getWordRange(pos.row, pos.column);
  2242. this.setState("selectByWords");
  2243. }
  2244. this.$clickSelection = range;
  2245. this.select();
  2246. };
  2247. this.onTripleClick = function(ev) {
  2248. var pos = ev.getDocumentPosition();
  2249. var editor = this.editor;
  2250. this.setState("selectByLines");
  2251. var range = editor.getSelectionRange();
  2252. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2253. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2254. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2255. } else {
  2256. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2257. }
  2258. this.select();
  2259. };
  2260. this.onQuadClick = function(ev) {
  2261. var editor = this.editor;
  2262. editor.selectAll();
  2263. this.$clickSelection = editor.getSelectionRange();
  2264. this.setState("selectAll");
  2265. };
  2266. this.onMouseWheel = function(ev) {
  2267. if (ev.getAccelKey())
  2268. return;
  2269. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2270. ev.wheelX = ev.wheelY;
  2271. ev.wheelY = 0;
  2272. }
  2273. var t = ev.domEvent.timeStamp;
  2274. var dt = t - (this.$lastScrollTime||0);
  2275. var editor = this.editor;
  2276. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2277. if (isScrolable || dt < 200) {
  2278. this.$lastScrollTime = t;
  2279. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2280. return ev.stop();
  2281. }
  2282. };
  2283. this.onTouchMove = function (ev) {
  2284. var t = ev.domEvent.timeStamp;
  2285. var dt = t - (this.$lastScrollTime || 0);
  2286. var editor = this.editor;
  2287. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2288. if (isScrolable || dt < 200) {
  2289. this.$lastScrollTime = t;
  2290. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2291. return ev.stop();
  2292. }
  2293. };
  2294. }).call(DefaultHandlers.prototype);
  2295. exports.DefaultHandlers = DefaultHandlers;
  2296. function calcDistance(ax, ay, bx, by) {
  2297. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2298. }
  2299. function calcRangeOrientation(range, cursor) {
  2300. if (range.start.row == range.end.row)
  2301. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2302. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2303. var cmp = cursor.column - 4;
  2304. else
  2305. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2306. if (cmp < 0)
  2307. return {cursor: range.start, anchor: range.end};
  2308. else
  2309. return {cursor: range.end, anchor: range.start};
  2310. }
  2311. });
  2312. ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2313. "use strict";
  2314. var oop = require("./lib/oop");
  2315. var dom = require("./lib/dom");
  2316. function Tooltip (parentNode) {
  2317. this.isOpen = false;
  2318. this.$element = null;
  2319. this.$parentNode = parentNode;
  2320. }
  2321. (function() {
  2322. this.$init = function() {
  2323. this.$element = dom.createElement("div");
  2324. this.$element.className = "ace_tooltip";
  2325. this.$element.style.display = "none";
  2326. this.$parentNode.appendChild(this.$element);
  2327. return this.$element;
  2328. };
  2329. this.getElement = function() {
  2330. return this.$element || this.$init();
  2331. };
  2332. this.setText = function(text) {
  2333. dom.setInnerText(this.getElement(), text);
  2334. };
  2335. this.setHtml = function(html) {
  2336. this.getElement().innerHTML = html;
  2337. };
  2338. this.setPosition = function(x, y) {
  2339. this.getElement().style.left = x + "px";
  2340. this.getElement().style.top = y + "px";
  2341. };
  2342. this.setClassName = function(className) {
  2343. dom.addCssClass(this.getElement(), className);
  2344. };
  2345. this.show = function(text, x, y) {
  2346. if (text != null)
  2347. this.setText(text);
  2348. if (x != null && y != null)
  2349. this.setPosition(x, y);
  2350. if (!this.isOpen) {
  2351. this.getElement().style.display = "block";
  2352. this.isOpen = true;
  2353. }
  2354. };
  2355. this.hide = function() {
  2356. if (this.isOpen) {
  2357. this.getElement().style.display = "none";
  2358. this.isOpen = false;
  2359. }
  2360. };
  2361. this.getHeight = function() {
  2362. return this.getElement().offsetHeight;
  2363. };
  2364. this.getWidth = function() {
  2365. return this.getElement().offsetWidth;
  2366. };
  2367. }).call(Tooltip.prototype);
  2368. exports.Tooltip = Tooltip;
  2369. });
  2370. ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
  2371. "use strict";
  2372. var dom = require("../lib/dom");
  2373. var oop = require("../lib/oop");
  2374. var event = require("../lib/event");
  2375. var Tooltip = require("../tooltip").Tooltip;
  2376. function GutterHandler(mouseHandler) {
  2377. var editor = mouseHandler.editor;
  2378. var gutter = editor.renderer.$gutterLayer;
  2379. var tooltip = new GutterTooltip(editor.container);
  2380. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2381. if (!editor.isFocused() || e.getButton() != 0)
  2382. return;
  2383. var gutterRegion = gutter.getRegion(e);
  2384. if (gutterRegion == "foldWidgets")
  2385. return;
  2386. var row = e.getDocumentPosition().row;
  2387. var selection = editor.session.selection;
  2388. if (e.getShiftKey())
  2389. selection.selectTo(row, 0);
  2390. else {
  2391. if (e.domEvent.detail == 2) {
  2392. editor.selectAll();
  2393. return e.preventDefault();
  2394. }
  2395. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2396. }
  2397. mouseHandler.setState("selectByLines");
  2398. mouseHandler.captureMouse(e);
  2399. return e.preventDefault();
  2400. });
  2401. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2402. function showTooltip() {
  2403. var row = mouseEvent.getDocumentPosition().row;
  2404. var annotation = gutter.$annotations[row];
  2405. if (!annotation)
  2406. return hideTooltip();
  2407. var maxRow = editor.session.getLength();
  2408. if (row == maxRow) {
  2409. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2410. var pos = mouseEvent.$pos;
  2411. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2412. return hideTooltip();
  2413. }
  2414. if (tooltipAnnotation == annotation)
  2415. return;
  2416. tooltipAnnotation = annotation.text.join("<br/>");
  2417. tooltip.setHtml(tooltipAnnotation);
  2418. tooltip.show();
  2419. editor.on("mousewheel", hideTooltip);
  2420. if (mouseHandler.$tooltipFollowsMouse) {
  2421. moveTooltip(mouseEvent);
  2422. } else {
  2423. var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
  2424. var rect = gutterElement.getBoundingClientRect();
  2425. var style = tooltip.getElement().style;
  2426. style.left = rect.right + "px";
  2427. style.top = rect.bottom + "px";
  2428. }
  2429. }
  2430. function hideTooltip() {
  2431. if (tooltipTimeout)
  2432. tooltipTimeout = clearTimeout(tooltipTimeout);
  2433. if (tooltipAnnotation) {
  2434. tooltip.hide();
  2435. tooltipAnnotation = null;
  2436. editor.removeEventListener("mousewheel", hideTooltip);
  2437. }
  2438. }
  2439. function moveTooltip(e) {
  2440. tooltip.setPosition(e.x, e.y);
  2441. }
  2442. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2443. var target = e.domEvent.target || e.domEvent.srcElement;
  2444. if (dom.hasCssClass(target, "ace_fold-widget"))
  2445. return hideTooltip();
  2446. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2447. moveTooltip(e);
  2448. mouseEvent = e;
  2449. if (tooltipTimeout)
  2450. return;
  2451. tooltipTimeout = setTimeout(function() {
  2452. tooltipTimeout = null;
  2453. if (mouseEvent && !mouseHandler.isMousePressed)
  2454. showTooltip();
  2455. else
  2456. hideTooltip();
  2457. }, 50);
  2458. });
  2459. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2460. mouseEvent = null;
  2461. if (!tooltipAnnotation || tooltipTimeout)
  2462. return;
  2463. tooltipTimeout = setTimeout(function() {
  2464. tooltipTimeout = null;
  2465. hideTooltip();
  2466. }, 50);
  2467. });
  2468. editor.on("changeSession", hideTooltip);
  2469. }
  2470. function GutterTooltip(parentNode) {
  2471. Tooltip.call(this, parentNode);
  2472. }
  2473. oop.inherits(GutterTooltip, Tooltip);
  2474. (function(){
  2475. this.setPosition = function(x, y) {
  2476. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2477. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2478. var width = this.getWidth();
  2479. var height = this.getHeight();
  2480. x += 15;
  2481. y += 15;
  2482. if (x + width > windowWidth) {
  2483. x -= (x + width) - windowWidth;
  2484. }
  2485. if (y + height > windowHeight) {
  2486. y -= 20 + height;
  2487. }
  2488. Tooltip.prototype.setPosition.call(this, x, y);
  2489. };
  2490. }).call(GutterTooltip.prototype);
  2491. exports.GutterHandler = GutterHandler;
  2492. });
  2493. ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2494. "use strict";
  2495. var event = require("../lib/event");
  2496. var useragent = require("../lib/useragent");
  2497. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2498. this.domEvent = domEvent;
  2499. this.editor = editor;
  2500. this.x = this.clientX = domEvent.clientX;
  2501. this.y = this.clientY = domEvent.clientY;
  2502. this.$pos = null;
  2503. this.$inSelection = null;
  2504. this.propagationStopped = false;
  2505. this.defaultPrevented = false;
  2506. };
  2507. (function() {
  2508. this.stopPropagation = function() {
  2509. event.stopPropagation(this.domEvent);
  2510. this.propagationStopped = true;
  2511. };
  2512. this.preventDefault = function() {
  2513. event.preventDefault(this.domEvent);
  2514. this.defaultPrevented = true;
  2515. };
  2516. this.stop = function() {
  2517. this.stopPropagation();
  2518. this.preventDefault();
  2519. };
  2520. this.getDocumentPosition = function() {
  2521. if (this.$pos)
  2522. return this.$pos;
  2523. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2524. return this.$pos;
  2525. };
  2526. this.inSelection = function() {
  2527. if (this.$inSelection !== null)
  2528. return this.$inSelection;
  2529. var editor = this.editor;
  2530. var selectionRange = editor.getSelectionRange();
  2531. if (selectionRange.isEmpty())
  2532. this.$inSelection = false;
  2533. else {
  2534. var pos = this.getDocumentPosition();
  2535. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2536. }
  2537. return this.$inSelection;
  2538. };
  2539. this.getButton = function() {
  2540. return event.getButton(this.domEvent);
  2541. };
  2542. this.getShiftKey = function() {
  2543. return this.domEvent.shiftKey;
  2544. };
  2545. this.getAccelKey = useragent.isMac
  2546. ? function() { return this.domEvent.metaKey; }
  2547. : function() { return this.domEvent.ctrlKey; };
  2548. }).call(MouseEvent.prototype);
  2549. });
  2550. ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2551. "use strict";
  2552. var dom = require("../lib/dom");
  2553. var event = require("../lib/event");
  2554. var useragent = require("../lib/useragent");
  2555. var AUTOSCROLL_DELAY = 200;
  2556. var SCROLL_CURSOR_DELAY = 200;
  2557. var SCROLL_CURSOR_HYSTERESIS = 5;
  2558. function DragdropHandler(mouseHandler) {
  2559. var editor = mouseHandler.editor;
  2560. var blankImage = dom.createElement("img");
  2561. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2562. if (useragent.isOpera)
  2563. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2564. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2565. exports.forEach(function(x) {
  2566. mouseHandler[x] = this[x];
  2567. }, this);
  2568. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2569. var mouseTarget = editor.container;
  2570. var dragSelectionMarker, x, y;
  2571. var timerId, range;
  2572. var dragCursor, counter = 0;
  2573. var dragOperation;
  2574. var isInternal;
  2575. var autoScrollStartTime;
  2576. var cursorMovedTime;
  2577. var cursorPointOnCaretMoved;
  2578. this.onDragStart = function(e) {
  2579. if (this.cancelDrag || !mouseTarget.draggable) {
  2580. var self = this;
  2581. setTimeout(function(){
  2582. self.startSelect();
  2583. self.captureMouse(e);
  2584. }, 0);
  2585. return e.preventDefault();
  2586. }
  2587. range = editor.getSelectionRange();
  2588. var dataTransfer = e.dataTransfer;
  2589. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2590. if (useragent.isOpera) {
  2591. editor.container.appendChild(blankImage);
  2592. blankImage.scrollTop = 0;
  2593. }
  2594. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2595. if (useragent.isOpera) {
  2596. editor.container.removeChild(blankImage);
  2597. }
  2598. dataTransfer.clearData();
  2599. dataTransfer.setData("Text", editor.session.getTextRange());
  2600. isInternal = true;
  2601. this.setState("drag");
  2602. };
  2603. this.onDragEnd = function(e) {
  2604. mouseTarget.draggable = false;
  2605. isInternal = false;
  2606. this.setState(null);
  2607. if (!editor.getReadOnly()) {
  2608. var dropEffect = e.dataTransfer.dropEffect;
  2609. if (!dragOperation && dropEffect == "move")
  2610. editor.session.remove(editor.getSelectionRange());
  2611. editor.renderer.$cursorLayer.setBlinking(true);
  2612. }
  2613. this.editor.unsetStyle("ace_dragging");
  2614. this.editor.renderer.setCursorStyle("");
  2615. };
  2616. this.onDragEnter = function(e) {
  2617. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2618. return;
  2619. x = e.clientX;
  2620. y = e.clientY;
  2621. if (!dragSelectionMarker)
  2622. addDragMarker();
  2623. counter++;
  2624. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2625. return event.preventDefault(e);
  2626. };
  2627. this.onDragOver = function(e) {
  2628. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2629. return;
  2630. x = e.clientX;
  2631. y = e.clientY;
  2632. if (!dragSelectionMarker) {
  2633. addDragMarker();
  2634. counter++;
  2635. }
  2636. if (onMouseMoveTimer !== null)
  2637. onMouseMoveTimer = null;
  2638. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2639. return event.preventDefault(e);
  2640. };
  2641. this.onDragLeave = function(e) {
  2642. counter--;
  2643. if (counter <= 0 && dragSelectionMarker) {
  2644. clearDragMarker();
  2645. dragOperation = null;
  2646. return event.preventDefault(e);
  2647. }
  2648. };
  2649. this.onDrop = function(e) {
  2650. if (!dragCursor)
  2651. return;
  2652. var dataTransfer = e.dataTransfer;
  2653. if (isInternal) {
  2654. switch (dragOperation) {
  2655. case "move":
  2656. if (range.contains(dragCursor.row, dragCursor.column)) {
  2657. range = {
  2658. start: dragCursor,
  2659. end: dragCursor
  2660. };
  2661. } else {
  2662. range = editor.moveText(range, dragCursor);
  2663. }
  2664. break;
  2665. case "copy":
  2666. range = editor.moveText(range, dragCursor, true);
  2667. break;
  2668. }
  2669. } else {
  2670. var dropData = dataTransfer.getData('Text');
  2671. range = {
  2672. start: dragCursor,
  2673. end: editor.session.insert(dragCursor, dropData)
  2674. };
  2675. editor.focus();
  2676. dragOperation = null;
  2677. }
  2678. clearDragMarker();
  2679. return event.preventDefault(e);
  2680. };
  2681. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2682. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2683. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2684. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2685. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2686. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2687. function scrollCursorIntoView(cursor, prevCursor) {
  2688. var now = Date.now();
  2689. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2690. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2691. if (!cursorMovedTime || vMovement || hMovement) {
  2692. editor.$blockScrolling += 1;
  2693. editor.moveCursorToPosition(cursor);
  2694. editor.$blockScrolling -= 1;
  2695. cursorMovedTime = now;
  2696. cursorPointOnCaretMoved = {x: x, y: y};
  2697. } else {
  2698. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2699. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2700. cursorMovedTime = null;
  2701. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2702. editor.renderer.scrollCursorIntoView();
  2703. cursorMovedTime = null;
  2704. }
  2705. }
  2706. }
  2707. function autoScroll(cursor, prevCursor) {
  2708. var now = Date.now();
  2709. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2710. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2711. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2712. var offsets = {
  2713. x: {
  2714. left: x - editorRect.left,
  2715. right: editorRect.right - x
  2716. },
  2717. y: {
  2718. top: y - editorRect.top,
  2719. bottom: editorRect.bottom - y
  2720. }
  2721. };
  2722. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2723. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2724. var scrollCursor = {row: cursor.row, column: cursor.column};
  2725. if (nearestXOffset / characterWidth <= 2) {
  2726. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2727. }
  2728. if (nearestYOffset / lineHeight <= 1) {
  2729. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2730. }
  2731. var vScroll = cursor.row != scrollCursor.row;
  2732. var hScroll = cursor.column != scrollCursor.column;
  2733. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2734. if (vScroll || (hScroll && !vMovement)) {
  2735. if (!autoScrollStartTime)
  2736. autoScrollStartTime = now;
  2737. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2738. editor.renderer.scrollCursorIntoView(scrollCursor);
  2739. } else {
  2740. autoScrollStartTime = null;
  2741. }
  2742. }
  2743. function onDragInterval() {
  2744. var prevCursor = dragCursor;
  2745. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2746. scrollCursorIntoView(dragCursor, prevCursor);
  2747. autoScroll(dragCursor, prevCursor);
  2748. }
  2749. function addDragMarker() {
  2750. range = editor.selection.toOrientedRange();
  2751. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2752. editor.clearSelection();
  2753. if (editor.isFocused())
  2754. editor.renderer.$cursorLayer.setBlinking(false);
  2755. clearInterval(timerId);
  2756. onDragInterval();
  2757. timerId = setInterval(onDragInterval, 20);
  2758. counter = 0;
  2759. event.addListener(document, "mousemove", onMouseMove);
  2760. }
  2761. function clearDragMarker() {
  2762. clearInterval(timerId);
  2763. editor.session.removeMarker(dragSelectionMarker);
  2764. dragSelectionMarker = null;
  2765. editor.$blockScrolling += 1;
  2766. editor.selection.fromOrientedRange(range);
  2767. editor.$blockScrolling -= 1;
  2768. if (editor.isFocused() && !isInternal)
  2769. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2770. range = null;
  2771. dragCursor = null;
  2772. counter = 0;
  2773. autoScrollStartTime = null;
  2774. cursorMovedTime = null;
  2775. event.removeListener(document, "mousemove", onMouseMove);
  2776. }
  2777. var onMouseMoveTimer = null;
  2778. function onMouseMove() {
  2779. if (onMouseMoveTimer == null) {
  2780. onMouseMoveTimer = setTimeout(function() {
  2781. if (onMouseMoveTimer != null && dragSelectionMarker)
  2782. clearDragMarker();
  2783. }, 20);
  2784. }
  2785. }
  2786. function canAccept(dataTransfer) {
  2787. var types = dataTransfer.types;
  2788. return !types || Array.prototype.some.call(types, function(type) {
  2789. return type == 'text/plain' || type == 'Text';
  2790. });
  2791. }
  2792. function getDropEffect(e) {
  2793. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2794. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2795. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2796. var effectAllowed = "uninitialized";
  2797. try {
  2798. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2799. } catch (e) {}
  2800. var dropEffect = "none";
  2801. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2802. dropEffect = "copy";
  2803. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2804. dropEffect = "move";
  2805. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2806. dropEffect = "copy";
  2807. return dropEffect;
  2808. }
  2809. }
  2810. (function() {
  2811. this.dragWait = function() {
  2812. var interval = Date.now() - this.mousedownEvent.time;
  2813. if (interval > this.editor.getDragDelay())
  2814. this.startDrag();
  2815. };
  2816. this.dragWaitEnd = function() {
  2817. var target = this.editor.container;
  2818. target.draggable = false;
  2819. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2820. this.selectEnd();
  2821. };
  2822. this.dragReadyEnd = function(e) {
  2823. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2824. this.editor.unsetStyle("ace_dragging");
  2825. this.editor.renderer.setCursorStyle("");
  2826. this.dragWaitEnd();
  2827. };
  2828. this.startDrag = function(){
  2829. this.cancelDrag = false;
  2830. var editor = this.editor;
  2831. var target = editor.container;
  2832. target.draggable = true;
  2833. editor.renderer.$cursorLayer.setBlinking(false);
  2834. editor.setStyle("ace_dragging");
  2835. var cursorStyle = useragent.isWin ? "default" : "move";
  2836. editor.renderer.setCursorStyle(cursorStyle);
  2837. this.setState("dragReady");
  2838. };
  2839. this.onMouseDrag = function(e) {
  2840. var target = this.editor.container;
  2841. if (useragent.isIE && this.state == "dragReady") {
  2842. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2843. if (distance > 3)
  2844. target.dragDrop();
  2845. }
  2846. if (this.state === "dragWait") {
  2847. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2848. if (distance > 0) {
  2849. target.draggable = false;
  2850. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2851. }
  2852. }
  2853. };
  2854. this.onMouseDown = function(e) {
  2855. if (!this.$dragEnabled)
  2856. return;
  2857. this.mousedownEvent = e;
  2858. var editor = this.editor;
  2859. var inSelection = e.inSelection();
  2860. var button = e.getButton();
  2861. var clickCount = e.domEvent.detail || 1;
  2862. if (clickCount === 1 && button === 0 && inSelection) {
  2863. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2864. return;
  2865. this.mousedownEvent.time = Date.now();
  2866. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2867. if ("unselectable" in eventTarget)
  2868. eventTarget.unselectable = "on";
  2869. if (editor.getDragDelay()) {
  2870. if (useragent.isWebKit) {
  2871. this.cancelDrag = true;
  2872. var mouseTarget = editor.container;
  2873. mouseTarget.draggable = true;
  2874. }
  2875. this.setState("dragWait");
  2876. } else {
  2877. this.startDrag();
  2878. }
  2879. this.captureMouse(e, this.onMouseDrag.bind(this));
  2880. e.defaultPrevented = true;
  2881. }
  2882. };
  2883. }).call(DragdropHandler.prototype);
  2884. function calcDistance(ax, ay, bx, by) {
  2885. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2886. }
  2887. exports.DragdropHandler = DragdropHandler;
  2888. });
  2889. ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2890. "use strict";
  2891. var dom = require("./dom");
  2892. exports.get = function (url, callback) {
  2893. var xhr = new XMLHttpRequest();
  2894. xhr.open('GET', url, true);
  2895. xhr.onreadystatechange = function () {
  2896. if (xhr.readyState === 4) {
  2897. callback(xhr.responseText);
  2898. }
  2899. };
  2900. xhr.send(null);
  2901. };
  2902. exports.loadScript = function(path, callback) {
  2903. var head = dom.getDocumentHead();
  2904. var s = document.createElement('script');
  2905. s.src = path;
  2906. head.appendChild(s);
  2907. s.onload = s.onreadystatechange = function(_, isAbort) {
  2908. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2909. s = s.onload = s.onreadystatechange = null;
  2910. if (!isAbort)
  2911. callback();
  2912. }
  2913. };
  2914. };
  2915. exports.qualifyURL = function(url) {
  2916. var a = document.createElement('a');
  2917. a.href = url;
  2918. return a.href;
  2919. }
  2920. });
  2921. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2922. "use strict";
  2923. var EventEmitter = {};
  2924. var stopPropagation = function() { this.propagationStopped = true; };
  2925. var preventDefault = function() { this.defaultPrevented = true; };
  2926. EventEmitter._emit =
  2927. EventEmitter._dispatchEvent = function(eventName, e) {
  2928. this._eventRegistry || (this._eventRegistry = {});
  2929. this._defaultHandlers || (this._defaultHandlers = {});
  2930. var listeners = this._eventRegistry[eventName] || [];
  2931. var defaultHandler = this._defaultHandlers[eventName];
  2932. if (!listeners.length && !defaultHandler)
  2933. return;
  2934. if (typeof e != "object" || !e)
  2935. e = {};
  2936. if (!e.type)
  2937. e.type = eventName;
  2938. if (!e.stopPropagation)
  2939. e.stopPropagation = stopPropagation;
  2940. if (!e.preventDefault)
  2941. e.preventDefault = preventDefault;
  2942. listeners = listeners.slice();
  2943. for (var i=0; i<listeners.length; i++) {
  2944. listeners[i](e, this);
  2945. if (e.propagationStopped)
  2946. break;
  2947. }
  2948. if (defaultHandler && !e.defaultPrevented)
  2949. return defaultHandler(e, this);
  2950. };
  2951. EventEmitter._signal = function(eventName, e) {
  2952. var listeners = (this._eventRegistry || {})[eventName];
  2953. if (!listeners)
  2954. return;
  2955. listeners = listeners.slice();
  2956. for (var i=0; i<listeners.length; i++)
  2957. listeners[i](e, this);
  2958. };
  2959. EventEmitter.once = function(eventName, callback) {
  2960. var _self = this;
  2961. callback && this.addEventListener(eventName, function newCallback() {
  2962. _self.removeEventListener(eventName, newCallback);
  2963. callback.apply(null, arguments);
  2964. });
  2965. };
  2966. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2967. var handlers = this._defaultHandlers
  2968. if (!handlers)
  2969. handlers = this._defaultHandlers = {_disabled_: {}};
  2970. if (handlers[eventName]) {
  2971. var old = handlers[eventName];
  2972. var disabled = handlers._disabled_[eventName];
  2973. if (!disabled)
  2974. handlers._disabled_[eventName] = disabled = [];
  2975. disabled.push(old);
  2976. var i = disabled.indexOf(callback);
  2977. if (i != -1)
  2978. disabled.splice(i, 1);
  2979. }
  2980. handlers[eventName] = callback;
  2981. };
  2982. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  2983. var handlers = this._defaultHandlers
  2984. if (!handlers)
  2985. return;
  2986. var disabled = handlers._disabled_[eventName];
  2987. if (handlers[eventName] == callback) {
  2988. var old = handlers[eventName];
  2989. if (disabled)
  2990. this.setDefaultHandler(eventName, disabled.pop());
  2991. } else if (disabled) {
  2992. var i = disabled.indexOf(callback);
  2993. if (i != -1)
  2994. disabled.splice(i, 1);
  2995. }
  2996. };
  2997. EventEmitter.on =
  2998. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  2999. this._eventRegistry = this._eventRegistry || {};
  3000. var listeners = this._eventRegistry[eventName];
  3001. if (!listeners)
  3002. listeners = this._eventRegistry[eventName] = [];
  3003. if (listeners.indexOf(callback) == -1)
  3004. listeners[capturing ? "unshift" : "push"](callback);
  3005. return callback;
  3006. };
  3007. EventEmitter.off =
  3008. EventEmitter.removeListener =
  3009. EventEmitter.removeEventListener = function(eventName, callback) {
  3010. this._eventRegistry = this._eventRegistry || {};
  3011. var listeners = this._eventRegistry[eventName];
  3012. if (!listeners)
  3013. return;
  3014. var index = listeners.indexOf(callback);
  3015. if (index !== -1)
  3016. listeners.splice(index, 1);
  3017. };
  3018. EventEmitter.removeAllListeners = function(eventName) {
  3019. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3020. };
  3021. exports.EventEmitter = EventEmitter;
  3022. });
  3023. ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3024. "no use strict";
  3025. var oop = require("./oop");
  3026. var EventEmitter = require("./event_emitter").EventEmitter;
  3027. var optionsProvider = {
  3028. setOptions: function(optList) {
  3029. Object.keys(optList).forEach(function(key) {
  3030. this.setOption(key, optList[key]);
  3031. }, this);
  3032. },
  3033. getOptions: function(optionNames) {
  3034. var result = {};
  3035. if (!optionNames) {
  3036. optionNames = Object.keys(this.$options);
  3037. } else if (!Array.isArray(optionNames)) {
  3038. result = optionNames;
  3039. optionNames = Object.keys(result);
  3040. }
  3041. optionNames.forEach(function(key) {
  3042. result[key] = this.getOption(key);
  3043. }, this);
  3044. return result;
  3045. },
  3046. setOption: function(name, value) {
  3047. if (this["$" + name] === value)
  3048. return;
  3049. var opt = this.$options[name];
  3050. if (!opt) {
  3051. return warn('misspelled option "' + name + '"');
  3052. }
  3053. if (opt.forwardTo)
  3054. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3055. if (!opt.handlesSet)
  3056. this["$" + name] = value;
  3057. if (opt && opt.set)
  3058. opt.set.call(this, value);
  3059. },
  3060. getOption: function(name) {
  3061. var opt = this.$options[name];
  3062. if (!opt) {
  3063. return warn('misspelled option "' + name + '"');
  3064. }
  3065. if (opt.forwardTo)
  3066. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3067. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3068. }
  3069. };
  3070. function warn(message) {
  3071. if (typeof console != "undefined" && console.warn)
  3072. console.warn.apply(console, arguments);
  3073. }
  3074. function reportError(msg, data) {
  3075. var e = new Error(msg);
  3076. e.data = data;
  3077. if (typeof console == "object" && console.error)
  3078. console.error(e);
  3079. setTimeout(function() { throw e; });
  3080. }
  3081. var AppConfig = function() {
  3082. this.$defaultOptions = {};
  3083. };
  3084. (function() {
  3085. oop.implement(this, EventEmitter);
  3086. this.defineOptions = function(obj, path, options) {
  3087. if (!obj.$options)
  3088. this.$defaultOptions[path] = obj.$options = {};
  3089. Object.keys(options).forEach(function(key) {
  3090. var opt = options[key];
  3091. if (typeof opt == "string")
  3092. opt = {forwardTo: opt};
  3093. opt.name || (opt.name = key);
  3094. obj.$options[opt.name] = opt;
  3095. if ("initialValue" in opt)
  3096. obj["$" + opt.name] = opt.initialValue;
  3097. });
  3098. oop.implement(obj, optionsProvider);
  3099. return this;
  3100. };
  3101. this.resetOptions = function(obj) {
  3102. Object.keys(obj.$options).forEach(function(key) {
  3103. var opt = obj.$options[key];
  3104. if ("value" in opt)
  3105. obj.setOption(key, opt.value);
  3106. });
  3107. };
  3108. this.setDefaultValue = function(path, name, value) {
  3109. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3110. if (opts[name]) {
  3111. if (opts.forwardTo)
  3112. this.setDefaultValue(opts.forwardTo, name, value);
  3113. else
  3114. opts[name].value = value;
  3115. }
  3116. };
  3117. this.setDefaultValues = function(path, optionHash) {
  3118. Object.keys(optionHash).forEach(function(key) {
  3119. this.setDefaultValue(path, key, optionHash[key]);
  3120. }, this);
  3121. };
  3122. this.warn = warn;
  3123. this.reportError = reportError;
  3124. }).call(AppConfig.prototype);
  3125. exports.AppConfig = AppConfig;
  3126. });
  3127. ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3128. "no use strict";
  3129. var lang = require("./lib/lang");
  3130. var oop = require("./lib/oop");
  3131. var net = require("./lib/net");
  3132. var AppConfig = require("./lib/app_config").AppConfig;
  3133. module.exports = exports = new AppConfig();
  3134. var global = (function() {
  3135. return this || typeof window != "undefined" && window;
  3136. })();
  3137. var options = {
  3138. packaged: false,
  3139. workerPath: null,
  3140. modePath: null,
  3141. themePath: null,
  3142. basePath: "",
  3143. suffix: ".js",
  3144. $moduleUrls: {}
  3145. };
  3146. exports.get = function(key) {
  3147. if (!options.hasOwnProperty(key))
  3148. throw new Error("Unknown config key: " + key);
  3149. return options[key];
  3150. };
  3151. exports.set = function(key, value) {
  3152. if (!options.hasOwnProperty(key))
  3153. throw new Error("Unknown config key: " + key);
  3154. options[key] = value;
  3155. };
  3156. exports.all = function() {
  3157. return lang.copyObject(options);
  3158. };
  3159. exports.moduleUrl = function(name, component) {
  3160. if (options.$moduleUrls[name])
  3161. return options.$moduleUrls[name];
  3162. var parts = name.split("/");
  3163. component = component || parts[parts.length - 2] || "";
  3164. var sep = component == "snippets" ? "/" : "-";
  3165. var base = parts[parts.length - 1];
  3166. if (component == "worker" && sep == "-") {
  3167. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3168. base = base.replace(re, "");
  3169. }
  3170. if ((!base || base == component) && parts.length > 1)
  3171. base = parts[parts.length - 2];
  3172. var path = options[component + "Path"];
  3173. if (path == null) {
  3174. path = options.basePath;
  3175. } else if (sep == "/") {
  3176. component = sep = "";
  3177. }
  3178. if (path && path.slice(-1) != "/")
  3179. path += "/";
  3180. return path + component + sep + base + this.get("suffix");
  3181. };
  3182. exports.setModuleUrl = function(name, subst) {
  3183. return options.$moduleUrls[name] = subst;
  3184. };
  3185. exports.$loading = {};
  3186. exports.loadModule = function(moduleName, onLoad) {
  3187. var module, moduleType;
  3188. if (Array.isArray(moduleName)) {
  3189. moduleType = moduleName[0];
  3190. moduleName = moduleName[1];
  3191. }
  3192. try {
  3193. module = require(moduleName);
  3194. } catch (e) {}
  3195. if (module && !exports.$loading[moduleName])
  3196. return onLoad && onLoad(module);
  3197. if (!exports.$loading[moduleName])
  3198. exports.$loading[moduleName] = [];
  3199. exports.$loading[moduleName].push(onLoad);
  3200. if (exports.$loading[moduleName].length > 1)
  3201. return;
  3202. var afterLoad = function() {
  3203. require([moduleName], function(module) {
  3204. exports._emit("load.module", {name: moduleName, module: module});
  3205. var listeners = exports.$loading[moduleName];
  3206. exports.$loading[moduleName] = null;
  3207. listeners.forEach(function(onLoad) {
  3208. onLoad && onLoad(module);
  3209. });
  3210. });
  3211. };
  3212. if (!exports.get("packaged"))
  3213. return afterLoad();
  3214. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3215. };
  3216. init(true);function init(packaged) {
  3217. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3218. if (!global.document)
  3219. return "";
  3220. var scriptOptions = {};
  3221. var scriptUrl = "";
  3222. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3223. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3224. var scripts = currentDocument.getElementsByTagName("script");
  3225. for (var i=0; i<scripts.length; i++) {
  3226. var script = scripts[i];
  3227. var src = script.src || script.getAttribute("src");
  3228. if (!src)
  3229. continue;
  3230. var attributes = script.attributes;
  3231. for (var j=0, l=attributes.length; j < l; j++) {
  3232. var attr = attributes[j];
  3233. if (attr.name.indexOf("data-ace-") === 0) {
  3234. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3235. }
  3236. }
  3237. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3238. if (m)
  3239. scriptUrl = m[1];
  3240. }
  3241. if (scriptUrl) {
  3242. scriptOptions.base = scriptOptions.base || scriptUrl;
  3243. scriptOptions.packaged = true;
  3244. }
  3245. scriptOptions.basePath = scriptOptions.base;
  3246. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3247. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3248. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3249. delete scriptOptions.base;
  3250. for (var key in scriptOptions)
  3251. if (typeof scriptOptions[key] !== "undefined")
  3252. exports.set(key, scriptOptions[key]);
  3253. };
  3254. exports.init = init;
  3255. function deHyphenate(str) {
  3256. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3257. }
  3258. });
  3259. ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"], function(require, exports, module) {
  3260. "use strict";
  3261. var event = require("../lib/event");
  3262. var useragent = require("../lib/useragent");
  3263. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3264. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3265. var MouseEvent = require("./mouse_event").MouseEvent;
  3266. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3267. var config = require("../config");
  3268. var MouseHandler = function(editor) {
  3269. var _self = this;
  3270. this.editor = editor;
  3271. new DefaultHandlers(this);
  3272. new DefaultGutterHandler(this);
  3273. new DragdropHandler(this);
  3274. var focusEditor = function(e) {
  3275. if (!document.hasFocus || !document.hasFocus())
  3276. window.focus();
  3277. editor.focus();
  3278. };
  3279. var mouseTarget = editor.renderer.getMouseEventTarget();
  3280. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3281. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3282. event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
  3283. if (editor.renderer.scrollBarV) {
  3284. event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
  3285. event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
  3286. if (useragent.isIE) {
  3287. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3288. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3289. }
  3290. }
  3291. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3292. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3293. var gutterEl = editor.renderer.$gutter;
  3294. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3295. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3296. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3297. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3298. event.addListener(mouseTarget, "mousedown", focusEditor);
  3299. event.addListener(gutterEl, "mousedown", function(e) {
  3300. editor.focus();
  3301. return event.preventDefault(e);
  3302. });
  3303. editor.on("mousemove", function(e){
  3304. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3305. return;
  3306. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3307. var range = editor.session.selection.getRange();
  3308. var renderer = editor.renderer;
  3309. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3310. renderer.setCursorStyle("default");
  3311. } else {
  3312. renderer.setCursorStyle("");
  3313. }
  3314. });
  3315. };
  3316. (function() {
  3317. this.onMouseEvent = function(name, e) {
  3318. this.editor._emit(name, new MouseEvent(e, this.editor));
  3319. };
  3320. this.onMouseMove = function(name, e) {
  3321. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3322. if (!listeners || !listeners.length)
  3323. return;
  3324. this.editor._emit(name, new MouseEvent(e, this.editor));
  3325. };
  3326. this.onMouseWheel = function(name, e) {
  3327. var mouseEvent = new MouseEvent(e, this.editor);
  3328. mouseEvent.speed = this.$scrollSpeed * 2;
  3329. mouseEvent.wheelX = e.wheelX;
  3330. mouseEvent.wheelY = e.wheelY;
  3331. this.editor._emit(name, mouseEvent);
  3332. };
  3333. this.onTouchMove = function (name, e) {
  3334. var mouseEvent = new MouseEvent(e, this.editor);
  3335. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3336. mouseEvent.wheelX = e.wheelX;
  3337. mouseEvent.wheelY = e.wheelY;
  3338. this.editor._emit(name, mouseEvent);
  3339. };
  3340. this.setState = function(state) {
  3341. this.state = state;
  3342. };
  3343. this.captureMouse = function(ev, mouseMoveHandler) {
  3344. this.x = ev.x;
  3345. this.y = ev.y;
  3346. this.isMousePressed = true;
  3347. var renderer = this.editor.renderer;
  3348. if (renderer.$keepTextAreaAtCursor)
  3349. renderer.$keepTextAreaAtCursor = null;
  3350. var self = this;
  3351. var onMouseMove = function(e) {
  3352. if (!e) return;
  3353. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3354. return self.releaseMouse();
  3355. self.x = e.clientX;
  3356. self.y = e.clientY;
  3357. mouseMoveHandler && mouseMoveHandler(e);
  3358. self.mouseEvent = new MouseEvent(e, self.editor);
  3359. self.$mouseMoved = true;
  3360. };
  3361. var onCaptureEnd = function(e) {
  3362. clearInterval(timerId);
  3363. onCaptureInterval();
  3364. self[self.state + "End"] && self[self.state + "End"](e);
  3365. self.state = "";
  3366. if (renderer.$keepTextAreaAtCursor == null) {
  3367. renderer.$keepTextAreaAtCursor = true;
  3368. renderer.$moveTextAreaToCursor();
  3369. }
  3370. self.isMousePressed = false;
  3371. self.$onCaptureMouseMove = self.releaseMouse = null;
  3372. e && self.onMouseEvent("mouseup", e);
  3373. };
  3374. var onCaptureInterval = function() {
  3375. self[self.state] && self[self.state]();
  3376. self.$mouseMoved = false;
  3377. };
  3378. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3379. return setTimeout(function() {onCaptureEnd(ev);});
  3380. }
  3381. self.$onCaptureMouseMove = onMouseMove;
  3382. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3383. var timerId = setInterval(onCaptureInterval, 20);
  3384. };
  3385. this.releaseMouse = null;
  3386. this.cancelContextMenu = function() {
  3387. var stop = function(e) {
  3388. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3389. return;
  3390. this.editor.off("nativecontextmenu", stop);
  3391. if (e && e.domEvent)
  3392. event.stopEvent(e.domEvent);
  3393. }.bind(this);
  3394. setTimeout(stop, 10);
  3395. this.editor.on("nativecontextmenu", stop);
  3396. };
  3397. }).call(MouseHandler.prototype);
  3398. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3399. scrollSpeed: {initialValue: 2},
  3400. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3401. dragEnabled: {initialValue: true},
  3402. focusTimout: {initialValue: 0},
  3403. tooltipFollowsMouse: {initialValue: true}
  3404. });
  3405. exports.MouseHandler = MouseHandler;
  3406. });
  3407. ace.define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3408. "use strict";
  3409. function FoldHandler(editor) {
  3410. editor.on("click", function(e) {
  3411. var position = e.getDocumentPosition();
  3412. var session = editor.session;
  3413. var fold = session.getFoldAt(position.row, position.column, 1);
  3414. if (fold) {
  3415. if (e.getAccelKey())
  3416. session.removeFold(fold);
  3417. else
  3418. session.expandFold(fold);
  3419. e.stop();
  3420. }
  3421. });
  3422. editor.on("gutterclick", function(e) {
  3423. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3424. if (gutterRegion == "foldWidgets") {
  3425. var row = e.getDocumentPosition().row;
  3426. var session = editor.session;
  3427. if (session.foldWidgets && session.foldWidgets[row])
  3428. editor.session.onFoldWidgetClick(row, e);
  3429. if (!editor.isFocused())
  3430. editor.focus();
  3431. e.stop();
  3432. }
  3433. });
  3434. editor.on("gutterdblclick", function(e) {
  3435. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3436. if (gutterRegion == "foldWidgets") {
  3437. var row = e.getDocumentPosition().row;
  3438. var session = editor.session;
  3439. var data = session.getParentFoldRangeData(row, true);
  3440. var range = data.range || data.firstRange;
  3441. if (range) {
  3442. row = range.start.row;
  3443. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3444. if (fold) {
  3445. session.removeFold(fold);
  3446. } else {
  3447. session.addFold("...", range);
  3448. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3449. }
  3450. }
  3451. e.stop();
  3452. }
  3453. });
  3454. }
  3455. exports.FoldHandler = FoldHandler;
  3456. });
  3457. ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3458. "use strict";
  3459. var keyUtil = require("../lib/keys");
  3460. var event = require("../lib/event");
  3461. var KeyBinding = function(editor) {
  3462. this.$editor = editor;
  3463. this.$data = {editor: editor};
  3464. this.$handlers = [];
  3465. this.setDefaultHandler(editor.commands);
  3466. };
  3467. (function() {
  3468. this.setDefaultHandler = function(kb) {
  3469. this.removeKeyboardHandler(this.$defaultHandler);
  3470. this.$defaultHandler = kb;
  3471. this.addKeyboardHandler(kb, 0);
  3472. };
  3473. this.setKeyboardHandler = function(kb) {
  3474. var h = this.$handlers;
  3475. if (h[h.length - 1] == kb)
  3476. return;
  3477. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3478. this.removeKeyboardHandler(h[h.length - 1]);
  3479. this.addKeyboardHandler(kb, 1);
  3480. };
  3481. this.addKeyboardHandler = function(kb, pos) {
  3482. if (!kb)
  3483. return;
  3484. if (typeof kb == "function" && !kb.handleKeyboard)
  3485. kb.handleKeyboard = kb;
  3486. var i = this.$handlers.indexOf(kb);
  3487. if (i != -1)
  3488. this.$handlers.splice(i, 1);
  3489. if (pos == undefined)
  3490. this.$handlers.push(kb);
  3491. else
  3492. this.$handlers.splice(pos, 0, kb);
  3493. if (i == -1 && kb.attach)
  3494. kb.attach(this.$editor);
  3495. };
  3496. this.removeKeyboardHandler = function(kb) {
  3497. var i = this.$handlers.indexOf(kb);
  3498. if (i == -1)
  3499. return false;
  3500. this.$handlers.splice(i, 1);
  3501. kb.detach && kb.detach(this.$editor);
  3502. return true;
  3503. };
  3504. this.getKeyboardHandler = function() {
  3505. return this.$handlers[this.$handlers.length - 1];
  3506. };
  3507. this.getStatusText = function() {
  3508. var data = this.$data;
  3509. var editor = data.editor;
  3510. return this.$handlers.map(function(h) {
  3511. return h.getStatusText && h.getStatusText(editor, data) || "";
  3512. }).filter(Boolean).join(" ");
  3513. };
  3514. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3515. var toExecute;
  3516. var success = false;
  3517. var commands = this.$editor.commands;
  3518. for (var i = this.$handlers.length; i--;) {
  3519. toExecute = this.$handlers[i].handleKeyboard(
  3520. this.$data, hashId, keyString, keyCode, e
  3521. );
  3522. if (!toExecute || !toExecute.command)
  3523. continue;
  3524. if (toExecute.command == "null") {
  3525. success = true;
  3526. } else {
  3527. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3528. }
  3529. if (success && e && hashId != -1 &&
  3530. toExecute.passEvent != true && toExecute.command.passEvent != true
  3531. ) {
  3532. event.stopEvent(e);
  3533. }
  3534. if (success)
  3535. break;
  3536. }
  3537. return success;
  3538. };
  3539. this.onCommandKey = function(e, hashId, keyCode) {
  3540. var keyString = keyUtil.keyCodeToString(keyCode);
  3541. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3542. };
  3543. this.onTextInput = function(text) {
  3544. var success = this.$callKeyboardHandlers(-1, text);
  3545. if (!success)
  3546. this.$editor.commands.exec("insertstring", this.$editor, text);
  3547. };
  3548. }).call(KeyBinding.prototype);
  3549. exports.KeyBinding = KeyBinding;
  3550. });
  3551. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  3552. "use strict";
  3553. var comparePoints = function(p1, p2) {
  3554. return p1.row - p2.row || p1.column - p2.column;
  3555. };
  3556. var Range = function(startRow, startColumn, endRow, endColumn) {
  3557. this.start = {
  3558. row: startRow,
  3559. column: startColumn
  3560. };
  3561. this.end = {
  3562. row: endRow,
  3563. column: endColumn
  3564. };
  3565. };
  3566. (function() {
  3567. this.isEqual = function(range) {
  3568. return this.start.row === range.start.row &&
  3569. this.end.row === range.end.row &&
  3570. this.start.column === range.start.column &&
  3571. this.end.column === range.end.column;
  3572. };
  3573. this.toString = function() {
  3574. return ("Range: [" + this.start.row + "/" + this.start.column +
  3575. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3576. };
  3577. this.contains = function(row, column) {
  3578. return this.compare(row, column) == 0;
  3579. };
  3580. this.compareRange = function(range) {
  3581. var cmp,
  3582. end = range.end,
  3583. start = range.start;
  3584. cmp = this.compare(end.row, end.column);
  3585. if (cmp == 1) {
  3586. cmp = this.compare(start.row, start.column);
  3587. if (cmp == 1) {
  3588. return 2;
  3589. } else if (cmp == 0) {
  3590. return 1;
  3591. } else {
  3592. return 0;
  3593. }
  3594. } else if (cmp == -1) {
  3595. return -2;
  3596. } else {
  3597. cmp = this.compare(start.row, start.column);
  3598. if (cmp == -1) {
  3599. return -1;
  3600. } else if (cmp == 1) {
  3601. return 42;
  3602. } else {
  3603. return 0;
  3604. }
  3605. }
  3606. };
  3607. this.comparePoint = function(p) {
  3608. return this.compare(p.row, p.column);
  3609. };
  3610. this.containsRange = function(range) {
  3611. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3612. };
  3613. this.intersects = function(range) {
  3614. var cmp = this.compareRange(range);
  3615. return (cmp == -1 || cmp == 0 || cmp == 1);
  3616. };
  3617. this.isEnd = function(row, column) {
  3618. return this.end.row == row && this.end.column == column;
  3619. };
  3620. this.isStart = function(row, column) {
  3621. return this.start.row == row && this.start.column == column;
  3622. };
  3623. this.setStart = function(row, column) {
  3624. if (typeof row == "object") {
  3625. this.start.column = row.column;
  3626. this.start.row = row.row;
  3627. } else {
  3628. this.start.row = row;
  3629. this.start.column = column;
  3630. }
  3631. };
  3632. this.setEnd = function(row, column) {
  3633. if (typeof row == "object") {
  3634. this.end.column = row.column;
  3635. this.end.row = row.row;
  3636. } else {
  3637. this.end.row = row;
  3638. this.end.column = column;
  3639. }
  3640. };
  3641. this.inside = function(row, column) {
  3642. if (this.compare(row, column) == 0) {
  3643. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3644. return false;
  3645. } else {
  3646. return true;
  3647. }
  3648. }
  3649. return false;
  3650. };
  3651. this.insideStart = function(row, column) {
  3652. if (this.compare(row, column) == 0) {
  3653. if (this.isEnd(row, column)) {
  3654. return false;
  3655. } else {
  3656. return true;
  3657. }
  3658. }
  3659. return false;
  3660. };
  3661. this.insideEnd = function(row, column) {
  3662. if (this.compare(row, column) == 0) {
  3663. if (this.isStart(row, column)) {
  3664. return false;
  3665. } else {
  3666. return true;
  3667. }
  3668. }
  3669. return false;
  3670. };
  3671. this.compare = function(row, column) {
  3672. if (!this.isMultiLine()) {
  3673. if (row === this.start.row) {
  3674. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3675. };
  3676. }
  3677. if (row < this.start.row)
  3678. return -1;
  3679. if (row > this.end.row)
  3680. return 1;
  3681. if (this.start.row === row)
  3682. return column >= this.start.column ? 0 : -1;
  3683. if (this.end.row === row)
  3684. return column <= this.end.column ? 0 : 1;
  3685. return 0;
  3686. };
  3687. this.compareStart = function(row, column) {
  3688. if (this.start.row == row && this.start.column == column) {
  3689. return -1;
  3690. } else {
  3691. return this.compare(row, column);
  3692. }
  3693. };
  3694. this.compareEnd = function(row, column) {
  3695. if (this.end.row == row && this.end.column == column) {
  3696. return 1;
  3697. } else {
  3698. return this.compare(row, column);
  3699. }
  3700. };
  3701. this.compareInside = function(row, column) {
  3702. if (this.end.row == row && this.end.column == column) {
  3703. return 1;
  3704. } else if (this.start.row == row && this.start.column == column) {
  3705. return -1;
  3706. } else {
  3707. return this.compare(row, column);
  3708. }
  3709. };
  3710. this.clipRows = function(firstRow, lastRow) {
  3711. if (this.end.row > lastRow)
  3712. var end = {row: lastRow + 1, column: 0};
  3713. else if (this.end.row < firstRow)
  3714. var end = {row: firstRow, column: 0};
  3715. if (this.start.row > lastRow)
  3716. var start = {row: lastRow + 1, column: 0};
  3717. else if (this.start.row < firstRow)
  3718. var start = {row: firstRow, column: 0};
  3719. return Range.fromPoints(start || this.start, end || this.end);
  3720. };
  3721. this.extend = function(row, column) {
  3722. var cmp = this.compare(row, column);
  3723. if (cmp == 0)
  3724. return this;
  3725. else if (cmp == -1)
  3726. var start = {row: row, column: column};
  3727. else
  3728. var end = {row: row, column: column};
  3729. return Range.fromPoints(start || this.start, end || this.end);
  3730. };
  3731. this.isEmpty = function() {
  3732. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3733. };
  3734. this.isMultiLine = function() {
  3735. return (this.start.row !== this.end.row);
  3736. };
  3737. this.clone = function() {
  3738. return Range.fromPoints(this.start, this.end);
  3739. };
  3740. this.collapseRows = function() {
  3741. if (this.end.column == 0)
  3742. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3743. else
  3744. return new Range(this.start.row, 0, this.end.row, 0)
  3745. };
  3746. this.toScreenRange = function(session) {
  3747. var screenPosStart = session.documentToScreenPosition(this.start);
  3748. var screenPosEnd = session.documentToScreenPosition(this.end);
  3749. return new Range(
  3750. screenPosStart.row, screenPosStart.column,
  3751. screenPosEnd.row, screenPosEnd.column
  3752. );
  3753. };
  3754. this.moveBy = function(row, column) {
  3755. this.start.row += row;
  3756. this.start.column += column;
  3757. this.end.row += row;
  3758. this.end.column += column;
  3759. };
  3760. }).call(Range.prototype);
  3761. Range.fromPoints = function(start, end) {
  3762. return new Range(start.row, start.column, end.row, end.column);
  3763. };
  3764. Range.comparePoints = comparePoints;
  3765. Range.comparePoints = function(p1, p2) {
  3766. return p1.row - p2.row || p1.column - p2.column;
  3767. };
  3768. exports.Range = Range;
  3769. });
  3770. ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3771. "use strict";
  3772. var oop = require("./lib/oop");
  3773. var lang = require("./lib/lang");
  3774. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3775. var Range = require("./range").Range;
  3776. var Selection = function(session) {
  3777. this.session = session;
  3778. this.doc = session.getDocument();
  3779. this.clearSelection();
  3780. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3781. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3782. var self = this;
  3783. this.lead.on("change", function(e) {
  3784. self._emit("changeCursor");
  3785. if (!self.$isEmpty)
  3786. self._emit("changeSelection");
  3787. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3788. self.$desiredColumn = null;
  3789. });
  3790. this.selectionAnchor.on("change", function() {
  3791. if (!self.$isEmpty)
  3792. self._emit("changeSelection");
  3793. });
  3794. };
  3795. (function() {
  3796. oop.implement(this, EventEmitter);
  3797. this.isEmpty = function() {
  3798. return (this.$isEmpty || (
  3799. this.anchor.row == this.lead.row &&
  3800. this.anchor.column == this.lead.column
  3801. ));
  3802. };
  3803. this.isMultiLine = function() {
  3804. if (this.isEmpty()) {
  3805. return false;
  3806. }
  3807. return this.getRange().isMultiLine();
  3808. };
  3809. this.getCursor = function() {
  3810. return this.lead.getPosition();
  3811. };
  3812. this.setSelectionAnchor = function(row, column) {
  3813. this.anchor.setPosition(row, column);
  3814. if (this.$isEmpty) {
  3815. this.$isEmpty = false;
  3816. this._emit("changeSelection");
  3817. }
  3818. };
  3819. this.getSelectionAnchor = function() {
  3820. if (this.$isEmpty)
  3821. return this.getSelectionLead();
  3822. else
  3823. return this.anchor.getPosition();
  3824. };
  3825. this.getSelectionLead = function() {
  3826. return this.lead.getPosition();
  3827. };
  3828. this.shiftSelection = function(columns) {
  3829. if (this.$isEmpty) {
  3830. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3831. return;
  3832. }
  3833. var anchor = this.getSelectionAnchor();
  3834. var lead = this.getSelectionLead();
  3835. var isBackwards = this.isBackwards();
  3836. if (!isBackwards || anchor.column !== 0)
  3837. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3838. if (isBackwards || lead.column !== 0) {
  3839. this.$moveSelection(function() {
  3840. this.moveCursorTo(lead.row, lead.column + columns);
  3841. });
  3842. }
  3843. };
  3844. this.isBackwards = function() {
  3845. var anchor = this.anchor;
  3846. var lead = this.lead;
  3847. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3848. };
  3849. this.getRange = function() {
  3850. var anchor = this.anchor;
  3851. var lead = this.lead;
  3852. if (this.isEmpty())
  3853. return Range.fromPoints(lead, lead);
  3854. if (this.isBackwards()) {
  3855. return Range.fromPoints(lead, anchor);
  3856. }
  3857. else {
  3858. return Range.fromPoints(anchor, lead);
  3859. }
  3860. };
  3861. this.clearSelection = function() {
  3862. if (!this.$isEmpty) {
  3863. this.$isEmpty = true;
  3864. this._emit("changeSelection");
  3865. }
  3866. };
  3867. this.selectAll = function() {
  3868. var lastRow = this.doc.getLength() - 1;
  3869. this.setSelectionAnchor(0, 0);
  3870. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3871. };
  3872. this.setRange =
  3873. this.setSelectionRange = function(range, reverse) {
  3874. if (reverse) {
  3875. this.setSelectionAnchor(range.end.row, range.end.column);
  3876. this.selectTo(range.start.row, range.start.column);
  3877. } else {
  3878. this.setSelectionAnchor(range.start.row, range.start.column);
  3879. this.selectTo(range.end.row, range.end.column);
  3880. }
  3881. if (this.getRange().isEmpty())
  3882. this.$isEmpty = true;
  3883. this.$desiredColumn = null;
  3884. };
  3885. this.$moveSelection = function(mover) {
  3886. var lead = this.lead;
  3887. if (this.$isEmpty)
  3888. this.setSelectionAnchor(lead.row, lead.column);
  3889. mover.call(this);
  3890. };
  3891. this.selectTo = function(row, column) {
  3892. this.$moveSelection(function() {
  3893. this.moveCursorTo(row, column);
  3894. });
  3895. };
  3896. this.selectToPosition = function(pos) {
  3897. this.$moveSelection(function() {
  3898. this.moveCursorToPosition(pos);
  3899. });
  3900. };
  3901. this.moveTo = function(row, column) {
  3902. this.clearSelection();
  3903. this.moveCursorTo(row, column);
  3904. };
  3905. this.moveToPosition = function(pos) {
  3906. this.clearSelection();
  3907. this.moveCursorToPosition(pos);
  3908. };
  3909. this.selectUp = function() {
  3910. this.$moveSelection(this.moveCursorUp);
  3911. };
  3912. this.selectDown = function() {
  3913. this.$moveSelection(this.moveCursorDown);
  3914. };
  3915. this.selectRight = function() {
  3916. this.$moveSelection(this.moveCursorRight);
  3917. };
  3918. this.selectLeft = function() {
  3919. this.$moveSelection(this.moveCursorLeft);
  3920. };
  3921. this.selectLineStart = function() {
  3922. this.$moveSelection(this.moveCursorLineStart);
  3923. };
  3924. this.selectLineEnd = function() {
  3925. this.$moveSelection(this.moveCursorLineEnd);
  3926. };
  3927. this.selectFileEnd = function() {
  3928. this.$moveSelection(this.moveCursorFileEnd);
  3929. };
  3930. this.selectFileStart = function() {
  3931. this.$moveSelection(this.moveCursorFileStart);
  3932. };
  3933. this.selectWordRight = function() {
  3934. this.$moveSelection(this.moveCursorWordRight);
  3935. };
  3936. this.selectWordLeft = function() {
  3937. this.$moveSelection(this.moveCursorWordLeft);
  3938. };
  3939. this.getWordRange = function(row, column) {
  3940. if (typeof column == "undefined") {
  3941. var cursor = row || this.lead;
  3942. row = cursor.row;
  3943. column = cursor.column;
  3944. }
  3945. return this.session.getWordRange(row, column);
  3946. };
  3947. this.selectWord = function() {
  3948. this.setSelectionRange(this.getWordRange());
  3949. };
  3950. this.selectAWord = function() {
  3951. var cursor = this.getCursor();
  3952. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3953. this.setSelectionRange(range);
  3954. };
  3955. this.getLineRange = function(row, excludeLastChar) {
  3956. var rowStart = typeof row == "number" ? row : this.lead.row;
  3957. var rowEnd;
  3958. var foldLine = this.session.getFoldLine(rowStart);
  3959. if (foldLine) {
  3960. rowStart = foldLine.start.row;
  3961. rowEnd = foldLine.end.row;
  3962. } else {
  3963. rowEnd = rowStart;
  3964. }
  3965. if (excludeLastChar === true)
  3966. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3967. else
  3968. return new Range(rowStart, 0, rowEnd + 1, 0);
  3969. };
  3970. this.selectLine = function() {
  3971. this.setSelectionRange(this.getLineRange());
  3972. };
  3973. this.moveCursorUp = function() {
  3974. this.moveCursorBy(-1, 0);
  3975. };
  3976. this.moveCursorDown = function() {
  3977. this.moveCursorBy(1, 0);
  3978. };
  3979. this.moveCursorLeft = function() {
  3980. var cursor = this.lead.getPosition(),
  3981. fold;
  3982. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  3983. this.moveCursorTo(fold.start.row, fold.start.column);
  3984. } else if (cursor.column === 0) {
  3985. if (cursor.row > 0) {
  3986. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  3987. }
  3988. }
  3989. else {
  3990. var tabSize = this.session.getTabSize();
  3991. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  3992. this.moveCursorBy(0, -tabSize);
  3993. else
  3994. this.moveCursorBy(0, -1);
  3995. }
  3996. };
  3997. this.moveCursorRight = function() {
  3998. var cursor = this.lead.getPosition(),
  3999. fold;
  4000. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4001. this.moveCursorTo(fold.end.row, fold.end.column);
  4002. }
  4003. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4004. if (this.lead.row < this.doc.getLength() - 1) {
  4005. this.moveCursorTo(this.lead.row + 1, 0);
  4006. }
  4007. }
  4008. else {
  4009. var tabSize = this.session.getTabSize();
  4010. var cursor = this.lead;
  4011. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  4012. this.moveCursorBy(0, tabSize);
  4013. else
  4014. this.moveCursorBy(0, 1);
  4015. }
  4016. };
  4017. this.moveCursorLineStart = function() {
  4018. var row = this.lead.row;
  4019. var column = this.lead.column;
  4020. var screenRow = this.session.documentToScreenRow(row, column);
  4021. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4022. var beforeCursor = this.session.getDisplayLine(
  4023. row, null, firstColumnPosition.row,
  4024. firstColumnPosition.column
  4025. );
  4026. var leadingSpace = beforeCursor.match(/^\s*/);
  4027. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4028. firstColumnPosition.column += leadingSpace[0].length;
  4029. this.moveCursorToPosition(firstColumnPosition);
  4030. };
  4031. this.moveCursorLineEnd = function() {
  4032. var lead = this.lead;
  4033. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4034. if (this.lead.column == lineEnd.column) {
  4035. var line = this.session.getLine(lineEnd.row);
  4036. if (lineEnd.column == line.length) {
  4037. var textEnd = line.search(/\s+$/);
  4038. if (textEnd > 0)
  4039. lineEnd.column = textEnd;
  4040. }
  4041. }
  4042. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4043. };
  4044. this.moveCursorFileEnd = function() {
  4045. var row = this.doc.getLength() - 1;
  4046. var column = this.doc.getLine(row).length;
  4047. this.moveCursorTo(row, column);
  4048. };
  4049. this.moveCursorFileStart = function() {
  4050. this.moveCursorTo(0, 0);
  4051. };
  4052. this.moveCursorLongWordRight = function() {
  4053. var row = this.lead.row;
  4054. var column = this.lead.column;
  4055. var line = this.doc.getLine(row);
  4056. var rightOfCursor = line.substring(column);
  4057. var match;
  4058. this.session.nonTokenRe.lastIndex = 0;
  4059. this.session.tokenRe.lastIndex = 0;
  4060. var fold = this.session.getFoldAt(row, column, 1);
  4061. if (fold) {
  4062. this.moveCursorTo(fold.end.row, fold.end.column);
  4063. return;
  4064. }
  4065. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4066. column += this.session.nonTokenRe.lastIndex;
  4067. this.session.nonTokenRe.lastIndex = 0;
  4068. rightOfCursor = line.substring(column);
  4069. }
  4070. if (column >= line.length) {
  4071. this.moveCursorTo(row, line.length);
  4072. this.moveCursorRight();
  4073. if (row < this.doc.getLength() - 1)
  4074. this.moveCursorWordRight();
  4075. return;
  4076. }
  4077. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4078. column += this.session.tokenRe.lastIndex;
  4079. this.session.tokenRe.lastIndex = 0;
  4080. }
  4081. this.moveCursorTo(row, column);
  4082. };
  4083. this.moveCursorLongWordLeft = function() {
  4084. var row = this.lead.row;
  4085. var column = this.lead.column;
  4086. var fold;
  4087. if (fold = this.session.getFoldAt(row, column, -1)) {
  4088. this.moveCursorTo(fold.start.row, fold.start.column);
  4089. return;
  4090. }
  4091. var str = this.session.getFoldStringAt(row, column, -1);
  4092. if (str == null) {
  4093. str = this.doc.getLine(row).substring(0, column);
  4094. }
  4095. var leftOfCursor = lang.stringReverse(str);
  4096. var match;
  4097. this.session.nonTokenRe.lastIndex = 0;
  4098. this.session.tokenRe.lastIndex = 0;
  4099. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4100. column -= this.session.nonTokenRe.lastIndex;
  4101. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4102. this.session.nonTokenRe.lastIndex = 0;
  4103. }
  4104. if (column <= 0) {
  4105. this.moveCursorTo(row, 0);
  4106. this.moveCursorLeft();
  4107. if (row > 0)
  4108. this.moveCursorWordLeft();
  4109. return;
  4110. }
  4111. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4112. column -= this.session.tokenRe.lastIndex;
  4113. this.session.tokenRe.lastIndex = 0;
  4114. }
  4115. this.moveCursorTo(row, column);
  4116. };
  4117. this.$shortWordEndIndex = function(rightOfCursor) {
  4118. var match, index = 0, ch;
  4119. var whitespaceRe = /\s/;
  4120. var tokenRe = this.session.tokenRe;
  4121. tokenRe.lastIndex = 0;
  4122. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4123. index = this.session.tokenRe.lastIndex;
  4124. } else {
  4125. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4126. index ++;
  4127. if (index < 1) {
  4128. tokenRe.lastIndex = 0;
  4129. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4130. tokenRe.lastIndex = 0;
  4131. index ++;
  4132. if (whitespaceRe.test(ch)) {
  4133. if (index > 2) {
  4134. index--;
  4135. break;
  4136. } else {
  4137. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4138. index ++;
  4139. if (index > 2)
  4140. break;
  4141. }
  4142. }
  4143. }
  4144. }
  4145. }
  4146. tokenRe.lastIndex = 0;
  4147. return index;
  4148. };
  4149. this.moveCursorShortWordRight = function() {
  4150. var row = this.lead.row;
  4151. var column = this.lead.column;
  4152. var line = this.doc.getLine(row);
  4153. var rightOfCursor = line.substring(column);
  4154. var fold = this.session.getFoldAt(row, column, 1);
  4155. if (fold)
  4156. return this.moveCursorTo(fold.end.row, fold.end.column);
  4157. if (column == line.length) {
  4158. var l = this.doc.getLength();
  4159. do {
  4160. row++;
  4161. rightOfCursor = this.doc.getLine(row);
  4162. } while (row < l && /^\s*$/.test(rightOfCursor));
  4163. if (!/^\s+/.test(rightOfCursor))
  4164. rightOfCursor = "";
  4165. column = 0;
  4166. }
  4167. var index = this.$shortWordEndIndex(rightOfCursor);
  4168. this.moveCursorTo(row, column + index);
  4169. };
  4170. this.moveCursorShortWordLeft = function() {
  4171. var row = this.lead.row;
  4172. var column = this.lead.column;
  4173. var fold;
  4174. if (fold = this.session.getFoldAt(row, column, -1))
  4175. return this.moveCursorTo(fold.start.row, fold.start.column);
  4176. var line = this.session.getLine(row).substring(0, column);
  4177. if (column === 0) {
  4178. do {
  4179. row--;
  4180. line = this.doc.getLine(row);
  4181. } while (row > 0 && /^\s*$/.test(line));
  4182. column = line.length;
  4183. if (!/\s+$/.test(line))
  4184. line = "";
  4185. }
  4186. var leftOfCursor = lang.stringReverse(line);
  4187. var index = this.$shortWordEndIndex(leftOfCursor);
  4188. return this.moveCursorTo(row, column - index);
  4189. };
  4190. this.moveCursorWordRight = function() {
  4191. if (this.session.$selectLongWords)
  4192. this.moveCursorLongWordRight();
  4193. else
  4194. this.moveCursorShortWordRight();
  4195. };
  4196. this.moveCursorWordLeft = function() {
  4197. if (this.session.$selectLongWords)
  4198. this.moveCursorLongWordLeft();
  4199. else
  4200. this.moveCursorShortWordLeft();
  4201. };
  4202. this.moveCursorBy = function(rows, chars) {
  4203. var screenPos = this.session.documentToScreenPosition(
  4204. this.lead.row,
  4205. this.lead.column
  4206. );
  4207. if (chars === 0) {
  4208. if (this.$desiredColumn)
  4209. screenPos.column = this.$desiredColumn;
  4210. else
  4211. this.$desiredColumn = screenPos.column;
  4212. }
  4213. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4214. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4215. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row])
  4216. docPos.row++;
  4217. }
  4218. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4219. };
  4220. this.moveCursorToPosition = function(position) {
  4221. this.moveCursorTo(position.row, position.column);
  4222. };
  4223. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4224. var fold = this.session.getFoldAt(row, column, 1);
  4225. if (fold) {
  4226. row = fold.start.row;
  4227. column = fold.start.column;
  4228. }
  4229. this.$keepDesiredColumnOnChange = true;
  4230. this.lead.setPosition(row, column);
  4231. this.$keepDesiredColumnOnChange = false;
  4232. if (!keepDesiredColumn)
  4233. this.$desiredColumn = null;
  4234. };
  4235. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4236. var pos = this.session.screenToDocumentPosition(row, column);
  4237. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4238. };
  4239. this.detach = function() {
  4240. this.lead.detach();
  4241. this.anchor.detach();
  4242. this.session = this.doc = null;
  4243. };
  4244. this.fromOrientedRange = function(range) {
  4245. this.setSelectionRange(range, range.cursor == range.start);
  4246. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4247. };
  4248. this.toOrientedRange = function(range) {
  4249. var r = this.getRange();
  4250. if (range) {
  4251. range.start.column = r.start.column;
  4252. range.start.row = r.start.row;
  4253. range.end.column = r.end.column;
  4254. range.end.row = r.end.row;
  4255. } else {
  4256. range = r;
  4257. }
  4258. range.cursor = this.isBackwards() ? range.start : range.end;
  4259. range.desiredColumn = this.$desiredColumn;
  4260. return range;
  4261. };
  4262. this.getRangeOfMovements = function(func) {
  4263. var start = this.getCursor();
  4264. try {
  4265. func.call(null, this);
  4266. var end = this.getCursor();
  4267. return Range.fromPoints(start,end);
  4268. } catch(e) {
  4269. return Range.fromPoints(start,start);
  4270. } finally {
  4271. this.moveCursorToPosition(start);
  4272. }
  4273. };
  4274. this.toJSON = function() {
  4275. if (this.rangeCount) {
  4276. var data = this.ranges.map(function(r) {
  4277. var r1 = r.clone();
  4278. r1.isBackwards = r.cursor == r.start;
  4279. return r1;
  4280. });
  4281. } else {
  4282. var data = this.getRange();
  4283. data.isBackwards = this.isBackwards();
  4284. }
  4285. return data;
  4286. };
  4287. this.fromJSON = function(data) {
  4288. if (data.start == undefined) {
  4289. if (this.rangeList) {
  4290. this.toSingleRange(data[0]);
  4291. for (var i = data.length; i--; ) {
  4292. var r = Range.fromPoints(data[i].start, data[i].end);
  4293. if (data[i].isBackwards)
  4294. r.cursor = r.start;
  4295. this.addRange(r, true);
  4296. }
  4297. return;
  4298. } else
  4299. data = data[0];
  4300. }
  4301. if (this.rangeList)
  4302. this.toSingleRange(data);
  4303. this.setSelectionRange(data, data.isBackwards);
  4304. };
  4305. this.isEqual = function(data) {
  4306. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4307. return false;
  4308. if (!data.length || !this.ranges)
  4309. return this.getRange().isEqual(data);
  4310. for (var i = this.ranges.length; i--; ) {
  4311. if (!this.ranges[i].isEqual(data[i]))
  4312. return false;
  4313. }
  4314. return true;
  4315. };
  4316. }).call(Selection.prototype);
  4317. exports.Selection = Selection;
  4318. });
  4319. ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4320. "use strict";
  4321. var config = require("./config");
  4322. var MAX_TOKEN_COUNT = 2000;
  4323. var Tokenizer = function(rules) {
  4324. this.states = rules;
  4325. this.regExps = {};
  4326. this.matchMappings = {};
  4327. for (var key in this.states) {
  4328. var state = this.states[key];
  4329. var ruleRegExps = [];
  4330. var matchTotal = 0;
  4331. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4332. var flag = "g";
  4333. var splitterRurles = [];
  4334. for (var i = 0; i < state.length; i++) {
  4335. var rule = state[i];
  4336. if (rule.defaultToken)
  4337. mapping.defaultToken = rule.defaultToken;
  4338. if (rule.caseInsensitive)
  4339. flag = "gi";
  4340. if (rule.regex == null)
  4341. continue;
  4342. if (rule.regex instanceof RegExp)
  4343. rule.regex = rule.regex.toString().slice(1, -1);
  4344. var adjustedregex = rule.regex;
  4345. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4346. if (Array.isArray(rule.token)) {
  4347. if (rule.token.length == 1 || matchcount == 1) {
  4348. rule.token = rule.token[0];
  4349. } else if (matchcount - 1 != rule.token.length) {
  4350. this.reportError("number of classes and regexp groups doesn't match", {
  4351. rule: rule,
  4352. groupCount: matchcount - 1
  4353. });
  4354. rule.token = rule.token[0];
  4355. } else {
  4356. rule.tokenArray = rule.token;
  4357. rule.token = null;
  4358. rule.onMatch = this.$arrayTokens;
  4359. }
  4360. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4361. if (matchcount > 1)
  4362. rule.onMatch = this.$applyToken;
  4363. else
  4364. rule.onMatch = rule.token;
  4365. }
  4366. if (matchcount > 1) {
  4367. if (/\\\d/.test(rule.regex)) {
  4368. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4369. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4370. });
  4371. } else {
  4372. matchcount = 1;
  4373. adjustedregex = this.removeCapturingGroups(rule.regex);
  4374. }
  4375. if (!rule.splitRegex && typeof rule.token != "string")
  4376. splitterRurles.push(rule); // flag will be known only at the very end
  4377. }
  4378. mapping[matchTotal] = i;
  4379. matchTotal += matchcount;
  4380. ruleRegExps.push(adjustedregex);
  4381. if (!rule.onMatch)
  4382. rule.onMatch = null;
  4383. }
  4384. if (!ruleRegExps.length) {
  4385. mapping[0] = 0;
  4386. ruleRegExps.push("$");
  4387. }
  4388. splitterRurles.forEach(function(rule) {
  4389. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4390. }, this);
  4391. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4392. }
  4393. };
  4394. (function() {
  4395. this.$setMaxTokenCount = function(m) {
  4396. MAX_TOKEN_COUNT = m | 0;
  4397. };
  4398. this.$applyToken = function(str) {
  4399. var values = this.splitRegex.exec(str).slice(1);
  4400. var types = this.token.apply(this, values);
  4401. if (typeof types === "string")
  4402. return [{type: types, value: str}];
  4403. var tokens = [];
  4404. for (var i = 0, l = types.length; i < l; i++) {
  4405. if (values[i])
  4406. tokens[tokens.length] = {
  4407. type: types[i],
  4408. value: values[i]
  4409. };
  4410. }
  4411. return tokens;
  4412. },
  4413. this.$arrayTokens = function(str) {
  4414. if (!str)
  4415. return [];
  4416. var values = this.splitRegex.exec(str);
  4417. if (!values)
  4418. return "text";
  4419. var tokens = [];
  4420. var types = this.tokenArray;
  4421. for (var i = 0, l = types.length; i < l; i++) {
  4422. if (values[i + 1])
  4423. tokens[tokens.length] = {
  4424. type: types[i],
  4425. value: values[i + 1]
  4426. };
  4427. }
  4428. return tokens;
  4429. };
  4430. this.removeCapturingGroups = function(src) {
  4431. var r = src.replace(
  4432. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4433. function(x, y) {return y ? "(?:" : x;}
  4434. );
  4435. return r;
  4436. };
  4437. this.createSplitterRegexp = function(src, flag) {
  4438. if (src.indexOf("(?=") != -1) {
  4439. var stack = 0;
  4440. var inChClass = false;
  4441. var lastCapture = {};
  4442. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4443. m, esc, parenOpen, parenClose, square, index
  4444. ) {
  4445. if (inChClass) {
  4446. inChClass = square != "]";
  4447. } else if (square) {
  4448. inChClass = true;
  4449. } else if (parenClose) {
  4450. if (stack == lastCapture.stack) {
  4451. lastCapture.end = index+1;
  4452. lastCapture.stack = -1;
  4453. }
  4454. stack--;
  4455. } else if (parenOpen) {
  4456. stack++;
  4457. if (parenOpen.length != 1) {
  4458. lastCapture.stack = stack
  4459. lastCapture.start = index;
  4460. }
  4461. }
  4462. return m;
  4463. });
  4464. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4465. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4466. }
  4467. return new RegExp(src, (flag||"").replace("g", ""));
  4468. };
  4469. this.getLineTokens = function(line, startState) {
  4470. if (startState && typeof startState != "string") {
  4471. var stack = startState.slice(0);
  4472. startState = stack[0];
  4473. if (startState === "#tmp") {
  4474. stack.shift()
  4475. startState = stack.shift()
  4476. }
  4477. } else
  4478. var stack = [];
  4479. var currentState = startState || "start";
  4480. var state = this.states[currentState];
  4481. if (!state) {
  4482. currentState = "start";
  4483. state = this.states[currentState];
  4484. }
  4485. var mapping = this.matchMappings[currentState];
  4486. var re = this.regExps[currentState];
  4487. re.lastIndex = 0;
  4488. var match, tokens = [];
  4489. var lastIndex = 0;
  4490. var matchAttempts = 0;
  4491. var token = {type: null, value: ""};
  4492. while (match = re.exec(line)) {
  4493. var type = mapping.defaultToken;
  4494. var rule = null;
  4495. var value = match[0];
  4496. var index = re.lastIndex;
  4497. if (index - value.length > lastIndex) {
  4498. var skipped = line.substring(lastIndex, index - value.length);
  4499. if (token.type == type) {
  4500. token.value += skipped;
  4501. } else {
  4502. if (token.type)
  4503. tokens.push(token);
  4504. token = {type: type, value: skipped};
  4505. }
  4506. }
  4507. for (var i = 0; i < match.length-2; i++) {
  4508. if (match[i + 1] === undefined)
  4509. continue;
  4510. rule = state[mapping[i]];
  4511. if (rule.onMatch)
  4512. type = rule.onMatch(value, currentState, stack);
  4513. else
  4514. type = rule.token;
  4515. if (rule.next) {
  4516. if (typeof rule.next == "string") {
  4517. currentState = rule.next;
  4518. } else {
  4519. currentState = rule.next(currentState, stack);
  4520. }
  4521. state = this.states[currentState];
  4522. if (!state) {
  4523. this.reportError("state doesn't exist", currentState);
  4524. currentState = "start";
  4525. state = this.states[currentState];
  4526. }
  4527. mapping = this.matchMappings[currentState];
  4528. lastIndex = index;
  4529. re = this.regExps[currentState];
  4530. re.lastIndex = index;
  4531. }
  4532. break;
  4533. }
  4534. if (value) {
  4535. if (typeof type === "string") {
  4536. if ((!rule || rule.merge !== false) && token.type === type) {
  4537. token.value += value;
  4538. } else {
  4539. if (token.type)
  4540. tokens.push(token);
  4541. token = {type: type, value: value};
  4542. }
  4543. } else if (type) {
  4544. if (token.type)
  4545. tokens.push(token);
  4546. token = {type: null, value: ""};
  4547. for (var i = 0; i < type.length; i++)
  4548. tokens.push(type[i]);
  4549. }
  4550. }
  4551. if (lastIndex == line.length)
  4552. break;
  4553. lastIndex = index;
  4554. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4555. if (matchAttempts > 2 * line.length) {
  4556. this.reportError("infinite loop with in ace tokenizer", {
  4557. startState: startState,
  4558. line: line
  4559. });
  4560. }
  4561. while (lastIndex < line.length) {
  4562. if (token.type)
  4563. tokens.push(token);
  4564. token = {
  4565. value: line.substring(lastIndex, lastIndex += 2000),
  4566. type: "overflow"
  4567. };
  4568. }
  4569. currentState = "start";
  4570. stack = [];
  4571. break;
  4572. }
  4573. }
  4574. if (token.type)
  4575. tokens.push(token);
  4576. if (stack.length > 1) {
  4577. if (stack[0] !== currentState)
  4578. stack.unshift("#tmp", currentState);
  4579. }
  4580. return {
  4581. tokens : tokens,
  4582. state : stack.length ? stack : currentState
  4583. };
  4584. };
  4585. this.reportError = config.reportError;
  4586. }).call(Tokenizer.prototype);
  4587. exports.Tokenizer = Tokenizer;
  4588. });
  4589. ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4590. "use strict";
  4591. var lang = require("../lib/lang");
  4592. var TextHighlightRules = function() {
  4593. this.$rules = {
  4594. "start" : [{
  4595. token : "empty_line",
  4596. regex : '^$'
  4597. }, {
  4598. defaultToken : "text"
  4599. }]
  4600. };
  4601. };
  4602. (function() {
  4603. this.addRules = function(rules, prefix) {
  4604. if (!prefix) {
  4605. for (var key in rules)
  4606. this.$rules[key] = rules[key];
  4607. return;
  4608. }
  4609. for (var key in rules) {
  4610. var state = rules[key];
  4611. for (var i = 0; i < state.length; i++) {
  4612. var rule = state[i];
  4613. if (rule.next || rule.onMatch) {
  4614. if (typeof rule.next != "string") {
  4615. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4616. rule.nextState = prefix + rule.nextState;
  4617. } else {
  4618. if (rule.next.indexOf(prefix) !== 0)
  4619. rule.next = prefix + rule.next;
  4620. }
  4621. }
  4622. }
  4623. this.$rules[prefix + key] = state;
  4624. }
  4625. };
  4626. this.getRules = function() {
  4627. return this.$rules;
  4628. };
  4629. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4630. var embedRules = typeof HighlightRules == "function"
  4631. ? new HighlightRules().getRules()
  4632. : HighlightRules;
  4633. if (states) {
  4634. for (var i = 0; i < states.length; i++)
  4635. states[i] = prefix + states[i];
  4636. } else {
  4637. states = [];
  4638. for (var key in embedRules)
  4639. states.push(prefix + key);
  4640. }
  4641. this.addRules(embedRules, prefix);
  4642. if (escapeRules) {
  4643. var addRules = Array.prototype[append ? "push" : "unshift"];
  4644. for (var i = 0; i < states.length; i++)
  4645. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4646. }
  4647. if (!this.$embeds)
  4648. this.$embeds = [];
  4649. this.$embeds.push(prefix);
  4650. };
  4651. this.getEmbeds = function() {
  4652. return this.$embeds;
  4653. };
  4654. var pushState = function(currentState, stack) {
  4655. if (currentState != "start" || stack.length)
  4656. stack.unshift(this.nextState, currentState);
  4657. return this.nextState;
  4658. };
  4659. var popState = function(currentState, stack) {
  4660. stack.shift();
  4661. return stack.shift() || "start";
  4662. };
  4663. this.normalizeRules = function() {
  4664. var id = 0;
  4665. var rules = this.$rules;
  4666. function processState(key) {
  4667. var state = rules[key];
  4668. state.processed = true;
  4669. for (var i = 0; i < state.length; i++) {
  4670. var rule = state[i];
  4671. if (!rule.regex && rule.start) {
  4672. rule.regex = rule.start;
  4673. if (!rule.next)
  4674. rule.next = [];
  4675. rule.next.push({
  4676. defaultToken: rule.token
  4677. }, {
  4678. token: rule.token + ".end",
  4679. regex: rule.end || rule.start,
  4680. next: "pop"
  4681. });
  4682. rule.token = rule.token + ".start";
  4683. rule.push = true;
  4684. }
  4685. var next = rule.next || rule.push;
  4686. if (next && Array.isArray(next)) {
  4687. var stateName = rule.stateName;
  4688. if (!stateName) {
  4689. stateName = rule.token;
  4690. if (typeof stateName != "string")
  4691. stateName = stateName[0] || "";
  4692. if (rules[stateName])
  4693. stateName += id++;
  4694. }
  4695. rules[stateName] = next;
  4696. rule.next = stateName;
  4697. processState(stateName);
  4698. } else if (next == "pop") {
  4699. rule.next = popState;
  4700. }
  4701. if (rule.push) {
  4702. rule.nextState = rule.next || rule.push;
  4703. rule.next = pushState;
  4704. delete rule.push;
  4705. }
  4706. if (rule.rules) {
  4707. for (var r in rule.rules) {
  4708. if (rules[r]) {
  4709. if (rules[r].push)
  4710. rules[r].push.apply(rules[r], rule.rules[r]);
  4711. } else {
  4712. rules[r] = rule.rules[r];
  4713. }
  4714. }
  4715. }
  4716. if (rule.include || typeof rule == "string") {
  4717. var includeName = rule.include || rule;
  4718. var toInsert = rules[includeName];
  4719. } else if (Array.isArray(rule))
  4720. toInsert = rule;
  4721. if (toInsert) {
  4722. var args = [i, 1].concat(toInsert);
  4723. if (rule.noEscape)
  4724. args = args.filter(function(x) {return !x.next;});
  4725. state.splice.apply(state, args);
  4726. i--;
  4727. toInsert = null;
  4728. }
  4729. if (rule.keywordMap) {
  4730. rule.token = this.createKeywordMapper(
  4731. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4732. );
  4733. delete rule.defaultToken;
  4734. }
  4735. }
  4736. }
  4737. Object.keys(rules).forEach(processState, this);
  4738. };
  4739. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4740. var keywords = Object.create(null);
  4741. Object.keys(map).forEach(function(className) {
  4742. var a = map[className];
  4743. if (ignoreCase)
  4744. a = a.toLowerCase();
  4745. var list = a.split(splitChar || "|");
  4746. for (var i = list.length; i--; )
  4747. keywords[list[i]] = className;
  4748. });
  4749. if (Object.getPrototypeOf(keywords)) {
  4750. keywords.__proto__ = null;
  4751. }
  4752. this.$keywordList = Object.keys(keywords);
  4753. map = null;
  4754. return ignoreCase
  4755. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4756. : function(value) {return keywords[value] || defaultToken };
  4757. };
  4758. this.getKeywords = function() {
  4759. return this.$keywords;
  4760. };
  4761. }).call(TextHighlightRules.prototype);
  4762. exports.TextHighlightRules = TextHighlightRules;
  4763. });
  4764. ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4765. "use strict";
  4766. var Behaviour = function() {
  4767. this.$behaviours = {};
  4768. };
  4769. (function () {
  4770. this.add = function (name, action, callback) {
  4771. switch (undefined) {
  4772. case this.$behaviours:
  4773. this.$behaviours = {};
  4774. case this.$behaviours[name]:
  4775. this.$behaviours[name] = {};
  4776. }
  4777. this.$behaviours[name][action] = callback;
  4778. }
  4779. this.addBehaviours = function (behaviours) {
  4780. for (var key in behaviours) {
  4781. for (var action in behaviours[key]) {
  4782. this.add(key, action, behaviours[key][action]);
  4783. }
  4784. }
  4785. }
  4786. this.remove = function (name) {
  4787. if (this.$behaviours && this.$behaviours[name]) {
  4788. delete this.$behaviours[name];
  4789. }
  4790. }
  4791. this.inherit = function (mode, filter) {
  4792. if (typeof mode === "function") {
  4793. var behaviours = new mode().getBehaviours(filter);
  4794. } else {
  4795. var behaviours = mode.getBehaviours(filter);
  4796. }
  4797. this.addBehaviours(behaviours);
  4798. }
  4799. this.getBehaviours = function (filter) {
  4800. if (!filter) {
  4801. return this.$behaviours;
  4802. } else {
  4803. var ret = {}
  4804. for (var i = 0; i < filter.length; i++) {
  4805. if (this.$behaviours[filter[i]]) {
  4806. ret[filter[i]] = this.$behaviours[filter[i]];
  4807. }
  4808. }
  4809. return ret;
  4810. }
  4811. }
  4812. }).call(Behaviour.prototype);
  4813. exports.Behaviour = Behaviour;
  4814. });
  4815. ace.define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4816. "use strict";
  4817. exports.packages = {};
  4818. addUnicodePackage({
  4819. 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",
  4820. 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",
  4821. 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",
  4822. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4823. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4824. 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",
  4825. 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",
  4826. 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",
  4827. 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",
  4828. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4829. 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",
  4830. 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",
  4831. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4832. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4833. 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",
  4834. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4835. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4836. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4837. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4838. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4839. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4840. 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",
  4841. 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",
  4842. 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",
  4843. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4844. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4845. 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",
  4846. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4847. Zs: "002000A01680180E2000-200A202F205F3000",
  4848. Zl: "2028",
  4849. Zp: "2029",
  4850. 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",
  4851. Cc: "0000-001F007F-009F",
  4852. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4853. Co: "E000-F8FF",
  4854. Cs: "D800-DFFF",
  4855. 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"
  4856. });
  4857. function addUnicodePackage (pack) {
  4858. var codePoint = /\w{4}/g;
  4859. for (var name in pack)
  4860. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4861. };
  4862. });
  4863. ace.define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4864. "use strict";
  4865. var TokenIterator = function(session, initialRow, initialColumn) {
  4866. this.$session = session;
  4867. this.$row = initialRow;
  4868. this.$rowTokens = session.getTokens(initialRow);
  4869. var token = session.getTokenAt(initialRow, initialColumn);
  4870. this.$tokenIndex = token ? token.index : -1;
  4871. };
  4872. (function() {
  4873. this.stepBackward = function() {
  4874. this.$tokenIndex -= 1;
  4875. while (this.$tokenIndex < 0) {
  4876. this.$row -= 1;
  4877. if (this.$row < 0) {
  4878. this.$row = 0;
  4879. return null;
  4880. }
  4881. this.$rowTokens = this.$session.getTokens(this.$row);
  4882. this.$tokenIndex = this.$rowTokens.length - 1;
  4883. }
  4884. return this.$rowTokens[this.$tokenIndex];
  4885. };
  4886. this.stepForward = function() {
  4887. this.$tokenIndex += 1;
  4888. var rowCount;
  4889. while (this.$tokenIndex >= this.$rowTokens.length) {
  4890. this.$row += 1;
  4891. if (!rowCount)
  4892. rowCount = this.$session.getLength();
  4893. if (this.$row >= rowCount) {
  4894. this.$row = rowCount - 1;
  4895. return null;
  4896. }
  4897. this.$rowTokens = this.$session.getTokens(this.$row);
  4898. this.$tokenIndex = 0;
  4899. }
  4900. return this.$rowTokens[this.$tokenIndex];
  4901. };
  4902. this.getCurrentToken = function () {
  4903. return this.$rowTokens[this.$tokenIndex];
  4904. };
  4905. this.getCurrentTokenRow = function () {
  4906. return this.$row;
  4907. };
  4908. this.getCurrentTokenColumn = function() {
  4909. var rowTokens = this.$rowTokens;
  4910. var tokenIndex = this.$tokenIndex;
  4911. var column = rowTokens[tokenIndex].start;
  4912. if (column !== undefined)
  4913. return column;
  4914. column = 0;
  4915. while (tokenIndex > 0) {
  4916. tokenIndex -= 1;
  4917. column += rowTokens[tokenIndex].value.length;
  4918. }
  4919. return column;
  4920. };
  4921. this.getCurrentTokenPosition = function() {
  4922. return {row: this.$row, column: this.getCurrentTokenColumn()};
  4923. };
  4924. }).call(TokenIterator.prototype);
  4925. exports.TokenIterator = TokenIterator;
  4926. });
  4927. ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
  4928. "use strict";
  4929. var Tokenizer = require("../tokenizer").Tokenizer;
  4930. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4931. var Behaviour = require("./behaviour").Behaviour;
  4932. var unicode = require("../unicode");
  4933. var lang = require("../lib/lang");
  4934. var TokenIterator = require("../token_iterator").TokenIterator;
  4935. var Range = require("../range").Range;
  4936. var Mode = function() {
  4937. this.HighlightRules = TextHighlightRules;
  4938. this.$behaviour = new Behaviour();
  4939. };
  4940. (function() {
  4941. this.tokenRe = new RegExp("^["
  4942. + unicode.packages.L
  4943. + unicode.packages.Mn + unicode.packages.Mc
  4944. + unicode.packages.Nd
  4945. + unicode.packages.Pc + "\\$_]+", "g"
  4946. );
  4947. this.nonTokenRe = new RegExp("^(?:[^"
  4948. + unicode.packages.L
  4949. + unicode.packages.Mn + unicode.packages.Mc
  4950. + unicode.packages.Nd
  4951. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4952. );
  4953. this.getTokenizer = function() {
  4954. if (!this.$tokenizer) {
  4955. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4956. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4957. }
  4958. return this.$tokenizer;
  4959. };
  4960. this.lineCommentStart = "";
  4961. this.blockComment = "";
  4962. this.toggleCommentLines = function(state, session, startRow, endRow) {
  4963. var doc = session.doc;
  4964. var ignoreBlankLines = true;
  4965. var shouldRemove = true;
  4966. var minIndent = Infinity;
  4967. var tabSize = session.getTabSize();
  4968. var insertAtTabStop = false;
  4969. if (!this.lineCommentStart) {
  4970. if (!this.blockComment)
  4971. return false;
  4972. var lineCommentStart = this.blockComment.start;
  4973. var lineCommentEnd = this.blockComment.end;
  4974. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  4975. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  4976. var comment = function(line, i) {
  4977. if (testRemove(line, i))
  4978. return;
  4979. if (!ignoreBlankLines || /\S/.test(line)) {
  4980. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  4981. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4982. }
  4983. };
  4984. var uncomment = function(line, i) {
  4985. var m;
  4986. if (m = line.match(regexpEnd))
  4987. doc.removeInLine(i, line.length - m[0].length, line.length);
  4988. if (m = line.match(regexpStart))
  4989. doc.removeInLine(i, m[1].length, m[0].length);
  4990. };
  4991. var testRemove = function(line, row) {
  4992. if (regexpStart.test(line))
  4993. return true;
  4994. var tokens = session.getTokens(row);
  4995. for (var i = 0; i < tokens.length; i++) {
  4996. if (tokens[i].type === 'comment')
  4997. return true;
  4998. }
  4999. };
  5000. } else {
  5001. if (Array.isArray(this.lineCommentStart)) {
  5002. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  5003. var lineCommentStart = this.lineCommentStart[0];
  5004. } else {
  5005. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  5006. var lineCommentStart = this.lineCommentStart;
  5007. }
  5008. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  5009. insertAtTabStop = session.getUseSoftTabs();
  5010. var uncomment = function(line, i) {
  5011. var m = line.match(regexpStart);
  5012. if (!m) return;
  5013. var start = m[1].length, end = m[0].length;
  5014. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  5015. end--;
  5016. doc.removeInLine(i, start, end);
  5017. };
  5018. var commentWithSpace = lineCommentStart + " ";
  5019. var comment = function(line, i) {
  5020. if (!ignoreBlankLines || /\S/.test(line)) {
  5021. if (shouldInsertSpace(line, minIndent, minIndent))
  5022. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  5023. else
  5024. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5025. }
  5026. };
  5027. var testRemove = function(line, i) {
  5028. return regexpStart.test(line);
  5029. };
  5030. var shouldInsertSpace = function(line, before, after) {
  5031. var spaces = 0;
  5032. while (before-- && line.charAt(before) == " ")
  5033. spaces++;
  5034. if (spaces % tabSize != 0)
  5035. return false;
  5036. var spaces = 0;
  5037. while (line.charAt(after++) == " ")
  5038. spaces++;
  5039. if (tabSize > 2)
  5040. return spaces % tabSize != tabSize - 1;
  5041. else
  5042. return spaces % tabSize == 0;
  5043. return true;
  5044. };
  5045. }
  5046. function iter(fun) {
  5047. for (var i = startRow; i <= endRow; i++)
  5048. fun(doc.getLine(i), i);
  5049. }
  5050. var minEmptyLength = Infinity;
  5051. iter(function(line, i) {
  5052. var indent = line.search(/\S/);
  5053. if (indent !== -1) {
  5054. if (indent < minIndent)
  5055. minIndent = indent;
  5056. if (shouldRemove && !testRemove(line, i))
  5057. shouldRemove = false;
  5058. } else if (minEmptyLength > line.length) {
  5059. minEmptyLength = line.length;
  5060. }
  5061. });
  5062. if (minIndent == Infinity) {
  5063. minIndent = minEmptyLength;
  5064. ignoreBlankLines = false;
  5065. shouldRemove = false;
  5066. }
  5067. if (insertAtTabStop && minIndent % tabSize != 0)
  5068. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5069. iter(shouldRemove ? uncomment : comment);
  5070. };
  5071. this.toggleBlockComment = function(state, session, range, cursor) {
  5072. var comment = this.blockComment;
  5073. if (!comment)
  5074. return;
  5075. if (!comment.start && comment[0])
  5076. comment = comment[0];
  5077. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5078. var token = iterator.getCurrentToken();
  5079. var sel = session.selection;
  5080. var initialRange = session.selection.toOrientedRange();
  5081. var startRow, colDiff;
  5082. if (token && /comment/.test(token.type)) {
  5083. var startRange, endRange;
  5084. while (token && /comment/.test(token.type)) {
  5085. var i = token.value.indexOf(comment.start);
  5086. if (i != -1) {
  5087. var row = iterator.getCurrentTokenRow();
  5088. var column = iterator.getCurrentTokenColumn() + i;
  5089. startRange = new Range(row, column, row, column + comment.start.length);
  5090. break;
  5091. }
  5092. token = iterator.stepBackward();
  5093. }
  5094. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5095. var token = iterator.getCurrentToken();
  5096. while (token && /comment/.test(token.type)) {
  5097. var i = token.value.indexOf(comment.end);
  5098. if (i != -1) {
  5099. var row = iterator.getCurrentTokenRow();
  5100. var column = iterator.getCurrentTokenColumn() + i;
  5101. endRange = new Range(row, column, row, column + comment.end.length);
  5102. break;
  5103. }
  5104. token = iterator.stepForward();
  5105. }
  5106. if (endRange)
  5107. session.remove(endRange);
  5108. if (startRange) {
  5109. session.remove(startRange);
  5110. startRow = startRange.start.row;
  5111. colDiff = -comment.start.length;
  5112. }
  5113. } else {
  5114. colDiff = comment.start.length;
  5115. startRow = range.start.row;
  5116. session.insert(range.end, comment.end);
  5117. session.insert(range.start, comment.start);
  5118. }
  5119. if (initialRange.start.row == startRow)
  5120. initialRange.start.column += colDiff;
  5121. if (initialRange.end.row == startRow)
  5122. initialRange.end.column += colDiff;
  5123. session.selection.fromOrientedRange(initialRange);
  5124. };
  5125. this.getNextLineIndent = function(state, line, tab) {
  5126. return this.$getIndent(line);
  5127. };
  5128. this.checkOutdent = function(state, line, input) {
  5129. return false;
  5130. };
  5131. this.autoOutdent = function(state, doc, row) {
  5132. };
  5133. this.$getIndent = function(line) {
  5134. return line.match(/^\s*/)[0];
  5135. };
  5136. this.createWorker = function(session) {
  5137. return null;
  5138. };
  5139. this.createModeDelegates = function (mapping) {
  5140. this.$embeds = [];
  5141. this.$modes = {};
  5142. for (var i in mapping) {
  5143. if (mapping[i]) {
  5144. this.$embeds.push(i);
  5145. this.$modes[i] = new mapping[i]();
  5146. }
  5147. }
  5148. var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
  5149. 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
  5150. for (var i = 0; i < delegations.length; i++) {
  5151. (function(scope) {
  5152. var functionName = delegations[i];
  5153. var defaultHandler = scope[functionName];
  5154. scope[delegations[i]] = function() {
  5155. return this.$delegator(functionName, arguments, defaultHandler);
  5156. };
  5157. } (this));
  5158. }
  5159. };
  5160. this.$delegator = function(method, args, defaultHandler) {
  5161. var state = args[0];
  5162. if (typeof state != "string")
  5163. state = state[0];
  5164. for (var i = 0; i < this.$embeds.length; i++) {
  5165. if (!this.$modes[this.$embeds[i]]) continue;
  5166. var split = state.split(this.$embeds[i]);
  5167. if (!split[0] && split[1]) {
  5168. args[0] = split[1];
  5169. var mode = this.$modes[this.$embeds[i]];
  5170. return mode[method].apply(mode, args);
  5171. }
  5172. }
  5173. var ret = defaultHandler.apply(this, args);
  5174. return defaultHandler ? ret : undefined;
  5175. };
  5176. this.transformAction = function(state, action, editor, session, param) {
  5177. if (this.$behaviour) {
  5178. var behaviours = this.$behaviour.getBehaviours();
  5179. for (var key in behaviours) {
  5180. if (behaviours[key][action]) {
  5181. var ret = behaviours[key][action].apply(this, arguments);
  5182. if (ret) {
  5183. return ret;
  5184. }
  5185. }
  5186. }
  5187. }
  5188. };
  5189. this.getKeywords = function(append) {
  5190. if (!this.completionKeywords) {
  5191. var rules = this.$tokenizer.rules;
  5192. var completionKeywords = [];
  5193. for (var rule in rules) {
  5194. var ruleItr = rules[rule];
  5195. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5196. if (typeof ruleItr[r].token === "string") {
  5197. if (/keyword|support|storage/.test(ruleItr[r].token))
  5198. completionKeywords.push(ruleItr[r].regex);
  5199. }
  5200. else if (typeof ruleItr[r].token === "object") {
  5201. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5202. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5203. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5204. completionKeywords.push(rule.substr(1, rule.length - 2));
  5205. }
  5206. }
  5207. }
  5208. }
  5209. }
  5210. this.completionKeywords = completionKeywords;
  5211. }
  5212. if (!append)
  5213. return this.$keywordList;
  5214. return completionKeywords.concat(this.$keywordList || []);
  5215. };
  5216. this.$createKeywordList = function() {
  5217. if (!this.$highlightRules)
  5218. this.getTokenizer();
  5219. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5220. };
  5221. this.getCompletions = function(state, session, pos, prefix) {
  5222. var keywords = this.$keywordList || this.$createKeywordList();
  5223. return keywords.map(function(word) {
  5224. return {
  5225. name: word,
  5226. value: word,
  5227. score: 0,
  5228. meta: "keyword"
  5229. };
  5230. });
  5231. };
  5232. this.$id = "ace/mode/text";
  5233. }).call(Mode.prototype);
  5234. exports.Mode = Mode;
  5235. });
  5236. ace.define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  5237. "use strict";
  5238. function throwDeltaError(delta, errorText){
  5239. console.log("Invalid Delta:", delta);
  5240. throw "Invalid Delta: " + errorText;
  5241. }
  5242. function positionInDocument(docLines, position) {
  5243. return position.row >= 0 && position.row < docLines.length &&
  5244. position.column >= 0 && position.column <= docLines[position.row].length;
  5245. }
  5246. function validateDelta(docLines, delta) {
  5247. if (delta.action != "insert" && delta.action != "remove")
  5248. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  5249. if (!(delta.lines instanceof Array))
  5250. throwDeltaError(delta, "delta.lines must be an Array");
  5251. if (!delta.start || !delta.end)
  5252. throwDeltaError(delta, "delta.start/end must be an present");
  5253. var start = delta.start;
  5254. if (!positionInDocument(docLines, delta.start))
  5255. throwDeltaError(delta, "delta.start must be contained in document");
  5256. var end = delta.end;
  5257. if (delta.action == "remove" && !positionInDocument(docLines, end))
  5258. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  5259. var numRangeRows = end.row - start.row;
  5260. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  5261. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  5262. throwDeltaError(delta, "delta.range must match delta lines");
  5263. }
  5264. exports.applyDelta = function(docLines, delta, doNotValidate) {
  5265. var row = delta.start.row;
  5266. var startColumn = delta.start.column;
  5267. var line = docLines[row] || "";
  5268. switch (delta.action) {
  5269. case "insert":
  5270. var lines = delta.lines;
  5271. if (lines.length === 1) {
  5272. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  5273. } else {
  5274. var args = [row, 1].concat(delta.lines);
  5275. docLines.splice.apply(docLines, args);
  5276. docLines[row] = line.substring(0, startColumn) + docLines[row];
  5277. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  5278. }
  5279. break;
  5280. case "remove":
  5281. var endColumn = delta.end.column;
  5282. var endRow = delta.end.row;
  5283. if (row === endRow) {
  5284. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  5285. } else {
  5286. docLines.splice(
  5287. row, endRow - row + 1,
  5288. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  5289. );
  5290. }
  5291. break;
  5292. }
  5293. }
  5294. });
  5295. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5296. "use strict";
  5297. var oop = require("./lib/oop");
  5298. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5299. var Anchor = exports.Anchor = function(doc, row, column) {
  5300. this.$onChange = this.onChange.bind(this);
  5301. this.attach(doc);
  5302. if (typeof column == "undefined")
  5303. this.setPosition(row.row, row.column);
  5304. else
  5305. this.setPosition(row, column);
  5306. };
  5307. (function() {
  5308. oop.implement(this, EventEmitter);
  5309. this.getPosition = function() {
  5310. return this.$clipPositionToDocument(this.row, this.column);
  5311. };
  5312. this.getDocument = function() {
  5313. return this.document;
  5314. };
  5315. this.$insertRight = false;
  5316. this.onChange = function(delta) {
  5317. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  5318. return;
  5319. if (delta.start.row > this.row)
  5320. return;
  5321. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  5322. this.setPosition(point.row, point.column, true);
  5323. };
  5324. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  5325. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  5326. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  5327. }
  5328. function $getTransformedPoint(delta, point, moveIfEqual) {
  5329. var deltaIsInsert = delta.action == "insert";
  5330. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  5331. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  5332. var deltaStart = delta.start;
  5333. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  5334. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  5335. return {
  5336. row: point.row,
  5337. column: point.column
  5338. };
  5339. }
  5340. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  5341. return {
  5342. row: point.row + deltaRowShift,
  5343. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  5344. };
  5345. }
  5346. return {
  5347. row: deltaStart.row,
  5348. column: deltaStart.column
  5349. };
  5350. }
  5351. this.setPosition = function(row, column, noClip) {
  5352. var pos;
  5353. if (noClip) {
  5354. pos = {
  5355. row: row,
  5356. column: column
  5357. };
  5358. } else {
  5359. pos = this.$clipPositionToDocument(row, column);
  5360. }
  5361. if (this.row == pos.row && this.column == pos.column)
  5362. return;
  5363. var old = {
  5364. row: this.row,
  5365. column: this.column
  5366. };
  5367. this.row = pos.row;
  5368. this.column = pos.column;
  5369. this._signal("change", {
  5370. old: old,
  5371. value: pos
  5372. });
  5373. };
  5374. this.detach = function() {
  5375. this.document.removeEventListener("change", this.$onChange);
  5376. };
  5377. this.attach = function(doc) {
  5378. this.document = doc || this.document;
  5379. this.document.on("change", this.$onChange);
  5380. };
  5381. this.$clipPositionToDocument = function(row, column) {
  5382. var pos = {};
  5383. if (row >= this.document.getLength()) {
  5384. pos.row = Math.max(0, this.document.getLength() - 1);
  5385. pos.column = this.document.getLine(pos.row).length;
  5386. }
  5387. else if (row < 0) {
  5388. pos.row = 0;
  5389. pos.column = 0;
  5390. }
  5391. else {
  5392. pos.row = row;
  5393. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5394. }
  5395. if (column < 0)
  5396. pos.column = 0;
  5397. return pos;
  5398. };
  5399. }).call(Anchor.prototype);
  5400. });
  5401. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5402. "use strict";
  5403. var oop = require("./lib/oop");
  5404. var applyDelta = require("./apply_delta").applyDelta;
  5405. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5406. var Range = require("./range").Range;
  5407. var Anchor = require("./anchor").Anchor;
  5408. var Document = function(textOrLines) {
  5409. this.$lines = [""];
  5410. if (textOrLines.length === 0) {
  5411. this.$lines = [""];
  5412. } else if (Array.isArray(textOrLines)) {
  5413. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  5414. } else {
  5415. this.insert({row: 0, column:0}, textOrLines);
  5416. }
  5417. };
  5418. (function() {
  5419. oop.implement(this, EventEmitter);
  5420. this.setValue = function(text) {
  5421. var len = this.getLength() - 1;
  5422. this.remove(new Range(0, 0, len, this.getLine(len).length));
  5423. this.insert({row: 0, column: 0}, text);
  5424. };
  5425. this.getValue = function() {
  5426. return this.getAllLines().join(this.getNewLineCharacter());
  5427. };
  5428. this.createAnchor = function(row, column) {
  5429. return new Anchor(this, row, column);
  5430. };
  5431. if ("aaa".split(/a/).length === 0) {
  5432. this.$split = function(text) {
  5433. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5434. };
  5435. } else {
  5436. this.$split = function(text) {
  5437. return text.split(/\r\n|\r|\n/);
  5438. };
  5439. }
  5440. this.$detectNewLine = function(text) {
  5441. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5442. this.$autoNewLine = match ? match[1] : "\n";
  5443. this._signal("changeNewLineMode");
  5444. };
  5445. this.getNewLineCharacter = function() {
  5446. switch (this.$newLineMode) {
  5447. case "windows":
  5448. return "\r\n";
  5449. case "unix":
  5450. return "\n";
  5451. default:
  5452. return this.$autoNewLine || "\n";
  5453. }
  5454. };
  5455. this.$autoNewLine = "";
  5456. this.$newLineMode = "auto";
  5457. this.setNewLineMode = function(newLineMode) {
  5458. if (this.$newLineMode === newLineMode)
  5459. return;
  5460. this.$newLineMode = newLineMode;
  5461. this._signal("changeNewLineMode");
  5462. };
  5463. this.getNewLineMode = function() {
  5464. return this.$newLineMode;
  5465. };
  5466. this.isNewLine = function(text) {
  5467. return (text == "\r\n" || text == "\r" || text == "\n");
  5468. };
  5469. this.getLine = function(row) {
  5470. return this.$lines[row] || "";
  5471. };
  5472. this.getLines = function(firstRow, lastRow) {
  5473. return this.$lines.slice(firstRow, lastRow + 1);
  5474. };
  5475. this.getAllLines = function() {
  5476. return this.getLines(0, this.getLength());
  5477. };
  5478. this.getLength = function() {
  5479. return this.$lines.length;
  5480. };
  5481. this.getTextRange = function(range) {
  5482. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  5483. };
  5484. this.getLinesForRange = function(range) {
  5485. var lines;
  5486. if (range.start.row === range.end.row) {
  5487. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  5488. } else {
  5489. lines = this.getLines(range.start.row, range.end.row);
  5490. lines[0] = (lines[0] || "").substring(range.start.column);
  5491. var l = lines.length - 1;
  5492. if (range.end.row - range.start.row == l)
  5493. lines[l] = lines[l].substring(0, range.end.column);
  5494. }
  5495. return lines;
  5496. };
  5497. this.insertLines = function(row, lines) {
  5498. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  5499. return this.insertFullLines(row, lines);
  5500. };
  5501. this.removeLines = function(firstRow, lastRow) {
  5502. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  5503. return this.removeFullLines(firstRow, lastRow);
  5504. };
  5505. this.insertNewLine = function(position) {
  5506. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
  5507. return this.insertMergedLines(position, ["", ""]);
  5508. };
  5509. this.insert = function(position, text) {
  5510. if (this.getLength() <= 1)
  5511. this.$detectNewLine(text);
  5512. return this.insertMergedLines(position, this.$split(text));
  5513. };
  5514. this.insertInLine = function(position, text) {
  5515. var start = this.clippedPos(position.row, position.column);
  5516. var end = this.pos(position.row, position.column + text.length);
  5517. this.applyDelta({
  5518. start: start,
  5519. end: end,
  5520. action: "insert",
  5521. lines: [text]
  5522. }, true);
  5523. return this.clonePos(end);
  5524. };
  5525. this.clippedPos = function(row, column) {
  5526. var length = this.getLength();
  5527. if (row === undefined) {
  5528. row = length;
  5529. } else if (row < 0) {
  5530. row = 0;
  5531. } else if (row >= length) {
  5532. row = length - 1;
  5533. column = undefined;
  5534. }
  5535. var line = this.getLine(row);
  5536. if (column == undefined)
  5537. column = line.length;
  5538. column = Math.min(Math.max(column, 0), line.length);
  5539. return {row: row, column: column};
  5540. };
  5541. this.clonePos = function(pos) {
  5542. return {row: pos.row, column: pos.column};
  5543. };
  5544. this.pos = function(row, column) {
  5545. return {row: row, column: column};
  5546. };
  5547. this.$clipPosition = function(position) {
  5548. var length = this.getLength();
  5549. if (position.row >= length) {
  5550. position.row = Math.max(0, length - 1);
  5551. position.column = this.getLine(length - 1).length;
  5552. } else {
  5553. position.row = Math.max(0, position.row);
  5554. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  5555. }
  5556. return position;
  5557. };
  5558. this.insertFullLines = function(row, lines) {
  5559. row = Math.min(Math.max(row, 0), this.getLength());
  5560. var column = 0;
  5561. if (row < this.getLength()) {
  5562. lines = lines.concat([""]);
  5563. column = 0;
  5564. } else {
  5565. lines = [""].concat(lines);
  5566. row--;
  5567. column = this.$lines[row].length;
  5568. }
  5569. this.insertMergedLines({row: row, column: column}, lines);
  5570. };
  5571. this.insertMergedLines = function(position, lines) {
  5572. var start = this.clippedPos(position.row, position.column);
  5573. var end = {
  5574. row: start.row + lines.length - 1,
  5575. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  5576. };
  5577. this.applyDelta({
  5578. start: start,
  5579. end: end,
  5580. action: "insert",
  5581. lines: lines
  5582. });
  5583. return this.clonePos(end);
  5584. };
  5585. this.remove = function(range) {
  5586. var start = this.clippedPos(range.start.row, range.start.column);
  5587. var end = this.clippedPos(range.end.row, range.end.column);
  5588. this.applyDelta({
  5589. start: start,
  5590. end: end,
  5591. action: "remove",
  5592. lines: this.getLinesForRange({start: start, end: end})
  5593. });
  5594. return this.clonePos(start);
  5595. };
  5596. this.removeInLine = function(row, startColumn, endColumn) {
  5597. var start = this.clippedPos(row, startColumn);
  5598. var end = this.clippedPos(row, endColumn);
  5599. this.applyDelta({
  5600. start: start,
  5601. end: end,
  5602. action: "remove",
  5603. lines: this.getLinesForRange({start: start, end: end})
  5604. }, true);
  5605. return this.clonePos(start);
  5606. };
  5607. this.removeFullLines = function(firstRow, lastRow) {
  5608. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  5609. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  5610. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  5611. var deleteLastNewLine = lastRow < this.getLength() - 1;
  5612. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  5613. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  5614. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  5615. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  5616. var range = new Range(startRow, startCol, endRow, endCol);
  5617. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  5618. this.applyDelta({
  5619. start: range.start,
  5620. end: range.end,
  5621. action: "remove",
  5622. lines: this.getLinesForRange(range)
  5623. });
  5624. return deletedLines;
  5625. };
  5626. this.removeNewLine = function(row) {
  5627. if (row < this.getLength() - 1 && row >= 0) {
  5628. this.applyDelta({
  5629. start: this.pos(row, this.getLine(row).length),
  5630. end: this.pos(row + 1, 0),
  5631. action: "remove",
  5632. lines: ["", ""]
  5633. });
  5634. }
  5635. };
  5636. this.replace = function(range, text) {
  5637. if (!range instanceof Range)
  5638. range = Range.fromPoints(range.start, range.end);
  5639. if (text.length === 0 && range.isEmpty())
  5640. return range.start;
  5641. if (text == this.getTextRange(range))
  5642. return range.end;
  5643. this.remove(range);
  5644. var end;
  5645. if (text) {
  5646. end = this.insert(range.start, text);
  5647. }
  5648. else {
  5649. end = range.start;
  5650. }
  5651. return end;
  5652. };
  5653. this.applyDeltas = function(deltas) {
  5654. for (var i=0; i<deltas.length; i++) {
  5655. this.applyDelta(deltas[i]);
  5656. }
  5657. };
  5658. this.revertDeltas = function(deltas) {
  5659. for (var i=deltas.length-1; i>=0; i--) {
  5660. this.revertDelta(deltas[i]);
  5661. }
  5662. };
  5663. this.applyDelta = function(delta, doNotValidate) {
  5664. var isInsert = delta.action == "insert";
  5665. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  5666. : !Range.comparePoints(delta.start, delta.end)) {
  5667. return;
  5668. }
  5669. if (isInsert && delta.lines.length > 20000)
  5670. this.$splitAndapplyLargeDelta(delta, 20000);
  5671. applyDelta(this.$lines, delta, doNotValidate);
  5672. this._signal("change", delta);
  5673. };
  5674. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  5675. var lines = delta.lines;
  5676. var l = lines.length;
  5677. var row = delta.start.row;
  5678. var column = delta.start.column;
  5679. var from = 0, to = 0;
  5680. do {
  5681. from = to;
  5682. to += MAX - 1;
  5683. var chunk = lines.slice(from, to);
  5684. if (to > l) {
  5685. delta.lines = chunk;
  5686. delta.start.row = row + from;
  5687. delta.start.column = column;
  5688. break;
  5689. }
  5690. chunk.push("");
  5691. this.applyDelta({
  5692. start: this.pos(row + from, column),
  5693. end: this.pos(row + to, column = 0),
  5694. action: delta.action,
  5695. lines: chunk
  5696. }, true);
  5697. } while(true);
  5698. };
  5699. this.revertDelta = function(delta) {
  5700. this.applyDelta({
  5701. start: this.clonePos(delta.start),
  5702. end: this.clonePos(delta.end),
  5703. action: (delta.action == "insert" ? "remove" : "insert"),
  5704. lines: delta.lines.slice()
  5705. });
  5706. };
  5707. this.indexToPosition = function(index, startRow) {
  5708. var lines = this.$lines || this.getAllLines();
  5709. var newlineLength = this.getNewLineCharacter().length;
  5710. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5711. index -= lines[i].length + newlineLength;
  5712. if (index < 0)
  5713. return {row: i, column: index + lines[i].length + newlineLength};
  5714. }
  5715. return {row: l-1, column: lines[l-1].length};
  5716. };
  5717. this.positionToIndex = function(pos, startRow) {
  5718. var lines = this.$lines || this.getAllLines();
  5719. var newlineLength = this.getNewLineCharacter().length;
  5720. var index = 0;
  5721. var row = Math.min(pos.row, lines.length);
  5722. for (var i = startRow || 0; i < row; ++i)
  5723. index += lines[i].length + newlineLength;
  5724. return index + pos.column;
  5725. };
  5726. }).call(Document.prototype);
  5727. exports.Document = Document;
  5728. });
  5729. ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5730. "use strict";
  5731. var oop = require("./lib/oop");
  5732. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5733. var BackgroundTokenizer = function(tokenizer, editor) {
  5734. this.running = false;
  5735. this.lines = [];
  5736. this.states = [];
  5737. this.currentLine = 0;
  5738. this.tokenizer = tokenizer;
  5739. var self = this;
  5740. this.$worker = function() {
  5741. if (!self.running) { return; }
  5742. var workerStart = new Date();
  5743. var currentLine = self.currentLine;
  5744. var endLine = -1;
  5745. var doc = self.doc;
  5746. var startLine = currentLine;
  5747. while (self.lines[currentLine])
  5748. currentLine++;
  5749. var len = doc.getLength();
  5750. var processedLines = 0;
  5751. self.running = false;
  5752. while (currentLine < len) {
  5753. self.$tokenizeRow(currentLine);
  5754. endLine = currentLine;
  5755. do {
  5756. currentLine++;
  5757. } while (self.lines[currentLine]);
  5758. processedLines ++;
  5759. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5760. self.running = setTimeout(self.$worker, 20);
  5761. break;
  5762. }
  5763. }
  5764. self.currentLine = currentLine;
  5765. if (startLine <= endLine)
  5766. self.fireUpdateEvent(startLine, endLine);
  5767. };
  5768. };
  5769. (function(){
  5770. oop.implement(this, EventEmitter);
  5771. this.setTokenizer = function(tokenizer) {
  5772. this.tokenizer = tokenizer;
  5773. this.lines = [];
  5774. this.states = [];
  5775. this.start(0);
  5776. };
  5777. this.setDocument = function(doc) {
  5778. this.doc = doc;
  5779. this.lines = [];
  5780. this.states = [];
  5781. this.stop();
  5782. };
  5783. this.fireUpdateEvent = function(firstRow, lastRow) {
  5784. var data = {
  5785. first: firstRow,
  5786. last: lastRow
  5787. };
  5788. this._signal("update", {data: data});
  5789. };
  5790. this.start = function(startRow) {
  5791. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5792. this.lines.splice(this.currentLine, this.lines.length);
  5793. this.states.splice(this.currentLine, this.states.length);
  5794. this.stop();
  5795. this.running = setTimeout(this.$worker, 700);
  5796. };
  5797. this.scheduleStart = function() {
  5798. if (!this.running)
  5799. this.running = setTimeout(this.$worker, 700);
  5800. }
  5801. this.$updateOnChange = function(delta) {
  5802. var startRow = delta.start.row;
  5803. var len = delta.end.row - startRow;
  5804. if (len === 0) {
  5805. this.lines[startRow] = null;
  5806. } else if (delta.action == "remove") {
  5807. this.lines.splice(startRow, len + 1, null);
  5808. this.states.splice(startRow, len + 1, null);
  5809. } else {
  5810. var args = Array(len + 1);
  5811. args.unshift(startRow, 1);
  5812. this.lines.splice.apply(this.lines, args);
  5813. this.states.splice.apply(this.states, args);
  5814. }
  5815. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5816. this.stop();
  5817. };
  5818. this.stop = function() {
  5819. if (this.running)
  5820. clearTimeout(this.running);
  5821. this.running = false;
  5822. };
  5823. this.getTokens = function(row) {
  5824. return this.lines[row] || this.$tokenizeRow(row);
  5825. };
  5826. this.getState = function(row) {
  5827. if (this.currentLine == row)
  5828. this.$tokenizeRow(row);
  5829. return this.states[row] || "start";
  5830. };
  5831. this.$tokenizeRow = function(row) {
  5832. var line = this.doc.getLine(row);
  5833. var state = this.states[row - 1];
  5834. var data = this.tokenizer.getLineTokens(line, state, row);
  5835. if (this.states[row] + "" !== data.state + "") {
  5836. this.states[row] = data.state;
  5837. this.lines[row + 1] = null;
  5838. if (this.currentLine > row + 1)
  5839. this.currentLine = row + 1;
  5840. } else if (this.currentLine == row) {
  5841. this.currentLine = row + 1;
  5842. }
  5843. return this.lines[row] = data.tokens;
  5844. };
  5845. }).call(BackgroundTokenizer.prototype);
  5846. exports.BackgroundTokenizer = BackgroundTokenizer;
  5847. });
  5848. ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5849. "use strict";
  5850. var lang = require("./lib/lang");
  5851. var oop = require("./lib/oop");
  5852. var Range = require("./range").Range;
  5853. var SearchHighlight = function(regExp, clazz, type) {
  5854. this.setRegexp(regExp);
  5855. this.clazz = clazz;
  5856. this.type = type || "text";
  5857. };
  5858. (function() {
  5859. this.MAX_RANGES = 500;
  5860. this.setRegexp = function(regExp) {
  5861. if (this.regExp+"" == regExp+"")
  5862. return;
  5863. this.regExp = regExp;
  5864. this.cache = [];
  5865. };
  5866. this.update = function(html, markerLayer, session, config) {
  5867. if (!this.regExp)
  5868. return;
  5869. var start = config.firstRow, end = config.lastRow;
  5870. for (var i = start; i <= end; i++) {
  5871. var ranges = this.cache[i];
  5872. if (ranges == null) {
  5873. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5874. if (ranges.length > this.MAX_RANGES)
  5875. ranges = ranges.slice(0, this.MAX_RANGES);
  5876. ranges = ranges.map(function(match) {
  5877. return new Range(i, match.offset, i, match.offset + match.length);
  5878. });
  5879. this.cache[i] = ranges.length ? ranges : "";
  5880. }
  5881. for (var j = ranges.length; j --; ) {
  5882. markerLayer.drawSingleLineMarker(
  5883. html, ranges[j].toScreenRange(session), this.clazz, config);
  5884. }
  5885. }
  5886. };
  5887. }).call(SearchHighlight.prototype);
  5888. exports.SearchHighlight = SearchHighlight;
  5889. });
  5890. ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5891. "use strict";
  5892. var Range = require("../range").Range;
  5893. function FoldLine(foldData, folds) {
  5894. this.foldData = foldData;
  5895. if (Array.isArray(folds)) {
  5896. this.folds = folds;
  5897. } else {
  5898. folds = this.folds = [ folds ];
  5899. }
  5900. var last = folds[folds.length - 1];
  5901. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5902. last.end.row, last.end.column);
  5903. this.start = this.range.start;
  5904. this.end = this.range.end;
  5905. this.folds.forEach(function(fold) {
  5906. fold.setFoldLine(this);
  5907. }, this);
  5908. }
  5909. (function() {
  5910. this.shiftRow = function(shift) {
  5911. this.start.row += shift;
  5912. this.end.row += shift;
  5913. this.folds.forEach(function(fold) {
  5914. fold.start.row += shift;
  5915. fold.end.row += shift;
  5916. });
  5917. };
  5918. this.addFold = function(fold) {
  5919. if (fold.sameRow) {
  5920. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5921. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5922. }
  5923. this.folds.push(fold);
  5924. this.folds.sort(function(a, b) {
  5925. return -a.range.compareEnd(b.start.row, b.start.column);
  5926. });
  5927. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5928. this.end.row = fold.end.row;
  5929. this.end.column = fold.end.column;
  5930. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5931. this.start.row = fold.start.row;
  5932. this.start.column = fold.start.column;
  5933. }
  5934. } else if (fold.start.row == this.end.row) {
  5935. this.folds.push(fold);
  5936. this.end.row = fold.end.row;
  5937. this.end.column = fold.end.column;
  5938. } else if (fold.end.row == this.start.row) {
  5939. this.folds.unshift(fold);
  5940. this.start.row = fold.start.row;
  5941. this.start.column = fold.start.column;
  5942. } else {
  5943. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5944. }
  5945. fold.foldLine = this;
  5946. };
  5947. this.containsRow = function(row) {
  5948. return row >= this.start.row && row <= this.end.row;
  5949. };
  5950. this.walk = function(callback, endRow, endColumn) {
  5951. var lastEnd = 0,
  5952. folds = this.folds,
  5953. fold,
  5954. cmp, stop, isNewRow = true;
  5955. if (endRow == null) {
  5956. endRow = this.end.row;
  5957. endColumn = this.end.column;
  5958. }
  5959. for (var i = 0; i < folds.length; i++) {
  5960. fold = folds[i];
  5961. cmp = fold.range.compareStart(endRow, endColumn);
  5962. if (cmp == -1) {
  5963. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5964. return;
  5965. }
  5966. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  5967. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  5968. if (stop || cmp === 0) {
  5969. return;
  5970. }
  5971. isNewRow = !fold.sameRow;
  5972. lastEnd = fold.end.column;
  5973. }
  5974. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5975. };
  5976. this.getNextFoldTo = function(row, column) {
  5977. var fold, cmp;
  5978. for (var i = 0; i < this.folds.length; i++) {
  5979. fold = this.folds[i];
  5980. cmp = fold.range.compareEnd(row, column);
  5981. if (cmp == -1) {
  5982. return {
  5983. fold: fold,
  5984. kind: "after"
  5985. };
  5986. } else if (cmp === 0) {
  5987. return {
  5988. fold: fold,
  5989. kind: "inside"
  5990. };
  5991. }
  5992. }
  5993. return null;
  5994. };
  5995. this.addRemoveChars = function(row, column, len) {
  5996. var ret = this.getNextFoldTo(row, column),
  5997. fold, folds;
  5998. if (ret) {
  5999. fold = ret.fold;
  6000. if (ret.kind == "inside"
  6001. && fold.start.column != column
  6002. && fold.start.row != row)
  6003. {
  6004. window.console && window.console.log(row, column, fold);
  6005. } else if (fold.start.row == row) {
  6006. folds = this.folds;
  6007. var i = folds.indexOf(fold);
  6008. if (i === 0) {
  6009. this.start.column += len;
  6010. }
  6011. for (i; i < folds.length; i++) {
  6012. fold = folds[i];
  6013. fold.start.column += len;
  6014. if (!fold.sameRow) {
  6015. return;
  6016. }
  6017. fold.end.column += len;
  6018. }
  6019. this.end.column += len;
  6020. }
  6021. }
  6022. };
  6023. this.split = function(row, column) {
  6024. var pos = this.getNextFoldTo(row, column);
  6025. if (!pos || pos.kind == "inside")
  6026. return null;
  6027. var fold = pos.fold;
  6028. var folds = this.folds;
  6029. var foldData = this.foldData;
  6030. var i = folds.indexOf(fold);
  6031. var foldBefore = folds[i - 1];
  6032. this.end.row = foldBefore.end.row;
  6033. this.end.column = foldBefore.end.column;
  6034. folds = folds.splice(i, folds.length - i);
  6035. var newFoldLine = new FoldLine(foldData, folds);
  6036. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  6037. return newFoldLine;
  6038. };
  6039. this.merge = function(foldLineNext) {
  6040. var folds = foldLineNext.folds;
  6041. for (var i = 0; i < folds.length; i++) {
  6042. this.addFold(folds[i]);
  6043. }
  6044. var foldData = this.foldData;
  6045. foldData.splice(foldData.indexOf(foldLineNext), 1);
  6046. };
  6047. this.toString = function() {
  6048. var ret = [this.range.toString() + ": [" ];
  6049. this.folds.forEach(function(fold) {
  6050. ret.push(" " + fold.toString());
  6051. });
  6052. ret.push("]");
  6053. return ret.join("\n");
  6054. };
  6055. this.idxToPosition = function(idx) {
  6056. var lastFoldEndColumn = 0;
  6057. for (var i = 0; i < this.folds.length; i++) {
  6058. var fold = this.folds[i];
  6059. idx -= fold.start.column - lastFoldEndColumn;
  6060. if (idx < 0) {
  6061. return {
  6062. row: fold.start.row,
  6063. column: fold.start.column + idx
  6064. };
  6065. }
  6066. idx -= fold.placeholder.length;
  6067. if (idx < 0) {
  6068. return fold.start;
  6069. }
  6070. lastFoldEndColumn = fold.end.column;
  6071. }
  6072. return {
  6073. row: this.end.row,
  6074. column: this.end.column + idx
  6075. };
  6076. };
  6077. }).call(FoldLine.prototype);
  6078. exports.FoldLine = FoldLine;
  6079. });
  6080. ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  6081. "use strict";
  6082. var Range = require("./range").Range;
  6083. var comparePoints = Range.comparePoints;
  6084. var RangeList = function() {
  6085. this.ranges = [];
  6086. };
  6087. (function() {
  6088. this.comparePoints = comparePoints;
  6089. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6090. var list = this.ranges;
  6091. for (var i = startIndex || 0; i < list.length; i++) {
  6092. var range = list[i];
  6093. var cmpEnd = comparePoints(pos, range.end);
  6094. if (cmpEnd > 0)
  6095. continue;
  6096. var cmpStart = comparePoints(pos, range.start);
  6097. if (cmpEnd === 0)
  6098. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6099. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6100. return i;
  6101. return -i-1;
  6102. }
  6103. return -i - 1;
  6104. };
  6105. this.add = function(range) {
  6106. var excludeEdges = !range.isEmpty();
  6107. var startIndex = this.pointIndex(range.start, excludeEdges);
  6108. if (startIndex < 0)
  6109. startIndex = -startIndex - 1;
  6110. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6111. if (endIndex < 0)
  6112. endIndex = -endIndex - 1;
  6113. else
  6114. endIndex++;
  6115. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6116. };
  6117. this.addList = function(list) {
  6118. var removed = [];
  6119. for (var i = list.length; i--; ) {
  6120. removed.push.call(removed, this.add(list[i]));
  6121. }
  6122. return removed;
  6123. };
  6124. this.substractPoint = function(pos) {
  6125. var i = this.pointIndex(pos);
  6126. if (i >= 0)
  6127. return this.ranges.splice(i, 1);
  6128. };
  6129. this.merge = function() {
  6130. var removed = [];
  6131. var list = this.ranges;
  6132. list = list.sort(function(a, b) {
  6133. return comparePoints(a.start, b.start);
  6134. });
  6135. var next = list[0], range;
  6136. for (var i = 1; i < list.length; i++) {
  6137. range = next;
  6138. next = list[i];
  6139. var cmp = comparePoints(range.end, next.start);
  6140. if (cmp < 0)
  6141. continue;
  6142. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6143. continue;
  6144. if (comparePoints(range.end, next.end) < 0) {
  6145. range.end.row = next.end.row;
  6146. range.end.column = next.end.column;
  6147. }
  6148. list.splice(i, 1);
  6149. removed.push(next);
  6150. next = range;
  6151. i--;
  6152. }
  6153. this.ranges = list;
  6154. return removed;
  6155. };
  6156. this.contains = function(row, column) {
  6157. return this.pointIndex({row: row, column: column}) >= 0;
  6158. };
  6159. this.containsPoint = function(pos) {
  6160. return this.pointIndex(pos) >= 0;
  6161. };
  6162. this.rangeAtPoint = function(pos) {
  6163. var i = this.pointIndex(pos);
  6164. if (i >= 0)
  6165. return this.ranges[i];
  6166. };
  6167. this.clipRows = function(startRow, endRow) {
  6168. var list = this.ranges;
  6169. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6170. return [];
  6171. var startIndex = this.pointIndex({row: startRow, column: 0});
  6172. if (startIndex < 0)
  6173. startIndex = -startIndex - 1;
  6174. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6175. if (endIndex < 0)
  6176. endIndex = -endIndex - 1;
  6177. var clipped = [];
  6178. for (var i = startIndex; i < endIndex; i++) {
  6179. clipped.push(list[i]);
  6180. }
  6181. return clipped;
  6182. };
  6183. this.removeAll = function() {
  6184. return this.ranges.splice(0, this.ranges.length);
  6185. };
  6186. this.attach = function(session) {
  6187. if (this.session)
  6188. this.detach();
  6189. this.session = session;
  6190. this.onChange = this.$onChange.bind(this);
  6191. this.session.on('change', this.onChange);
  6192. };
  6193. this.detach = function() {
  6194. if (!this.session)
  6195. return;
  6196. this.session.removeListener('change', this.onChange);
  6197. this.session = null;
  6198. };
  6199. this.$onChange = function(delta) {
  6200. if (delta.action == "insert"){
  6201. var start = delta.start;
  6202. var end = delta.end;
  6203. } else {
  6204. var end = delta.start;
  6205. var start = delta.end;
  6206. }
  6207. var startRow = start.row;
  6208. var endRow = end.row;
  6209. var lineDif = endRow - startRow;
  6210. var colDiff = -start.column + end.column;
  6211. var ranges = this.ranges;
  6212. for (var i = 0, n = ranges.length; i < n; i++) {
  6213. var r = ranges[i];
  6214. if (r.end.row < startRow)
  6215. continue;
  6216. if (r.start.row > startRow)
  6217. break;
  6218. if (r.start.row == startRow && r.start.column >= start.column ) {
  6219. if (r.start.column == start.column && this.$insertRight) {
  6220. } else {
  6221. r.start.column += colDiff;
  6222. r.start.row += lineDif;
  6223. }
  6224. }
  6225. if (r.end.row == startRow && r.end.column >= start.column) {
  6226. if (r.end.column == start.column && this.$insertRight) {
  6227. continue;
  6228. }
  6229. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6230. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6231. r.end.column -= colDiff;
  6232. }
  6233. r.end.column += colDiff;
  6234. r.end.row += lineDif;
  6235. }
  6236. }
  6237. if (lineDif != 0 && i < n) {
  6238. for (; i < n; i++) {
  6239. var r = ranges[i];
  6240. r.start.row += lineDif;
  6241. r.end.row += lineDif;
  6242. }
  6243. }
  6244. };
  6245. }).call(RangeList.prototype);
  6246. exports.RangeList = RangeList;
  6247. });
  6248. ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6249. "use strict";
  6250. var Range = require("../range").Range;
  6251. var RangeList = require("../range_list").RangeList;
  6252. var oop = require("../lib/oop")
  6253. var Fold = exports.Fold = function(range, placeholder) {
  6254. this.foldLine = null;
  6255. this.placeholder = placeholder;
  6256. this.range = range;
  6257. this.start = range.start;
  6258. this.end = range.end;
  6259. this.sameRow = range.start.row == range.end.row;
  6260. this.subFolds = this.ranges = [];
  6261. };
  6262. oop.inherits(Fold, RangeList);
  6263. (function() {
  6264. this.toString = function() {
  6265. return '"' + this.placeholder + '" ' + this.range.toString();
  6266. };
  6267. this.setFoldLine = function(foldLine) {
  6268. this.foldLine = foldLine;
  6269. this.subFolds.forEach(function(fold) {
  6270. fold.setFoldLine(foldLine);
  6271. });
  6272. };
  6273. this.clone = function() {
  6274. var range = this.range.clone();
  6275. var fold = new Fold(range, this.placeholder);
  6276. this.subFolds.forEach(function(subFold) {
  6277. fold.subFolds.push(subFold.clone());
  6278. });
  6279. fold.collapseChildren = this.collapseChildren;
  6280. return fold;
  6281. };
  6282. this.addSubFold = function(fold) {
  6283. if (this.range.isEqual(fold))
  6284. return;
  6285. if (!this.range.containsRange(fold))
  6286. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6287. consumeRange(fold, this.start);
  6288. var row = fold.start.row, column = fold.start.column;
  6289. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6290. cmp = this.subFolds[i].range.compare(row, column);
  6291. if (cmp != 1)
  6292. break;
  6293. }
  6294. var afterStart = this.subFolds[i];
  6295. if (cmp == 0)
  6296. return afterStart.addSubFold(fold);
  6297. var row = fold.range.end.row, column = fold.range.end.column;
  6298. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6299. cmp = this.subFolds[j].range.compare(row, column);
  6300. if (cmp != 1)
  6301. break;
  6302. }
  6303. var afterEnd = this.subFolds[j];
  6304. if (cmp == 0)
  6305. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6306. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6307. fold.setFoldLine(this.foldLine);
  6308. return fold;
  6309. };
  6310. this.restoreRange = function(range) {
  6311. return restoreRange(range, this.start);
  6312. };
  6313. }).call(Fold.prototype);
  6314. function consumePoint(point, anchor) {
  6315. point.row -= anchor.row;
  6316. if (point.row == 0)
  6317. point.column -= anchor.column;
  6318. }
  6319. function consumeRange(range, anchor) {
  6320. consumePoint(range.start, anchor);
  6321. consumePoint(range.end, anchor);
  6322. }
  6323. function restorePoint(point, anchor) {
  6324. if (point.row == 0)
  6325. point.column += anchor.column;
  6326. point.row += anchor.row;
  6327. }
  6328. function restoreRange(range, anchor) {
  6329. restorePoint(range.start, anchor);
  6330. restorePoint(range.end, anchor);
  6331. }
  6332. });
  6333. ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"], function(require, exports, module) {
  6334. "use strict";
  6335. var Range = require("../range").Range;
  6336. var FoldLine = require("./fold_line").FoldLine;
  6337. var Fold = require("./fold").Fold;
  6338. var TokenIterator = require("../token_iterator").TokenIterator;
  6339. function Folding() {
  6340. this.getFoldAt = function(row, column, side) {
  6341. var foldLine = this.getFoldLine(row);
  6342. if (!foldLine)
  6343. return null;
  6344. var folds = foldLine.folds;
  6345. for (var i = 0; i < folds.length; i++) {
  6346. var fold = folds[i];
  6347. if (fold.range.contains(row, column)) {
  6348. if (side == 1 && fold.range.isEnd(row, column)) {
  6349. continue;
  6350. } else if (side == -1 && fold.range.isStart(row, column)) {
  6351. continue;
  6352. }
  6353. return fold;
  6354. }
  6355. }
  6356. };
  6357. this.getFoldsInRange = function(range) {
  6358. var start = range.start;
  6359. var end = range.end;
  6360. var foldLines = this.$foldData;
  6361. var foundFolds = [];
  6362. start.column += 1;
  6363. end.column -= 1;
  6364. for (var i = 0; i < foldLines.length; i++) {
  6365. var cmp = foldLines[i].range.compareRange(range);
  6366. if (cmp == 2) {
  6367. continue;
  6368. }
  6369. else if (cmp == -2) {
  6370. break;
  6371. }
  6372. var folds = foldLines[i].folds;
  6373. for (var j = 0; j < folds.length; j++) {
  6374. var fold = folds[j];
  6375. cmp = fold.range.compareRange(range);
  6376. if (cmp == -2) {
  6377. break;
  6378. } else if (cmp == 2) {
  6379. continue;
  6380. } else
  6381. if (cmp == 42) {
  6382. break;
  6383. }
  6384. foundFolds.push(fold);
  6385. }
  6386. }
  6387. start.column -= 1;
  6388. end.column += 1;
  6389. return foundFolds;
  6390. };
  6391. this.getFoldsInRangeList = function(ranges) {
  6392. if (Array.isArray(ranges)) {
  6393. var folds = [];
  6394. ranges.forEach(function(range) {
  6395. folds = folds.concat(this.getFoldsInRange(range));
  6396. }, this);
  6397. } else {
  6398. var folds = this.getFoldsInRange(ranges);
  6399. }
  6400. return folds;
  6401. }
  6402. this.getAllFolds = function() {
  6403. var folds = [];
  6404. var foldLines = this.$foldData;
  6405. for (var i = 0; i < foldLines.length; i++)
  6406. for (var j = 0; j < foldLines[i].folds.length; j++)
  6407. folds.push(foldLines[i].folds[j]);
  6408. return folds;
  6409. };
  6410. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6411. foldLine = foldLine || this.getFoldLine(row);
  6412. if (!foldLine)
  6413. return null;
  6414. var lastFold = {
  6415. end: { column: 0 }
  6416. };
  6417. var str, fold;
  6418. for (var i = 0; i < foldLine.folds.length; i++) {
  6419. fold = foldLine.folds[i];
  6420. var cmp = fold.range.compareEnd(row, column);
  6421. if (cmp == -1) {
  6422. str = this
  6423. .getLine(fold.start.row)
  6424. .substring(lastFold.end.column, fold.start.column);
  6425. break;
  6426. }
  6427. else if (cmp === 0) {
  6428. return null;
  6429. }
  6430. lastFold = fold;
  6431. }
  6432. if (!str)
  6433. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6434. if (trim == -1)
  6435. return str.substring(0, column - lastFold.end.column);
  6436. else if (trim == 1)
  6437. return str.substring(column - lastFold.end.column);
  6438. else
  6439. return str;
  6440. };
  6441. this.getFoldLine = function(docRow, startFoldLine) {
  6442. var foldData = this.$foldData;
  6443. var i = 0;
  6444. if (startFoldLine)
  6445. i = foldData.indexOf(startFoldLine);
  6446. if (i == -1)
  6447. i = 0;
  6448. for (i; i < foldData.length; i++) {
  6449. var foldLine = foldData[i];
  6450. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6451. return foldLine;
  6452. } else if (foldLine.end.row > docRow) {
  6453. return null;
  6454. }
  6455. }
  6456. return null;
  6457. };
  6458. this.getNextFoldLine = function(docRow, startFoldLine) {
  6459. var foldData = this.$foldData;
  6460. var i = 0;
  6461. if (startFoldLine)
  6462. i = foldData.indexOf(startFoldLine);
  6463. if (i == -1)
  6464. i = 0;
  6465. for (i; i < foldData.length; i++) {
  6466. var foldLine = foldData[i];
  6467. if (foldLine.end.row >= docRow) {
  6468. return foldLine;
  6469. }
  6470. }
  6471. return null;
  6472. };
  6473. this.getFoldedRowCount = function(first, last) {
  6474. var foldData = this.$foldData, rowCount = last-first+1;
  6475. for (var i = 0; i < foldData.length; i++) {
  6476. var foldLine = foldData[i],
  6477. end = foldLine.end.row,
  6478. start = foldLine.start.row;
  6479. if (end >= last) {
  6480. if(start < last) {
  6481. if(start >= first)
  6482. rowCount -= last-start;
  6483. else
  6484. rowCount = 0;//in one fold
  6485. }
  6486. break;
  6487. } else if(end >= first){
  6488. if (start >= first) //fold inside range
  6489. rowCount -= end-start;
  6490. else
  6491. rowCount -= end-first+1;
  6492. }
  6493. }
  6494. return rowCount;
  6495. };
  6496. this.$addFoldLine = function(foldLine) {
  6497. this.$foldData.push(foldLine);
  6498. this.$foldData.sort(function(a, b) {
  6499. return a.start.row - b.start.row;
  6500. });
  6501. return foldLine;
  6502. };
  6503. this.addFold = function(placeholder, range) {
  6504. var foldData = this.$foldData;
  6505. var added = false;
  6506. var fold;
  6507. if (placeholder instanceof Fold)
  6508. fold = placeholder;
  6509. else {
  6510. fold = new Fold(range, placeholder);
  6511. fold.collapseChildren = range.collapseChildren;
  6512. }
  6513. this.$clipRangeToDocument(fold.range);
  6514. var startRow = fold.start.row;
  6515. var startColumn = fold.start.column;
  6516. var endRow = fold.end.row;
  6517. var endColumn = fold.end.column;
  6518. if (!(startRow < endRow ||
  6519. startRow == endRow && startColumn <= endColumn - 2))
  6520. throw new Error("The range has to be at least 2 characters width");
  6521. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6522. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6523. if (startFold && endFold == startFold)
  6524. return startFold.addSubFold(fold);
  6525. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6526. this.removeFold(startFold);
  6527. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6528. this.removeFold(endFold);
  6529. var folds = this.getFoldsInRange(fold.range);
  6530. if (folds.length > 0) {
  6531. this.removeFolds(folds);
  6532. folds.forEach(function(subFold) {
  6533. fold.addSubFold(subFold);
  6534. });
  6535. }
  6536. for (var i = 0; i < foldData.length; i++) {
  6537. var foldLine = foldData[i];
  6538. if (endRow == foldLine.start.row) {
  6539. foldLine.addFold(fold);
  6540. added = true;
  6541. break;
  6542. } else if (startRow == foldLine.end.row) {
  6543. foldLine.addFold(fold);
  6544. added = true;
  6545. if (!fold.sameRow) {
  6546. var foldLineNext = foldData[i + 1];
  6547. if (foldLineNext && foldLineNext.start.row == endRow) {
  6548. foldLine.merge(foldLineNext);
  6549. break;
  6550. }
  6551. }
  6552. break;
  6553. } else if (endRow <= foldLine.start.row) {
  6554. break;
  6555. }
  6556. }
  6557. if (!added)
  6558. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6559. if (this.$useWrapMode)
  6560. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6561. else
  6562. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6563. this.$modified = true;
  6564. this._emit("changeFold", { data: fold, action: "add" });
  6565. return fold;
  6566. };
  6567. this.addFolds = function(folds) {
  6568. folds.forEach(function(fold) {
  6569. this.addFold(fold);
  6570. }, this);
  6571. };
  6572. this.removeFold = function(fold) {
  6573. var foldLine = fold.foldLine;
  6574. var startRow = foldLine.start.row;
  6575. var endRow = foldLine.end.row;
  6576. var foldLines = this.$foldData;
  6577. var folds = foldLine.folds;
  6578. if (folds.length == 1) {
  6579. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6580. } else
  6581. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6582. folds.pop();
  6583. foldLine.end.row = folds[folds.length - 1].end.row;
  6584. foldLine.end.column = folds[folds.length - 1].end.column;
  6585. } else
  6586. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6587. folds.shift();
  6588. foldLine.start.row = folds[0].start.row;
  6589. foldLine.start.column = folds[0].start.column;
  6590. } else
  6591. if (fold.sameRow) {
  6592. folds.splice(folds.indexOf(fold), 1);
  6593. } else
  6594. {
  6595. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6596. folds = newFoldLine.folds;
  6597. folds.shift();
  6598. newFoldLine.start.row = folds[0].start.row;
  6599. newFoldLine.start.column = folds[0].start.column;
  6600. }
  6601. if (!this.$updating) {
  6602. if (this.$useWrapMode)
  6603. this.$updateWrapData(startRow, endRow);
  6604. else
  6605. this.$updateRowLengthCache(startRow, endRow);
  6606. }
  6607. this.$modified = true;
  6608. this._emit("changeFold", { data: fold, action: "remove" });
  6609. };
  6610. this.removeFolds = function(folds) {
  6611. var cloneFolds = [];
  6612. for (var i = 0; i < folds.length; i++) {
  6613. cloneFolds.push(folds[i]);
  6614. }
  6615. cloneFolds.forEach(function(fold) {
  6616. this.removeFold(fold);
  6617. }, this);
  6618. this.$modified = true;
  6619. };
  6620. this.expandFold = function(fold) {
  6621. this.removeFold(fold);
  6622. fold.subFolds.forEach(function(subFold) {
  6623. fold.restoreRange(subFold);
  6624. this.addFold(subFold);
  6625. }, this);
  6626. if (fold.collapseChildren > 0) {
  6627. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6628. }
  6629. fold.subFolds = [];
  6630. };
  6631. this.expandFolds = function(folds) {
  6632. folds.forEach(function(fold) {
  6633. this.expandFold(fold);
  6634. }, this);
  6635. };
  6636. this.unfold = function(location, expandInner) {
  6637. var range, folds;
  6638. if (location == null) {
  6639. range = new Range(0, 0, this.getLength(), 0);
  6640. expandInner = true;
  6641. } else if (typeof location == "number")
  6642. range = new Range(location, 0, location, this.getLine(location).length);
  6643. else if ("row" in location)
  6644. range = Range.fromPoints(location, location);
  6645. else
  6646. range = location;
  6647. folds = this.getFoldsInRangeList(range);
  6648. if (expandInner) {
  6649. this.removeFolds(folds);
  6650. } else {
  6651. var subFolds = folds;
  6652. while (subFolds.length) {
  6653. this.expandFolds(subFolds);
  6654. subFolds = this.getFoldsInRangeList(range);
  6655. }
  6656. }
  6657. if (folds.length)
  6658. return folds;
  6659. };
  6660. this.isRowFolded = function(docRow, startFoldRow) {
  6661. return !!this.getFoldLine(docRow, startFoldRow);
  6662. };
  6663. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6664. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6665. return foldLine ? foldLine.end.row : docRow;
  6666. };
  6667. this.getRowFoldStart = function(docRow, startFoldRow) {
  6668. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6669. return foldLine ? foldLine.start.row : docRow;
  6670. };
  6671. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6672. if (startRow == null)
  6673. startRow = foldLine.start.row;
  6674. if (startColumn == null)
  6675. startColumn = 0;
  6676. if (endRow == null)
  6677. endRow = foldLine.end.row;
  6678. if (endColumn == null)
  6679. endColumn = this.getLine(endRow).length;
  6680. var doc = this.doc;
  6681. var textLine = "";
  6682. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6683. if (row < startRow)
  6684. return;
  6685. if (row == startRow) {
  6686. if (column < startColumn)
  6687. return;
  6688. lastColumn = Math.max(startColumn, lastColumn);
  6689. }
  6690. if (placeholder != null) {
  6691. textLine += placeholder;
  6692. } else {
  6693. textLine += doc.getLine(row).substring(lastColumn, column);
  6694. }
  6695. }, endRow, endColumn);
  6696. return textLine;
  6697. };
  6698. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6699. var foldLine = this.getFoldLine(row);
  6700. if (!foldLine) {
  6701. var line;
  6702. line = this.doc.getLine(row);
  6703. return line.substring(startColumn || 0, endColumn || line.length);
  6704. } else {
  6705. return this.getFoldDisplayLine(
  6706. foldLine, row, endColumn, startRow, startColumn);
  6707. }
  6708. };
  6709. this.$cloneFoldData = function() {
  6710. var fd = [];
  6711. fd = this.$foldData.map(function(foldLine) {
  6712. var folds = foldLine.folds.map(function(fold) {
  6713. return fold.clone();
  6714. });
  6715. return new FoldLine(fd, folds);
  6716. });
  6717. return fd;
  6718. };
  6719. this.toggleFold = function(tryToUnfold) {
  6720. var selection = this.selection;
  6721. var range = selection.getRange();
  6722. var fold;
  6723. var bracketPos;
  6724. if (range.isEmpty()) {
  6725. var cursor = range.start;
  6726. fold = this.getFoldAt(cursor.row, cursor.column);
  6727. if (fold) {
  6728. this.expandFold(fold);
  6729. return;
  6730. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6731. if (range.comparePoint(bracketPos) == 1) {
  6732. range.end = bracketPos;
  6733. } else {
  6734. range.start = bracketPos;
  6735. range.start.column++;
  6736. range.end.column--;
  6737. }
  6738. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6739. if (range.comparePoint(bracketPos) == 1)
  6740. range.end = bracketPos;
  6741. else
  6742. range.start = bracketPos;
  6743. range.start.column++;
  6744. } else {
  6745. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6746. }
  6747. } else {
  6748. var folds = this.getFoldsInRange(range);
  6749. if (tryToUnfold && folds.length) {
  6750. this.expandFolds(folds);
  6751. return;
  6752. } else if (folds.length == 1 ) {
  6753. fold = folds[0];
  6754. }
  6755. }
  6756. if (!fold)
  6757. fold = this.getFoldAt(range.start.row, range.start.column);
  6758. if (fold && fold.range.toString() == range.toString()) {
  6759. this.expandFold(fold);
  6760. return;
  6761. }
  6762. var placeholder = "...";
  6763. if (!range.isMultiLine()) {
  6764. placeholder = this.getTextRange(range);
  6765. if(placeholder.length < 4)
  6766. return;
  6767. placeholder = placeholder.trim().substring(0, 2) + "..";
  6768. }
  6769. this.addFold(placeholder, range);
  6770. };
  6771. this.getCommentFoldRange = function(row, column, dir) {
  6772. var iterator = new TokenIterator(this, row, column);
  6773. var token = iterator.getCurrentToken();
  6774. if (token && /^comment|string/.test(token.type)) {
  6775. var range = new Range();
  6776. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6777. if (dir != 1) {
  6778. do {
  6779. token = iterator.stepBackward();
  6780. } while(token && re.test(token.type));
  6781. iterator.stepForward();
  6782. }
  6783. range.start.row = iterator.getCurrentTokenRow();
  6784. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6785. iterator = new TokenIterator(this, row, column);
  6786. if (dir != -1) {
  6787. do {
  6788. token = iterator.stepForward();
  6789. } while(token && re.test(token.type));
  6790. token = iterator.stepBackward();
  6791. } else
  6792. token = iterator.getCurrentToken();
  6793. range.end.row = iterator.getCurrentTokenRow();
  6794. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6795. return range;
  6796. }
  6797. };
  6798. this.foldAll = function(startRow, endRow, depth) {
  6799. if (depth == undefined)
  6800. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6801. var foldWidgets = this.foldWidgets;
  6802. if (!foldWidgets)
  6803. return; // mode doesn't support folding
  6804. endRow = endRow || this.getLength();
  6805. startRow = startRow || 0;
  6806. for (var row = startRow; row < endRow; row++) {
  6807. if (foldWidgets[row] == null)
  6808. foldWidgets[row] = this.getFoldWidget(row);
  6809. if (foldWidgets[row] != "start")
  6810. continue;
  6811. var range = this.getFoldWidgetRange(row);
  6812. if (range && range.isMultiLine()
  6813. && range.end.row <= endRow
  6814. && range.start.row >= startRow
  6815. ) {
  6816. row = range.end.row;
  6817. try {
  6818. var fold = this.addFold("...", range);
  6819. if (fold)
  6820. fold.collapseChildren = depth;
  6821. } catch(e) {}
  6822. }
  6823. }
  6824. };
  6825. this.$foldStyles = {
  6826. "manual": 1,
  6827. "markbegin": 1,
  6828. "markbeginend": 1
  6829. };
  6830. this.$foldStyle = "markbegin";
  6831. this.setFoldStyle = function(style) {
  6832. if (!this.$foldStyles[style])
  6833. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6834. if (this.$foldStyle == style)
  6835. return;
  6836. this.$foldStyle = style;
  6837. if (style == "manual")
  6838. this.unfold();
  6839. var mode = this.$foldMode;
  6840. this.$setFolding(null);
  6841. this.$setFolding(mode);
  6842. };
  6843. this.$setFolding = function(foldMode) {
  6844. if (this.$foldMode == foldMode)
  6845. return;
  6846. this.$foldMode = foldMode;
  6847. this.off('change', this.$updateFoldWidgets);
  6848. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6849. this._emit("changeAnnotation");
  6850. if (!foldMode || this.$foldStyle == "manual") {
  6851. this.foldWidgets = null;
  6852. return;
  6853. }
  6854. this.foldWidgets = [];
  6855. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6856. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6857. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6858. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6859. this.on('change', this.$updateFoldWidgets);
  6860. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6861. };
  6862. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6863. var fw = this.foldWidgets;
  6864. if (!fw || (ignoreCurrent && fw[row]))
  6865. return {};
  6866. var i = row - 1, firstRange;
  6867. while (i >= 0) {
  6868. var c = fw[i];
  6869. if (c == null)
  6870. c = fw[i] = this.getFoldWidget(i);
  6871. if (c == "start") {
  6872. var range = this.getFoldWidgetRange(i);
  6873. if (!firstRange)
  6874. firstRange = range;
  6875. if (range && range.end.row >= row)
  6876. break;
  6877. }
  6878. i--;
  6879. }
  6880. return {
  6881. range: i !== -1 && range,
  6882. firstRange: firstRange
  6883. };
  6884. }
  6885. this.onFoldWidgetClick = function(row, e) {
  6886. e = e.domEvent;
  6887. var options = {
  6888. children: e.shiftKey,
  6889. all: e.ctrlKey || e.metaKey,
  6890. siblings: e.altKey
  6891. };
  6892. var range = this.$toggleFoldWidget(row, options);
  6893. if (!range) {
  6894. var el = (e.target || e.srcElement)
  6895. if (el && /ace_fold-widget/.test(el.className))
  6896. el.className += " ace_invalid";
  6897. }
  6898. };
  6899. this.$toggleFoldWidget = function(row, options) {
  6900. if (!this.getFoldWidget)
  6901. return;
  6902. var type = this.getFoldWidget(row);
  6903. var line = this.getLine(row);
  6904. var dir = type === "end" ? -1 : 1;
  6905. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6906. if (fold) {
  6907. if (options.children || options.all)
  6908. this.removeFold(fold);
  6909. else
  6910. this.expandFold(fold);
  6911. return;
  6912. }
  6913. var range = this.getFoldWidgetRange(row, true);
  6914. if (range && !range.isMultiLine()) {
  6915. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6916. if (fold && range.isEqual(fold.range)) {
  6917. this.removeFold(fold);
  6918. return;
  6919. }
  6920. }
  6921. if (options.siblings) {
  6922. var data = this.getParentFoldRangeData(row);
  6923. if (data.range) {
  6924. var startRow = data.range.start.row + 1;
  6925. var endRow = data.range.end.row;
  6926. }
  6927. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6928. } else if (options.children) {
  6929. endRow = range ? range.end.row : this.getLength();
  6930. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  6931. } else if (range) {
  6932. if (options.all)
  6933. range.collapseChildren = 10000;
  6934. this.addFold("...", range);
  6935. }
  6936. return range;
  6937. };
  6938. this.toggleFoldWidget = function(toggleParent) {
  6939. var row = this.selection.getCursor().row;
  6940. row = this.getRowFoldStart(row);
  6941. var range = this.$toggleFoldWidget(row, {});
  6942. if (range)
  6943. return;
  6944. var data = this.getParentFoldRangeData(row, true);
  6945. range = data.range || data.firstRange;
  6946. if (range) {
  6947. row = range.start.row;
  6948. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6949. if (fold) {
  6950. this.removeFold(fold);
  6951. } else {
  6952. this.addFold("...", range);
  6953. }
  6954. }
  6955. };
  6956. this.updateFoldWidgets = function(delta) {
  6957. var firstRow = delta.start.row;
  6958. var len = delta.end.row - firstRow;
  6959. if (len === 0) {
  6960. this.foldWidgets[firstRow] = null;
  6961. } else if (delta.action == 'remove') {
  6962. this.foldWidgets.splice(firstRow, len + 1, null);
  6963. } else {
  6964. var args = Array(len + 1);
  6965. args.unshift(firstRow, 1);
  6966. this.foldWidgets.splice.apply(this.foldWidgets, args);
  6967. }
  6968. };
  6969. this.tokenizerUpdateFoldWidgets = function(e) {
  6970. var rows = e.data;
  6971. if (rows.first != rows.last) {
  6972. if (this.foldWidgets.length > rows.first)
  6973. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  6974. }
  6975. }
  6976. }
  6977. exports.Folding = Folding;
  6978. });
  6979. ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  6980. "use strict";
  6981. var TokenIterator = require("../token_iterator").TokenIterator;
  6982. var Range = require("../range").Range;
  6983. function BracketMatch() {
  6984. this.findMatchingBracket = function(position, chr) {
  6985. if (position.column == 0) return null;
  6986. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  6987. if (charBeforeCursor == "") return null;
  6988. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  6989. if (!match)
  6990. return null;
  6991. if (match[1])
  6992. return this.$findClosingBracket(match[1], position);
  6993. else
  6994. return this.$findOpeningBracket(match[2], position);
  6995. };
  6996. this.getBracketRange = function(pos) {
  6997. var line = this.getLine(pos.row);
  6998. var before = true, range;
  6999. var chr = line.charAt(pos.column-1);
  7000. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7001. if (!match) {
  7002. chr = line.charAt(pos.column);
  7003. pos = {row: pos.row, column: pos.column + 1};
  7004. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7005. before = false;
  7006. }
  7007. if (!match)
  7008. return null;
  7009. if (match[1]) {
  7010. var bracketPos = this.$findClosingBracket(match[1], pos);
  7011. if (!bracketPos)
  7012. return null;
  7013. range = Range.fromPoints(pos, bracketPos);
  7014. if (!before) {
  7015. range.end.column++;
  7016. range.start.column--;
  7017. }
  7018. range.cursor = range.end;
  7019. } else {
  7020. var bracketPos = this.$findOpeningBracket(match[2], pos);
  7021. if (!bracketPos)
  7022. return null;
  7023. range = Range.fromPoints(bracketPos, pos);
  7024. if (!before) {
  7025. range.start.column++;
  7026. range.end.column--;
  7027. }
  7028. range.cursor = range.start;
  7029. }
  7030. return range;
  7031. };
  7032. this.$brackets = {
  7033. ")": "(",
  7034. "(": ")",
  7035. "]": "[",
  7036. "[": "]",
  7037. "{": "}",
  7038. "}": "{"
  7039. };
  7040. this.$findOpeningBracket = function(bracket, position, typeRe) {
  7041. var openBracket = this.$brackets[bracket];
  7042. var depth = 1;
  7043. var iterator = new TokenIterator(this, position.row, position.column);
  7044. var token = iterator.getCurrentToken();
  7045. if (!token)
  7046. token = iterator.stepForward();
  7047. if (!token)
  7048. return;
  7049. if (!typeRe){
  7050. typeRe = new RegExp(
  7051. "(\\.?" +
  7052. token.type.replace(".", "\\.").replace("rparen", ".paren")
  7053. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  7054. + ")+"
  7055. );
  7056. }
  7057. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  7058. var value = token.value;
  7059. while (true) {
  7060. while (valueIndex >= 0) {
  7061. var chr = value.charAt(valueIndex);
  7062. if (chr == openBracket) {
  7063. depth -= 1;
  7064. if (depth == 0) {
  7065. return {row: iterator.getCurrentTokenRow(),
  7066. column: valueIndex + iterator.getCurrentTokenColumn()};
  7067. }
  7068. }
  7069. else if (chr == bracket) {
  7070. depth += 1;
  7071. }
  7072. valueIndex -= 1;
  7073. }
  7074. do {
  7075. token = iterator.stepBackward();
  7076. } while (token && !typeRe.test(token.type));
  7077. if (token == null)
  7078. break;
  7079. value = token.value;
  7080. valueIndex = value.length - 1;
  7081. }
  7082. return null;
  7083. };
  7084. this.$findClosingBracket = function(bracket, position, typeRe) {
  7085. var closingBracket = this.$brackets[bracket];
  7086. var depth = 1;
  7087. var iterator = new TokenIterator(this, position.row, position.column);
  7088. var token = iterator.getCurrentToken();
  7089. if (!token)
  7090. token = iterator.stepForward();
  7091. if (!token)
  7092. return;
  7093. if (!typeRe){
  7094. typeRe = new RegExp(
  7095. "(\\.?" +
  7096. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7097. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  7098. + ")+"
  7099. );
  7100. }
  7101. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7102. while (true) {
  7103. var value = token.value;
  7104. var valueLength = value.length;
  7105. while (valueIndex < valueLength) {
  7106. var chr = value.charAt(valueIndex);
  7107. if (chr == closingBracket) {
  7108. depth -= 1;
  7109. if (depth == 0) {
  7110. return {row: iterator.getCurrentTokenRow(),
  7111. column: valueIndex + iterator.getCurrentTokenColumn()};
  7112. }
  7113. }
  7114. else if (chr == bracket) {
  7115. depth += 1;
  7116. }
  7117. valueIndex += 1;
  7118. }
  7119. do {
  7120. token = iterator.stepForward();
  7121. } while (token && !typeRe.test(token.type));
  7122. if (token == null)
  7123. break;
  7124. valueIndex = 0;
  7125. }
  7126. return null;
  7127. };
  7128. }
  7129. exports.BracketMatch = BracketMatch;
  7130. });
  7131. ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"], function(require, exports, module) {
  7132. "use strict";
  7133. var oop = require("./lib/oop");
  7134. var lang = require("./lib/lang");
  7135. var config = require("./config");
  7136. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7137. var Selection = require("./selection").Selection;
  7138. var TextMode = require("./mode/text").Mode;
  7139. var Range = require("./range").Range;
  7140. var Document = require("./document").Document;
  7141. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7142. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7143. var EditSession = function(text, mode) {
  7144. this.$breakpoints = [];
  7145. this.$decorations = [];
  7146. this.$frontMarkers = {};
  7147. this.$backMarkers = {};
  7148. this.$markerId = 1;
  7149. this.$undoSelect = true;
  7150. this.$foldData = [];
  7151. this.$foldData.toString = function() {
  7152. return this.join("\n");
  7153. };
  7154. this.on("changeFold", this.onChangeFold.bind(this));
  7155. this.$onChange = this.onChange.bind(this);
  7156. if (typeof text != "object" || !text.getLine)
  7157. text = new Document(text);
  7158. this.setDocument(text);
  7159. this.selection = new Selection(this);
  7160. config.resetOptions(this);
  7161. this.setMode(mode);
  7162. config._signal("session", this);
  7163. };
  7164. (function() {
  7165. oop.implement(this, EventEmitter);
  7166. this.setDocument = function(doc) {
  7167. if (this.doc)
  7168. this.doc.removeListener("change", this.$onChange);
  7169. this.doc = doc;
  7170. doc.on("change", this.$onChange);
  7171. if (this.bgTokenizer)
  7172. this.bgTokenizer.setDocument(this.getDocument());
  7173. this.resetCaches();
  7174. };
  7175. this.getDocument = function() {
  7176. return this.doc;
  7177. };
  7178. this.$resetRowCache = function(docRow) {
  7179. if (!docRow) {
  7180. this.$docRowCache = [];
  7181. this.$screenRowCache = [];
  7182. return;
  7183. }
  7184. var l = this.$docRowCache.length;
  7185. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7186. if (l > i) {
  7187. this.$docRowCache.splice(i, l);
  7188. this.$screenRowCache.splice(i, l);
  7189. }
  7190. };
  7191. this.$getRowCacheIndex = function(cacheArray, val) {
  7192. var low = 0;
  7193. var hi = cacheArray.length - 1;
  7194. while (low <= hi) {
  7195. var mid = (low + hi) >> 1;
  7196. var c = cacheArray[mid];
  7197. if (val > c)
  7198. low = mid + 1;
  7199. else if (val < c)
  7200. hi = mid - 1;
  7201. else
  7202. return mid;
  7203. }
  7204. return low -1;
  7205. };
  7206. this.resetCaches = function() {
  7207. this.$modified = true;
  7208. this.$wrapData = [];
  7209. this.$rowLengthCache = [];
  7210. this.$resetRowCache(0);
  7211. if (this.bgTokenizer)
  7212. this.bgTokenizer.start(0);
  7213. };
  7214. this.onChangeFold = function(e) {
  7215. var fold = e.data;
  7216. this.$resetRowCache(fold.start.row);
  7217. };
  7218. this.onChange = function(delta) {
  7219. this.$modified = true;
  7220. this.$resetRowCache(delta.start.row);
  7221. var removedFolds = this.$updateInternalDataOnChange(delta);
  7222. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7223. this.$deltasDoc.push(delta);
  7224. if (removedFolds && removedFolds.length != 0) {
  7225. this.$deltasFold.push({
  7226. action: "removeFolds",
  7227. folds: removedFolds
  7228. });
  7229. }
  7230. this.$informUndoManager.schedule();
  7231. }
  7232. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7233. this._signal("change", delta);
  7234. };
  7235. this.setValue = function(text) {
  7236. this.doc.setValue(text);
  7237. this.selection.moveTo(0, 0);
  7238. this.$resetRowCache(0);
  7239. this.$deltas = [];
  7240. this.$deltasDoc = [];
  7241. this.$deltasFold = [];
  7242. this.setUndoManager(this.$undoManager);
  7243. this.getUndoManager().reset();
  7244. };
  7245. this.getValue =
  7246. this.toString = function() {
  7247. return this.doc.getValue();
  7248. };
  7249. this.getSelection = function() {
  7250. return this.selection;
  7251. };
  7252. this.getState = function(row) {
  7253. return this.bgTokenizer.getState(row);
  7254. };
  7255. this.getTokens = function(row) {
  7256. return this.bgTokenizer.getTokens(row);
  7257. };
  7258. this.getTokenAt = function(row, column) {
  7259. var tokens = this.bgTokenizer.getTokens(row);
  7260. var token, c = 0;
  7261. if (column == null) {
  7262. i = tokens.length - 1;
  7263. c = this.getLine(row).length;
  7264. } else {
  7265. for (var i = 0; i < tokens.length; i++) {
  7266. c += tokens[i].value.length;
  7267. if (c >= column)
  7268. break;
  7269. }
  7270. }
  7271. token = tokens[i];
  7272. if (!token)
  7273. return null;
  7274. token.index = i;
  7275. token.start = c - token.value.length;
  7276. return token;
  7277. };
  7278. this.setUndoManager = function(undoManager) {
  7279. this.$undoManager = undoManager;
  7280. this.$deltas = [];
  7281. this.$deltasDoc = [];
  7282. this.$deltasFold = [];
  7283. if (this.$informUndoManager)
  7284. this.$informUndoManager.cancel();
  7285. if (undoManager) {
  7286. var self = this;
  7287. this.$syncInformUndoManager = function() {
  7288. self.$informUndoManager.cancel();
  7289. if (self.$deltasFold.length) {
  7290. self.$deltas.push({
  7291. group: "fold",
  7292. deltas: self.$deltasFold
  7293. });
  7294. self.$deltasFold = [];
  7295. }
  7296. if (self.$deltasDoc.length) {
  7297. self.$deltas.push({
  7298. group: "doc",
  7299. deltas: self.$deltasDoc
  7300. });
  7301. self.$deltasDoc = [];
  7302. }
  7303. if (self.$deltas.length > 0) {
  7304. undoManager.execute({
  7305. action: "aceupdate",
  7306. args: [self.$deltas, self],
  7307. merge: self.mergeUndoDeltas
  7308. });
  7309. }
  7310. self.mergeUndoDeltas = false;
  7311. self.$deltas = [];
  7312. };
  7313. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7314. }
  7315. };
  7316. this.markUndoGroup = function() {
  7317. if (this.$syncInformUndoManager)
  7318. this.$syncInformUndoManager();
  7319. };
  7320. this.$defaultUndoManager = {
  7321. undo: function() {},
  7322. redo: function() {},
  7323. reset: function() {}
  7324. };
  7325. this.getUndoManager = function() {
  7326. return this.$undoManager || this.$defaultUndoManager;
  7327. };
  7328. this.getTabString = function() {
  7329. if (this.getUseSoftTabs()) {
  7330. return lang.stringRepeat(" ", this.getTabSize());
  7331. } else {
  7332. return "\t";
  7333. }
  7334. };
  7335. this.setUseSoftTabs = function(val) {
  7336. this.setOption("useSoftTabs", val);
  7337. };
  7338. this.getUseSoftTabs = function() {
  7339. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7340. };
  7341. this.setTabSize = function(tabSize) {
  7342. this.setOption("tabSize", tabSize);
  7343. };
  7344. this.getTabSize = function() {
  7345. return this.$tabSize;
  7346. };
  7347. this.isTabStop = function(position) {
  7348. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7349. };
  7350. this.$overwrite = false;
  7351. this.setOverwrite = function(overwrite) {
  7352. this.setOption("overwrite", overwrite);
  7353. };
  7354. this.getOverwrite = function() {
  7355. return this.$overwrite;
  7356. };
  7357. this.toggleOverwrite = function() {
  7358. this.setOverwrite(!this.$overwrite);
  7359. };
  7360. this.addGutterDecoration = function(row, className) {
  7361. if (!this.$decorations[row])
  7362. this.$decorations[row] = "";
  7363. this.$decorations[row] += " " + className;
  7364. this._signal("changeBreakpoint", {});
  7365. };
  7366. this.removeGutterDecoration = function(row, className) {
  7367. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7368. this._signal("changeBreakpoint", {});
  7369. };
  7370. this.getBreakpoints = function() {
  7371. return this.$breakpoints;
  7372. };
  7373. this.setBreakpoints = function(rows) {
  7374. this.$breakpoints = [];
  7375. for (var i=0; i<rows.length; i++) {
  7376. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7377. }
  7378. this._signal("changeBreakpoint", {});
  7379. };
  7380. this.clearBreakpoints = function() {
  7381. this.$breakpoints = [];
  7382. this._signal("changeBreakpoint", {});
  7383. };
  7384. this.setBreakpoint = function(row, className) {
  7385. if (className === undefined)
  7386. className = "ace_breakpoint";
  7387. if (className)
  7388. this.$breakpoints[row] = className;
  7389. else
  7390. delete this.$breakpoints[row];
  7391. this._signal("changeBreakpoint", {});
  7392. };
  7393. this.clearBreakpoint = function(row) {
  7394. delete this.$breakpoints[row];
  7395. this._signal("changeBreakpoint", {});
  7396. };
  7397. this.addMarker = function(range, clazz, type, inFront) {
  7398. var id = this.$markerId++;
  7399. var marker = {
  7400. range : range,
  7401. type : type || "line",
  7402. renderer: typeof type == "function" ? type : null,
  7403. clazz : clazz,
  7404. inFront: !!inFront,
  7405. id: id
  7406. };
  7407. if (inFront) {
  7408. this.$frontMarkers[id] = marker;
  7409. this._signal("changeFrontMarker");
  7410. } else {
  7411. this.$backMarkers[id] = marker;
  7412. this._signal("changeBackMarker");
  7413. }
  7414. return id;
  7415. };
  7416. this.addDynamicMarker = function(marker, inFront) {
  7417. if (!marker.update)
  7418. return;
  7419. var id = this.$markerId++;
  7420. marker.id = id;
  7421. marker.inFront = !!inFront;
  7422. if (inFront) {
  7423. this.$frontMarkers[id] = marker;
  7424. this._signal("changeFrontMarker");
  7425. } else {
  7426. this.$backMarkers[id] = marker;
  7427. this._signal("changeBackMarker");
  7428. }
  7429. return marker;
  7430. };
  7431. this.removeMarker = function(markerId) {
  7432. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7433. if (!marker)
  7434. return;
  7435. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7436. if (marker) {
  7437. delete (markers[markerId]);
  7438. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7439. }
  7440. };
  7441. this.getMarkers = function(inFront) {
  7442. return inFront ? this.$frontMarkers : this.$backMarkers;
  7443. };
  7444. this.highlight = function(re) {
  7445. if (!this.$searchHighlight) {
  7446. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7447. this.$searchHighlight = this.addDynamicMarker(highlight);
  7448. }
  7449. this.$searchHighlight.setRegexp(re);
  7450. };
  7451. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7452. if (typeof endRow != "number") {
  7453. clazz = endRow;
  7454. endRow = startRow;
  7455. }
  7456. if (!clazz)
  7457. clazz = "ace_step";
  7458. var range = new Range(startRow, 0, endRow, Infinity);
  7459. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7460. return range;
  7461. };
  7462. this.setAnnotations = function(annotations) {
  7463. this.$annotations = annotations;
  7464. this._signal("changeAnnotation", {});
  7465. };
  7466. this.getAnnotations = function() {
  7467. return this.$annotations || [];
  7468. };
  7469. this.clearAnnotations = function() {
  7470. this.setAnnotations([]);
  7471. };
  7472. this.$detectNewLine = function(text) {
  7473. var match = text.match(/^.*?(\r?\n)/m);
  7474. if (match) {
  7475. this.$autoNewLine = match[1];
  7476. } else {
  7477. this.$autoNewLine = "\n";
  7478. }
  7479. };
  7480. this.getWordRange = function(row, column) {
  7481. var line = this.getLine(row);
  7482. var inToken = false;
  7483. if (column > 0)
  7484. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7485. if (!inToken)
  7486. inToken = !!line.charAt(column).match(this.tokenRe);
  7487. if (inToken)
  7488. var re = this.tokenRe;
  7489. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7490. var re = /\s/;
  7491. else
  7492. var re = this.nonTokenRe;
  7493. var start = column;
  7494. if (start > 0) {
  7495. do {
  7496. start--;
  7497. }
  7498. while (start >= 0 && line.charAt(start).match(re));
  7499. start++;
  7500. }
  7501. var end = column;
  7502. while (end < line.length && line.charAt(end).match(re)) {
  7503. end++;
  7504. }
  7505. return new Range(row, start, row, end);
  7506. };
  7507. this.getAWordRange = function(row, column) {
  7508. var wordRange = this.getWordRange(row, column);
  7509. var line = this.getLine(wordRange.end.row);
  7510. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7511. wordRange.end.column += 1;
  7512. }
  7513. return wordRange;
  7514. };
  7515. this.setNewLineMode = function(newLineMode) {
  7516. this.doc.setNewLineMode(newLineMode);
  7517. };
  7518. this.getNewLineMode = function() {
  7519. return this.doc.getNewLineMode();
  7520. };
  7521. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7522. this.getUseWorker = function() { return this.$useWorker; };
  7523. this.onReloadTokenizer = function(e) {
  7524. var rows = e.data;
  7525. this.bgTokenizer.start(rows.first);
  7526. this._signal("tokenizerUpdate", e);
  7527. };
  7528. this.$modes = {};
  7529. this.$mode = null;
  7530. this.$modeId = null;
  7531. this.setMode = function(mode, cb) {
  7532. if (mode && typeof mode === "object") {
  7533. if (mode.getTokenizer)
  7534. return this.$onChangeMode(mode);
  7535. var options = mode;
  7536. var path = options.path;
  7537. } else {
  7538. path = mode || "ace/mode/text";
  7539. }
  7540. if (!this.$modes["ace/mode/text"])
  7541. this.$modes["ace/mode/text"] = new TextMode();
  7542. if (this.$modes[path] && !options) {
  7543. this.$onChangeMode(this.$modes[path]);
  7544. cb && cb();
  7545. return;
  7546. }
  7547. this.$modeId = path;
  7548. config.loadModule(["mode", path], function(m) {
  7549. if (this.$modeId !== path)
  7550. return cb && cb();
  7551. if (this.$modes[path] && !options) {
  7552. this.$onChangeMode(this.$modes[path]);
  7553. } else if (m && m.Mode) {
  7554. m = new m.Mode(options);
  7555. if (!options) {
  7556. this.$modes[path] = m;
  7557. m.$id = path;
  7558. }
  7559. this.$onChangeMode(m);
  7560. }
  7561. cb && cb();
  7562. }.bind(this));
  7563. if (!this.$mode)
  7564. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7565. };
  7566. this.$onChangeMode = function(mode, $isPlaceholder) {
  7567. if (!$isPlaceholder)
  7568. this.$modeId = mode.$id;
  7569. if (this.$mode === mode)
  7570. return;
  7571. this.$mode = mode;
  7572. this.$stopWorker();
  7573. if (this.$useWorker)
  7574. this.$startWorker();
  7575. var tokenizer = mode.getTokenizer();
  7576. if(tokenizer.addEventListener !== undefined) {
  7577. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7578. tokenizer.addEventListener("update", onReloadTokenizer);
  7579. }
  7580. if (!this.bgTokenizer) {
  7581. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7582. var _self = this;
  7583. this.bgTokenizer.addEventListener("update", function(e) {
  7584. _self._signal("tokenizerUpdate", e);
  7585. });
  7586. } else {
  7587. this.bgTokenizer.setTokenizer(tokenizer);
  7588. }
  7589. this.bgTokenizer.setDocument(this.getDocument());
  7590. this.tokenRe = mode.tokenRe;
  7591. this.nonTokenRe = mode.nonTokenRe;
  7592. if (!$isPlaceholder) {
  7593. if (mode.attachToSession)
  7594. mode.attachToSession(this);
  7595. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7596. this.$setFolding(mode.foldingRules);
  7597. this.bgTokenizer.start(0);
  7598. this._emit("changeMode");
  7599. }
  7600. };
  7601. this.$stopWorker = function() {
  7602. if (this.$worker) {
  7603. this.$worker.terminate();
  7604. this.$worker = null;
  7605. }
  7606. };
  7607. this.$startWorker = function() {
  7608. try {
  7609. this.$worker = this.$mode.createWorker(this);
  7610. } catch (e) {
  7611. config.warn("Could not load worker", e);
  7612. this.$worker = null;
  7613. }
  7614. };
  7615. this.getMode = function() {
  7616. return this.$mode;
  7617. };
  7618. this.$scrollTop = 0;
  7619. this.setScrollTop = function(scrollTop) {
  7620. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7621. return;
  7622. this.$scrollTop = scrollTop;
  7623. this._signal("changeScrollTop", scrollTop);
  7624. };
  7625. this.getScrollTop = function() {
  7626. return this.$scrollTop;
  7627. };
  7628. this.$scrollLeft = 0;
  7629. this.setScrollLeft = function(scrollLeft) {
  7630. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7631. return;
  7632. this.$scrollLeft = scrollLeft;
  7633. this._signal("changeScrollLeft", scrollLeft);
  7634. };
  7635. this.getScrollLeft = function() {
  7636. return this.$scrollLeft;
  7637. };
  7638. this.getScreenWidth = function() {
  7639. this.$computeWidth();
  7640. if (this.lineWidgets)
  7641. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7642. return this.screenWidth;
  7643. };
  7644. this.getLineWidgetMaxWidth = function() {
  7645. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7646. var width = 0;
  7647. this.lineWidgets.forEach(function(w) {
  7648. if (w && w.screenWidth > width)
  7649. width = w.screenWidth;
  7650. });
  7651. return this.lineWidgetWidth = width;
  7652. };
  7653. this.$computeWidth = function(force) {
  7654. if (this.$modified || force) {
  7655. this.$modified = false;
  7656. if (this.$useWrapMode)
  7657. return this.screenWidth = this.$wrapLimit;
  7658. var lines = this.doc.getAllLines();
  7659. var cache = this.$rowLengthCache;
  7660. var longestScreenLine = 0;
  7661. var foldIndex = 0;
  7662. var foldLine = this.$foldData[foldIndex];
  7663. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7664. var len = lines.length;
  7665. for (var i = 0; i < len; i++) {
  7666. if (i > foldStart) {
  7667. i = foldLine.end.row + 1;
  7668. if (i >= len)
  7669. break;
  7670. foldLine = this.$foldData[foldIndex++];
  7671. foldStart = foldLine ? foldLine.start.row : Infinity;
  7672. }
  7673. if (cache[i] == null)
  7674. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7675. if (cache[i] > longestScreenLine)
  7676. longestScreenLine = cache[i];
  7677. }
  7678. this.screenWidth = longestScreenLine;
  7679. }
  7680. };
  7681. this.getLine = function(row) {
  7682. return this.doc.getLine(row);
  7683. };
  7684. this.getLines = function(firstRow, lastRow) {
  7685. return this.doc.getLines(firstRow, lastRow);
  7686. };
  7687. this.getLength = function() {
  7688. return this.doc.getLength();
  7689. };
  7690. this.getTextRange = function(range) {
  7691. return this.doc.getTextRange(range || this.selection.getRange());
  7692. };
  7693. this.insert = function(position, text) {
  7694. return this.doc.insert(position, text);
  7695. };
  7696. this.remove = function(range) {
  7697. return this.doc.remove(range);
  7698. };
  7699. this.removeFullLines = function(firstRow, lastRow){
  7700. return this.doc.removeFullLines(firstRow, lastRow);
  7701. };
  7702. this.undoChanges = function(deltas, dontSelect) {
  7703. if (!deltas.length)
  7704. return;
  7705. this.$fromUndo = true;
  7706. var lastUndoRange = null;
  7707. for (var i = deltas.length - 1; i != -1; i--) {
  7708. var delta = deltas[i];
  7709. if (delta.group == "doc") {
  7710. this.doc.revertDeltas(delta.deltas);
  7711. lastUndoRange =
  7712. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7713. } else {
  7714. delta.deltas.forEach(function(foldDelta) {
  7715. this.addFolds(foldDelta.folds);
  7716. }, this);
  7717. }
  7718. }
  7719. this.$fromUndo = false;
  7720. lastUndoRange &&
  7721. this.$undoSelect &&
  7722. !dontSelect &&
  7723. this.selection.setSelectionRange(lastUndoRange);
  7724. return lastUndoRange;
  7725. };
  7726. this.redoChanges = function(deltas, dontSelect) {
  7727. if (!deltas.length)
  7728. return;
  7729. this.$fromUndo = true;
  7730. var lastUndoRange = null;
  7731. for (var i = 0; i < deltas.length; i++) {
  7732. var delta = deltas[i];
  7733. if (delta.group == "doc") {
  7734. this.doc.applyDeltas(delta.deltas);
  7735. lastUndoRange =
  7736. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7737. }
  7738. }
  7739. this.$fromUndo = false;
  7740. lastUndoRange &&
  7741. this.$undoSelect &&
  7742. !dontSelect &&
  7743. this.selection.setSelectionRange(lastUndoRange);
  7744. return lastUndoRange;
  7745. };
  7746. this.setUndoSelect = function(enable) {
  7747. this.$undoSelect = enable;
  7748. };
  7749. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7750. function isInsert(delta) {
  7751. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  7752. }
  7753. var delta = deltas[0];
  7754. var range, point;
  7755. var lastDeltaIsInsert = false;
  7756. if (isInsert(delta)) {
  7757. range = Range.fromPoints(delta.start, delta.end);
  7758. lastDeltaIsInsert = true;
  7759. } else {
  7760. range = Range.fromPoints(delta.start, delta.start);
  7761. lastDeltaIsInsert = false;
  7762. }
  7763. for (var i = 1; i < deltas.length; i++) {
  7764. delta = deltas[i];
  7765. if (isInsert(delta)) {
  7766. point = delta.start;
  7767. if (range.compare(point.row, point.column) == -1) {
  7768. range.setStart(point);
  7769. }
  7770. point = delta.end;
  7771. if (range.compare(point.row, point.column) == 1) {
  7772. range.setEnd(point);
  7773. }
  7774. lastDeltaIsInsert = true;
  7775. } else {
  7776. point = delta.start;
  7777. if (range.compare(point.row, point.column) == -1) {
  7778. range = Range.fromPoints(delta.start, delta.start);
  7779. }
  7780. lastDeltaIsInsert = false;
  7781. }
  7782. }
  7783. if (lastUndoRange != null) {
  7784. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7785. lastUndoRange.start.column += range.end.column - range.start.column;
  7786. lastUndoRange.end.column += range.end.column - range.start.column;
  7787. }
  7788. var cmp = lastUndoRange.compareRange(range);
  7789. if (cmp == 1) {
  7790. range.setStart(lastUndoRange.start);
  7791. } else if (cmp == -1) {
  7792. range.setEnd(lastUndoRange.end);
  7793. }
  7794. }
  7795. return range;
  7796. };
  7797. this.replace = function(range, text) {
  7798. return this.doc.replace(range, text);
  7799. };
  7800. this.moveText = function(fromRange, toPosition, copy) {
  7801. var text = this.getTextRange(fromRange);
  7802. var folds = this.getFoldsInRange(fromRange);
  7803. var toRange = Range.fromPoints(toPosition, toPosition);
  7804. if (!copy) {
  7805. this.remove(fromRange);
  7806. var rowDiff = fromRange.start.row - fromRange.end.row;
  7807. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7808. if (collDiff) {
  7809. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7810. toRange.start.column += collDiff;
  7811. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7812. toRange.end.column += collDiff;
  7813. }
  7814. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7815. toRange.start.row += rowDiff;
  7816. toRange.end.row += rowDiff;
  7817. }
  7818. }
  7819. toRange.end = this.insert(toRange.start, text);
  7820. if (folds.length) {
  7821. var oldStart = fromRange.start;
  7822. var newStart = toRange.start;
  7823. var rowDiff = newStart.row - oldStart.row;
  7824. var collDiff = newStart.column - oldStart.column;
  7825. this.addFolds(folds.map(function(x) {
  7826. x = x.clone();
  7827. if (x.start.row == oldStart.row)
  7828. x.start.column += collDiff;
  7829. if (x.end.row == oldStart.row)
  7830. x.end.column += collDiff;
  7831. x.start.row += rowDiff;
  7832. x.end.row += rowDiff;
  7833. return x;
  7834. }));
  7835. }
  7836. return toRange;
  7837. };
  7838. this.indentRows = function(startRow, endRow, indentString) {
  7839. indentString = indentString.replace(/\t/g, this.getTabString());
  7840. for (var row=startRow; row<=endRow; row++)
  7841. this.doc.insertInLine({row: row, column: 0}, indentString);
  7842. };
  7843. this.outdentRows = function (range) {
  7844. var rowRange = range.collapseRows();
  7845. var deleteRange = new Range(0, 0, 0, 0);
  7846. var size = this.getTabSize();
  7847. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7848. var line = this.getLine(i);
  7849. deleteRange.start.row = i;
  7850. deleteRange.end.row = i;
  7851. for (var j = 0; j < size; ++j)
  7852. if (line.charAt(j) != ' ')
  7853. break;
  7854. if (j < size && line.charAt(j) == '\t') {
  7855. deleteRange.start.column = j;
  7856. deleteRange.end.column = j + 1;
  7857. } else {
  7858. deleteRange.start.column = 0;
  7859. deleteRange.end.column = j;
  7860. }
  7861. this.remove(deleteRange);
  7862. }
  7863. };
  7864. this.$moveLines = function(firstRow, lastRow, dir) {
  7865. firstRow = this.getRowFoldStart(firstRow);
  7866. lastRow = this.getRowFoldEnd(lastRow);
  7867. if (dir < 0) {
  7868. var row = this.getRowFoldStart(firstRow + dir);
  7869. if (row < 0) return 0;
  7870. var diff = row-firstRow;
  7871. } else if (dir > 0) {
  7872. var row = this.getRowFoldEnd(lastRow + dir);
  7873. if (row > this.doc.getLength()-1) return 0;
  7874. var diff = row-lastRow;
  7875. } else {
  7876. firstRow = this.$clipRowToDocument(firstRow);
  7877. lastRow = this.$clipRowToDocument(lastRow);
  7878. var diff = lastRow - firstRow + 1;
  7879. }
  7880. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7881. var folds = this.getFoldsInRange(range).map(function(x){
  7882. x = x.clone();
  7883. x.start.row += diff;
  7884. x.end.row += diff;
  7885. return x;
  7886. });
  7887. var lines = dir == 0
  7888. ? this.doc.getLines(firstRow, lastRow)
  7889. : this.doc.removeFullLines(firstRow, lastRow);
  7890. this.doc.insertFullLines(firstRow+diff, lines);
  7891. folds.length && this.addFolds(folds);
  7892. return diff;
  7893. };
  7894. this.moveLinesUp = function(firstRow, lastRow) {
  7895. return this.$moveLines(firstRow, lastRow, -1);
  7896. };
  7897. this.moveLinesDown = function(firstRow, lastRow) {
  7898. return this.$moveLines(firstRow, lastRow, 1);
  7899. };
  7900. this.duplicateLines = function(firstRow, lastRow) {
  7901. return this.$moveLines(firstRow, lastRow, 0);
  7902. };
  7903. this.$clipRowToDocument = function(row) {
  7904. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7905. };
  7906. this.$clipColumnToRow = function(row, column) {
  7907. if (column < 0)
  7908. return 0;
  7909. return Math.min(this.doc.getLine(row).length, column);
  7910. };
  7911. this.$clipPositionToDocument = function(row, column) {
  7912. column = Math.max(0, column);
  7913. if (row < 0) {
  7914. row = 0;
  7915. column = 0;
  7916. } else {
  7917. var len = this.doc.getLength();
  7918. if (row >= len) {
  7919. row = len - 1;
  7920. column = this.doc.getLine(len-1).length;
  7921. } else {
  7922. column = Math.min(this.doc.getLine(row).length, column);
  7923. }
  7924. }
  7925. return {
  7926. row: row,
  7927. column: column
  7928. };
  7929. };
  7930. this.$clipRangeToDocument = function(range) {
  7931. if (range.start.row < 0) {
  7932. range.start.row = 0;
  7933. range.start.column = 0;
  7934. } else {
  7935. range.start.column = this.$clipColumnToRow(
  7936. range.start.row,
  7937. range.start.column
  7938. );
  7939. }
  7940. var len = this.doc.getLength() - 1;
  7941. if (range.end.row > len) {
  7942. range.end.row = len;
  7943. range.end.column = this.doc.getLine(len).length;
  7944. } else {
  7945. range.end.column = this.$clipColumnToRow(
  7946. range.end.row,
  7947. range.end.column
  7948. );
  7949. }
  7950. return range;
  7951. };
  7952. this.$wrapLimit = 80;
  7953. this.$useWrapMode = false;
  7954. this.$wrapLimitRange = {
  7955. min : null,
  7956. max : null
  7957. };
  7958. this.setUseWrapMode = function(useWrapMode) {
  7959. if (useWrapMode != this.$useWrapMode) {
  7960. this.$useWrapMode = useWrapMode;
  7961. this.$modified = true;
  7962. this.$resetRowCache(0);
  7963. if (useWrapMode) {
  7964. var len = this.getLength();
  7965. this.$wrapData = Array(len);
  7966. this.$updateWrapData(0, len - 1);
  7967. }
  7968. this._signal("changeWrapMode");
  7969. }
  7970. };
  7971. this.getUseWrapMode = function() {
  7972. return this.$useWrapMode;
  7973. };
  7974. this.setWrapLimitRange = function(min, max) {
  7975. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  7976. this.$wrapLimitRange = { min: min, max: max };
  7977. this.$modified = true;
  7978. if (this.$useWrapMode)
  7979. this._signal("changeWrapMode");
  7980. }
  7981. };
  7982. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  7983. var limits = this.$wrapLimitRange;
  7984. if (limits.max < 0)
  7985. limits = {min: $printMargin, max: $printMargin};
  7986. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  7987. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  7988. this.$wrapLimit = wrapLimit;
  7989. this.$modified = true;
  7990. if (this.$useWrapMode) {
  7991. this.$updateWrapData(0, this.getLength() - 1);
  7992. this.$resetRowCache(0);
  7993. this._signal("changeWrapLimit");
  7994. }
  7995. return true;
  7996. }
  7997. return false;
  7998. };
  7999. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  8000. if (min)
  8001. wrapLimit = Math.max(min, wrapLimit);
  8002. if (max)
  8003. wrapLimit = Math.min(max, wrapLimit);
  8004. return wrapLimit;
  8005. };
  8006. this.getWrapLimit = function() {
  8007. return this.$wrapLimit;
  8008. };
  8009. this.setWrapLimit = function (limit) {
  8010. this.setWrapLimitRange(limit, limit);
  8011. };
  8012. this.getWrapLimitRange = function() {
  8013. return {
  8014. min : this.$wrapLimitRange.min,
  8015. max : this.$wrapLimitRange.max
  8016. };
  8017. };
  8018. this.$updateInternalDataOnChange = function(delta) {
  8019. var useWrapMode = this.$useWrapMode;
  8020. var action = delta.action;
  8021. var start = delta.start;
  8022. var end = delta.end;
  8023. var firstRow = start.row;
  8024. var lastRow = end.row;
  8025. var len = lastRow - firstRow;
  8026. var removedFolds = null;
  8027. this.$updating = true;
  8028. if (len != 0) {
  8029. if (action === "remove") {
  8030. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  8031. var foldLines = this.$foldData;
  8032. removedFolds = this.getFoldsInRange(delta);
  8033. this.removeFolds(removedFolds);
  8034. var foldLine = this.getFoldLine(end.row);
  8035. var idx = 0;
  8036. if (foldLine) {
  8037. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  8038. foldLine.shiftRow(-len);
  8039. var foldLineBefore = this.getFoldLine(firstRow);
  8040. if (foldLineBefore && foldLineBefore !== foldLine) {
  8041. foldLineBefore.merge(foldLine);
  8042. foldLine = foldLineBefore;
  8043. }
  8044. idx = foldLines.indexOf(foldLine) + 1;
  8045. }
  8046. for (idx; idx < foldLines.length; idx++) {
  8047. var foldLine = foldLines[idx];
  8048. if (foldLine.start.row >= end.row) {
  8049. foldLine.shiftRow(-len);
  8050. }
  8051. }
  8052. lastRow = firstRow;
  8053. } else {
  8054. var args = Array(len);
  8055. args.unshift(firstRow, 0);
  8056. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  8057. arr.splice.apply(arr, args);
  8058. var foldLines = this.$foldData;
  8059. var foldLine = this.getFoldLine(firstRow);
  8060. var idx = 0;
  8061. if (foldLine) {
  8062. var cmp = foldLine.range.compareInside(start.row, start.column);
  8063. if (cmp == 0) {
  8064. foldLine = foldLine.split(start.row, start.column);
  8065. if (foldLine) {
  8066. foldLine.shiftRow(len);
  8067. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  8068. }
  8069. } else
  8070. if (cmp == -1) {
  8071. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8072. foldLine.shiftRow(len);
  8073. }
  8074. idx = foldLines.indexOf(foldLine) + 1;
  8075. }
  8076. for (idx; idx < foldLines.length; idx++) {
  8077. var foldLine = foldLines[idx];
  8078. if (foldLine.start.row >= firstRow) {
  8079. foldLine.shiftRow(len);
  8080. }
  8081. }
  8082. }
  8083. } else {
  8084. len = Math.abs(delta.start.column - delta.end.column);
  8085. if (action === "remove") {
  8086. removedFolds = this.getFoldsInRange(delta);
  8087. this.removeFolds(removedFolds);
  8088. len = -len;
  8089. }
  8090. var foldLine = this.getFoldLine(firstRow);
  8091. if (foldLine) {
  8092. foldLine.addRemoveChars(firstRow, start.column, len);
  8093. }
  8094. }
  8095. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8096. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8097. }
  8098. this.$updating = false;
  8099. if (useWrapMode)
  8100. this.$updateWrapData(firstRow, lastRow);
  8101. else
  8102. this.$updateRowLengthCache(firstRow, lastRow);
  8103. return removedFolds;
  8104. };
  8105. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8106. this.$rowLengthCache[firstRow] = null;
  8107. this.$rowLengthCache[lastRow] = null;
  8108. };
  8109. this.$updateWrapData = function(firstRow, lastRow) {
  8110. var lines = this.doc.getAllLines();
  8111. var tabSize = this.getTabSize();
  8112. var wrapData = this.$wrapData;
  8113. var wrapLimit = this.$wrapLimit;
  8114. var tokens;
  8115. var foldLine;
  8116. var row = firstRow;
  8117. lastRow = Math.min(lastRow, lines.length - 1);
  8118. while (row <= lastRow) {
  8119. foldLine = this.getFoldLine(row, foldLine);
  8120. if (!foldLine) {
  8121. tokens = this.$getDisplayTokens(lines[row]);
  8122. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8123. row ++;
  8124. } else {
  8125. tokens = [];
  8126. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8127. var walkTokens;
  8128. if (placeholder != null) {
  8129. walkTokens = this.$getDisplayTokens(
  8130. placeholder, tokens.length);
  8131. walkTokens[0] = PLACEHOLDER_START;
  8132. for (var i = 1; i < walkTokens.length; i++) {
  8133. walkTokens[i] = PLACEHOLDER_BODY;
  8134. }
  8135. } else {
  8136. walkTokens = this.$getDisplayTokens(
  8137. lines[row].substring(lastColumn, column),
  8138. tokens.length);
  8139. }
  8140. tokens = tokens.concat(walkTokens);
  8141. }.bind(this),
  8142. foldLine.end.row,
  8143. lines[foldLine.end.row].length + 1
  8144. );
  8145. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8146. row = foldLine.end.row + 1;
  8147. }
  8148. }
  8149. };
  8150. var CHAR = 1,
  8151. CHAR_EXT = 2,
  8152. PLACEHOLDER_START = 3,
  8153. PLACEHOLDER_BODY = 4,
  8154. PUNCTUATION = 9,
  8155. SPACE = 10,
  8156. TAB = 11,
  8157. TAB_SPACE = 12;
  8158. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  8159. if (tokens.length == 0) {
  8160. return [];
  8161. }
  8162. var splits = [];
  8163. var displayLength = tokens.length;
  8164. var lastSplit = 0, lastDocSplit = 0;
  8165. var isCode = this.$wrapAsCode;
  8166. var indentedSoftWrap = this.$indentedSoftWrap;
  8167. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  8168. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  8169. function getWrapIndent() {
  8170. var indentation = 0;
  8171. if (maxIndent === 0)
  8172. return indentation;
  8173. if (indentedSoftWrap) {
  8174. for (var i = 0; i < tokens.length; i++) {
  8175. var token = tokens[i];
  8176. if (token == SPACE)
  8177. indentation += 1;
  8178. else if (token == TAB)
  8179. indentation += tabSize;
  8180. else if (token == TAB_SPACE)
  8181. continue;
  8182. else
  8183. break;
  8184. }
  8185. }
  8186. if (isCode && indentedSoftWrap !== false)
  8187. indentation += tabSize;
  8188. return Math.min(indentation, maxIndent);
  8189. }
  8190. function addSplit(screenPos) {
  8191. var displayed = tokens.slice(lastSplit, screenPos);
  8192. var len = displayed.length;
  8193. displayed.join("").
  8194. replace(/12/g, function() {
  8195. len -= 1;
  8196. }).
  8197. replace(/2/g, function() {
  8198. len -= 1;
  8199. });
  8200. if (!splits.length) {
  8201. indent = getWrapIndent();
  8202. splits.indent = indent;
  8203. }
  8204. lastDocSplit += len;
  8205. splits.push(lastDocSplit);
  8206. lastSplit = screenPos;
  8207. }
  8208. var indent = 0;
  8209. while (displayLength - lastSplit > wrapLimit - indent) {
  8210. var split = lastSplit + wrapLimit - indent;
  8211. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8212. addSplit(split);
  8213. continue;
  8214. }
  8215. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8216. for (split; split != lastSplit - 1; split--) {
  8217. if (tokens[split] == PLACEHOLDER_START) {
  8218. break;
  8219. }
  8220. }
  8221. if (split > lastSplit) {
  8222. addSplit(split);
  8223. continue;
  8224. }
  8225. split = lastSplit + wrapLimit;
  8226. for (split; split < tokens.length; split++) {
  8227. if (tokens[split] != PLACEHOLDER_BODY) {
  8228. break;
  8229. }
  8230. }
  8231. if (split == tokens.length) {
  8232. break; // Breaks the while-loop.
  8233. }
  8234. addSplit(split);
  8235. continue;
  8236. }
  8237. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  8238. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8239. split --;
  8240. }
  8241. if (isCode) {
  8242. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8243. split --;
  8244. }
  8245. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8246. split --;
  8247. }
  8248. } else {
  8249. while (split > minSplit && tokens[split] < SPACE) {
  8250. split --;
  8251. }
  8252. }
  8253. if (split > minSplit) {
  8254. addSplit(++split);
  8255. continue;
  8256. }
  8257. split = lastSplit + wrapLimit;
  8258. if (tokens[split] == CHAR_EXT)
  8259. split--;
  8260. addSplit(split - indent);
  8261. }
  8262. return splits;
  8263. };
  8264. this.$getDisplayTokens = function(str, offset) {
  8265. var arr = [];
  8266. var tabSize;
  8267. offset = offset || 0;
  8268. for (var i = 0; i < str.length; i++) {
  8269. var c = str.charCodeAt(i);
  8270. if (c == 9) {
  8271. tabSize = this.getScreenTabSize(arr.length + offset);
  8272. arr.push(TAB);
  8273. for (var n = 1; n < tabSize; n++) {
  8274. arr.push(TAB_SPACE);
  8275. }
  8276. }
  8277. else if (c == 32) {
  8278. arr.push(SPACE);
  8279. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8280. arr.push(PUNCTUATION);
  8281. }
  8282. else if (c >= 0x1100 && isFullWidth(c)) {
  8283. arr.push(CHAR, CHAR_EXT);
  8284. } else {
  8285. arr.push(CHAR);
  8286. }
  8287. }
  8288. return arr;
  8289. };
  8290. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8291. if (maxScreenColumn == 0)
  8292. return [0, 0];
  8293. if (maxScreenColumn == null)
  8294. maxScreenColumn = Infinity;
  8295. screenColumn = screenColumn || 0;
  8296. var c, column;
  8297. for (column = 0; column < str.length; column++) {
  8298. c = str.charCodeAt(column);
  8299. if (c == 9) {
  8300. screenColumn += this.getScreenTabSize(screenColumn);
  8301. }
  8302. else if (c >= 0x1100 && isFullWidth(c)) {
  8303. screenColumn += 2;
  8304. } else {
  8305. screenColumn += 1;
  8306. }
  8307. if (screenColumn > maxScreenColumn) {
  8308. break;
  8309. }
  8310. }
  8311. return [screenColumn, column];
  8312. };
  8313. this.lineWidgets = null;
  8314. this.getRowLength = function(row) {
  8315. if (this.lineWidgets)
  8316. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8317. else
  8318. h = 0
  8319. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8320. return 1 + h;
  8321. } else {
  8322. return this.$wrapData[row].length + 1 + h;
  8323. }
  8324. };
  8325. this.getRowLineCount = function(row) {
  8326. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8327. return 1;
  8328. } else {
  8329. return this.$wrapData[row].length + 1;
  8330. }
  8331. };
  8332. this.getRowWrapIndent = function(screenRow) {
  8333. if (this.$useWrapMode) {
  8334. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8335. var splits = this.$wrapData[pos.row];
  8336. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  8337. } else {
  8338. return 0;
  8339. }
  8340. }
  8341. this.getScreenLastRowColumn = function(screenRow) {
  8342. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8343. return this.documentToScreenColumn(pos.row, pos.column);
  8344. };
  8345. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8346. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8347. return this.getScreenLastRowColumn(screenRow);
  8348. };
  8349. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8350. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8351. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8352. };
  8353. this.getRowSplitData = function(row) {
  8354. if (!this.$useWrapMode) {
  8355. return undefined;
  8356. } else {
  8357. return this.$wrapData[row];
  8358. }
  8359. };
  8360. this.getScreenTabSize = function(screenColumn) {
  8361. return this.$tabSize - screenColumn % this.$tabSize;
  8362. };
  8363. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8364. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8365. };
  8366. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8367. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8368. };
  8369. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8370. if (screenRow < 0)
  8371. return {row: 0, column: 0};
  8372. var line;
  8373. var docRow = 0;
  8374. var docColumn = 0;
  8375. var column;
  8376. var row = 0;
  8377. var rowLength = 0;
  8378. var rowCache = this.$screenRowCache;
  8379. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8380. var l = rowCache.length;
  8381. if (l && i >= 0) {
  8382. var row = rowCache[i];
  8383. var docRow = this.$docRowCache[i];
  8384. var doCache = screenRow > rowCache[l - 1];
  8385. } else {
  8386. var doCache = !l;
  8387. }
  8388. var maxRow = this.getLength() - 1;
  8389. var foldLine = this.getNextFoldLine(docRow);
  8390. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8391. while (row <= screenRow) {
  8392. rowLength = this.getRowLength(docRow);
  8393. if (row + rowLength > screenRow || docRow >= maxRow) {
  8394. break;
  8395. } else {
  8396. row += rowLength;
  8397. docRow++;
  8398. if (docRow > foldStart) {
  8399. docRow = foldLine.end.row+1;
  8400. foldLine = this.getNextFoldLine(docRow, foldLine);
  8401. foldStart = foldLine ? foldLine.start.row : Infinity;
  8402. }
  8403. }
  8404. if (doCache) {
  8405. this.$docRowCache.push(docRow);
  8406. this.$screenRowCache.push(row);
  8407. }
  8408. }
  8409. if (foldLine && foldLine.start.row <= docRow) {
  8410. line = this.getFoldDisplayLine(foldLine);
  8411. docRow = foldLine.start.row;
  8412. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8413. return {
  8414. row: maxRow,
  8415. column: this.getLine(maxRow).length
  8416. };
  8417. } else {
  8418. line = this.getLine(docRow);
  8419. foldLine = null;
  8420. }
  8421. var wrapIndent = 0;
  8422. if (this.$useWrapMode) {
  8423. var splits = this.$wrapData[docRow];
  8424. if (splits) {
  8425. var splitIndex = Math.floor(screenRow - row);
  8426. column = splits[splitIndex];
  8427. if(splitIndex > 0 && splits.length) {
  8428. wrapIndent = splits.indent;
  8429. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8430. line = line.substring(docColumn);
  8431. }
  8432. }
  8433. }
  8434. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  8435. if (this.$useWrapMode && docColumn >= column)
  8436. docColumn = column - 1;
  8437. if (foldLine)
  8438. return foldLine.idxToPosition(docColumn);
  8439. return {row: docRow, column: docColumn};
  8440. };
  8441. this.documentToScreenPosition = function(docRow, docColumn) {
  8442. if (typeof docColumn === "undefined")
  8443. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8444. else
  8445. pos = this.$clipPositionToDocument(docRow, docColumn);
  8446. docRow = pos.row;
  8447. docColumn = pos.column;
  8448. var screenRow = 0;
  8449. var foldStartRow = null;
  8450. var fold = null;
  8451. fold = this.getFoldAt(docRow, docColumn, 1);
  8452. if (fold) {
  8453. docRow = fold.start.row;
  8454. docColumn = fold.start.column;
  8455. }
  8456. var rowEnd, row = 0;
  8457. var rowCache = this.$docRowCache;
  8458. var i = this.$getRowCacheIndex(rowCache, docRow);
  8459. var l = rowCache.length;
  8460. if (l && i >= 0) {
  8461. var row = rowCache[i];
  8462. var screenRow = this.$screenRowCache[i];
  8463. var doCache = docRow > rowCache[l - 1];
  8464. } else {
  8465. var doCache = !l;
  8466. }
  8467. var foldLine = this.getNextFoldLine(row);
  8468. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8469. while (row < docRow) {
  8470. if (row >= foldStart) {
  8471. rowEnd = foldLine.end.row + 1;
  8472. if (rowEnd > docRow)
  8473. break;
  8474. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8475. foldStart = foldLine ?foldLine.start.row :Infinity;
  8476. }
  8477. else {
  8478. rowEnd = row + 1;
  8479. }
  8480. screenRow += this.getRowLength(row);
  8481. row = rowEnd;
  8482. if (doCache) {
  8483. this.$docRowCache.push(row);
  8484. this.$screenRowCache.push(screenRow);
  8485. }
  8486. }
  8487. var textLine = "";
  8488. if (foldLine && row >= foldStart) {
  8489. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8490. foldStartRow = foldLine.start.row;
  8491. } else {
  8492. textLine = this.getLine(docRow).substring(0, docColumn);
  8493. foldStartRow = docRow;
  8494. }
  8495. var wrapIndent = 0;
  8496. if (this.$useWrapMode) {
  8497. var wrapRow = this.$wrapData[foldStartRow];
  8498. if (wrapRow) {
  8499. var screenRowOffset = 0;
  8500. while (textLine.length >= wrapRow[screenRowOffset]) {
  8501. screenRow ++;
  8502. screenRowOffset++;
  8503. }
  8504. textLine = textLine.substring(
  8505. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8506. );
  8507. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  8508. }
  8509. }
  8510. return {
  8511. row: screenRow,
  8512. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  8513. };
  8514. };
  8515. this.documentToScreenColumn = function(row, docColumn) {
  8516. return this.documentToScreenPosition(row, docColumn).column;
  8517. };
  8518. this.documentToScreenRow = function(docRow, docColumn) {
  8519. return this.documentToScreenPosition(docRow, docColumn).row;
  8520. };
  8521. this.getScreenLength = function() {
  8522. var screenRows = 0;
  8523. var fold = null;
  8524. if (!this.$useWrapMode) {
  8525. screenRows = this.getLength();
  8526. var foldData = this.$foldData;
  8527. for (var i = 0; i < foldData.length; i++) {
  8528. fold = foldData[i];
  8529. screenRows -= fold.end.row - fold.start.row;
  8530. }
  8531. } else {
  8532. var lastRow = this.$wrapData.length;
  8533. var row = 0, i = 0;
  8534. var fold = this.$foldData[i++];
  8535. var foldStart = fold ? fold.start.row :Infinity;
  8536. while (row < lastRow) {
  8537. var splits = this.$wrapData[row];
  8538. screenRows += splits ? splits.length + 1 : 1;
  8539. row ++;
  8540. if (row > foldStart) {
  8541. row = fold.end.row+1;
  8542. fold = this.$foldData[i++];
  8543. foldStart = fold ?fold.start.row :Infinity;
  8544. }
  8545. }
  8546. }
  8547. if (this.lineWidgets)
  8548. screenRows += this.$getWidgetScreenLength();
  8549. return screenRows;
  8550. };
  8551. this.$setFontMetrics = function(fm) {
  8552. };
  8553. this.destroy = function() {
  8554. if (this.bgTokenizer) {
  8555. this.bgTokenizer.setDocument(null);
  8556. this.bgTokenizer = null;
  8557. }
  8558. this.$stopWorker();
  8559. };
  8560. function isFullWidth(c) {
  8561. if (c < 0x1100)
  8562. return false;
  8563. return c >= 0x1100 && c <= 0x115F ||
  8564. c >= 0x11A3 && c <= 0x11A7 ||
  8565. c >= 0x11FA && c <= 0x11FF ||
  8566. c >= 0x2329 && c <= 0x232A ||
  8567. c >= 0x2E80 && c <= 0x2E99 ||
  8568. c >= 0x2E9B && c <= 0x2EF3 ||
  8569. c >= 0x2F00 && c <= 0x2FD5 ||
  8570. c >= 0x2FF0 && c <= 0x2FFB ||
  8571. c >= 0x3000 && c <= 0x303E ||
  8572. c >= 0x3041 && c <= 0x3096 ||
  8573. c >= 0x3099 && c <= 0x30FF ||
  8574. c >= 0x3105 && c <= 0x312D ||
  8575. c >= 0x3131 && c <= 0x318E ||
  8576. c >= 0x3190 && c <= 0x31BA ||
  8577. c >= 0x31C0 && c <= 0x31E3 ||
  8578. c >= 0x31F0 && c <= 0x321E ||
  8579. c >= 0x3220 && c <= 0x3247 ||
  8580. c >= 0x3250 && c <= 0x32FE ||
  8581. c >= 0x3300 && c <= 0x4DBF ||
  8582. c >= 0x4E00 && c <= 0xA48C ||
  8583. c >= 0xA490 && c <= 0xA4C6 ||
  8584. c >= 0xA960 && c <= 0xA97C ||
  8585. c >= 0xAC00 && c <= 0xD7A3 ||
  8586. c >= 0xD7B0 && c <= 0xD7C6 ||
  8587. c >= 0xD7CB && c <= 0xD7FB ||
  8588. c >= 0xF900 && c <= 0xFAFF ||
  8589. c >= 0xFE10 && c <= 0xFE19 ||
  8590. c >= 0xFE30 && c <= 0xFE52 ||
  8591. c >= 0xFE54 && c <= 0xFE66 ||
  8592. c >= 0xFE68 && c <= 0xFE6B ||
  8593. c >= 0xFF01 && c <= 0xFF60 ||
  8594. c >= 0xFFE0 && c <= 0xFFE6;
  8595. };
  8596. }).call(EditSession.prototype);
  8597. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8598. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8599. config.defineOptions(EditSession.prototype, "session", {
  8600. wrap: {
  8601. set: function(value) {
  8602. if (!value || value == "off")
  8603. value = false;
  8604. else if (value == "free")
  8605. value = true;
  8606. else if (value == "printMargin")
  8607. value = -1;
  8608. else if (typeof value == "string")
  8609. value = parseInt(value, 10) || false;
  8610. if (this.$wrap == value)
  8611. return;
  8612. this.$wrap = value;
  8613. if (!value) {
  8614. this.setUseWrapMode(false);
  8615. } else {
  8616. var col = typeof value == "number" ? value : null;
  8617. this.setWrapLimitRange(col, col);
  8618. this.setUseWrapMode(true);
  8619. }
  8620. },
  8621. get: function() {
  8622. if (this.getUseWrapMode()) {
  8623. if (this.$wrap == -1)
  8624. return "printMargin";
  8625. if (!this.getWrapLimitRange().min)
  8626. return "free";
  8627. return this.$wrap;
  8628. }
  8629. return "off";
  8630. },
  8631. handlesSet: true
  8632. },
  8633. wrapMethod: {
  8634. set: function(val) {
  8635. val = val == "auto"
  8636. ? this.$mode.type != "text"
  8637. : val != "text";
  8638. if (val != this.$wrapAsCode) {
  8639. this.$wrapAsCode = val;
  8640. if (this.$useWrapMode) {
  8641. this.$modified = true;
  8642. this.$resetRowCache(0);
  8643. this.$updateWrapData(0, this.getLength() - 1);
  8644. }
  8645. }
  8646. },
  8647. initialValue: "auto"
  8648. },
  8649. indentedSoftWrap: { initialValue: true },
  8650. firstLineNumber: {
  8651. set: function() {this._signal("changeBreakpoint");},
  8652. initialValue: 1
  8653. },
  8654. useWorker: {
  8655. set: function(useWorker) {
  8656. this.$useWorker = useWorker;
  8657. this.$stopWorker();
  8658. if (useWorker)
  8659. this.$startWorker();
  8660. },
  8661. initialValue: true
  8662. },
  8663. useSoftTabs: {initialValue: true},
  8664. tabSize: {
  8665. set: function(tabSize) {
  8666. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8667. this.$modified = true;
  8668. this.$rowLengthCache = [];
  8669. this.$tabSize = tabSize;
  8670. this._signal("changeTabSize");
  8671. },
  8672. initialValue: 4,
  8673. handlesSet: true
  8674. },
  8675. overwrite: {
  8676. set: function(val) {this._signal("changeOverwrite");},
  8677. initialValue: false
  8678. },
  8679. newLineMode: {
  8680. set: function(val) {this.doc.setNewLineMode(val)},
  8681. get: function() {return this.doc.getNewLineMode()},
  8682. handlesSet: true
  8683. },
  8684. mode: {
  8685. set: function(val) { this.setMode(val) },
  8686. get: function() { return this.$modeId }
  8687. }
  8688. });
  8689. exports.EditSession = EditSession;
  8690. });
  8691. ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8692. "use strict";
  8693. var lang = require("./lib/lang");
  8694. var oop = require("./lib/oop");
  8695. var Range = require("./range").Range;
  8696. var Search = function() {
  8697. this.$options = {};
  8698. };
  8699. (function() {
  8700. this.set = function(options) {
  8701. oop.mixin(this.$options, options);
  8702. return this;
  8703. };
  8704. this.getOptions = function() {
  8705. return lang.copyObject(this.$options);
  8706. };
  8707. this.setOptions = function(options) {
  8708. this.$options = options;
  8709. };
  8710. this.find = function(session) {
  8711. var options = this.$options;
  8712. var iterator = this.$matchIterator(session, options);
  8713. if (!iterator)
  8714. return false;
  8715. var firstRange = null;
  8716. iterator.forEach(function(range, row, offset) {
  8717. if (!range.start) {
  8718. var column = range.offset + (offset || 0);
  8719. firstRange = new Range(row, column, row, column + range.length);
  8720. if (!range.length && options.start && options.start.start
  8721. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8722. ) {
  8723. firstRange = null;
  8724. return false;
  8725. }
  8726. } else
  8727. firstRange = range;
  8728. return true;
  8729. });
  8730. return firstRange;
  8731. };
  8732. this.findAll = function(session) {
  8733. var options = this.$options;
  8734. if (!options.needle)
  8735. return [];
  8736. this.$assembleRegExp(options);
  8737. var range = options.range;
  8738. var lines = range
  8739. ? session.getLines(range.start.row, range.end.row)
  8740. : session.doc.getAllLines();
  8741. var ranges = [];
  8742. var re = options.re;
  8743. if (options.$isMultiLine) {
  8744. var len = re.length;
  8745. var maxRow = lines.length - len;
  8746. var prevRange;
  8747. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8748. for (var j = 0; j < len; j++)
  8749. if (lines[row + j].search(re[j]) == -1)
  8750. continue outer;
  8751. var startLine = lines[row];
  8752. var line = lines[row + len - 1];
  8753. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8754. var endIndex = line.match(re[len - 1])[0].length;
  8755. if (prevRange && prevRange.end.row === row &&
  8756. prevRange.end.column > startIndex
  8757. ) {
  8758. continue;
  8759. }
  8760. ranges.push(prevRange = new Range(
  8761. row, startIndex, row + len - 1, endIndex
  8762. ));
  8763. if (len > 2)
  8764. row = row + len - 2;
  8765. }
  8766. } else {
  8767. for (var i = 0; i < lines.length; i++) {
  8768. var matches = lang.getMatchOffsets(lines[i], re);
  8769. for (var j = 0; j < matches.length; j++) {
  8770. var match = matches[j];
  8771. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8772. }
  8773. }
  8774. }
  8775. if (range) {
  8776. var startColumn = range.start.column;
  8777. var endColumn = range.start.column;
  8778. var i = 0, j = ranges.length - 1;
  8779. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8780. i++;
  8781. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8782. j--;
  8783. ranges = ranges.slice(i, j + 1);
  8784. for (i = 0, j = ranges.length; i < j; i++) {
  8785. ranges[i].start.row += range.start.row;
  8786. ranges[i].end.row += range.start.row;
  8787. }
  8788. }
  8789. return ranges;
  8790. };
  8791. this.replace = function(input, replacement) {
  8792. var options = this.$options;
  8793. var re = this.$assembleRegExp(options);
  8794. if (options.$isMultiLine)
  8795. return replacement;
  8796. if (!re)
  8797. return;
  8798. var match = re.exec(input);
  8799. if (!match || match[0].length != input.length)
  8800. return null;
  8801. replacement = input.replace(re, replacement);
  8802. if (options.preserveCase) {
  8803. replacement = replacement.split("");
  8804. for (var i = Math.min(input.length, input.length); i--; ) {
  8805. var ch = input[i];
  8806. if (ch && ch.toLowerCase() != ch)
  8807. replacement[i] = replacement[i].toUpperCase();
  8808. else
  8809. replacement[i] = replacement[i].toLowerCase();
  8810. }
  8811. replacement = replacement.join("");
  8812. }
  8813. return replacement;
  8814. };
  8815. this.$matchIterator = function(session, options) {
  8816. var re = this.$assembleRegExp(options);
  8817. if (!re)
  8818. return false;
  8819. var callback;
  8820. if (options.$isMultiLine) {
  8821. var len = re.length;
  8822. var matchIterator = function(line, row, offset) {
  8823. var startIndex = line.search(re[0]);
  8824. if (startIndex == -1)
  8825. return;
  8826. for (var i = 1; i < len; i++) {
  8827. line = session.getLine(row + i);
  8828. if (line.search(re[i]) == -1)
  8829. return;
  8830. }
  8831. var endIndex = line.match(re[len - 1])[0].length;
  8832. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8833. if (re.offset == 1) {
  8834. range.start.row--;
  8835. range.start.column = Number.MAX_VALUE;
  8836. } else if (offset)
  8837. range.start.column += offset;
  8838. if (callback(range))
  8839. return true;
  8840. };
  8841. } else if (options.backwards) {
  8842. var matchIterator = function(line, row, startIndex) {
  8843. var matches = lang.getMatchOffsets(line, re);
  8844. for (var i = matches.length-1; i >= 0; i--)
  8845. if (callback(matches[i], row, startIndex))
  8846. return true;
  8847. };
  8848. } else {
  8849. var matchIterator = function(line, row, startIndex) {
  8850. var matches = lang.getMatchOffsets(line, re);
  8851. for (var i = 0; i < matches.length; i++)
  8852. if (callback(matches[i], row, startIndex))
  8853. return true;
  8854. };
  8855. }
  8856. var lineIterator = this.$lineIterator(session, options);
  8857. return {
  8858. forEach: function(_callback) {
  8859. callback = _callback;
  8860. lineIterator.forEach(matchIterator);
  8861. }
  8862. };
  8863. };
  8864. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8865. if (options.needle instanceof RegExp)
  8866. return options.re = options.needle;
  8867. var needle = options.needle;
  8868. if (!options.needle)
  8869. return options.re = false;
  8870. if (!options.regExp)
  8871. needle = lang.escapeRegExp(needle);
  8872. if (options.wholeWord)
  8873. needle = "\\b" + needle + "\\b";
  8874. var modifier = options.caseSensitive ? "gm" : "gmi";
  8875. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8876. if (options.$isMultiLine)
  8877. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8878. try {
  8879. var re = new RegExp(needle, modifier);
  8880. } catch(e) {
  8881. re = false;
  8882. }
  8883. return options.re = re;
  8884. };
  8885. this.$assembleMultilineRegExp = function(needle, modifier) {
  8886. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8887. var re = [];
  8888. for (var i = 0; i < parts.length; i++) try {
  8889. re.push(new RegExp(parts[i], modifier));
  8890. } catch(e) {
  8891. return false;
  8892. }
  8893. if (parts[0] == "") {
  8894. re.shift();
  8895. re.offset = 1;
  8896. } else {
  8897. re.offset = 0;
  8898. }
  8899. return re;
  8900. };
  8901. this.$lineIterator = function(session, options) {
  8902. var backwards = options.backwards == true;
  8903. var skipCurrent = options.skipCurrent != false;
  8904. var range = options.range;
  8905. var start = options.start;
  8906. if (!start)
  8907. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8908. if (start.start)
  8909. start = start[skipCurrent != backwards ? "end" : "start"];
  8910. var firstRow = range ? range.start.row : 0;
  8911. var lastRow = range ? range.end.row : session.getLength() - 1;
  8912. var forEach = backwards ? function(callback) {
  8913. var row = start.row;
  8914. var line = session.getLine(row).substring(0, start.column);
  8915. if (callback(line, row))
  8916. return;
  8917. for (row--; row >= firstRow; row--)
  8918. if (callback(session.getLine(row), row))
  8919. return;
  8920. if (options.wrap == false)
  8921. return;
  8922. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8923. if (callback(session.getLine(row), row))
  8924. return;
  8925. } : function(callback) {
  8926. var row = start.row;
  8927. var line = session.getLine(row).substr(start.column);
  8928. if (callback(line, row, start.column))
  8929. return;
  8930. for (row = row+1; row <= lastRow; row++)
  8931. if (callback(session.getLine(row), row))
  8932. return;
  8933. if (options.wrap == false)
  8934. return;
  8935. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8936. if (callback(session.getLine(row), row))
  8937. return;
  8938. };
  8939. return {forEach: forEach};
  8940. };
  8941. }).call(Search.prototype);
  8942. exports.Search = Search;
  8943. });
  8944. ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  8945. "use strict";
  8946. var keyUtil = require("../lib/keys");
  8947. var useragent = require("../lib/useragent");
  8948. var KEY_MODS = keyUtil.KEY_MODS;
  8949. function HashHandler(config, platform) {
  8950. this.platform = platform || (useragent.isMac ? "mac" : "win");
  8951. this.commands = {};
  8952. this.commandKeyBinding = {};
  8953. this.addCommands(config);
  8954. this.$singleCommand = true;
  8955. }
  8956. function MultiHashHandler(config, platform) {
  8957. HashHandler.call(this, config, platform);
  8958. this.$singleCommand = false;
  8959. }
  8960. MultiHashHandler.prototype = HashHandler.prototype;
  8961. (function() {
  8962. this.addCommand = function(command) {
  8963. if (this.commands[command.name])
  8964. this.removeCommand(command);
  8965. this.commands[command.name] = command;
  8966. if (command.bindKey)
  8967. this._buildKeyHash(command);
  8968. };
  8969. this.removeCommand = function(command, keepCommand) {
  8970. var name = command && (typeof command === 'string' ? command : command.name);
  8971. command = this.commands[name];
  8972. if (!keepCommand)
  8973. delete this.commands[name];
  8974. var ckb = this.commandKeyBinding;
  8975. for (var keyId in ckb) {
  8976. var cmdGroup = ckb[keyId];
  8977. if (cmdGroup == command) {
  8978. delete ckb[keyId];
  8979. } else if (Array.isArray(cmdGroup)) {
  8980. var i = cmdGroup.indexOf(command);
  8981. if (i != -1) {
  8982. cmdGroup.splice(i, 1);
  8983. if (cmdGroup.length == 1)
  8984. ckb[keyId] = cmdGroup[0];
  8985. }
  8986. }
  8987. }
  8988. };
  8989. this.bindKey = function(key, command, position) {
  8990. if (typeof key == "object") {
  8991. if (position == undefined)
  8992. position = key.position;
  8993. key = key[this.platform];
  8994. }
  8995. if (!key)
  8996. return;
  8997. if (typeof command == "function")
  8998. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  8999. key.split("|").forEach(function(keyPart) {
  9000. var chain = "";
  9001. if (keyPart.indexOf(" ") != -1) {
  9002. var parts = keyPart.split(/\s+/);
  9003. keyPart = parts.pop();
  9004. parts.forEach(function(keyPart) {
  9005. var binding = this.parseKeys(keyPart);
  9006. var id = KEY_MODS[binding.hashId] + binding.key;
  9007. chain += (chain ? " " : "") + id;
  9008. this._addCommandToBinding(chain, "chainKeys");
  9009. }, this);
  9010. chain += " ";
  9011. }
  9012. var binding = this.parseKeys(keyPart);
  9013. var id = KEY_MODS[binding.hashId] + binding.key;
  9014. this._addCommandToBinding(chain + id, command, position);
  9015. }, this);
  9016. };
  9017. function getPosition(command) {
  9018. return typeof command == "object" && command.bindKey
  9019. && command.bindKey.position || 0;
  9020. }
  9021. this._addCommandToBinding = function(keyId, command, position) {
  9022. var ckb = this.commandKeyBinding, i;
  9023. if (!command) {
  9024. delete ckb[keyId];
  9025. } else if (!ckb[keyId] || this.$singleCommand) {
  9026. ckb[keyId] = command;
  9027. } else {
  9028. if (!Array.isArray(ckb[keyId])) {
  9029. ckb[keyId] = [ckb[keyId]];
  9030. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  9031. ckb[keyId].splice(i, 1);
  9032. }
  9033. if (typeof position != "number") {
  9034. if (position || command.isDefault)
  9035. position = -100;
  9036. else
  9037. position = getPosition(command);
  9038. }
  9039. var commands = ckb[keyId];
  9040. for (i = 0; i < commands.length; i++) {
  9041. var other = commands[i];
  9042. var otherPos = getPosition(other);
  9043. if (otherPos > position)
  9044. break;
  9045. }
  9046. commands.splice(i, 0, command);
  9047. }
  9048. };
  9049. this.addCommands = function(commands) {
  9050. commands && Object.keys(commands).forEach(function(name) {
  9051. var command = commands[name];
  9052. if (!command)
  9053. return;
  9054. if (typeof command === "string")
  9055. return this.bindKey(command, name);
  9056. if (typeof command === "function")
  9057. command = { exec: command };
  9058. if (typeof command !== "object")
  9059. return;
  9060. if (!command.name)
  9061. command.name = name;
  9062. this.addCommand(command);
  9063. }, this);
  9064. };
  9065. this.removeCommands = function(commands) {
  9066. Object.keys(commands).forEach(function(name) {
  9067. this.removeCommand(commands[name]);
  9068. }, this);
  9069. };
  9070. this.bindKeys = function(keyList) {
  9071. Object.keys(keyList).forEach(function(key) {
  9072. this.bindKey(key, keyList[key]);
  9073. }, this);
  9074. };
  9075. this._buildKeyHash = function(command) {
  9076. this.bindKey(command.bindKey, command);
  9077. };
  9078. this.parseKeys = function(keys) {
  9079. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  9080. var key = parts.pop();
  9081. var keyCode = keyUtil[key];
  9082. if (keyUtil.FUNCTION_KEYS[keyCode])
  9083. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  9084. else if (!parts.length)
  9085. return {key: key, hashId: -1};
  9086. else if (parts.length == 1 && parts[0] == "shift")
  9087. return {key: key.toUpperCase(), hashId: -1};
  9088. var hashId = 0;
  9089. for (var i = parts.length; i--;) {
  9090. var modifier = keyUtil.KEY_MODS[parts[i]];
  9091. if (modifier == null) {
  9092. if (typeof console != "undefined")
  9093. console.error("invalid modifier " + parts[i] + " in " + keys);
  9094. return false;
  9095. }
  9096. hashId |= modifier;
  9097. }
  9098. return {key: key, hashId: hashId};
  9099. };
  9100. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9101. var key = KEY_MODS[hashId] + keyString;
  9102. return this.commandKeyBinding[key];
  9103. };
  9104. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9105. var key = KEY_MODS[hashId] + keyString;
  9106. var command = this.commandKeyBinding[key];
  9107. if (data.$keyChain) {
  9108. data.$keyChain += " " + key;
  9109. command = this.commandKeyBinding[data.$keyChain] || command;
  9110. }
  9111. if (command) {
  9112. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  9113. data.$keyChain = data.$keyChain || key;
  9114. return {command: "null"};
  9115. }
  9116. }
  9117. if (data.$keyChain) {
  9118. if ((!hashId || hashId == 4) && keyString.length == 1)
  9119. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  9120. else if (hashId == -1 || keyCode > 0)
  9121. data.$keyChain = ""; // reset keyChain
  9122. }
  9123. return {command: command};
  9124. };
  9125. this.getStatusText = function(editor, data) {
  9126. return data.$keyChain || "";
  9127. };
  9128. }).call(HashHandler.prototype);
  9129. exports.HashHandler = HashHandler;
  9130. exports.MultiHashHandler = MultiHashHandler;
  9131. });
  9132. ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  9133. "use strict";
  9134. var oop = require("../lib/oop");
  9135. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  9136. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  9137. var CommandManager = function(platform, commands) {
  9138. MultiHashHandler.call(this, commands, platform);
  9139. this.byName = this.commands;
  9140. this.setDefaultHandler("exec", function(e) {
  9141. return e.command.exec(e.editor, e.args || {});
  9142. });
  9143. };
  9144. oop.inherits(CommandManager, MultiHashHandler);
  9145. (function() {
  9146. oop.implement(this, EventEmitter);
  9147. this.exec = function(command, editor, args) {
  9148. if (Array.isArray(command)) {
  9149. for (var i = command.length; i--; ) {
  9150. if (this.exec(command[i], editor, args)) return true;
  9151. }
  9152. return false;
  9153. }
  9154. if (typeof command === "string")
  9155. command = this.commands[command];
  9156. if (!command)
  9157. return false;
  9158. if (editor && editor.$readOnly && !command.readOnly)
  9159. return false;
  9160. var e = {editor: editor, command: command, args: args};
  9161. e.returnValue = this._emit("exec", e);
  9162. this._signal("afterExec", e);
  9163. return e.returnValue === false ? false : true;
  9164. };
  9165. this.toggleRecording = function(editor) {
  9166. if (this.$inReplay)
  9167. return;
  9168. editor && editor._emit("changeStatus");
  9169. if (this.recording) {
  9170. this.macro.pop();
  9171. this.removeEventListener("exec", this.$addCommandToMacro);
  9172. if (!this.macro.length)
  9173. this.macro = this.oldMacro;
  9174. return this.recording = false;
  9175. }
  9176. if (!this.$addCommandToMacro) {
  9177. this.$addCommandToMacro = function(e) {
  9178. this.macro.push([e.command, e.args]);
  9179. }.bind(this);
  9180. }
  9181. this.oldMacro = this.macro;
  9182. this.macro = [];
  9183. this.on("exec", this.$addCommandToMacro);
  9184. return this.recording = true;
  9185. };
  9186. this.replay = function(editor) {
  9187. if (this.$inReplay || !this.macro)
  9188. return;
  9189. if (this.recording)
  9190. return this.toggleRecording(editor);
  9191. try {
  9192. this.$inReplay = true;
  9193. this.macro.forEach(function(x) {
  9194. if (typeof x == "string")
  9195. this.exec(x, editor);
  9196. else
  9197. this.exec(x[0], editor, x[1]);
  9198. }, this);
  9199. } finally {
  9200. this.$inReplay = false;
  9201. }
  9202. };
  9203. this.trimMacro = function(m) {
  9204. return m.map(function(x){
  9205. if (typeof x[0] != "string")
  9206. x[0] = x[0].name;
  9207. if (!x[1])
  9208. x = x[0];
  9209. return x;
  9210. });
  9211. };
  9212. }).call(CommandManager.prototype);
  9213. exports.CommandManager = CommandManager;
  9214. });
  9215. ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9216. "use strict";
  9217. var lang = require("../lib/lang");
  9218. var config = require("../config");
  9219. var Range = require("../range").Range;
  9220. function bindKey(win, mac) {
  9221. return {win: win, mac: mac};
  9222. }
  9223. exports.commands = [{
  9224. name: "showSettingsMenu",
  9225. bindKey: bindKey("Ctrl-,", "Command-,"),
  9226. exec: function(editor) {
  9227. config.loadModule("ace/ext/settings_menu", function(module) {
  9228. module.init(editor);
  9229. editor.showSettingsMenu();
  9230. });
  9231. },
  9232. readOnly: true
  9233. }, {
  9234. name: "goToNextError",
  9235. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9236. exec: function(editor) {
  9237. config.loadModule("ace/ext/error_marker", function(module) {
  9238. module.showErrorMarker(editor, 1);
  9239. });
  9240. },
  9241. scrollIntoView: "animate",
  9242. readOnly: true
  9243. }, {
  9244. name: "goToPreviousError",
  9245. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9246. exec: function(editor) {
  9247. config.loadModule("ace/ext/error_marker", function(module) {
  9248. module.showErrorMarker(editor, -1);
  9249. });
  9250. },
  9251. scrollIntoView: "animate",
  9252. readOnly: true
  9253. }, {
  9254. name: "selectall",
  9255. bindKey: bindKey("Ctrl-A", "Command-A"),
  9256. exec: function(editor) { editor.selectAll(); },
  9257. readOnly: true
  9258. }, {
  9259. name: "centerselection",
  9260. bindKey: bindKey(null, "Ctrl-L"),
  9261. exec: function(editor) { editor.centerSelection(); },
  9262. readOnly: true
  9263. }, {
  9264. name: "gotoline",
  9265. bindKey: bindKey("Ctrl-L", "Command-L"),
  9266. exec: function(editor) {
  9267. var line = parseInt(prompt("Enter line number:"), 10);
  9268. if (!isNaN(line)) {
  9269. editor.gotoLine(line);
  9270. }
  9271. },
  9272. readOnly: true
  9273. }, {
  9274. name: "fold",
  9275. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9276. exec: function(editor) { editor.session.toggleFold(false); },
  9277. multiSelectAction: "forEach",
  9278. scrollIntoView: "center",
  9279. readOnly: true
  9280. }, {
  9281. name: "unfold",
  9282. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9283. exec: function(editor) { editor.session.toggleFold(true); },
  9284. multiSelectAction: "forEach",
  9285. scrollIntoView: "center",
  9286. readOnly: true
  9287. }, {
  9288. name: "toggleFoldWidget",
  9289. bindKey: bindKey("F2", "F2"),
  9290. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9291. multiSelectAction: "forEach",
  9292. scrollIntoView: "center",
  9293. readOnly: true
  9294. }, {
  9295. name: "toggleParentFoldWidget",
  9296. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9297. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9298. multiSelectAction: "forEach",
  9299. scrollIntoView: "center",
  9300. readOnly: true
  9301. }, {
  9302. name: "foldall",
  9303. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9304. exec: function(editor) { editor.session.foldAll(); },
  9305. scrollIntoView: "center",
  9306. readOnly: true
  9307. }, {
  9308. name: "foldOther",
  9309. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9310. exec: function(editor) {
  9311. editor.session.foldAll();
  9312. editor.session.unfold(editor.selection.getAllRanges());
  9313. },
  9314. scrollIntoView: "center",
  9315. readOnly: true
  9316. }, {
  9317. name: "unfoldall",
  9318. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9319. exec: function(editor) { editor.session.unfold(); },
  9320. scrollIntoView: "center",
  9321. readOnly: true
  9322. }, {
  9323. name: "findnext",
  9324. bindKey: bindKey("Ctrl-K", "Command-G"),
  9325. exec: function(editor) { editor.findNext(); },
  9326. multiSelectAction: "forEach",
  9327. scrollIntoView: "center",
  9328. readOnly: true
  9329. }, {
  9330. name: "findprevious",
  9331. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9332. exec: function(editor) { editor.findPrevious(); },
  9333. multiSelectAction: "forEach",
  9334. scrollIntoView: "center",
  9335. readOnly: true
  9336. }, {
  9337. name: "selectOrFindNext",
  9338. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9339. exec: function(editor) {
  9340. if (editor.selection.isEmpty())
  9341. editor.selection.selectWord();
  9342. else
  9343. editor.findNext();
  9344. },
  9345. readOnly: true
  9346. }, {
  9347. name: "selectOrFindPrevious",
  9348. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9349. exec: function(editor) {
  9350. if (editor.selection.isEmpty())
  9351. editor.selection.selectWord();
  9352. else
  9353. editor.findPrevious();
  9354. },
  9355. readOnly: true
  9356. }, {
  9357. name: "find",
  9358. bindKey: bindKey("Ctrl-F", "Command-F"),
  9359. exec: function(editor) {
  9360. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9361. },
  9362. readOnly: true
  9363. }, {
  9364. name: "overwrite",
  9365. bindKey: "Insert",
  9366. exec: function(editor) { editor.toggleOverwrite(); },
  9367. readOnly: true
  9368. }, {
  9369. name: "selecttostart",
  9370. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9371. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9372. multiSelectAction: "forEach",
  9373. readOnly: true,
  9374. scrollIntoView: "animate",
  9375. aceCommandGroup: "fileJump"
  9376. }, {
  9377. name: "gotostart",
  9378. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9379. exec: function(editor) { editor.navigateFileStart(); },
  9380. multiSelectAction: "forEach",
  9381. readOnly: true,
  9382. scrollIntoView: "animate",
  9383. aceCommandGroup: "fileJump"
  9384. }, {
  9385. name: "selectup",
  9386. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9387. exec: function(editor) { editor.getSelection().selectUp(); },
  9388. multiSelectAction: "forEach",
  9389. scrollIntoView: "cursor",
  9390. readOnly: true
  9391. }, {
  9392. name: "golineup",
  9393. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9394. exec: function(editor, args) { editor.navigateUp(args.times); },
  9395. multiSelectAction: "forEach",
  9396. scrollIntoView: "cursor",
  9397. readOnly: true
  9398. }, {
  9399. name: "selecttoend",
  9400. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9401. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9402. multiSelectAction: "forEach",
  9403. readOnly: true,
  9404. scrollIntoView: "animate",
  9405. aceCommandGroup: "fileJump"
  9406. }, {
  9407. name: "gotoend",
  9408. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9409. exec: function(editor) { editor.navigateFileEnd(); },
  9410. multiSelectAction: "forEach",
  9411. readOnly: true,
  9412. scrollIntoView: "animate",
  9413. aceCommandGroup: "fileJump"
  9414. }, {
  9415. name: "selectdown",
  9416. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9417. exec: function(editor) { editor.getSelection().selectDown(); },
  9418. multiSelectAction: "forEach",
  9419. scrollIntoView: "cursor",
  9420. readOnly: true
  9421. }, {
  9422. name: "golinedown",
  9423. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9424. exec: function(editor, args) { editor.navigateDown(args.times); },
  9425. multiSelectAction: "forEach",
  9426. scrollIntoView: "cursor",
  9427. readOnly: true
  9428. }, {
  9429. name: "selectwordleft",
  9430. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9431. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9432. multiSelectAction: "forEach",
  9433. scrollIntoView: "cursor",
  9434. readOnly: true
  9435. }, {
  9436. name: "gotowordleft",
  9437. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9438. exec: function(editor) { editor.navigateWordLeft(); },
  9439. multiSelectAction: "forEach",
  9440. scrollIntoView: "cursor",
  9441. readOnly: true
  9442. }, {
  9443. name: "selecttolinestart",
  9444. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9445. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9446. multiSelectAction: "forEach",
  9447. scrollIntoView: "cursor",
  9448. readOnly: true
  9449. }, {
  9450. name: "gotolinestart",
  9451. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9452. exec: function(editor) { editor.navigateLineStart(); },
  9453. multiSelectAction: "forEach",
  9454. scrollIntoView: "cursor",
  9455. readOnly: true
  9456. }, {
  9457. name: "selectleft",
  9458. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9459. exec: function(editor) { editor.getSelection().selectLeft(); },
  9460. multiSelectAction: "forEach",
  9461. scrollIntoView: "cursor",
  9462. readOnly: true
  9463. }, {
  9464. name: "gotoleft",
  9465. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9466. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9467. multiSelectAction: "forEach",
  9468. scrollIntoView: "cursor",
  9469. readOnly: true
  9470. }, {
  9471. name: "selectwordright",
  9472. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9473. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9474. multiSelectAction: "forEach",
  9475. scrollIntoView: "cursor",
  9476. readOnly: true
  9477. }, {
  9478. name: "gotowordright",
  9479. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9480. exec: function(editor) { editor.navigateWordRight(); },
  9481. multiSelectAction: "forEach",
  9482. scrollIntoView: "cursor",
  9483. readOnly: true
  9484. }, {
  9485. name: "selecttolineend",
  9486. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9487. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9488. multiSelectAction: "forEach",
  9489. scrollIntoView: "cursor",
  9490. readOnly: true
  9491. }, {
  9492. name: "gotolineend",
  9493. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9494. exec: function(editor) { editor.navigateLineEnd(); },
  9495. multiSelectAction: "forEach",
  9496. scrollIntoView: "cursor",
  9497. readOnly: true
  9498. }, {
  9499. name: "selectright",
  9500. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9501. exec: function(editor) { editor.getSelection().selectRight(); },
  9502. multiSelectAction: "forEach",
  9503. scrollIntoView: "cursor",
  9504. readOnly: true
  9505. }, {
  9506. name: "gotoright",
  9507. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9508. exec: function(editor, args) { editor.navigateRight(args.times); },
  9509. multiSelectAction: "forEach",
  9510. scrollIntoView: "cursor",
  9511. readOnly: true
  9512. }, {
  9513. name: "selectpagedown",
  9514. bindKey: "Shift-PageDown",
  9515. exec: function(editor) { editor.selectPageDown(); },
  9516. readOnly: true
  9517. }, {
  9518. name: "pagedown",
  9519. bindKey: bindKey(null, "Option-PageDown"),
  9520. exec: function(editor) { editor.scrollPageDown(); },
  9521. readOnly: true
  9522. }, {
  9523. name: "gotopagedown",
  9524. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9525. exec: function(editor) { editor.gotoPageDown(); },
  9526. readOnly: true
  9527. }, {
  9528. name: "selectpageup",
  9529. bindKey: "Shift-PageUp",
  9530. exec: function(editor) { editor.selectPageUp(); },
  9531. readOnly: true
  9532. }, {
  9533. name: "pageup",
  9534. bindKey: bindKey(null, "Option-PageUp"),
  9535. exec: function(editor) { editor.scrollPageUp(); },
  9536. readOnly: true
  9537. }, {
  9538. name: "gotopageup",
  9539. bindKey: "PageUp",
  9540. exec: function(editor) { editor.gotoPageUp(); },
  9541. readOnly: true
  9542. }, {
  9543. name: "scrollup",
  9544. bindKey: bindKey("Ctrl-Up", null),
  9545. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9546. readOnly: true
  9547. }, {
  9548. name: "scrolldown",
  9549. bindKey: bindKey("Ctrl-Down", null),
  9550. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9551. readOnly: true
  9552. }, {
  9553. name: "selectlinestart",
  9554. bindKey: "Shift-Home",
  9555. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9556. multiSelectAction: "forEach",
  9557. scrollIntoView: "cursor",
  9558. readOnly: true
  9559. }, {
  9560. name: "selectlineend",
  9561. bindKey: "Shift-End",
  9562. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9563. multiSelectAction: "forEach",
  9564. scrollIntoView: "cursor",
  9565. readOnly: true
  9566. }, {
  9567. name: "togglerecording",
  9568. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9569. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9570. readOnly: true
  9571. }, {
  9572. name: "replaymacro",
  9573. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9574. exec: function(editor) { editor.commands.replay(editor); },
  9575. readOnly: true
  9576. }, {
  9577. name: "jumptomatching",
  9578. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9579. exec: function(editor) { editor.jumpToMatching(); },
  9580. multiSelectAction: "forEach",
  9581. scrollIntoView: "animate",
  9582. readOnly: true
  9583. }, {
  9584. name: "selecttomatching",
  9585. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9586. exec: function(editor) { editor.jumpToMatching(true); },
  9587. multiSelectAction: "forEach",
  9588. scrollIntoView: "animate",
  9589. readOnly: true
  9590. }, {
  9591. name: "expandToMatching",
  9592. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9593. exec: function(editor) { editor.jumpToMatching(true, true); },
  9594. multiSelectAction: "forEach",
  9595. scrollIntoView: "animate",
  9596. readOnly: true
  9597. }, {
  9598. name: "passKeysToBrowser",
  9599. bindKey: bindKey(null, null),
  9600. exec: function() {},
  9601. passEvent: true,
  9602. readOnly: true
  9603. }, {
  9604. name: "copy",
  9605. exec: function(editor) {
  9606. },
  9607. readOnly: true
  9608. },
  9609. {
  9610. name: "cut",
  9611. exec: function(editor) {
  9612. var range = editor.getSelectionRange();
  9613. editor._emit("cut", range);
  9614. if (!editor.selection.isEmpty()) {
  9615. editor.session.remove(range);
  9616. editor.clearSelection();
  9617. }
  9618. },
  9619. scrollIntoView: "cursor",
  9620. multiSelectAction: "forEach"
  9621. }, {
  9622. name: "paste",
  9623. exec: function(editor, args) {
  9624. editor.$handlePaste(args);
  9625. },
  9626. scrollIntoView: "cursor"
  9627. }, {
  9628. name: "removeline",
  9629. bindKey: bindKey("Ctrl-D", "Command-D"),
  9630. exec: function(editor) { editor.removeLines(); },
  9631. scrollIntoView: "cursor",
  9632. multiSelectAction: "forEachLine"
  9633. }, {
  9634. name: "duplicateSelection",
  9635. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9636. exec: function(editor) { editor.duplicateSelection(); },
  9637. scrollIntoView: "cursor",
  9638. multiSelectAction: "forEach"
  9639. }, {
  9640. name: "sortlines",
  9641. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9642. exec: function(editor) { editor.sortLines(); },
  9643. scrollIntoView: "selection",
  9644. multiSelectAction: "forEachLine"
  9645. }, {
  9646. name: "togglecomment",
  9647. bindKey: bindKey("Ctrl-/", "Command-/"),
  9648. exec: function(editor) { editor.toggleCommentLines(); },
  9649. multiSelectAction: "forEachLine",
  9650. scrollIntoView: "selectionPart"
  9651. }, {
  9652. name: "toggleBlockComment",
  9653. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9654. exec: function(editor) { editor.toggleBlockComment(); },
  9655. multiSelectAction: "forEach",
  9656. scrollIntoView: "selectionPart"
  9657. }, {
  9658. name: "modifyNumberUp",
  9659. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9660. exec: function(editor) { editor.modifyNumber(1); },
  9661. scrollIntoView: "cursor",
  9662. multiSelectAction: "forEach"
  9663. }, {
  9664. name: "modifyNumberDown",
  9665. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9666. exec: function(editor) { editor.modifyNumber(-1); },
  9667. scrollIntoView: "cursor",
  9668. multiSelectAction: "forEach"
  9669. }, {
  9670. name: "replace",
  9671. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9672. exec: function(editor) {
  9673. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9674. }
  9675. }, {
  9676. name: "undo",
  9677. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9678. exec: function(editor) { editor.undo(); }
  9679. }, {
  9680. name: "redo",
  9681. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9682. exec: function(editor) { editor.redo(); }
  9683. }, {
  9684. name: "copylinesup",
  9685. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9686. exec: function(editor) { editor.copyLinesUp(); },
  9687. scrollIntoView: "cursor"
  9688. }, {
  9689. name: "movelinesup",
  9690. bindKey: bindKey("Alt-Up", "Option-Up"),
  9691. exec: function(editor) { editor.moveLinesUp(); },
  9692. scrollIntoView: "cursor"
  9693. }, {
  9694. name: "copylinesdown",
  9695. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9696. exec: function(editor) { editor.copyLinesDown(); },
  9697. scrollIntoView: "cursor"
  9698. }, {
  9699. name: "movelinesdown",
  9700. bindKey: bindKey("Alt-Down", "Option-Down"),
  9701. exec: function(editor) { editor.moveLinesDown(); },
  9702. scrollIntoView: "cursor"
  9703. }, {
  9704. name: "del",
  9705. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9706. exec: function(editor) { editor.remove("right"); },
  9707. multiSelectAction: "forEach",
  9708. scrollIntoView: "cursor"
  9709. }, {
  9710. name: "backspace",
  9711. bindKey: bindKey(
  9712. "Shift-Backspace|Backspace",
  9713. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9714. ),
  9715. exec: function(editor) { editor.remove("left"); },
  9716. multiSelectAction: "forEach",
  9717. scrollIntoView: "cursor"
  9718. }, {
  9719. name: "cut_or_delete",
  9720. bindKey: bindKey("Shift-Delete", null),
  9721. exec: function(editor) {
  9722. if (editor.selection.isEmpty()) {
  9723. editor.remove("left");
  9724. } else {
  9725. return false;
  9726. }
  9727. },
  9728. multiSelectAction: "forEach",
  9729. scrollIntoView: "cursor"
  9730. }, {
  9731. name: "removetolinestart",
  9732. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9733. exec: function(editor) { editor.removeToLineStart(); },
  9734. multiSelectAction: "forEach",
  9735. scrollIntoView: "cursor"
  9736. }, {
  9737. name: "removetolineend",
  9738. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9739. exec: function(editor) { editor.removeToLineEnd(); },
  9740. multiSelectAction: "forEach",
  9741. scrollIntoView: "cursor"
  9742. }, {
  9743. name: "removewordleft",
  9744. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9745. exec: function(editor) { editor.removeWordLeft(); },
  9746. multiSelectAction: "forEach",
  9747. scrollIntoView: "cursor"
  9748. }, {
  9749. name: "removewordright",
  9750. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9751. exec: function(editor) { editor.removeWordRight(); },
  9752. multiSelectAction: "forEach",
  9753. scrollIntoView: "cursor"
  9754. }, {
  9755. name: "outdent",
  9756. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9757. exec: function(editor) { editor.blockOutdent(); },
  9758. multiSelectAction: "forEach",
  9759. scrollIntoView: "selectionPart"
  9760. }, {
  9761. name: "indent",
  9762. bindKey: bindKey("Tab", "Tab"),
  9763. exec: function(editor) { editor.indent(); },
  9764. multiSelectAction: "forEach",
  9765. scrollIntoView: "selectionPart"
  9766. }, {
  9767. name: "blockoutdent",
  9768. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9769. exec: function(editor) { editor.blockOutdent(); },
  9770. multiSelectAction: "forEachLine",
  9771. scrollIntoView: "selectionPart"
  9772. }, {
  9773. name: "blockindent",
  9774. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9775. exec: function(editor) { editor.blockIndent(); },
  9776. multiSelectAction: "forEachLine",
  9777. scrollIntoView: "selectionPart"
  9778. }, {
  9779. name: "insertstring",
  9780. exec: function(editor, str) { editor.insert(str); },
  9781. multiSelectAction: "forEach",
  9782. scrollIntoView: "cursor"
  9783. }, {
  9784. name: "inserttext",
  9785. exec: function(editor, args) {
  9786. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9787. },
  9788. multiSelectAction: "forEach",
  9789. scrollIntoView: "cursor"
  9790. }, {
  9791. name: "splitline",
  9792. bindKey: bindKey(null, "Ctrl-O"),
  9793. exec: function(editor) { editor.splitLine(); },
  9794. multiSelectAction: "forEach",
  9795. scrollIntoView: "cursor"
  9796. }, {
  9797. name: "transposeletters",
  9798. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9799. exec: function(editor) { editor.transposeLetters(); },
  9800. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9801. scrollIntoView: "cursor"
  9802. }, {
  9803. name: "touppercase",
  9804. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9805. exec: function(editor) { editor.toUpperCase(); },
  9806. multiSelectAction: "forEach",
  9807. scrollIntoView: "cursor"
  9808. }, {
  9809. name: "tolowercase",
  9810. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9811. exec: function(editor) { editor.toLowerCase(); },
  9812. multiSelectAction: "forEach",
  9813. scrollIntoView: "cursor"
  9814. }, {
  9815. name: "expandtoline",
  9816. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9817. exec: function(editor) {
  9818. var range = editor.selection.getRange();
  9819. range.start.column = range.end.column = 0;
  9820. range.end.row++;
  9821. editor.selection.setRange(range, false);
  9822. },
  9823. multiSelectAction: "forEach",
  9824. scrollIntoView: "cursor",
  9825. readOnly: true
  9826. }, {
  9827. name: "joinlines",
  9828. bindKey: bindKey(null, null),
  9829. exec: function(editor) {
  9830. var isBackwards = editor.selection.isBackwards();
  9831. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9832. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9833. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9834. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9835. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9836. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9837. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9838. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9839. if (curLine.length !== 0) {
  9840. curLine = " " + curLine;
  9841. }
  9842. insertLine += curLine;
  9843. }
  9844. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9845. insertLine += editor.session.doc.getNewLineCharacter();
  9846. }
  9847. editor.clearSelection();
  9848. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9849. if (selectedCount > 0) {
  9850. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9851. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9852. } else {
  9853. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9854. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9855. }
  9856. },
  9857. multiSelectAction: "forEach",
  9858. readOnly: true
  9859. }, {
  9860. name: "invertSelection",
  9861. bindKey: bindKey(null, null),
  9862. exec: function(editor) {
  9863. var endRow = editor.session.doc.getLength() - 1;
  9864. var endCol = editor.session.doc.getLine(endRow).length;
  9865. var ranges = editor.selection.rangeList.ranges;
  9866. var newRanges = [];
  9867. if (ranges.length < 1) {
  9868. ranges = [editor.selection.getRange()];
  9869. }
  9870. for (var i = 0; i < ranges.length; i++) {
  9871. if (i == (ranges.length - 1)) {
  9872. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9873. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9874. }
  9875. }
  9876. if (i === 0) {
  9877. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9878. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9879. }
  9880. } else {
  9881. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9882. }
  9883. }
  9884. editor.exitMultiSelectMode();
  9885. editor.clearSelection();
  9886. for(var i = 0; i < newRanges.length; i++) {
  9887. editor.selection.addRange(newRanges[i], false);
  9888. }
  9889. },
  9890. readOnly: true,
  9891. scrollIntoView: "none"
  9892. }];
  9893. });
  9894. ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(require, exports, module) {
  9895. "use strict";
  9896. require("./lib/fixoldbrowsers");
  9897. var oop = require("./lib/oop");
  9898. var dom = require("./lib/dom");
  9899. var lang = require("./lib/lang");
  9900. var useragent = require("./lib/useragent");
  9901. var TextInput = require("./keyboard/textinput").TextInput;
  9902. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9903. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9904. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9905. var EditSession = require("./edit_session").EditSession;
  9906. var Search = require("./search").Search;
  9907. var Range = require("./range").Range;
  9908. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9909. var CommandManager = require("./commands/command_manager").CommandManager;
  9910. var defaultCommands = require("./commands/default_commands").commands;
  9911. var config = require("./config");
  9912. var TokenIterator = require("./token_iterator").TokenIterator;
  9913. var Editor = function(renderer, session) {
  9914. var container = renderer.getContainerElement();
  9915. this.container = container;
  9916. this.renderer = renderer;
  9917. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9918. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9919. this.renderer.textarea = this.textInput.getElement();
  9920. this.keyBinding = new KeyBinding(this);
  9921. this.$mouseHandler = new MouseHandler(this);
  9922. new FoldHandler(this);
  9923. this.$blockScrolling = 0;
  9924. this.$search = new Search().set({
  9925. wrap: true
  9926. });
  9927. this.$historyTracker = this.$historyTracker.bind(this);
  9928. this.commands.on("exec", this.$historyTracker);
  9929. this.$initOperationListeners();
  9930. this._$emitInputEvent = lang.delayedCall(function() {
  9931. this._signal("input", {});
  9932. if (this.session && this.session.bgTokenizer)
  9933. this.session.bgTokenizer.scheduleStart();
  9934. }.bind(this));
  9935. this.on("change", function(_, _self) {
  9936. _self._$emitInputEvent.schedule(31);
  9937. });
  9938. this.setSession(session || new EditSession(""));
  9939. config.resetOptions(this);
  9940. config._signal("editor", this);
  9941. };
  9942. (function(){
  9943. oop.implement(this, EventEmitter);
  9944. this.$initOperationListeners = function() {
  9945. function last(a) {return a[a.length - 1]}
  9946. this.selections = [];
  9947. this.commands.on("exec", this.startOperation.bind(this), true);
  9948. this.commands.on("afterExec", this.endOperation.bind(this), true);
  9949. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  9950. this.on("change", function() {
  9951. this.curOp || this.startOperation();
  9952. this.curOp.docChanged = true;
  9953. }.bind(this), true);
  9954. this.on("changeSelection", function() {
  9955. this.curOp || this.startOperation();
  9956. this.curOp.selectionChanged = true;
  9957. }.bind(this), true);
  9958. };
  9959. this.curOp = null;
  9960. this.prevOp = {};
  9961. this.startOperation = function(commadEvent) {
  9962. if (this.curOp) {
  9963. if (!commadEvent || this.curOp.command)
  9964. return;
  9965. this.prevOp = this.curOp;
  9966. }
  9967. if (!commadEvent) {
  9968. this.previousCommand = null;
  9969. commadEvent = {};
  9970. }
  9971. this.$opResetTimer.schedule();
  9972. this.curOp = {
  9973. command: commadEvent.command || {},
  9974. args: commadEvent.args,
  9975. scrollTop: this.renderer.scrollTop
  9976. };
  9977. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  9978. this.$blockScrolling++;
  9979. };
  9980. this.endOperation = function(e) {
  9981. if (this.curOp) {
  9982. if (e && e.returnValue === false)
  9983. return this.curOp = null;
  9984. this._signal("beforeEndOperation");
  9985. var command = this.curOp.command;
  9986. if (command.name && this.$blockScrolling > 0)
  9987. this.$blockScrolling--;
  9988. var scrollIntoView = command && command.scrollIntoView;
  9989. if (scrollIntoView) {
  9990. switch (scrollIntoView) {
  9991. case "center-animate":
  9992. scrollIntoView = "animate";
  9993. case "center":
  9994. this.renderer.scrollCursorIntoView(null, 0.5);
  9995. break;
  9996. case "animate":
  9997. case "cursor":
  9998. this.renderer.scrollCursorIntoView();
  9999. break;
  10000. case "selectionPart":
  10001. var range = this.selection.getRange();
  10002. var config = this.renderer.layerConfig;
  10003. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  10004. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  10005. }
  10006. break;
  10007. default:
  10008. break;
  10009. }
  10010. if (scrollIntoView == "animate")
  10011. this.renderer.animateScrolling(this.curOp.scrollTop);
  10012. }
  10013. this.prevOp = this.curOp;
  10014. this.curOp = null;
  10015. }
  10016. };
  10017. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  10018. this.$historyTracker = function(e) {
  10019. if (!this.$mergeUndoDeltas)
  10020. return;
  10021. var prev = this.prevOp;
  10022. var mergeableCommands = this.$mergeableCommands;
  10023. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  10024. if (e.command.name == "insertstring") {
  10025. var text = e.args;
  10026. if (this.mergeNextCommand === undefined)
  10027. this.mergeNextCommand = true;
  10028. shouldMerge = shouldMerge
  10029. && this.mergeNextCommand // previous command allows to coalesce with
  10030. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  10031. this.mergeNextCommand = true;
  10032. } else {
  10033. shouldMerge = shouldMerge
  10034. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  10035. }
  10036. if (
  10037. this.$mergeUndoDeltas != "always"
  10038. && Date.now() - this.sequenceStartTime > 2000
  10039. ) {
  10040. shouldMerge = false; // the sequence is too long
  10041. }
  10042. if (shouldMerge)
  10043. this.session.mergeUndoDeltas = true;
  10044. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  10045. this.sequenceStartTime = Date.now();
  10046. };
  10047. this.setKeyboardHandler = function(keyboardHandler, cb) {
  10048. if (keyboardHandler && typeof keyboardHandler === "string") {
  10049. this.$keybindingId = keyboardHandler;
  10050. var _self = this;
  10051. config.loadModule(["keybinding", keyboardHandler], function(module) {
  10052. if (_self.$keybindingId == keyboardHandler)
  10053. _self.keyBinding.setKeyboardHandler(module && module.handler);
  10054. cb && cb();
  10055. });
  10056. } else {
  10057. this.$keybindingId = null;
  10058. this.keyBinding.setKeyboardHandler(keyboardHandler);
  10059. cb && cb();
  10060. }
  10061. };
  10062. this.getKeyboardHandler = function() {
  10063. return this.keyBinding.getKeyboardHandler();
  10064. };
  10065. this.setSession = function(session) {
  10066. if (this.session == session)
  10067. return;
  10068. if (this.curOp) this.endOperation();
  10069. this.curOp = {};
  10070. var oldSession = this.session;
  10071. if (oldSession) {
  10072. this.session.removeEventListener("change", this.$onDocumentChange);
  10073. this.session.removeEventListener("changeMode", this.$onChangeMode);
  10074. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10075. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  10076. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10077. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  10078. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  10079. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10080. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  10081. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10082. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  10083. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  10084. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  10085. this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10086. var selection = this.session.getSelection();
  10087. selection.removeEventListener("changeCursor", this.$onCursorChange);
  10088. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  10089. }
  10090. this.session = session;
  10091. if (session) {
  10092. this.$onDocumentChange = this.onDocumentChange.bind(this);
  10093. session.addEventListener("change", this.$onDocumentChange);
  10094. this.renderer.setSession(session);
  10095. this.$onChangeMode = this.onChangeMode.bind(this);
  10096. session.addEventListener("changeMode", this.$onChangeMode);
  10097. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  10098. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10099. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  10100. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  10101. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  10102. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10103. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  10104. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  10105. this.$onChangeFold = this.onChangeFold.bind(this);
  10106. session.addEventListener("changeFold", this.$onChangeFold);
  10107. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  10108. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10109. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  10110. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  10111. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  10112. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10113. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  10114. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  10115. this.$onCursorChange = this.onCursorChange.bind(this);
  10116. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  10117. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  10118. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  10119. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  10120. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10121. this.selection = session.getSelection();
  10122. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  10123. this.$onSelectionChange = this.onSelectionChange.bind(this);
  10124. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  10125. this.onChangeMode();
  10126. this.$blockScrolling += 1;
  10127. this.onCursorChange();
  10128. this.$blockScrolling -= 1;
  10129. this.onScrollTopChange();
  10130. this.onScrollLeftChange();
  10131. this.onSelectionChange();
  10132. this.onChangeFrontMarker();
  10133. this.onChangeBackMarker();
  10134. this.onChangeBreakpoint();
  10135. this.onChangeAnnotation();
  10136. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  10137. this.renderer.updateFull();
  10138. } else {
  10139. this.selection = null;
  10140. this.renderer.setSession(session);
  10141. }
  10142. this._signal("changeSession", {
  10143. session: session,
  10144. oldSession: oldSession
  10145. });
  10146. this.curOp = null;
  10147. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  10148. session && session._signal("changeEditor", {editor: this});
  10149. };
  10150. this.getSession = function() {
  10151. return this.session;
  10152. };
  10153. this.setValue = function(val, cursorPos) {
  10154. this.session.doc.setValue(val);
  10155. if (!cursorPos)
  10156. this.selectAll();
  10157. else if (cursorPos == 1)
  10158. this.navigateFileEnd();
  10159. else if (cursorPos == -1)
  10160. this.navigateFileStart();
  10161. return val;
  10162. };
  10163. this.getValue = function() {
  10164. return this.session.getValue();
  10165. };
  10166. this.getSelection = function() {
  10167. return this.selection;
  10168. };
  10169. this.resize = function(force) {
  10170. this.renderer.onResize(force);
  10171. };
  10172. this.setTheme = function(theme, cb) {
  10173. this.renderer.setTheme(theme, cb);
  10174. };
  10175. this.getTheme = function() {
  10176. return this.renderer.getTheme();
  10177. };
  10178. this.setStyle = function(style) {
  10179. this.renderer.setStyle(style);
  10180. };
  10181. this.unsetStyle = function(style) {
  10182. this.renderer.unsetStyle(style);
  10183. };
  10184. this.getFontSize = function () {
  10185. return this.getOption("fontSize") ||
  10186. dom.computedStyle(this.container, "fontSize");
  10187. };
  10188. this.setFontSize = function(size) {
  10189. this.setOption("fontSize", size);
  10190. };
  10191. this.$highlightBrackets = function() {
  10192. if (this.session.$bracketHighlight) {
  10193. this.session.removeMarker(this.session.$bracketHighlight);
  10194. this.session.$bracketHighlight = null;
  10195. }
  10196. if (this.$highlightPending) {
  10197. return;
  10198. }
  10199. var self = this;
  10200. this.$highlightPending = true;
  10201. setTimeout(function() {
  10202. self.$highlightPending = false;
  10203. var session = self.session;
  10204. if (!session || !session.bgTokenizer) return;
  10205. var pos = session.findMatchingBracket(self.getCursorPosition());
  10206. if (pos) {
  10207. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10208. } else if (session.$mode.getMatching) {
  10209. var range = session.$mode.getMatching(self.session);
  10210. }
  10211. if (range)
  10212. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10213. }, 50);
  10214. };
  10215. this.$highlightTags = function() {
  10216. if (this.$highlightTagPending)
  10217. return;
  10218. var self = this;
  10219. this.$highlightTagPending = true;
  10220. setTimeout(function() {
  10221. self.$highlightTagPending = false;
  10222. var session = self.session;
  10223. if (!session || !session.bgTokenizer) return;
  10224. var pos = self.getCursorPosition();
  10225. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10226. var token = iterator.getCurrentToken();
  10227. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10228. session.removeMarker(session.$tagHighlight);
  10229. session.$tagHighlight = null;
  10230. return;
  10231. }
  10232. if (token.type.indexOf("tag-open") != -1) {
  10233. token = iterator.stepForward();
  10234. if (!token)
  10235. return;
  10236. }
  10237. var tag = token.value;
  10238. var depth = 0;
  10239. var prevToken = iterator.stepBackward();
  10240. if (prevToken.value == '<'){
  10241. do {
  10242. prevToken = token;
  10243. token = iterator.stepForward();
  10244. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10245. if (prevToken.value === '<'){
  10246. depth++;
  10247. } else if (prevToken.value === '</'){
  10248. depth--;
  10249. }
  10250. }
  10251. } while (token && depth >= 0);
  10252. } else {
  10253. do {
  10254. token = prevToken;
  10255. prevToken = iterator.stepBackward();
  10256. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10257. if (prevToken.value === '<') {
  10258. depth++;
  10259. } else if (prevToken.value === '</') {
  10260. depth--;
  10261. }
  10262. }
  10263. } while (prevToken && depth <= 0);
  10264. iterator.stepForward();
  10265. }
  10266. if (!token) {
  10267. session.removeMarker(session.$tagHighlight);
  10268. session.$tagHighlight = null;
  10269. return;
  10270. }
  10271. var row = iterator.getCurrentTokenRow();
  10272. var column = iterator.getCurrentTokenColumn();
  10273. var range = new Range(row, column, row, column+token.value.length);
  10274. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10275. session.removeMarker(session.$tagHighlight);
  10276. session.$tagHighlight = null;
  10277. }
  10278. if (range && !session.$tagHighlight)
  10279. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10280. }, 50);
  10281. };
  10282. this.focus = function() {
  10283. var _self = this;
  10284. setTimeout(function() {
  10285. _self.textInput.focus();
  10286. });
  10287. this.textInput.focus();
  10288. };
  10289. this.isFocused = function() {
  10290. return this.textInput.isFocused();
  10291. };
  10292. this.blur = function() {
  10293. this.textInput.blur();
  10294. };
  10295. this.onFocus = function(e) {
  10296. if (this.$isFocused)
  10297. return;
  10298. this.$isFocused = true;
  10299. this.renderer.showCursor();
  10300. this.renderer.visualizeFocus();
  10301. this._emit("focus", e);
  10302. };
  10303. this.onBlur = function(e) {
  10304. if (!this.$isFocused)
  10305. return;
  10306. this.$isFocused = false;
  10307. this.renderer.hideCursor();
  10308. this.renderer.visualizeBlur();
  10309. this._emit("blur", e);
  10310. };
  10311. this.$cursorChange = function() {
  10312. this.renderer.updateCursor();
  10313. };
  10314. this.onDocumentChange = function(delta) {
  10315. var wrap = this.session.$useWrapMode;
  10316. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  10317. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  10318. this._signal("change", delta);
  10319. this.$cursorChange();
  10320. this.$updateHighlightActiveLine();
  10321. };
  10322. this.onTokenizerUpdate = function(e) {
  10323. var rows = e.data;
  10324. this.renderer.updateLines(rows.first, rows.last);
  10325. };
  10326. this.onScrollTopChange = function() {
  10327. this.renderer.scrollToY(this.session.getScrollTop());
  10328. };
  10329. this.onScrollLeftChange = function() {
  10330. this.renderer.scrollToX(this.session.getScrollLeft());
  10331. };
  10332. this.onCursorChange = function() {
  10333. this.$cursorChange();
  10334. if (!this.$blockScrolling) {
  10335. config.warn("Automatically scrolling cursor into view after selection change",
  10336. "this will be disabled in the next version",
  10337. "set editor.$blockScrolling = Infinity to disable this message"
  10338. );
  10339. this.renderer.scrollCursorIntoView();
  10340. }
  10341. this.$highlightBrackets();
  10342. this.$highlightTags();
  10343. this.$updateHighlightActiveLine();
  10344. this._signal("changeSelection");
  10345. };
  10346. this.$updateHighlightActiveLine = function() {
  10347. var session = this.getSession();
  10348. var highlight;
  10349. if (this.$highlightActiveLine) {
  10350. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10351. highlight = this.getCursorPosition();
  10352. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10353. highlight = false;
  10354. }
  10355. if (session.$highlightLineMarker && !highlight) {
  10356. session.removeMarker(session.$highlightLineMarker.id);
  10357. session.$highlightLineMarker = null;
  10358. } else if (!session.$highlightLineMarker && highlight) {
  10359. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10360. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10361. session.$highlightLineMarker = range;
  10362. } else if (highlight) {
  10363. session.$highlightLineMarker.start.row = highlight.row;
  10364. session.$highlightLineMarker.end.row = highlight.row;
  10365. session.$highlightLineMarker.start.column = highlight.column;
  10366. session._signal("changeBackMarker");
  10367. }
  10368. };
  10369. this.onSelectionChange = function(e) {
  10370. var session = this.session;
  10371. if (session.$selectionMarker) {
  10372. session.removeMarker(session.$selectionMarker);
  10373. }
  10374. session.$selectionMarker = null;
  10375. if (!this.selection.isEmpty()) {
  10376. var range = this.selection.getRange();
  10377. var style = this.getSelectionStyle();
  10378. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10379. } else {
  10380. this.$updateHighlightActiveLine();
  10381. }
  10382. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10383. this.session.highlight(re);
  10384. this._signal("changeSelection");
  10385. };
  10386. this.$getSelectionHighLightRegexp = function() {
  10387. var session = this.session;
  10388. var selection = this.getSelectionRange();
  10389. if (selection.isEmpty() || selection.isMultiLine())
  10390. return;
  10391. var startOuter = selection.start.column - 1;
  10392. var endOuter = selection.end.column + 1;
  10393. var line = session.getLine(selection.start.row);
  10394. var lineCols = line.length;
  10395. var needle = line.substring(Math.max(startOuter, 0),
  10396. Math.min(endOuter, lineCols));
  10397. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10398. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10399. return;
  10400. needle = line.substring(selection.start.column, selection.end.column);
  10401. if (!/^[\w\d]+$/.test(needle))
  10402. return;
  10403. var re = this.$search.$assembleRegExp({
  10404. wholeWord: true,
  10405. caseSensitive: true,
  10406. needle: needle
  10407. });
  10408. return re;
  10409. };
  10410. this.onChangeFrontMarker = function() {
  10411. this.renderer.updateFrontMarkers();
  10412. };
  10413. this.onChangeBackMarker = function() {
  10414. this.renderer.updateBackMarkers();
  10415. };
  10416. this.onChangeBreakpoint = function() {
  10417. this.renderer.updateBreakpoints();
  10418. };
  10419. this.onChangeAnnotation = function() {
  10420. this.renderer.setAnnotations(this.session.getAnnotations());
  10421. };
  10422. this.onChangeMode = function(e) {
  10423. this.renderer.updateText();
  10424. this._emit("changeMode", e);
  10425. };
  10426. this.onChangeWrapLimit = function() {
  10427. this.renderer.updateFull();
  10428. };
  10429. this.onChangeWrapMode = function() {
  10430. this.renderer.onResize(true);
  10431. };
  10432. this.onChangeFold = function() {
  10433. this.$updateHighlightActiveLine();
  10434. this.renderer.updateFull();
  10435. };
  10436. this.getSelectedText = function() {
  10437. return this.session.getTextRange(this.getSelectionRange());
  10438. };
  10439. this.getCopyText = function() {
  10440. var text = this.getSelectedText();
  10441. this._signal("copy", text);
  10442. return text;
  10443. };
  10444. this.onCopy = function() {
  10445. this.commands.exec("copy", this);
  10446. };
  10447. this.onCut = function() {
  10448. this.commands.exec("cut", this);
  10449. };
  10450. this.onPaste = function(text, event) {
  10451. var e = {text: text, event: event};
  10452. this.commands.exec("paste", this, e);
  10453. };
  10454. this.$handlePaste = function(e) {
  10455. if (typeof e == "string")
  10456. e = {text: e};
  10457. this._signal("paste", e);
  10458. var text = e.text;
  10459. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10460. this.insert(text);
  10461. } else {
  10462. var lines = text.split(/\r\n|\r|\n/);
  10463. var ranges = this.selection.rangeList.ranges;
  10464. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10465. return this.commands.exec("insertstring", this, text);
  10466. for (var i = ranges.length; i--;) {
  10467. var range = ranges[i];
  10468. if (!range.isEmpty())
  10469. this.session.remove(range);
  10470. this.session.insert(range.start, lines[i]);
  10471. }
  10472. }
  10473. };
  10474. this.execCommand = function(command, args) {
  10475. return this.commands.exec(command, this, args);
  10476. };
  10477. this.insert = function(text, pasted) {
  10478. var session = this.session;
  10479. var mode = session.getMode();
  10480. var cursor = this.getCursorPosition();
  10481. if (this.getBehavioursEnabled() && !pasted) {
  10482. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10483. if (transform) {
  10484. if (text !== transform.text) {
  10485. this.session.mergeUndoDeltas = false;
  10486. this.$mergeNextCommand = false;
  10487. }
  10488. text = transform.text;
  10489. }
  10490. }
  10491. if (text == "\t")
  10492. text = this.session.getTabString();
  10493. if (!this.selection.isEmpty()) {
  10494. var range = this.getSelectionRange();
  10495. cursor = this.session.remove(range);
  10496. this.clearSelection();
  10497. }
  10498. else if (this.session.getOverwrite()) {
  10499. var range = new Range.fromPoints(cursor, cursor);
  10500. range.end.column += text.length;
  10501. this.session.remove(range);
  10502. }
  10503. if (text == "\n" || text == "\r\n") {
  10504. var line = session.getLine(cursor.row);
  10505. if (cursor.column > line.search(/\S|$/)) {
  10506. var d = line.substr(cursor.column).search(/\S|$/);
  10507. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10508. }
  10509. }
  10510. this.clearSelection();
  10511. var start = cursor.column;
  10512. var lineState = session.getState(cursor.row);
  10513. var line = session.getLine(cursor.row);
  10514. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10515. var end = session.insert(cursor, text);
  10516. if (transform && transform.selection) {
  10517. if (transform.selection.length == 2) { // Transform relative to the current column
  10518. this.selection.setSelectionRange(
  10519. new Range(cursor.row, start + transform.selection[0],
  10520. cursor.row, start + transform.selection[1]));
  10521. } else { // Transform relative to the current row.
  10522. this.selection.setSelectionRange(
  10523. new Range(cursor.row + transform.selection[0],
  10524. transform.selection[1],
  10525. cursor.row + transform.selection[2],
  10526. transform.selection[3]));
  10527. }
  10528. }
  10529. if (session.getDocument().isNewLine(text)) {
  10530. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10531. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10532. }
  10533. if (shouldOutdent)
  10534. mode.autoOutdent(lineState, session, cursor.row);
  10535. };
  10536. this.onTextInput = function(text) {
  10537. this.keyBinding.onTextInput(text);
  10538. };
  10539. this.onCommandKey = function(e, hashId, keyCode) {
  10540. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10541. };
  10542. this.setOverwrite = function(overwrite) {
  10543. this.session.setOverwrite(overwrite);
  10544. };
  10545. this.getOverwrite = function() {
  10546. return this.session.getOverwrite();
  10547. };
  10548. this.toggleOverwrite = function() {
  10549. this.session.toggleOverwrite();
  10550. };
  10551. this.setScrollSpeed = function(speed) {
  10552. this.setOption("scrollSpeed", speed);
  10553. };
  10554. this.getScrollSpeed = function() {
  10555. return this.getOption("scrollSpeed");
  10556. };
  10557. this.setDragDelay = function(dragDelay) {
  10558. this.setOption("dragDelay", dragDelay);
  10559. };
  10560. this.getDragDelay = function() {
  10561. return this.getOption("dragDelay");
  10562. };
  10563. this.setSelectionStyle = function(val) {
  10564. this.setOption("selectionStyle", val);
  10565. };
  10566. this.getSelectionStyle = function() {
  10567. return this.getOption("selectionStyle");
  10568. };
  10569. this.setHighlightActiveLine = function(shouldHighlight) {
  10570. this.setOption("highlightActiveLine", shouldHighlight);
  10571. };
  10572. this.getHighlightActiveLine = function() {
  10573. return this.getOption("highlightActiveLine");
  10574. };
  10575. this.setHighlightGutterLine = function(shouldHighlight) {
  10576. this.setOption("highlightGutterLine", shouldHighlight);
  10577. };
  10578. this.getHighlightGutterLine = function() {
  10579. return this.getOption("highlightGutterLine");
  10580. };
  10581. this.setHighlightSelectedWord = function(shouldHighlight) {
  10582. this.setOption("highlightSelectedWord", shouldHighlight);
  10583. };
  10584. this.getHighlightSelectedWord = function() {
  10585. return this.$highlightSelectedWord;
  10586. };
  10587. this.setAnimatedScroll = function(shouldAnimate){
  10588. this.renderer.setAnimatedScroll(shouldAnimate);
  10589. };
  10590. this.getAnimatedScroll = function(){
  10591. return this.renderer.getAnimatedScroll();
  10592. };
  10593. this.setShowInvisibles = function(showInvisibles) {
  10594. this.renderer.setShowInvisibles(showInvisibles);
  10595. };
  10596. this.getShowInvisibles = function() {
  10597. return this.renderer.getShowInvisibles();
  10598. };
  10599. this.setDisplayIndentGuides = function(display) {
  10600. this.renderer.setDisplayIndentGuides(display);
  10601. };
  10602. this.getDisplayIndentGuides = function() {
  10603. return this.renderer.getDisplayIndentGuides();
  10604. };
  10605. this.setShowPrintMargin = function(showPrintMargin) {
  10606. this.renderer.setShowPrintMargin(showPrintMargin);
  10607. };
  10608. this.getShowPrintMargin = function() {
  10609. return this.renderer.getShowPrintMargin();
  10610. };
  10611. this.setPrintMarginColumn = function(showPrintMargin) {
  10612. this.renderer.setPrintMarginColumn(showPrintMargin);
  10613. };
  10614. this.getPrintMarginColumn = function() {
  10615. return this.renderer.getPrintMarginColumn();
  10616. };
  10617. this.setReadOnly = function(readOnly) {
  10618. this.setOption("readOnly", readOnly);
  10619. };
  10620. this.getReadOnly = function() {
  10621. return this.getOption("readOnly");
  10622. };
  10623. this.setBehavioursEnabled = function (enabled) {
  10624. this.setOption("behavioursEnabled", enabled);
  10625. };
  10626. this.getBehavioursEnabled = function () {
  10627. return this.getOption("behavioursEnabled");
  10628. };
  10629. this.setWrapBehavioursEnabled = function (enabled) {
  10630. this.setOption("wrapBehavioursEnabled", enabled);
  10631. };
  10632. this.getWrapBehavioursEnabled = function () {
  10633. return this.getOption("wrapBehavioursEnabled");
  10634. };
  10635. this.setShowFoldWidgets = function(show) {
  10636. this.setOption("showFoldWidgets", show);
  10637. };
  10638. this.getShowFoldWidgets = function() {
  10639. return this.getOption("showFoldWidgets");
  10640. };
  10641. this.setFadeFoldWidgets = function(fade) {
  10642. this.setOption("fadeFoldWidgets", fade);
  10643. };
  10644. this.getFadeFoldWidgets = function() {
  10645. return this.getOption("fadeFoldWidgets");
  10646. };
  10647. this.remove = function(dir) {
  10648. if (this.selection.isEmpty()){
  10649. if (dir == "left")
  10650. this.selection.selectLeft();
  10651. else
  10652. this.selection.selectRight();
  10653. }
  10654. var range = this.getSelectionRange();
  10655. if (this.getBehavioursEnabled()) {
  10656. var session = this.session;
  10657. var state = session.getState(range.start.row);
  10658. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10659. if (range.end.column === 0) {
  10660. var text = session.getTextRange(range);
  10661. if (text[text.length - 1] == "\n") {
  10662. var line = session.getLine(range.end.row);
  10663. if (/^\s+$/.test(line)) {
  10664. range.end.column = line.length;
  10665. }
  10666. }
  10667. }
  10668. if (new_range)
  10669. range = new_range;
  10670. }
  10671. this.session.remove(range);
  10672. this.clearSelection();
  10673. };
  10674. this.removeWordRight = function() {
  10675. if (this.selection.isEmpty())
  10676. this.selection.selectWordRight();
  10677. this.session.remove(this.getSelectionRange());
  10678. this.clearSelection();
  10679. };
  10680. this.removeWordLeft = function() {
  10681. if (this.selection.isEmpty())
  10682. this.selection.selectWordLeft();
  10683. this.session.remove(this.getSelectionRange());
  10684. this.clearSelection();
  10685. };
  10686. this.removeToLineStart = function() {
  10687. if (this.selection.isEmpty())
  10688. this.selection.selectLineStart();
  10689. this.session.remove(this.getSelectionRange());
  10690. this.clearSelection();
  10691. };
  10692. this.removeToLineEnd = function() {
  10693. if (this.selection.isEmpty())
  10694. this.selection.selectLineEnd();
  10695. var range = this.getSelectionRange();
  10696. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10697. range.end.column = 0;
  10698. range.end.row++;
  10699. }
  10700. this.session.remove(range);
  10701. this.clearSelection();
  10702. };
  10703. this.splitLine = function() {
  10704. if (!this.selection.isEmpty()) {
  10705. this.session.remove(this.getSelectionRange());
  10706. this.clearSelection();
  10707. }
  10708. var cursor = this.getCursorPosition();
  10709. this.insert("\n");
  10710. this.moveCursorToPosition(cursor);
  10711. };
  10712. this.transposeLetters = function() {
  10713. if (!this.selection.isEmpty()) {
  10714. return;
  10715. }
  10716. var cursor = this.getCursorPosition();
  10717. var column = cursor.column;
  10718. if (column === 0)
  10719. return;
  10720. var line = this.session.getLine(cursor.row);
  10721. var swap, range;
  10722. if (column < line.length) {
  10723. swap = line.charAt(column) + line.charAt(column-1);
  10724. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10725. }
  10726. else {
  10727. swap = line.charAt(column-1) + line.charAt(column-2);
  10728. range = new Range(cursor.row, column-2, cursor.row, column);
  10729. }
  10730. this.session.replace(range, swap);
  10731. };
  10732. this.toLowerCase = function() {
  10733. var originalRange = this.getSelectionRange();
  10734. if (this.selection.isEmpty()) {
  10735. this.selection.selectWord();
  10736. }
  10737. var range = this.getSelectionRange();
  10738. var text = this.session.getTextRange(range);
  10739. this.session.replace(range, text.toLowerCase());
  10740. this.selection.setSelectionRange(originalRange);
  10741. };
  10742. this.toUpperCase = function() {
  10743. var originalRange = this.getSelectionRange();
  10744. if (this.selection.isEmpty()) {
  10745. this.selection.selectWord();
  10746. }
  10747. var range = this.getSelectionRange();
  10748. var text = this.session.getTextRange(range);
  10749. this.session.replace(range, text.toUpperCase());
  10750. this.selection.setSelectionRange(originalRange);
  10751. };
  10752. this.indent = function() {
  10753. var session = this.session;
  10754. var range = this.getSelectionRange();
  10755. if (range.start.row < range.end.row) {
  10756. var rows = this.$getSelectedRows();
  10757. session.indentRows(rows.first, rows.last, "\t");
  10758. return;
  10759. } else if (range.start.column < range.end.column) {
  10760. var text = session.getTextRange(range);
  10761. if (!/^\s+$/.test(text)) {
  10762. var rows = this.$getSelectedRows();
  10763. session.indentRows(rows.first, rows.last, "\t");
  10764. return;
  10765. }
  10766. }
  10767. var line = session.getLine(range.start.row);
  10768. var position = range.start;
  10769. var size = session.getTabSize();
  10770. var column = session.documentToScreenColumn(position.row, position.column);
  10771. if (this.session.getUseSoftTabs()) {
  10772. var count = (size - column % size);
  10773. var indentString = lang.stringRepeat(" ", count);
  10774. } else {
  10775. var count = column % size;
  10776. while (line[range.start.column] == " " && count) {
  10777. range.start.column--;
  10778. count--;
  10779. }
  10780. this.selection.setSelectionRange(range);
  10781. indentString = "\t";
  10782. }
  10783. return this.insert(indentString);
  10784. };
  10785. this.blockIndent = function() {
  10786. var rows = this.$getSelectedRows();
  10787. this.session.indentRows(rows.first, rows.last, "\t");
  10788. };
  10789. this.blockOutdent = function() {
  10790. var selection = this.session.getSelection();
  10791. this.session.outdentRows(selection.getRange());
  10792. };
  10793. this.sortLines = function() {
  10794. var rows = this.$getSelectedRows();
  10795. var session = this.session;
  10796. var lines = [];
  10797. for (i = rows.first; i <= rows.last; i++)
  10798. lines.push(session.getLine(i));
  10799. lines.sort(function(a, b) {
  10800. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10801. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10802. return 0;
  10803. });
  10804. var deleteRange = new Range(0, 0, 0, 0);
  10805. for (var i = rows.first; i <= rows.last; i++) {
  10806. var line = session.getLine(i);
  10807. deleteRange.start.row = i;
  10808. deleteRange.end.row = i;
  10809. deleteRange.end.column = line.length;
  10810. session.replace(deleteRange, lines[i-rows.first]);
  10811. }
  10812. };
  10813. this.toggleCommentLines = function() {
  10814. var state = this.session.getState(this.getCursorPosition().row);
  10815. var rows = this.$getSelectedRows();
  10816. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10817. };
  10818. this.toggleBlockComment = function() {
  10819. var cursor = this.getCursorPosition();
  10820. var state = this.session.getState(cursor.row);
  10821. var range = this.getSelectionRange();
  10822. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10823. };
  10824. this.getNumberAt = function(row, column) {
  10825. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10826. _numberRx.lastIndex = 0;
  10827. var s = this.session.getLine(row);
  10828. while (_numberRx.lastIndex < column) {
  10829. var m = _numberRx.exec(s);
  10830. if(m.index <= column && m.index+m[0].length >= column){
  10831. var number = {
  10832. value: m[0],
  10833. start: m.index,
  10834. end: m.index+m[0].length
  10835. };
  10836. return number;
  10837. }
  10838. }
  10839. return null;
  10840. };
  10841. this.modifyNumber = function(amount) {
  10842. var row = this.selection.getCursor().row;
  10843. var column = this.selection.getCursor().column;
  10844. var charRange = new Range(row, column-1, row, column);
  10845. var c = this.session.getTextRange(charRange);
  10846. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10847. var nr = this.getNumberAt(row, column);
  10848. if (nr) {
  10849. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10850. var decimals = nr.start + nr.value.length - fp;
  10851. var t = parseFloat(nr.value);
  10852. t *= Math.pow(10, decimals);
  10853. if(fp !== nr.end && column < fp){
  10854. amount *= Math.pow(10, nr.end - column - 1);
  10855. } else {
  10856. amount *= Math.pow(10, nr.end - column);
  10857. }
  10858. t += amount;
  10859. t /= Math.pow(10, decimals);
  10860. var nnr = t.toFixed(decimals);
  10861. var replaceRange = new Range(row, nr.start, row, nr.end);
  10862. this.session.replace(replaceRange, nnr);
  10863. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10864. }
  10865. }
  10866. };
  10867. this.removeLines = function() {
  10868. var rows = this.$getSelectedRows();
  10869. this.session.removeFullLines(rows.first, rows.last);
  10870. this.clearSelection();
  10871. };
  10872. this.duplicateSelection = function() {
  10873. var sel = this.selection;
  10874. var doc = this.session;
  10875. var range = sel.getRange();
  10876. var reverse = sel.isBackwards();
  10877. if (range.isEmpty()) {
  10878. var row = range.start.row;
  10879. doc.duplicateLines(row, row);
  10880. } else {
  10881. var point = reverse ? range.start : range.end;
  10882. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10883. range.start = point;
  10884. range.end = endPoint;
  10885. sel.setSelectionRange(range, reverse);
  10886. }
  10887. };
  10888. this.moveLinesDown = function() {
  10889. this.$moveLines(1, false);
  10890. };
  10891. this.moveLinesUp = function() {
  10892. this.$moveLines(-1, false);
  10893. };
  10894. this.moveText = function(range, toPosition, copy) {
  10895. return this.session.moveText(range, toPosition, copy);
  10896. };
  10897. this.copyLinesUp = function() {
  10898. this.$moveLines(-1, true);
  10899. };
  10900. this.copyLinesDown = function() {
  10901. this.$moveLines(1, true);
  10902. };
  10903. this.$moveLines = function(dir, copy) {
  10904. var rows, moved;
  10905. var selection = this.selection;
  10906. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10907. var range = selection.toOrientedRange();
  10908. rows = this.$getSelectedRows(range);
  10909. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10910. if (copy && dir == -1) moved = 0;
  10911. range.moveBy(moved, 0);
  10912. selection.fromOrientedRange(range);
  10913. } else {
  10914. var ranges = selection.rangeList.ranges;
  10915. selection.rangeList.detach(this.session);
  10916. this.inVirtualSelectionMode = true;
  10917. var diff = 0;
  10918. var totalDiff = 0;
  10919. var l = ranges.length;
  10920. for (var i = 0; i < l; i++) {
  10921. var rangeIndex = i;
  10922. ranges[i].moveBy(diff, 0);
  10923. rows = this.$getSelectedRows(ranges[i]);
  10924. var first = rows.first;
  10925. var last = rows.last;
  10926. while (++i < l) {
  10927. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10928. var subRows = this.$getSelectedRows(ranges[i]);
  10929. if (copy && subRows.first != last)
  10930. break;
  10931. else if (!copy && subRows.first > last + 1)
  10932. break;
  10933. last = subRows.last;
  10934. }
  10935. i--;
  10936. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10937. if (copy && dir == -1) rangeIndex = i + 1;
  10938. while (rangeIndex <= i) {
  10939. ranges[rangeIndex].moveBy(diff, 0);
  10940. rangeIndex++;
  10941. }
  10942. if (!copy) diff = 0;
  10943. totalDiff += diff;
  10944. }
  10945. selection.fromOrientedRange(selection.ranges[0]);
  10946. selection.rangeList.attach(this.session);
  10947. this.inVirtualSelectionMode = false;
  10948. }
  10949. };
  10950. this.$getSelectedRows = function(range) {
  10951. range = (range || this.getSelectionRange()).collapseRows();
  10952. return {
  10953. first: this.session.getRowFoldStart(range.start.row),
  10954. last: this.session.getRowFoldEnd(range.end.row)
  10955. };
  10956. };
  10957. this.onCompositionStart = function(text) {
  10958. this.renderer.showComposition(this.getCursorPosition());
  10959. };
  10960. this.onCompositionUpdate = function(text) {
  10961. this.renderer.setCompositionText(text);
  10962. };
  10963. this.onCompositionEnd = function() {
  10964. this.renderer.hideComposition();
  10965. };
  10966. this.getFirstVisibleRow = function() {
  10967. return this.renderer.getFirstVisibleRow();
  10968. };
  10969. this.getLastVisibleRow = function() {
  10970. return this.renderer.getLastVisibleRow();
  10971. };
  10972. this.isRowVisible = function(row) {
  10973. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  10974. };
  10975. this.isRowFullyVisible = function(row) {
  10976. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  10977. };
  10978. this.$getVisibleRowCount = function() {
  10979. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  10980. };
  10981. this.$moveByPage = function(dir, select) {
  10982. var renderer = this.renderer;
  10983. var config = this.renderer.layerConfig;
  10984. var rows = dir * Math.floor(config.height / config.lineHeight);
  10985. this.$blockScrolling++;
  10986. if (select === true) {
  10987. this.selection.$moveSelection(function(){
  10988. this.moveCursorBy(rows, 0);
  10989. });
  10990. } else if (select === false) {
  10991. this.selection.moveCursorBy(rows, 0);
  10992. this.selection.clearSelection();
  10993. }
  10994. this.$blockScrolling--;
  10995. var scrollTop = renderer.scrollTop;
  10996. renderer.scrollBy(0, rows * config.lineHeight);
  10997. if (select != null)
  10998. renderer.scrollCursorIntoView(null, 0.5);
  10999. renderer.animateScrolling(scrollTop);
  11000. };
  11001. this.selectPageDown = function() {
  11002. this.$moveByPage(1, true);
  11003. };
  11004. this.selectPageUp = function() {
  11005. this.$moveByPage(-1, true);
  11006. };
  11007. this.gotoPageDown = function() {
  11008. this.$moveByPage(1, false);
  11009. };
  11010. this.gotoPageUp = function() {
  11011. this.$moveByPage(-1, false);
  11012. };
  11013. this.scrollPageDown = function() {
  11014. this.$moveByPage(1);
  11015. };
  11016. this.scrollPageUp = function() {
  11017. this.$moveByPage(-1);
  11018. };
  11019. this.scrollToRow = function(row) {
  11020. this.renderer.scrollToRow(row);
  11021. };
  11022. this.scrollToLine = function(line, center, animate, callback) {
  11023. this.renderer.scrollToLine(line, center, animate, callback);
  11024. };
  11025. this.centerSelection = function() {
  11026. var range = this.getSelectionRange();
  11027. var pos = {
  11028. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  11029. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  11030. };
  11031. this.renderer.alignCursor(pos, 0.5);
  11032. };
  11033. this.getCursorPosition = function() {
  11034. return this.selection.getCursor();
  11035. };
  11036. this.getCursorPositionScreen = function() {
  11037. return this.session.documentToScreenPosition(this.getCursorPosition());
  11038. };
  11039. this.getSelectionRange = function() {
  11040. return this.selection.getRange();
  11041. };
  11042. this.selectAll = function() {
  11043. this.$blockScrolling += 1;
  11044. this.selection.selectAll();
  11045. this.$blockScrolling -= 1;
  11046. };
  11047. this.clearSelection = function() {
  11048. this.selection.clearSelection();
  11049. };
  11050. this.moveCursorTo = function(row, column) {
  11051. this.selection.moveCursorTo(row, column);
  11052. };
  11053. this.moveCursorToPosition = function(pos) {
  11054. this.selection.moveCursorToPosition(pos);
  11055. };
  11056. this.jumpToMatching = function(select, expand) {
  11057. var cursor = this.getCursorPosition();
  11058. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  11059. var prevToken = iterator.getCurrentToken();
  11060. var token = prevToken || iterator.stepForward();
  11061. if (!token) return;
  11062. var matchType;
  11063. var found = false;
  11064. var depth = {};
  11065. var i = cursor.column - token.start;
  11066. var bracketType;
  11067. var brackets = {
  11068. ")": "(",
  11069. "(": "(",
  11070. "]": "[",
  11071. "[": "[",
  11072. "{": "{",
  11073. "}": "{"
  11074. };
  11075. do {
  11076. if (token.value.match(/[{}()\[\]]/g)) {
  11077. for (; i < token.value.length && !found; i++) {
  11078. if (!brackets[token.value[i]]) {
  11079. continue;
  11080. }
  11081. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  11082. if (isNaN(depth[bracketType])) {
  11083. depth[bracketType] = 0;
  11084. }
  11085. switch (token.value[i]) {
  11086. case '(':
  11087. case '[':
  11088. case '{':
  11089. depth[bracketType]++;
  11090. break;
  11091. case ')':
  11092. case ']':
  11093. case '}':
  11094. depth[bracketType]--;
  11095. if (depth[bracketType] === -1) {
  11096. matchType = 'bracket';
  11097. found = true;
  11098. }
  11099. break;
  11100. }
  11101. }
  11102. }
  11103. else if (token && token.type.indexOf('tag-name') !== -1) {
  11104. if (isNaN(depth[token.value])) {
  11105. depth[token.value] = 0;
  11106. }
  11107. if (prevToken.value === '<') {
  11108. depth[token.value]++;
  11109. }
  11110. else if (prevToken.value === '</') {
  11111. depth[token.value]--;
  11112. }
  11113. if (depth[token.value] === -1) {
  11114. matchType = 'tag';
  11115. found = true;
  11116. }
  11117. }
  11118. if (!found) {
  11119. prevToken = token;
  11120. token = iterator.stepForward();
  11121. i = 0;
  11122. }
  11123. } while (token && !found);
  11124. if (!matchType)
  11125. return;
  11126. var range, pos;
  11127. if (matchType === 'bracket') {
  11128. range = this.session.getBracketRange(cursor);
  11129. if (!range) {
  11130. range = new Range(
  11131. iterator.getCurrentTokenRow(),
  11132. iterator.getCurrentTokenColumn() + i - 1,
  11133. iterator.getCurrentTokenRow(),
  11134. iterator.getCurrentTokenColumn() + i - 1
  11135. );
  11136. pos = range.start;
  11137. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11138. range = this.session.getBracketRange(pos);
  11139. }
  11140. }
  11141. else if (matchType === 'tag') {
  11142. if (token && token.type.indexOf('tag-name') !== -1)
  11143. var tag = token.value;
  11144. else
  11145. return;
  11146. range = new Range(
  11147. iterator.getCurrentTokenRow(),
  11148. iterator.getCurrentTokenColumn() - 2,
  11149. iterator.getCurrentTokenRow(),
  11150. iterator.getCurrentTokenColumn() - 2
  11151. );
  11152. if (range.compare(cursor.row, cursor.column) === 0) {
  11153. found = false;
  11154. do {
  11155. token = prevToken;
  11156. prevToken = iterator.stepBackward();
  11157. if (prevToken) {
  11158. if (prevToken.type.indexOf('tag-close') !== -1) {
  11159. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11160. }
  11161. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11162. if (prevToken.value === '<') {
  11163. depth[tag]++;
  11164. }
  11165. else if (prevToken.value === '</') {
  11166. depth[tag]--;
  11167. }
  11168. if (depth[tag] === 0)
  11169. found = true;
  11170. }
  11171. }
  11172. } while (prevToken && !found);
  11173. }
  11174. if (token && token.type.indexOf('tag-name')) {
  11175. pos = range.start;
  11176. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11177. pos = range.end;
  11178. }
  11179. }
  11180. pos = range && range.cursor || pos;
  11181. if (pos) {
  11182. if (select) {
  11183. if (range && expand) {
  11184. this.selection.setRange(range);
  11185. } else if (range && range.isEqual(this.getSelectionRange())) {
  11186. this.clearSelection();
  11187. } else {
  11188. this.selection.selectTo(pos.row, pos.column);
  11189. }
  11190. } else {
  11191. this.selection.moveTo(pos.row, pos.column);
  11192. }
  11193. }
  11194. };
  11195. this.gotoLine = function(lineNumber, column, animate) {
  11196. this.selection.clearSelection();
  11197. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11198. this.$blockScrolling += 1;
  11199. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11200. this.moveCursorTo(lineNumber - 1, column || 0);
  11201. this.$blockScrolling -= 1;
  11202. if (!this.isRowFullyVisible(lineNumber - 1))
  11203. this.scrollToLine(lineNumber - 1, true, animate);
  11204. };
  11205. this.navigateTo = function(row, column) {
  11206. this.selection.moveTo(row, column);
  11207. };
  11208. this.navigateUp = function(times) {
  11209. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11210. var selectionStart = this.selection.anchor.getPosition();
  11211. return this.moveCursorToPosition(selectionStart);
  11212. }
  11213. this.selection.clearSelection();
  11214. this.selection.moveCursorBy(-times || -1, 0);
  11215. };
  11216. this.navigateDown = function(times) {
  11217. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11218. var selectionEnd = this.selection.anchor.getPosition();
  11219. return this.moveCursorToPosition(selectionEnd);
  11220. }
  11221. this.selection.clearSelection();
  11222. this.selection.moveCursorBy(times || 1, 0);
  11223. };
  11224. this.navigateLeft = function(times) {
  11225. if (!this.selection.isEmpty()) {
  11226. var selectionStart = this.getSelectionRange().start;
  11227. this.moveCursorToPosition(selectionStart);
  11228. }
  11229. else {
  11230. times = times || 1;
  11231. while (times--) {
  11232. this.selection.moveCursorLeft();
  11233. }
  11234. }
  11235. this.clearSelection();
  11236. };
  11237. this.navigateRight = function(times) {
  11238. if (!this.selection.isEmpty()) {
  11239. var selectionEnd = this.getSelectionRange().end;
  11240. this.moveCursorToPosition(selectionEnd);
  11241. }
  11242. else {
  11243. times = times || 1;
  11244. while (times--) {
  11245. this.selection.moveCursorRight();
  11246. }
  11247. }
  11248. this.clearSelection();
  11249. };
  11250. this.navigateLineStart = function() {
  11251. this.selection.moveCursorLineStart();
  11252. this.clearSelection();
  11253. };
  11254. this.navigateLineEnd = function() {
  11255. this.selection.moveCursorLineEnd();
  11256. this.clearSelection();
  11257. };
  11258. this.navigateFileEnd = function() {
  11259. this.selection.moveCursorFileEnd();
  11260. this.clearSelection();
  11261. };
  11262. this.navigateFileStart = function() {
  11263. this.selection.moveCursorFileStart();
  11264. this.clearSelection();
  11265. };
  11266. this.navigateWordRight = function() {
  11267. this.selection.moveCursorWordRight();
  11268. this.clearSelection();
  11269. };
  11270. this.navigateWordLeft = function() {
  11271. this.selection.moveCursorWordLeft();
  11272. this.clearSelection();
  11273. };
  11274. this.replace = function(replacement, options) {
  11275. if (options)
  11276. this.$search.set(options);
  11277. var range = this.$search.find(this.session);
  11278. var replaced = 0;
  11279. if (!range)
  11280. return replaced;
  11281. if (this.$tryReplace(range, replacement)) {
  11282. replaced = 1;
  11283. }
  11284. if (range !== null) {
  11285. this.selection.setSelectionRange(range);
  11286. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11287. }
  11288. return replaced;
  11289. };
  11290. this.replaceAll = function(replacement, options) {
  11291. if (options) {
  11292. this.$search.set(options);
  11293. }
  11294. var ranges = this.$search.findAll(this.session);
  11295. var replaced = 0;
  11296. if (!ranges.length)
  11297. return replaced;
  11298. this.$blockScrolling += 1;
  11299. var selection = this.getSelectionRange();
  11300. this.selection.moveTo(0, 0);
  11301. for (var i = ranges.length - 1; i >= 0; --i) {
  11302. if(this.$tryReplace(ranges[i], replacement)) {
  11303. replaced++;
  11304. }
  11305. }
  11306. this.selection.setSelectionRange(selection);
  11307. this.$blockScrolling -= 1;
  11308. return replaced;
  11309. };
  11310. this.$tryReplace = function(range, replacement) {
  11311. var input = this.session.getTextRange(range);
  11312. replacement = this.$search.replace(input, replacement);
  11313. if (replacement !== null) {
  11314. range.end = this.session.replace(range, replacement);
  11315. return range;
  11316. } else {
  11317. return null;
  11318. }
  11319. };
  11320. this.getLastSearchOptions = function() {
  11321. return this.$search.getOptions();
  11322. };
  11323. this.find = function(needle, options, animate) {
  11324. if (!options)
  11325. options = {};
  11326. if (typeof needle == "string" || needle instanceof RegExp)
  11327. options.needle = needle;
  11328. else if (typeof needle == "object")
  11329. oop.mixin(options, needle);
  11330. var range = this.selection.getRange();
  11331. if (options.needle == null) {
  11332. needle = this.session.getTextRange(range)
  11333. || this.$search.$options.needle;
  11334. if (!needle) {
  11335. range = this.session.getWordRange(range.start.row, range.start.column);
  11336. needle = this.session.getTextRange(range);
  11337. }
  11338. this.$search.set({needle: needle});
  11339. }
  11340. this.$search.set(options);
  11341. if (!options.start)
  11342. this.$search.set({start: range});
  11343. var newRange = this.$search.find(this.session);
  11344. if (options.preventScroll)
  11345. return newRange;
  11346. if (newRange) {
  11347. this.revealRange(newRange, animate);
  11348. return newRange;
  11349. }
  11350. if (options.backwards)
  11351. range.start = range.end;
  11352. else
  11353. range.end = range.start;
  11354. this.selection.setRange(range);
  11355. };
  11356. this.findNext = function(options, animate) {
  11357. this.find({skipCurrent: true, backwards: false}, options, animate);
  11358. };
  11359. this.findPrevious = function(options, animate) {
  11360. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11361. };
  11362. this.revealRange = function(range, animate) {
  11363. this.$blockScrolling += 1;
  11364. this.session.unfold(range);
  11365. this.selection.setSelectionRange(range);
  11366. this.$blockScrolling -= 1;
  11367. var scrollTop = this.renderer.scrollTop;
  11368. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11369. if (animate !== false)
  11370. this.renderer.animateScrolling(scrollTop);
  11371. };
  11372. this.undo = function() {
  11373. this.$blockScrolling++;
  11374. this.session.getUndoManager().undo();
  11375. this.$blockScrolling--;
  11376. this.renderer.scrollCursorIntoView(null, 0.5);
  11377. };
  11378. this.redo = function() {
  11379. this.$blockScrolling++;
  11380. this.session.getUndoManager().redo();
  11381. this.$blockScrolling--;
  11382. this.renderer.scrollCursorIntoView(null, 0.5);
  11383. };
  11384. this.destroy = function() {
  11385. this.renderer.destroy();
  11386. this._signal("destroy", this);
  11387. if (this.session) {
  11388. this.session.destroy();
  11389. }
  11390. };
  11391. this.setAutoScrollEditorIntoView = function(enable) {
  11392. if (!enable)
  11393. return;
  11394. var rect;
  11395. var self = this;
  11396. var shouldScroll = false;
  11397. if (!this.$scrollAnchor)
  11398. this.$scrollAnchor = document.createElement("div");
  11399. var scrollAnchor = this.$scrollAnchor;
  11400. scrollAnchor.style.cssText = "position:absolute";
  11401. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11402. var onChangeSelection = this.on("changeSelection", function() {
  11403. shouldScroll = true;
  11404. });
  11405. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11406. if (shouldScroll)
  11407. rect = self.renderer.container.getBoundingClientRect();
  11408. });
  11409. var onAfterRender = this.renderer.on("afterRender", function() {
  11410. if (shouldScroll && rect && (self.isFocused()
  11411. || self.searchBox && self.searchBox.isFocused())
  11412. ) {
  11413. var renderer = self.renderer;
  11414. var pos = renderer.$cursorLayer.$pixelPos;
  11415. var config = renderer.layerConfig;
  11416. var top = pos.top - config.offset;
  11417. if (pos.top >= 0 && top + rect.top < 0) {
  11418. shouldScroll = true;
  11419. } else if (pos.top < config.height &&
  11420. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11421. shouldScroll = false;
  11422. } else {
  11423. shouldScroll = null;
  11424. }
  11425. if (shouldScroll != null) {
  11426. scrollAnchor.style.top = top + "px";
  11427. scrollAnchor.style.left = pos.left + "px";
  11428. scrollAnchor.style.height = config.lineHeight + "px";
  11429. scrollAnchor.scrollIntoView(shouldScroll);
  11430. }
  11431. shouldScroll = rect = null;
  11432. }
  11433. });
  11434. this.setAutoScrollEditorIntoView = function(enable) {
  11435. if (enable)
  11436. return;
  11437. delete this.setAutoScrollEditorIntoView;
  11438. this.removeEventListener("changeSelection", onChangeSelection);
  11439. this.renderer.removeEventListener("afterRender", onAfterRender);
  11440. this.renderer.removeEventListener("beforeRender", onBeforeRender);
  11441. };
  11442. };
  11443. this.$resetCursorStyle = function() {
  11444. var style = this.$cursorStyle || "ace";
  11445. var cursorLayer = this.renderer.$cursorLayer;
  11446. if (!cursorLayer)
  11447. return;
  11448. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11449. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11450. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11451. };
  11452. }).call(Editor.prototype);
  11453. config.defineOptions(Editor.prototype, "editor", {
  11454. selectionStyle: {
  11455. set: function(style) {
  11456. this.onSelectionChange();
  11457. this._signal("changeSelectionStyle", {data: style});
  11458. },
  11459. initialValue: "line"
  11460. },
  11461. highlightActiveLine: {
  11462. set: function() {this.$updateHighlightActiveLine();},
  11463. initialValue: true
  11464. },
  11465. highlightSelectedWord: {
  11466. set: function(shouldHighlight) {this.$onSelectionChange();},
  11467. initialValue: true
  11468. },
  11469. readOnly: {
  11470. set: function(readOnly) {
  11471. this.$resetCursorStyle();
  11472. },
  11473. initialValue: false
  11474. },
  11475. cursorStyle: {
  11476. set: function(val) { this.$resetCursorStyle(); },
  11477. values: ["ace", "slim", "smooth", "wide"],
  11478. initialValue: "ace"
  11479. },
  11480. mergeUndoDeltas: {
  11481. values: [false, true, "always"],
  11482. initialValue: true
  11483. },
  11484. behavioursEnabled: {initialValue: true},
  11485. wrapBehavioursEnabled: {initialValue: true},
  11486. autoScrollEditorIntoView: {
  11487. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11488. },
  11489. hScrollBarAlwaysVisible: "renderer",
  11490. vScrollBarAlwaysVisible: "renderer",
  11491. highlightGutterLine: "renderer",
  11492. animatedScroll: "renderer",
  11493. showInvisibles: "renderer",
  11494. showPrintMargin: "renderer",
  11495. printMarginColumn: "renderer",
  11496. printMargin: "renderer",
  11497. fadeFoldWidgets: "renderer",
  11498. showFoldWidgets: "renderer",
  11499. showLineNumbers: "renderer",
  11500. showGutter: "renderer",
  11501. displayIndentGuides: "renderer",
  11502. fontSize: "renderer",
  11503. fontFamily: "renderer",
  11504. maxLines: "renderer",
  11505. minLines: "renderer",
  11506. scrollPastEnd: "renderer",
  11507. fixedWidthGutter: "renderer",
  11508. theme: "renderer",
  11509. scrollSpeed: "$mouseHandler",
  11510. dragDelay: "$mouseHandler",
  11511. dragEnabled: "$mouseHandler",
  11512. focusTimout: "$mouseHandler",
  11513. tooltipFollowsMouse: "$mouseHandler",
  11514. firstLineNumber: "session",
  11515. overwrite: "session",
  11516. newLineMode: "session",
  11517. useWorker: "session",
  11518. useSoftTabs: "session",
  11519. tabSize: "session",
  11520. wrap: "session",
  11521. indentedSoftWrap: "session",
  11522. foldStyle: "session",
  11523. mode: "session"
  11524. });
  11525. exports.Editor = Editor;
  11526. });
  11527. ace.define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11528. "use strict";
  11529. var UndoManager = function() {
  11530. this.reset();
  11531. };
  11532. (function() {
  11533. this.execute = function(options) {
  11534. var deltaSets = options.args[0];
  11535. this.$doc = options.args[1];
  11536. if (options.merge && this.hasUndo()){
  11537. this.dirtyCounter--;
  11538. deltaSets = this.$undoStack.pop().concat(deltaSets);
  11539. }
  11540. this.$undoStack.push(deltaSets);
  11541. this.$redoStack = [];
  11542. if (this.dirtyCounter < 0) {
  11543. this.dirtyCounter = NaN;
  11544. }
  11545. this.dirtyCounter++;
  11546. };
  11547. this.undo = function(dontSelect) {
  11548. var deltaSets = this.$undoStack.pop();
  11549. var undoSelectionRange = null;
  11550. if (deltaSets) {
  11551. undoSelectionRange = this.$doc.undoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11552. this.$redoStack.push(deltaSets);
  11553. this.dirtyCounter--;
  11554. }
  11555. return undoSelectionRange;
  11556. };
  11557. this.redo = function(dontSelect) {
  11558. var deltaSets = this.$redoStack.pop();
  11559. var redoSelectionRange = null;
  11560. if (deltaSets) {
  11561. redoSelectionRange =
  11562. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11563. this.$undoStack.push(deltaSets);
  11564. this.dirtyCounter++;
  11565. }
  11566. return redoSelectionRange;
  11567. };
  11568. this.reset = function() {
  11569. this.$undoStack = [];
  11570. this.$redoStack = [];
  11571. this.dirtyCounter = 0;
  11572. };
  11573. this.hasUndo = function() {
  11574. return this.$undoStack.length > 0;
  11575. };
  11576. this.hasRedo = function() {
  11577. return this.$redoStack.length > 0;
  11578. };
  11579. this.markClean = function() {
  11580. this.dirtyCounter = 0;
  11581. };
  11582. this.isClean = function() {
  11583. return this.dirtyCounter === 0;
  11584. };
  11585. this.$serializeDeltas = function(deltaSets) {
  11586. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  11587. };
  11588. this.$deserializeDeltas = function(deltaSets) {
  11589. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  11590. };
  11591. function $serializeDelta(delta){
  11592. return {
  11593. action: delta.action,
  11594. start: delta.start,
  11595. end: delta.end,
  11596. lines: delta.lines.length == 1 ? null : delta.lines,
  11597. text: delta.lines.length == 1 ? delta.lines[0] : null,
  11598. };
  11599. }
  11600. function $deserializeDelta(delta) {
  11601. return {
  11602. action: delta.action,
  11603. start: delta.start,
  11604. end: delta.end,
  11605. lines: delta.lines || [delta.text]
  11606. };
  11607. }
  11608. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  11609. var deltaSets_new = new Array(deltaSets_old.length);
  11610. for (var i = 0; i < deltaSets_old.length; i++) {
  11611. var deltaSet_old = deltaSets_old[i];
  11612. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  11613. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  11614. var delta_old = deltaSet_old.deltas[j];
  11615. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  11616. }
  11617. deltaSets_new[i] = deltaSet_new;
  11618. }
  11619. return deltaSets_new;
  11620. }
  11621. }).call(UndoManager.prototype);
  11622. exports.UndoManager = UndoManager;
  11623. });
  11624. ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
  11625. "use strict";
  11626. var dom = require("../lib/dom");
  11627. var oop = require("../lib/oop");
  11628. var lang = require("../lib/lang");
  11629. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11630. var Gutter = function(parentEl) {
  11631. this.element = dom.createElement("div");
  11632. this.element.className = "ace_layer ace_gutter-layer";
  11633. parentEl.appendChild(this.element);
  11634. this.setShowFoldWidgets(this.$showFoldWidgets);
  11635. this.gutterWidth = 0;
  11636. this.$annotations = [];
  11637. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11638. this.$cells = [];
  11639. };
  11640. (function() {
  11641. oop.implement(this, EventEmitter);
  11642. this.setSession = function(session) {
  11643. if (this.session)
  11644. this.session.removeEventListener("change", this.$updateAnnotations);
  11645. this.session = session;
  11646. if (session)
  11647. session.on("change", this.$updateAnnotations);
  11648. };
  11649. this.addGutterDecoration = function(row, className){
  11650. if (window.console)
  11651. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11652. this.session.addGutterDecoration(row, className);
  11653. };
  11654. this.removeGutterDecoration = function(row, className){
  11655. if (window.console)
  11656. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11657. this.session.removeGutterDecoration(row, className);
  11658. };
  11659. this.setAnnotations = function(annotations) {
  11660. this.$annotations = [];
  11661. for (var i = 0; i < annotations.length; i++) {
  11662. var annotation = annotations[i];
  11663. var row = annotation.row;
  11664. var rowInfo = this.$annotations[row];
  11665. if (!rowInfo)
  11666. rowInfo = this.$annotations[row] = {text: []};
  11667. var annoText = annotation.text;
  11668. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11669. if (rowInfo.text.indexOf(annoText) === -1)
  11670. rowInfo.text.push(annoText);
  11671. var type = annotation.type;
  11672. if (type == "error")
  11673. rowInfo.className = " ace_error";
  11674. else if (type == "warning" && rowInfo.className != " ace_error")
  11675. rowInfo.className = " ace_warning";
  11676. else if (type == "info" && (!rowInfo.className))
  11677. rowInfo.className = " ace_info";
  11678. }
  11679. };
  11680. this.$updateAnnotations = function (delta) {
  11681. if (!this.$annotations.length)
  11682. return;
  11683. var firstRow = delta.start.row;
  11684. var len = delta.end.row - firstRow;
  11685. if (len === 0) {
  11686. } else if (delta.action == 'remove') {
  11687. this.$annotations.splice(firstRow, len + 1, null);
  11688. } else {
  11689. var args = new Array(len + 1);
  11690. args.unshift(firstRow, 1);
  11691. this.$annotations.splice.apply(this.$annotations, args);
  11692. }
  11693. };
  11694. this.update = function(config) {
  11695. var session = this.session;
  11696. var firstRow = config.firstRow;
  11697. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11698. session.getLength() - 1);
  11699. var fold = session.getNextFoldLine(firstRow);
  11700. var foldStart = fold ? fold.start.row : Infinity;
  11701. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11702. var breakpoints = session.$breakpoints;
  11703. var decorations = session.$decorations;
  11704. var firstLineNumber = session.$firstLineNumber;
  11705. var lastLineNumber = 0;
  11706. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11707. var cell = null;
  11708. var index = -1;
  11709. var row = firstRow;
  11710. while (true) {
  11711. if (row > foldStart) {
  11712. row = fold.end.row + 1;
  11713. fold = session.getNextFoldLine(row, fold);
  11714. foldStart = fold ? fold.start.row : Infinity;
  11715. }
  11716. if (row > lastRow) {
  11717. while (this.$cells.length > index + 1) {
  11718. cell = this.$cells.pop();
  11719. this.element.removeChild(cell.element);
  11720. }
  11721. break;
  11722. }
  11723. cell = this.$cells[++index];
  11724. if (!cell) {
  11725. cell = {element: null, textNode: null, foldWidget: null};
  11726. cell.element = dom.createElement("div");
  11727. cell.textNode = document.createTextNode('');
  11728. cell.element.appendChild(cell.textNode);
  11729. this.element.appendChild(cell.element);
  11730. this.$cells[index] = cell;
  11731. }
  11732. var className = "ace_gutter-cell ";
  11733. if (breakpoints[row])
  11734. className += breakpoints[row];
  11735. if (decorations[row])
  11736. className += decorations[row];
  11737. if (this.$annotations[row])
  11738. className += this.$annotations[row].className;
  11739. if (cell.element.className != className)
  11740. cell.element.className = className;
  11741. var height = session.getRowLength(row) * config.lineHeight + "px";
  11742. if (height != cell.element.style.height)
  11743. cell.element.style.height = height;
  11744. if (foldWidgets) {
  11745. var c = foldWidgets[row];
  11746. if (c == null)
  11747. c = foldWidgets[row] = session.getFoldWidget(row);
  11748. }
  11749. if (c) {
  11750. if (!cell.foldWidget) {
  11751. cell.foldWidget = dom.createElement("span");
  11752. cell.element.appendChild(cell.foldWidget);
  11753. }
  11754. var className = "ace_fold-widget ace_" + c;
  11755. if (c == "start" && row == foldStart && row < fold.end.row)
  11756. className += " ace_closed";
  11757. else
  11758. className += " ace_open";
  11759. if (cell.foldWidget.className != className)
  11760. cell.foldWidget.className = className;
  11761. var height = config.lineHeight + "px";
  11762. if (cell.foldWidget.style.height != height)
  11763. cell.foldWidget.style.height = height;
  11764. } else {
  11765. if (cell.foldWidget) {
  11766. cell.element.removeChild(cell.foldWidget);
  11767. cell.foldWidget = null;
  11768. }
  11769. }
  11770. var text = lastLineNumber = gutterRenderer
  11771. ? gutterRenderer.getText(session, row)
  11772. : row + firstLineNumber;
  11773. if (text != cell.textNode.data)
  11774. cell.textNode.data = text;
  11775. row++;
  11776. }
  11777. this.element.style.height = config.minHeight + "px";
  11778. if (this.$fixedWidth || session.$useWrapMode)
  11779. lastLineNumber = session.getLength() + firstLineNumber;
  11780. var gutterWidth = gutterRenderer
  11781. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11782. : lastLineNumber.toString().length * config.characterWidth;
  11783. var padding = this.$padding || this.$computePadding();
  11784. gutterWidth += padding.left + padding.right;
  11785. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11786. this.gutterWidth = gutterWidth;
  11787. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11788. this._emit("changeGutterWidth", gutterWidth);
  11789. }
  11790. };
  11791. this.$fixedWidth = false;
  11792. this.$showLineNumbers = true;
  11793. this.$renderer = "";
  11794. this.setShowLineNumbers = function(show) {
  11795. this.$renderer = !show && {
  11796. getWidth: function() {return ""},
  11797. getText: function() {return ""}
  11798. };
  11799. };
  11800. this.getShowLineNumbers = function() {
  11801. return this.$showLineNumbers;
  11802. };
  11803. this.$showFoldWidgets = true;
  11804. this.setShowFoldWidgets = function(show) {
  11805. if (show)
  11806. dom.addCssClass(this.element, "ace_folding-enabled");
  11807. else
  11808. dom.removeCssClass(this.element, "ace_folding-enabled");
  11809. this.$showFoldWidgets = show;
  11810. this.$padding = null;
  11811. };
  11812. this.getShowFoldWidgets = function() {
  11813. return this.$showFoldWidgets;
  11814. };
  11815. this.$computePadding = function() {
  11816. if (!this.element.firstChild)
  11817. return {left: 0, right: 0};
  11818. var style = dom.computedStyle(this.element.firstChild);
  11819. this.$padding = {};
  11820. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11821. this.$padding.right = parseInt(style.paddingRight) || 0;
  11822. return this.$padding;
  11823. };
  11824. this.getRegion = function(point) {
  11825. var padding = this.$padding || this.$computePadding();
  11826. var rect = this.element.getBoundingClientRect();
  11827. if (point.x < padding.left + rect.left)
  11828. return "markers";
  11829. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11830. return "foldWidgets";
  11831. };
  11832. }).call(Gutter.prototype);
  11833. exports.Gutter = Gutter;
  11834. });
  11835. ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11836. "use strict";
  11837. var Range = require("../range").Range;
  11838. var dom = require("../lib/dom");
  11839. var Marker = function(parentEl) {
  11840. this.element = dom.createElement("div");
  11841. this.element.className = "ace_layer ace_marker-layer";
  11842. parentEl.appendChild(this.element);
  11843. };
  11844. (function() {
  11845. this.$padding = 0;
  11846. this.setPadding = function(padding) {
  11847. this.$padding = padding;
  11848. };
  11849. this.setSession = function(session) {
  11850. this.session = session;
  11851. };
  11852. this.setMarkers = function(markers) {
  11853. this.markers = markers;
  11854. };
  11855. this.update = function(config) {
  11856. var config = config || this.config;
  11857. if (!config)
  11858. return;
  11859. this.config = config;
  11860. var html = [];
  11861. for (var key in this.markers) {
  11862. var marker = this.markers[key];
  11863. if (!marker.range) {
  11864. marker.update(html, this, this.session, config);
  11865. continue;
  11866. }
  11867. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11868. if (range.isEmpty()) continue;
  11869. range = range.toScreenRange(this.session);
  11870. if (marker.renderer) {
  11871. var top = this.$getTop(range.start.row, config);
  11872. var left = this.$padding + range.start.column * config.characterWidth;
  11873. marker.renderer(html, range, left, top, config);
  11874. } else if (marker.type == "fullLine") {
  11875. this.drawFullLineMarker(html, range, marker.clazz, config);
  11876. } else if (marker.type == "screenLine") {
  11877. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11878. } else if (range.isMultiLine()) {
  11879. if (marker.type == "text")
  11880. this.drawTextMarker(html, range, marker.clazz, config);
  11881. else
  11882. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11883. } else {
  11884. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  11885. }
  11886. }
  11887. this.element.innerHTML = html.join("");
  11888. };
  11889. this.$getTop = function(row, layerConfig) {
  11890. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11891. };
  11892. function getBorderClass(tl, tr, br, bl) {
  11893. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  11894. }
  11895. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11896. var session = this.session;
  11897. var start = range.start.row;
  11898. var end = range.end.row;
  11899. var row = start;
  11900. var prev = 0;
  11901. var curr = 0;
  11902. var next = session.getScreenLastRowColumn(row);
  11903. var lineRange = new Range(row, range.start.column, row, curr);
  11904. for (; row <= end; row++) {
  11905. lineRange.start.row = lineRange.end.row = row;
  11906. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  11907. lineRange.end.column = next;
  11908. prev = curr;
  11909. curr = next;
  11910. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  11911. this.drawSingleLineMarker(stringBuilder, lineRange,
  11912. clazz + (row == start ? " ace_start" : "") + " ace_br"
  11913. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
  11914. layerConfig, row == end ? 0 : 1, extraStyle);
  11915. }
  11916. };
  11917. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11918. var padding = this.$padding;
  11919. var height = config.lineHeight;
  11920. var top = this.$getTop(range.start.row, config);
  11921. var left = padding + range.start.column * config.characterWidth;
  11922. extraStyle = extraStyle || "";
  11923. stringBuilder.push(
  11924. "<div class='", clazz, " ace_br1 ace_start' style='",
  11925. "height:", height, "px;",
  11926. "right:0;",
  11927. "top:", top, "px;",
  11928. "left:", left, "px;", extraStyle, "'></div>"
  11929. );
  11930. top = this.$getTop(range.end.row, config);
  11931. var width = range.end.column * config.characterWidth;
  11932. stringBuilder.push(
  11933. "<div class='", clazz, " ace_br12' style='",
  11934. "height:", height, "px;",
  11935. "width:", width, "px;",
  11936. "top:", top, "px;",
  11937. "left:", padding, "px;", extraStyle, "'></div>"
  11938. );
  11939. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  11940. if (height <= 0)
  11941. return;
  11942. top = this.$getTop(range.start.row + 1, config);
  11943. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  11944. stringBuilder.push(
  11945. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  11946. "height:", height, "px;",
  11947. "right:0;",
  11948. "top:", top, "px;",
  11949. "left:", padding, "px;", extraStyle, "'></div>"
  11950. );
  11951. };
  11952. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  11953. var height = config.lineHeight;
  11954. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  11955. var top = this.$getTop(range.start.row, config);
  11956. var left = this.$padding + range.start.column * config.characterWidth;
  11957. stringBuilder.push(
  11958. "<div class='", clazz, "' style='",
  11959. "height:", height, "px;",
  11960. "width:", width, "px;",
  11961. "top:", top, "px;",
  11962. "left:", left, "px;", extraStyle || "", "'></div>"
  11963. );
  11964. };
  11965. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11966. var top = this.$getTop(range.start.row, config);
  11967. var height = config.lineHeight;
  11968. if (range.start.row != range.end.row)
  11969. height += this.$getTop(range.end.row, config) - top;
  11970. stringBuilder.push(
  11971. "<div class='", clazz, "' style='",
  11972. "height:", height, "px;",
  11973. "top:", top, "px;",
  11974. "left:0;right:0;", extraStyle || "", "'></div>"
  11975. );
  11976. };
  11977. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11978. var top = this.$getTop(range.start.row, config);
  11979. var height = config.lineHeight;
  11980. stringBuilder.push(
  11981. "<div class='", clazz, "' style='",
  11982. "height:", height, "px;",
  11983. "top:", top, "px;",
  11984. "left:0;right:0;", extraStyle || "", "'></div>"
  11985. );
  11986. };
  11987. }).call(Marker.prototype);
  11988. exports.Marker = Marker;
  11989. });
  11990. ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
  11991. "use strict";
  11992. var oop = require("../lib/oop");
  11993. var dom = require("../lib/dom");
  11994. var lang = require("../lib/lang");
  11995. var useragent = require("../lib/useragent");
  11996. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11997. var Text = function(parentEl) {
  11998. this.element = dom.createElement("div");
  11999. this.element.className = "ace_layer ace_text-layer";
  12000. parentEl.appendChild(this.element);
  12001. this.$updateEolChar = this.$updateEolChar.bind(this);
  12002. };
  12003. (function() {
  12004. oop.implement(this, EventEmitter);
  12005. this.EOF_CHAR = "\xB6";
  12006. this.EOL_CHAR_LF = "\xAC";
  12007. this.EOL_CHAR_CRLF = "\xa4";
  12008. this.EOL_CHAR = this.EOL_CHAR_LF;
  12009. this.TAB_CHAR = "\u2014"; //"\u21E5";
  12010. this.SPACE_CHAR = "\xB7";
  12011. this.$padding = 0;
  12012. this.$updateEolChar = function() {
  12013. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  12014. ? this.EOL_CHAR_LF
  12015. : this.EOL_CHAR_CRLF;
  12016. if (this.EOL_CHAR != EOL_CHAR) {
  12017. this.EOL_CHAR = EOL_CHAR;
  12018. return true;
  12019. }
  12020. }
  12021. this.setPadding = function(padding) {
  12022. this.$padding = padding;
  12023. this.element.style.padding = "0 " + padding + "px";
  12024. };
  12025. this.getLineHeight = function() {
  12026. return this.$fontMetrics.$characterSize.height || 0;
  12027. };
  12028. this.getCharacterWidth = function() {
  12029. return this.$fontMetrics.$characterSize.width || 0;
  12030. };
  12031. this.$setFontMetrics = function(measure) {
  12032. this.$fontMetrics = measure;
  12033. this.$fontMetrics.on("changeCharacterSize", function(e) {
  12034. this._signal("changeCharacterSize", e);
  12035. }.bind(this));
  12036. this.$pollSizeChanges();
  12037. }
  12038. this.checkForSizeChanges = function() {
  12039. this.$fontMetrics.checkForSizeChanges();
  12040. };
  12041. this.$pollSizeChanges = function() {
  12042. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  12043. };
  12044. this.setSession = function(session) {
  12045. this.session = session;
  12046. if (session)
  12047. this.$computeTabString();
  12048. };
  12049. this.showInvisibles = false;
  12050. this.setShowInvisibles = function(showInvisibles) {
  12051. if (this.showInvisibles == showInvisibles)
  12052. return false;
  12053. this.showInvisibles = showInvisibles;
  12054. this.$computeTabString();
  12055. return true;
  12056. };
  12057. this.displayIndentGuides = true;
  12058. this.setDisplayIndentGuides = function(display) {
  12059. if (this.displayIndentGuides == display)
  12060. return false;
  12061. this.displayIndentGuides = display;
  12062. this.$computeTabString();
  12063. return true;
  12064. };
  12065. this.$tabStrings = [];
  12066. this.onChangeTabSize =
  12067. this.$computeTabString = function() {
  12068. var tabSize = this.session.getTabSize();
  12069. this.tabSize = tabSize;
  12070. var tabStr = this.$tabStrings = [0];
  12071. for (var i = 1; i < tabSize + 1; i++) {
  12072. if (this.showInvisibles) {
  12073. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  12074. + lang.stringRepeat(this.TAB_CHAR, i)
  12075. + "</span>");
  12076. } else {
  12077. tabStr.push(lang.stringRepeat(" ", i));
  12078. }
  12079. }
  12080. if (this.displayIndentGuides) {
  12081. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  12082. var className = "ace_indent-guide";
  12083. var spaceClass = "";
  12084. var tabClass = "";
  12085. if (this.showInvisibles) {
  12086. className += " ace_invisible";
  12087. spaceClass = " ace_invisible_space";
  12088. tabClass = " ace_invisible_tab";
  12089. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  12090. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  12091. } else{
  12092. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  12093. var tabContent = spaceContent;
  12094. }
  12095. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  12096. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  12097. }
  12098. };
  12099. this.updateLines = function(config, firstRow, lastRow) {
  12100. if (this.config.lastRow != config.lastRow ||
  12101. this.config.firstRow != config.firstRow) {
  12102. this.scrollLines(config);
  12103. }
  12104. this.config = config;
  12105. var first = Math.max(firstRow, config.firstRow);
  12106. var last = Math.min(lastRow, config.lastRow);
  12107. var lineElements = this.element.childNodes;
  12108. var lineElementsIdx = 0;
  12109. for (var row = config.firstRow; row < first; row++) {
  12110. var foldLine = this.session.getFoldLine(row);
  12111. if (foldLine) {
  12112. if (foldLine.containsRow(first)) {
  12113. first = foldLine.start.row;
  12114. break;
  12115. } else {
  12116. row = foldLine.end.row;
  12117. }
  12118. }
  12119. lineElementsIdx ++;
  12120. }
  12121. var row = first;
  12122. var foldLine = this.session.getNextFoldLine(row);
  12123. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12124. while (true) {
  12125. if (row > foldStart) {
  12126. row = foldLine.end.row+1;
  12127. foldLine = this.session.getNextFoldLine(row, foldLine);
  12128. foldStart = foldLine ? foldLine.start.row :Infinity;
  12129. }
  12130. if (row > last)
  12131. break;
  12132. var lineElement = lineElements[lineElementsIdx++];
  12133. if (lineElement) {
  12134. var html = [];
  12135. this.$renderLine(
  12136. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  12137. );
  12138. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12139. lineElement.innerHTML = html.join("");
  12140. }
  12141. row++;
  12142. }
  12143. };
  12144. this.scrollLines = function(config) {
  12145. var oldConfig = this.config;
  12146. this.config = config;
  12147. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  12148. return this.update(config);
  12149. if (config.lastRow < oldConfig.firstRow)
  12150. return this.update(config);
  12151. var el = this.element;
  12152. if (oldConfig.firstRow < config.firstRow)
  12153. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  12154. el.removeChild(el.firstChild);
  12155. if (oldConfig.lastRow > config.lastRow)
  12156. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  12157. el.removeChild(el.lastChild);
  12158. if (config.firstRow < oldConfig.firstRow) {
  12159. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  12160. if (el.firstChild)
  12161. el.insertBefore(fragment, el.firstChild);
  12162. else
  12163. el.appendChild(fragment);
  12164. }
  12165. if (config.lastRow > oldConfig.lastRow) {
  12166. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  12167. el.appendChild(fragment);
  12168. }
  12169. };
  12170. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  12171. var fragment = this.element.ownerDocument.createDocumentFragment();
  12172. var row = firstRow;
  12173. var foldLine = this.session.getNextFoldLine(row);
  12174. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12175. while (true) {
  12176. if (row > foldStart) {
  12177. row = foldLine.end.row+1;
  12178. foldLine = this.session.getNextFoldLine(row, foldLine);
  12179. foldStart = foldLine ? foldLine.start.row : Infinity;
  12180. }
  12181. if (row > lastRow)
  12182. break;
  12183. var container = dom.createElement("div");
  12184. var html = [];
  12185. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12186. container.innerHTML = html.join("");
  12187. if (this.$useLineGroups()) {
  12188. container.className = 'ace_line_group';
  12189. fragment.appendChild(container);
  12190. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12191. } else {
  12192. while(container.firstChild)
  12193. fragment.appendChild(container.firstChild);
  12194. }
  12195. row++;
  12196. }
  12197. return fragment;
  12198. };
  12199. this.update = function(config) {
  12200. this.config = config;
  12201. var html = [];
  12202. var firstRow = config.firstRow, lastRow = config.lastRow;
  12203. var row = firstRow;
  12204. var foldLine = this.session.getNextFoldLine(row);
  12205. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12206. while (true) {
  12207. if (row > foldStart) {
  12208. row = foldLine.end.row+1;
  12209. foldLine = this.session.getNextFoldLine(row, foldLine);
  12210. foldStart = foldLine ? foldLine.start.row :Infinity;
  12211. }
  12212. if (row > lastRow)
  12213. break;
  12214. if (this.$useLineGroups())
  12215. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12216. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12217. if (this.$useLineGroups())
  12218. html.push("</div>"); // end the line group
  12219. row++;
  12220. }
  12221. this.element.innerHTML = html.join("");
  12222. };
  12223. this.$textToken = {
  12224. "text": true,
  12225. "rparen": true,
  12226. "lparen": true
  12227. };
  12228. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12229. var self = this;
  12230. var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
  12231. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12232. if (a) {
  12233. return self.showInvisibles
  12234. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12235. : c;
  12236. } else if (c == "&") {
  12237. return "&#38;";
  12238. } else if (c == "<") {
  12239. return "&#60;";
  12240. } else if (c == ">") {
  12241. return "&#62;";
  12242. } else if (c == "\t") {
  12243. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12244. screenColumn += tabSize - 1;
  12245. return self.$tabStrings[tabSize];
  12246. } else if (c == "\u3000") {
  12247. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12248. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12249. screenColumn += 1;
  12250. return "<span class='" + classToUse + "' style='width:" +
  12251. (self.config.characterWidth * 2) +
  12252. "px'>" + space + "</span>";
  12253. } else if (b) {
  12254. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12255. } else {
  12256. screenColumn += 1;
  12257. return "<span class='ace_cjk' style='width:" +
  12258. (self.config.characterWidth * 2) +
  12259. "px'>" + c + "</span>";
  12260. }
  12261. };
  12262. var output = value.replace(replaceReg, replaceFunc);
  12263. if (!this.$textToken[token.type]) {
  12264. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12265. var style = "";
  12266. if (token.type == "fold")
  12267. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12268. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12269. }
  12270. else {
  12271. stringBuilder.push(output);
  12272. }
  12273. return screenColumn + value.length;
  12274. };
  12275. this.renderIndentGuide = function(stringBuilder, value, max) {
  12276. var cols = value.search(this.$indentGuideRe);
  12277. if (cols <= 0 || cols >= max)
  12278. return value;
  12279. if (value[0] == " ") {
  12280. cols -= cols % this.tabSize;
  12281. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12282. return value.substr(cols);
  12283. } else if (value[0] == "\t") {
  12284. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12285. return value.substr(cols);
  12286. }
  12287. return value;
  12288. };
  12289. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12290. var chars = 0;
  12291. var split = 0;
  12292. var splitChars = splits[0];
  12293. var screenColumn = 0;
  12294. for (var i = 0; i < tokens.length; i++) {
  12295. var token = tokens[i];
  12296. var value = token.value;
  12297. if (i == 0 && this.displayIndentGuides) {
  12298. chars = value.length;
  12299. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12300. if (!value)
  12301. continue;
  12302. chars -= value.length;
  12303. }
  12304. if (chars + value.length < splitChars) {
  12305. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12306. chars += value.length;
  12307. } else {
  12308. while (chars + value.length >= splitChars) {
  12309. screenColumn = this.$renderToken(
  12310. stringBuilder, screenColumn,
  12311. token, value.substring(0, splitChars - chars)
  12312. );
  12313. value = value.substring(splitChars - chars);
  12314. chars = splitChars;
  12315. if (!onlyContents) {
  12316. stringBuilder.push("</div>",
  12317. "<div class='ace_line' style='height:",
  12318. this.config.lineHeight, "px'>"
  12319. );
  12320. }
  12321. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  12322. split ++;
  12323. screenColumn = 0;
  12324. splitChars = splits[split] || Number.MAX_VALUE;
  12325. }
  12326. if (value.length != 0) {
  12327. chars += value.length;
  12328. screenColumn = this.$renderToken(
  12329. stringBuilder, screenColumn, token, value
  12330. );
  12331. }
  12332. }
  12333. }
  12334. };
  12335. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12336. var screenColumn = 0;
  12337. var token = tokens[0];
  12338. var value = token.value;
  12339. if (this.displayIndentGuides)
  12340. value = this.renderIndentGuide(stringBuilder, value);
  12341. if (value)
  12342. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12343. for (var i = 1; i < tokens.length; i++) {
  12344. token = tokens[i];
  12345. value = token.value;
  12346. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12347. }
  12348. };
  12349. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12350. if (!foldLine && foldLine != false)
  12351. foldLine = this.session.getFoldLine(row);
  12352. if (foldLine)
  12353. var tokens = this.$getFoldLineTokens(row, foldLine);
  12354. else
  12355. var tokens = this.session.getTokens(row);
  12356. if (!onlyContents) {
  12357. stringBuilder.push(
  12358. "<div class='ace_line' style='height:",
  12359. this.config.lineHeight * (
  12360. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12361. ), "px'>"
  12362. );
  12363. }
  12364. if (tokens.length) {
  12365. var splits = this.session.getRowSplitData(row);
  12366. if (splits && splits.length)
  12367. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12368. else
  12369. this.$renderSimpleLine(stringBuilder, tokens);
  12370. }
  12371. if (this.showInvisibles) {
  12372. if (foldLine)
  12373. row = foldLine.end.row
  12374. stringBuilder.push(
  12375. "<span class='ace_invisible ace_invisible_eol'>",
  12376. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12377. "</span>"
  12378. );
  12379. }
  12380. if (!onlyContents)
  12381. stringBuilder.push("</div>");
  12382. };
  12383. this.$getFoldLineTokens = function(row, foldLine) {
  12384. var session = this.session;
  12385. var renderTokens = [];
  12386. function addTokens(tokens, from, to) {
  12387. var idx = 0, col = 0;
  12388. while ((col + tokens[idx].value.length) < from) {
  12389. col += tokens[idx].value.length;
  12390. idx++;
  12391. if (idx == tokens.length)
  12392. return;
  12393. }
  12394. if (col != from) {
  12395. var value = tokens[idx].value.substring(from - col);
  12396. if (value.length > (to - from))
  12397. value = value.substring(0, to - from);
  12398. renderTokens.push({
  12399. type: tokens[idx].type,
  12400. value: value
  12401. });
  12402. col = from + value.length;
  12403. idx += 1;
  12404. }
  12405. while (col < to && idx < tokens.length) {
  12406. var value = tokens[idx].value;
  12407. if (value.length + col > to) {
  12408. renderTokens.push({
  12409. type: tokens[idx].type,
  12410. value: value.substring(0, to - col)
  12411. });
  12412. } else
  12413. renderTokens.push(tokens[idx]);
  12414. col += value.length;
  12415. idx += 1;
  12416. }
  12417. }
  12418. var tokens = session.getTokens(row);
  12419. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12420. if (placeholder != null) {
  12421. renderTokens.push({
  12422. type: "fold",
  12423. value: placeholder
  12424. });
  12425. } else {
  12426. if (isNewRow)
  12427. tokens = session.getTokens(row);
  12428. if (tokens.length)
  12429. addTokens(tokens, lastColumn, column);
  12430. }
  12431. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12432. return renderTokens;
  12433. };
  12434. this.$useLineGroups = function() {
  12435. return this.session.getUseWrapMode();
  12436. };
  12437. this.destroy = function() {
  12438. clearInterval(this.$pollSizeChangesTimer);
  12439. if (this.$measureNode)
  12440. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12441. delete this.$measureNode;
  12442. };
  12443. }).call(Text.prototype);
  12444. exports.Text = Text;
  12445. });
  12446. ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12447. "use strict";
  12448. var dom = require("../lib/dom");
  12449. var isIE8;
  12450. var Cursor = function(parentEl) {
  12451. this.element = dom.createElement("div");
  12452. this.element.className = "ace_layer ace_cursor-layer";
  12453. parentEl.appendChild(this.element);
  12454. if (isIE8 === undefined)
  12455. isIE8 = !("opacity" in this.element.style);
  12456. this.isVisible = false;
  12457. this.isBlinking = true;
  12458. this.blinkInterval = 1000;
  12459. this.smoothBlinking = false;
  12460. this.cursors = [];
  12461. this.cursor = this.addCursor();
  12462. dom.addCssClass(this.element, "ace_hidden-cursors");
  12463. this.$updateCursors = (isIE8
  12464. ? this.$updateVisibility
  12465. : this.$updateOpacity).bind(this);
  12466. };
  12467. (function() {
  12468. this.$updateVisibility = function(val) {
  12469. var cursors = this.cursors;
  12470. for (var i = cursors.length; i--; )
  12471. cursors[i].style.visibility = val ? "" : "hidden";
  12472. };
  12473. this.$updateOpacity = function(val) {
  12474. var cursors = this.cursors;
  12475. for (var i = cursors.length; i--; )
  12476. cursors[i].style.opacity = val ? "" : "0";
  12477. };
  12478. this.$padding = 0;
  12479. this.setPadding = function(padding) {
  12480. this.$padding = padding;
  12481. };
  12482. this.setSession = function(session) {
  12483. this.session = session;
  12484. };
  12485. this.setBlinking = function(blinking) {
  12486. if (blinking != this.isBlinking){
  12487. this.isBlinking = blinking;
  12488. this.restartTimer();
  12489. }
  12490. };
  12491. this.setBlinkInterval = function(blinkInterval) {
  12492. if (blinkInterval != this.blinkInterval){
  12493. this.blinkInterval = blinkInterval;
  12494. this.restartTimer();
  12495. }
  12496. };
  12497. this.setSmoothBlinking = function(smoothBlinking) {
  12498. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  12499. this.smoothBlinking = smoothBlinking;
  12500. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12501. this.$updateCursors(true);
  12502. this.$updateCursors = (this.$updateOpacity).bind(this);
  12503. this.restartTimer();
  12504. }
  12505. };
  12506. this.addCursor = function() {
  12507. var el = dom.createElement("div");
  12508. el.className = "ace_cursor";
  12509. this.element.appendChild(el);
  12510. this.cursors.push(el);
  12511. return el;
  12512. };
  12513. this.removeCursor = function() {
  12514. if (this.cursors.length > 1) {
  12515. var el = this.cursors.pop();
  12516. el.parentNode.removeChild(el);
  12517. return el;
  12518. }
  12519. };
  12520. this.hideCursor = function() {
  12521. this.isVisible = false;
  12522. dom.addCssClass(this.element, "ace_hidden-cursors");
  12523. this.restartTimer();
  12524. };
  12525. this.showCursor = function() {
  12526. this.isVisible = true;
  12527. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12528. this.restartTimer();
  12529. };
  12530. this.restartTimer = function() {
  12531. var update = this.$updateCursors;
  12532. clearInterval(this.intervalId);
  12533. clearTimeout(this.timeoutId);
  12534. if (this.smoothBlinking) {
  12535. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12536. }
  12537. update(true);
  12538. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12539. return;
  12540. if (this.smoothBlinking) {
  12541. setTimeout(function(){
  12542. dom.addCssClass(this.element, "ace_smooth-blinking");
  12543. }.bind(this));
  12544. }
  12545. var blink = function(){
  12546. this.timeoutId = setTimeout(function() {
  12547. update(false);
  12548. }, 0.6 * this.blinkInterval);
  12549. }.bind(this);
  12550. this.intervalId = setInterval(function() {
  12551. update(true);
  12552. blink();
  12553. }, this.blinkInterval);
  12554. blink();
  12555. };
  12556. this.getPixelPosition = function(position, onScreen) {
  12557. if (!this.config || !this.session)
  12558. return {left : 0, top : 0};
  12559. if (!position)
  12560. position = this.session.selection.getCursor();
  12561. var pos = this.session.documentToScreenPosition(position);
  12562. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12563. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12564. this.config.lineHeight;
  12565. return {left : cursorLeft, top : cursorTop};
  12566. };
  12567. this.update = function(config) {
  12568. this.config = config;
  12569. var selections = this.session.$selectionMarkers;
  12570. var i = 0, cursorIndex = 0;
  12571. if (selections === undefined || selections.length === 0){
  12572. selections = [{cursor: null}];
  12573. }
  12574. for (var i = 0, n = selections.length; i < n; i++) {
  12575. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12576. if ((pixelPos.top > config.height + config.offset ||
  12577. pixelPos.top < 0) && i > 1) {
  12578. continue;
  12579. }
  12580. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12581. if (!this.drawCursor) {
  12582. style.left = pixelPos.left + "px";
  12583. style.top = pixelPos.top + "px";
  12584. style.width = config.characterWidth + "px";
  12585. style.height = config.lineHeight + "px";
  12586. } else {
  12587. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12588. }
  12589. }
  12590. while (this.cursors.length > cursorIndex)
  12591. this.removeCursor();
  12592. var overwrite = this.session.getOverwrite();
  12593. this.$setOverwrite(overwrite);
  12594. this.$pixelPos = pixelPos;
  12595. this.restartTimer();
  12596. };
  12597. this.drawCursor = null;
  12598. this.$setOverwrite = function(overwrite) {
  12599. if (overwrite != this.overwrite) {
  12600. this.overwrite = overwrite;
  12601. if (overwrite)
  12602. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12603. else
  12604. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12605. }
  12606. };
  12607. this.destroy = function() {
  12608. clearInterval(this.intervalId);
  12609. clearTimeout(this.timeoutId);
  12610. };
  12611. }).call(Cursor.prototype);
  12612. exports.Cursor = Cursor;
  12613. });
  12614. ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12615. "use strict";
  12616. var oop = require("./lib/oop");
  12617. var dom = require("./lib/dom");
  12618. var event = require("./lib/event");
  12619. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12620. var ScrollBar = function(parent) {
  12621. this.element = dom.createElement("div");
  12622. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12623. this.inner = dom.createElement("div");
  12624. this.inner.className = "ace_scrollbar-inner";
  12625. this.element.appendChild(this.inner);
  12626. parent.appendChild(this.element);
  12627. this.setVisible(false);
  12628. this.skipEvent = false;
  12629. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12630. event.addListener(this.element, "mousedown", event.preventDefault);
  12631. };
  12632. (function() {
  12633. oop.implement(this, EventEmitter);
  12634. this.setVisible = function(isVisible) {
  12635. this.element.style.display = isVisible ? "" : "none";
  12636. this.isVisible = isVisible;
  12637. };
  12638. }).call(ScrollBar.prototype);
  12639. var VScrollBar = function(parent, renderer) {
  12640. ScrollBar.call(this, parent);
  12641. this.scrollTop = 0;
  12642. renderer.$scrollbarWidth =
  12643. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12644. this.inner.style.width =
  12645. this.element.style.width = (this.width || 15) + 5 + "px";
  12646. };
  12647. oop.inherits(VScrollBar, ScrollBar);
  12648. (function() {
  12649. this.classSuffix = '-v';
  12650. this.onScroll = function() {
  12651. if (!this.skipEvent) {
  12652. this.scrollTop = this.element.scrollTop;
  12653. this._emit("scroll", {data: this.scrollTop});
  12654. }
  12655. this.skipEvent = false;
  12656. };
  12657. this.getWidth = function() {
  12658. return this.isVisible ? this.width : 0;
  12659. };
  12660. this.setHeight = function(height) {
  12661. this.element.style.height = height + "px";
  12662. };
  12663. this.setInnerHeight = function(height) {
  12664. this.inner.style.height = height + "px";
  12665. };
  12666. this.setScrollHeight = function(height) {
  12667. this.inner.style.height = height + "px";
  12668. };
  12669. this.setScrollTop = function(scrollTop) {
  12670. if (this.scrollTop != scrollTop) {
  12671. this.skipEvent = true;
  12672. this.scrollTop = this.element.scrollTop = scrollTop;
  12673. }
  12674. };
  12675. }).call(VScrollBar.prototype);
  12676. var HScrollBar = function(parent, renderer) {
  12677. ScrollBar.call(this, parent);
  12678. this.scrollLeft = 0;
  12679. this.height = renderer.$scrollbarWidth;
  12680. this.inner.style.height =
  12681. this.element.style.height = (this.height || 15) + 5 + "px";
  12682. };
  12683. oop.inherits(HScrollBar, ScrollBar);
  12684. (function() {
  12685. this.classSuffix = '-h';
  12686. this.onScroll = function() {
  12687. if (!this.skipEvent) {
  12688. this.scrollLeft = this.element.scrollLeft;
  12689. this._emit("scroll", {data: this.scrollLeft});
  12690. }
  12691. this.skipEvent = false;
  12692. };
  12693. this.getHeight = function() {
  12694. return this.isVisible ? this.height : 0;
  12695. };
  12696. this.setWidth = function(width) {
  12697. this.element.style.width = width + "px";
  12698. };
  12699. this.setInnerWidth = function(width) {
  12700. this.inner.style.width = width + "px";
  12701. };
  12702. this.setScrollWidth = function(width) {
  12703. this.inner.style.width = width + "px";
  12704. };
  12705. this.setScrollLeft = function(scrollLeft) {
  12706. if (this.scrollLeft != scrollLeft) {
  12707. this.skipEvent = true;
  12708. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12709. }
  12710. };
  12711. }).call(HScrollBar.prototype);
  12712. exports.ScrollBar = VScrollBar; // backward compatibility
  12713. exports.ScrollBarV = VScrollBar; // backward compatibility
  12714. exports.ScrollBarH = HScrollBar; // backward compatibility
  12715. exports.VScrollBar = VScrollBar;
  12716. exports.HScrollBar = HScrollBar;
  12717. });
  12718. ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12719. "use strict";
  12720. var event = require("./lib/event");
  12721. var RenderLoop = function(onRender, win) {
  12722. this.onRender = onRender;
  12723. this.pending = false;
  12724. this.changes = 0;
  12725. this.window = win || window;
  12726. };
  12727. (function() {
  12728. this.schedule = function(change) {
  12729. this.changes = this.changes | change;
  12730. if (!this.pending && this.changes) {
  12731. this.pending = true;
  12732. var _self = this;
  12733. event.nextFrame(function() {
  12734. _self.pending = false;
  12735. var changes;
  12736. while (changes = _self.changes) {
  12737. _self.changes = 0;
  12738. _self.onRender(changes);
  12739. }
  12740. }, this.window);
  12741. }
  12742. };
  12743. }).call(RenderLoop.prototype);
  12744. exports.RenderLoop = RenderLoop;
  12745. });
  12746. ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
  12747. var oop = require("../lib/oop");
  12748. var dom = require("../lib/dom");
  12749. var lang = require("../lib/lang");
  12750. var useragent = require("../lib/useragent");
  12751. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12752. var CHAR_COUNT = 0;
  12753. var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
  12754. this.el = dom.createElement("div");
  12755. this.$setMeasureNodeStyles(this.el.style, true);
  12756. this.$main = dom.createElement("div");
  12757. this.$setMeasureNodeStyles(this.$main.style);
  12758. this.$measureNode = dom.createElement("div");
  12759. this.$setMeasureNodeStyles(this.$measureNode.style);
  12760. this.el.appendChild(this.$main);
  12761. this.el.appendChild(this.$measureNode);
  12762. parentEl.appendChild(this.el);
  12763. if (!CHAR_COUNT)
  12764. this.$testFractionalRect();
  12765. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12766. this.$characterSize = {width: 0, height: 0};
  12767. this.checkForSizeChanges();
  12768. };
  12769. (function() {
  12770. oop.implement(this, EventEmitter);
  12771. this.$characterSize = {width: 0, height: 0};
  12772. this.$testFractionalRect = function() {
  12773. var el = dom.createElement("div");
  12774. this.$setMeasureNodeStyles(el.style);
  12775. el.style.width = "0.2px";
  12776. document.documentElement.appendChild(el);
  12777. var w = el.getBoundingClientRect().width;
  12778. if (w > 0 && w < 1)
  12779. CHAR_COUNT = 50;
  12780. else
  12781. CHAR_COUNT = 100;
  12782. el.parentNode.removeChild(el);
  12783. };
  12784. this.$setMeasureNodeStyles = function(style, isRoot) {
  12785. style.width = style.height = "auto";
  12786. style.left = style.top = "0px";
  12787. style.visibility = "hidden";
  12788. style.position = "absolute";
  12789. style.whiteSpace = "pre";
  12790. if (useragent.isIE < 8) {
  12791. style["font-family"] = "inherit";
  12792. } else {
  12793. style.font = "inherit";
  12794. }
  12795. style.overflow = isRoot ? "hidden" : "visible";
  12796. };
  12797. this.checkForSizeChanges = function() {
  12798. var size = this.$measureSizes();
  12799. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12800. this.$measureNode.style.fontWeight = "bold";
  12801. var boldSize = this.$measureSizes();
  12802. this.$measureNode.style.fontWeight = "";
  12803. this.$characterSize = size;
  12804. this.charSizes = Object.create(null);
  12805. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12806. this._emit("changeCharacterSize", {data: size});
  12807. }
  12808. };
  12809. this.$pollSizeChanges = function() {
  12810. if (this.$pollSizeChangesTimer)
  12811. return this.$pollSizeChangesTimer;
  12812. var self = this;
  12813. return this.$pollSizeChangesTimer = setInterval(function() {
  12814. self.checkForSizeChanges();
  12815. }, 500);
  12816. };
  12817. this.setPolling = function(val) {
  12818. if (val) {
  12819. this.$pollSizeChanges();
  12820. } else if (this.$pollSizeChangesTimer) {
  12821. clearInterval(this.$pollSizeChangesTimer);
  12822. this.$pollSizeChangesTimer = 0;
  12823. }
  12824. };
  12825. this.$measureSizes = function() {
  12826. if (CHAR_COUNT === 50) {
  12827. var rect = null;
  12828. try {
  12829. rect = this.$measureNode.getBoundingClientRect();
  12830. } catch(e) {
  12831. rect = {width: 0, height:0 };
  12832. };
  12833. var size = {
  12834. height: rect.height,
  12835. width: rect.width / CHAR_COUNT
  12836. };
  12837. } else {
  12838. var size = {
  12839. height: this.$measureNode.clientHeight,
  12840. width: this.$measureNode.clientWidth / CHAR_COUNT
  12841. };
  12842. }
  12843. if (size.width === 0 || size.height === 0)
  12844. return null;
  12845. return size;
  12846. };
  12847. this.$measureCharWidth = function(ch) {
  12848. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12849. var rect = this.$main.getBoundingClientRect();
  12850. return rect.width / CHAR_COUNT;
  12851. };
  12852. this.getCharacterWidth = function(ch) {
  12853. var w = this.charSizes[ch];
  12854. if (w === undefined) {
  12855. this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12856. }
  12857. return w;
  12858. };
  12859. this.destroy = function() {
  12860. clearInterval(this.$pollSizeChangesTimer);
  12861. if (this.el && this.el.parentNode)
  12862. this.el.parentNode.removeChild(this.el);
  12863. };
  12864. }).call(FontMetrics.prototype);
  12865. });
  12866. ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"], function(require, exports, module) {
  12867. "use strict";
  12868. var oop = require("./lib/oop");
  12869. var dom = require("./lib/dom");
  12870. var config = require("./config");
  12871. var useragent = require("./lib/useragent");
  12872. var GutterLayer = require("./layer/gutter").Gutter;
  12873. var MarkerLayer = require("./layer/marker").Marker;
  12874. var TextLayer = require("./layer/text").Text;
  12875. var CursorLayer = require("./layer/cursor").Cursor;
  12876. var HScrollBar = require("./scrollbar").HScrollBar;
  12877. var VScrollBar = require("./scrollbar").VScrollBar;
  12878. var RenderLoop = require("./renderloop").RenderLoop;
  12879. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12880. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12881. var editorCss = ".ace_editor {\
  12882. position: relative;\
  12883. overflow: hidden;\
  12884. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12885. direction: ltr;\
  12886. }\
  12887. .ace_scroller {\
  12888. position: absolute;\
  12889. overflow: hidden;\
  12890. top: 0;\
  12891. bottom: 0;\
  12892. background-color: inherit;\
  12893. -ms-user-select: none;\
  12894. -moz-user-select: none;\
  12895. -webkit-user-select: none;\
  12896. user-select: none;\
  12897. cursor: text;\
  12898. }\
  12899. .ace_content {\
  12900. position: absolute;\
  12901. -moz-box-sizing: border-box;\
  12902. -webkit-box-sizing: border-box;\
  12903. box-sizing: border-box;\
  12904. min-width: 100%;\
  12905. }\
  12906. .ace_dragging .ace_scroller:before{\
  12907. position: absolute;\
  12908. top: 0;\
  12909. left: 0;\
  12910. right: 0;\
  12911. bottom: 0;\
  12912. content: '';\
  12913. background: rgba(250, 250, 250, 0.01);\
  12914. z-index: 1000;\
  12915. }\
  12916. .ace_dragging.ace_dark .ace_scroller:before{\
  12917. background: rgba(0, 0, 0, 0.01);\
  12918. }\
  12919. .ace_selecting, .ace_selecting * {\
  12920. cursor: text !important;\
  12921. }\
  12922. .ace_gutter {\
  12923. position: absolute;\
  12924. overflow : hidden;\
  12925. width: auto;\
  12926. top: 0;\
  12927. bottom: 0;\
  12928. left: 0;\
  12929. cursor: default;\
  12930. z-index: 4;\
  12931. -ms-user-select: none;\
  12932. -moz-user-select: none;\
  12933. -webkit-user-select: none;\
  12934. user-select: none;\
  12935. }\
  12936. .ace_gutter-active-line {\
  12937. position: absolute;\
  12938. left: 0;\
  12939. right: 0;\
  12940. }\
  12941. .ace_scroller.ace_scroll-left {\
  12942. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  12943. }\
  12944. .ace_gutter-cell {\
  12945. padding-left: 19px;\
  12946. padding-right: 6px;\
  12947. background-repeat: no-repeat;\
  12948. }\
  12949. .ace_gutter-cell.ace_error {\
  12950. 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==\");\
  12951. background-repeat: no-repeat;\
  12952. background-position: 2px center;\
  12953. }\
  12954. .ace_gutter-cell.ace_warning {\
  12955. 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==\");\
  12956. background-position: 2px center;\
  12957. }\
  12958. .ace_gutter-cell.ace_info {\
  12959. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  12960. background-position: 2px center;\
  12961. }\
  12962. .ace_dark .ace_gutter-cell.ace_info {\
  12963. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  12964. }\
  12965. .ace_scrollbar {\
  12966. position: absolute;\
  12967. right: 0;\
  12968. bottom: 0;\
  12969. z-index: 6;\
  12970. }\
  12971. .ace_scrollbar-inner {\
  12972. position: absolute;\
  12973. cursor: text;\
  12974. left: 0;\
  12975. top: 0;\
  12976. }\
  12977. .ace_scrollbar-v{\
  12978. overflow-x: hidden;\
  12979. overflow-y: scroll;\
  12980. top: 0;\
  12981. }\
  12982. .ace_scrollbar-h {\
  12983. overflow-x: scroll;\
  12984. overflow-y: hidden;\
  12985. left: 0;\
  12986. }\
  12987. .ace_print-margin {\
  12988. position: absolute;\
  12989. height: 100%;\
  12990. }\
  12991. .ace_text-input {\
  12992. position: absolute;\
  12993. z-index: 0;\
  12994. width: 0.5em;\
  12995. height: 1em;\
  12996. opacity: 0;\
  12997. background: transparent;\
  12998. -moz-appearance: none;\
  12999. appearance: none;\
  13000. border: none;\
  13001. resize: none;\
  13002. outline: none;\
  13003. overflow: hidden;\
  13004. font: inherit;\
  13005. padding: 0 1px;\
  13006. margin: 0 -1px;\
  13007. text-indent: -1em;\
  13008. -ms-user-select: text;\
  13009. -moz-user-select: text;\
  13010. -webkit-user-select: text;\
  13011. user-select: text;\
  13012. white-space: pre!important;\
  13013. }\
  13014. .ace_text-input.ace_composition {\
  13015. background: inherit;\
  13016. color: inherit;\
  13017. z-index: 1000;\
  13018. opacity: 1;\
  13019. text-indent: 0;\
  13020. }\
  13021. .ace_layer {\
  13022. z-index: 1;\
  13023. position: absolute;\
  13024. overflow: hidden;\
  13025. word-wrap: normal;\
  13026. white-space: pre;\
  13027. height: 100%;\
  13028. width: 100%;\
  13029. -moz-box-sizing: border-box;\
  13030. -webkit-box-sizing: border-box;\
  13031. box-sizing: border-box;\
  13032. pointer-events: none;\
  13033. }\
  13034. .ace_gutter-layer {\
  13035. position: relative;\
  13036. width: auto;\
  13037. text-align: right;\
  13038. pointer-events: auto;\
  13039. }\
  13040. .ace_text-layer {\
  13041. font: inherit !important;\
  13042. }\
  13043. .ace_cjk {\
  13044. display: inline-block;\
  13045. text-align: center;\
  13046. }\
  13047. .ace_cursor-layer {\
  13048. z-index: 4;\
  13049. }\
  13050. .ace_cursor {\
  13051. z-index: 4;\
  13052. position: absolute;\
  13053. -moz-box-sizing: border-box;\
  13054. -webkit-box-sizing: border-box;\
  13055. box-sizing: border-box;\
  13056. border-left: 2px solid;\
  13057. transform: translatez(0);\
  13058. }\
  13059. .ace_slim-cursors .ace_cursor {\
  13060. border-left-width: 1px;\
  13061. }\
  13062. .ace_overwrite-cursors .ace_cursor {\
  13063. border-left-width: 0;\
  13064. border-bottom: 1px solid;\
  13065. }\
  13066. .ace_hidden-cursors .ace_cursor {\
  13067. opacity: 0.2;\
  13068. }\
  13069. .ace_smooth-blinking .ace_cursor {\
  13070. -webkit-transition: opacity 0.18s;\
  13071. transition: opacity 0.18s;\
  13072. }\
  13073. .ace_editor.ace_multiselect .ace_cursor {\
  13074. border-left-width: 1px;\
  13075. }\
  13076. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  13077. position: absolute;\
  13078. z-index: 3;\
  13079. }\
  13080. .ace_marker-layer .ace_selection {\
  13081. position: absolute;\
  13082. z-index: 5;\
  13083. }\
  13084. .ace_marker-layer .ace_bracket {\
  13085. position: absolute;\
  13086. z-index: 6;\
  13087. }\
  13088. .ace_marker-layer .ace_active-line {\
  13089. position: absolute;\
  13090. z-index: 2;\
  13091. }\
  13092. .ace_marker-layer .ace_selected-word {\
  13093. position: absolute;\
  13094. z-index: 4;\
  13095. -moz-box-sizing: border-box;\
  13096. -webkit-box-sizing: border-box;\
  13097. box-sizing: border-box;\
  13098. }\
  13099. .ace_line .ace_fold {\
  13100. -moz-box-sizing: border-box;\
  13101. -webkit-box-sizing: border-box;\
  13102. box-sizing: border-box;\
  13103. display: inline-block;\
  13104. height: 11px;\
  13105. margin-top: -2px;\
  13106. vertical-align: middle;\
  13107. background-image:\
  13108. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13109. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  13110. background-repeat: no-repeat, repeat-x;\
  13111. background-position: center center, top left;\
  13112. color: transparent;\
  13113. border: 1px solid black;\
  13114. border-radius: 2px;\
  13115. cursor: pointer;\
  13116. pointer-events: auto;\
  13117. }\
  13118. .ace_dark .ace_fold {\
  13119. }\
  13120. .ace_fold:hover{\
  13121. background-image:\
  13122. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13123. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  13124. }\
  13125. .ace_tooltip {\
  13126. background-color: #FFF;\
  13127. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  13128. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  13129. border: 1px solid gray;\
  13130. border-radius: 1px;\
  13131. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  13132. color: black;\
  13133. max-width: 100%;\
  13134. padding: 3px 4px;\
  13135. position: fixed;\
  13136. z-index: 999999;\
  13137. -moz-box-sizing: border-box;\
  13138. -webkit-box-sizing: border-box;\
  13139. box-sizing: border-box;\
  13140. cursor: default;\
  13141. white-space: pre;\
  13142. word-wrap: break-word;\
  13143. line-height: normal;\
  13144. font-style: normal;\
  13145. font-weight: normal;\
  13146. letter-spacing: normal;\
  13147. pointer-events: none;\
  13148. }\
  13149. .ace_folding-enabled > .ace_gutter-cell {\
  13150. padding-right: 13px;\
  13151. }\
  13152. .ace_fold-widget {\
  13153. -moz-box-sizing: border-box;\
  13154. -webkit-box-sizing: border-box;\
  13155. box-sizing: border-box;\
  13156. margin: 0 -12px 0 1px;\
  13157. display: none;\
  13158. width: 11px;\
  13159. vertical-align: top;\
  13160. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  13161. background-repeat: no-repeat;\
  13162. background-position: center;\
  13163. border-radius: 3px;\
  13164. border: 1px solid transparent;\
  13165. cursor: pointer;\
  13166. }\
  13167. .ace_folding-enabled .ace_fold-widget {\
  13168. display: inline-block; \
  13169. }\
  13170. .ace_fold-widget.ace_end {\
  13171. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  13172. }\
  13173. .ace_fold-widget.ace_closed {\
  13174. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  13175. }\
  13176. .ace_fold-widget:hover {\
  13177. border: 1px solid rgba(0, 0, 0, 0.3);\
  13178. background-color: rgba(255, 255, 255, 0.2);\
  13179. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  13180. }\
  13181. .ace_fold-widget:active {\
  13182. border: 1px solid rgba(0, 0, 0, 0.4);\
  13183. background-color: rgba(0, 0, 0, 0.05);\
  13184. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  13185. }\
  13186. .ace_dark .ace_fold-widget {\
  13187. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  13188. }\
  13189. .ace_dark .ace_fold-widget.ace_end {\
  13190. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  13191. }\
  13192. .ace_dark .ace_fold-widget.ace_closed {\
  13193. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  13194. }\
  13195. .ace_dark .ace_fold-widget:hover {\
  13196. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13197. background-color: rgba(255, 255, 255, 0.1);\
  13198. }\
  13199. .ace_dark .ace_fold-widget:active {\
  13200. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13201. }\
  13202. .ace_fold-widget.ace_invalid {\
  13203. background-color: #FFB4B4;\
  13204. border-color: #DE5555;\
  13205. }\
  13206. .ace_fade-fold-widgets .ace_fold-widget {\
  13207. -webkit-transition: opacity 0.4s ease 0.05s;\
  13208. transition: opacity 0.4s ease 0.05s;\
  13209. opacity: 0;\
  13210. }\
  13211. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13212. -webkit-transition: opacity 0.05s ease 0.05s;\
  13213. transition: opacity 0.05s ease 0.05s;\
  13214. opacity:1;\
  13215. }\
  13216. .ace_underline {\
  13217. text-decoration: underline;\
  13218. }\
  13219. .ace_bold {\
  13220. font-weight: bold;\
  13221. }\
  13222. .ace_nobold .ace_bold {\
  13223. font-weight: normal;\
  13224. }\
  13225. .ace_italic {\
  13226. font-style: italic;\
  13227. }\
  13228. .ace_error-marker {\
  13229. background-color: rgba(255, 0, 0,0.2);\
  13230. position: absolute;\
  13231. z-index: 9;\
  13232. }\
  13233. .ace_highlight-marker {\
  13234. background-color: rgba(255, 255, 0,0.2);\
  13235. position: absolute;\
  13236. z-index: 8;\
  13237. }\
  13238. .ace_br1 {border-top-left-radius : 3px;}\
  13239. .ace_br2 {border-top-right-radius : 3px;}\
  13240. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  13241. .ace_br4 {border-bottom-right-radius: 3px;}\
  13242. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  13243. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  13244. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  13245. .ace_br8 {border-bottom-left-radius : 3px;}\
  13246. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  13247. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  13248. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13249. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13250. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13251. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13252. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13253. ";
  13254. dom.importCssString(editorCss, "ace_editor.css");
  13255. var VirtualRenderer = function(container, theme) {
  13256. var _self = this;
  13257. this.container = container || dom.createElement("div");
  13258. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13259. dom.addCssClass(this.container, "ace_editor");
  13260. this.setTheme(theme);
  13261. this.$gutter = dom.createElement("div");
  13262. this.$gutter.className = "ace_gutter";
  13263. this.container.appendChild(this.$gutter);
  13264. this.scroller = dom.createElement("div");
  13265. this.scroller.className = "ace_scroller";
  13266. this.container.appendChild(this.scroller);
  13267. this.content = dom.createElement("div");
  13268. this.content.className = "ace_content";
  13269. this.scroller.appendChild(this.content);
  13270. this.$gutterLayer = new GutterLayer(this.$gutter);
  13271. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13272. this.$markerBack = new MarkerLayer(this.content);
  13273. var textLayer = this.$textLayer = new TextLayer(this.content);
  13274. this.canvas = textLayer.element;
  13275. this.$markerFront = new MarkerLayer(this.content);
  13276. this.$cursorLayer = new CursorLayer(this.content);
  13277. this.$horizScroll = false;
  13278. this.$vScroll = false;
  13279. this.scrollBar =
  13280. this.scrollBarV = new VScrollBar(this.container, this);
  13281. this.scrollBarH = new HScrollBar(this.container, this);
  13282. this.scrollBarV.addEventListener("scroll", function(e) {
  13283. if (!_self.$scrollAnimation)
  13284. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13285. });
  13286. this.scrollBarH.addEventListener("scroll", function(e) {
  13287. if (!_self.$scrollAnimation)
  13288. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13289. });
  13290. this.scrollTop = 0;
  13291. this.scrollLeft = 0;
  13292. this.cursorPos = {
  13293. row : 0,
  13294. column : 0
  13295. };
  13296. this.$fontMetrics = new FontMetrics(this.container, 500);
  13297. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13298. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13299. _self.updateCharacterSize();
  13300. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13301. _self._signal("changeCharacterSize", e);
  13302. });
  13303. this.$size = {
  13304. width: 0,
  13305. height: 0,
  13306. scrollerHeight: 0,
  13307. scrollerWidth: 0,
  13308. $dirty: true
  13309. };
  13310. this.layerConfig = {
  13311. width : 1,
  13312. padding : 0,
  13313. firstRow : 0,
  13314. firstRowScreen: 0,
  13315. lastRow : 0,
  13316. lineHeight : 0,
  13317. characterWidth : 0,
  13318. minHeight : 1,
  13319. maxHeight : 1,
  13320. offset : 0,
  13321. height : 1,
  13322. gutterOffset: 1
  13323. };
  13324. this.scrollMargin = {
  13325. left: 0,
  13326. right: 0,
  13327. top: 0,
  13328. bottom: 0,
  13329. v: 0,
  13330. h: 0
  13331. };
  13332. this.$loop = new RenderLoop(
  13333. this.$renderChanges.bind(this),
  13334. this.container.ownerDocument.defaultView
  13335. );
  13336. this.$loop.schedule(this.CHANGE_FULL);
  13337. this.updateCharacterSize();
  13338. this.setPadding(4);
  13339. config.resetOptions(this);
  13340. config._emit("renderer", this);
  13341. };
  13342. (function() {
  13343. this.CHANGE_CURSOR = 1;
  13344. this.CHANGE_MARKER = 2;
  13345. this.CHANGE_GUTTER = 4;
  13346. this.CHANGE_SCROLL = 8;
  13347. this.CHANGE_LINES = 16;
  13348. this.CHANGE_TEXT = 32;
  13349. this.CHANGE_SIZE = 64;
  13350. this.CHANGE_MARKER_BACK = 128;
  13351. this.CHANGE_MARKER_FRONT = 256;
  13352. this.CHANGE_FULL = 512;
  13353. this.CHANGE_H_SCROLL = 1024;
  13354. oop.implement(this, EventEmitter);
  13355. this.updateCharacterSize = function() {
  13356. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13357. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13358. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13359. }
  13360. this.layerConfig.characterWidth =
  13361. this.characterWidth = this.$textLayer.getCharacterWidth();
  13362. this.layerConfig.lineHeight =
  13363. this.lineHeight = this.$textLayer.getLineHeight();
  13364. this.$updatePrintMargin();
  13365. };
  13366. this.setSession = function(session) {
  13367. if (this.session)
  13368. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13369. this.session = session;
  13370. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13371. session.setScrollTop(-this.scrollMargin.top);
  13372. this.$cursorLayer.setSession(session);
  13373. this.$markerBack.setSession(session);
  13374. this.$markerFront.setSession(session);
  13375. this.$gutterLayer.setSession(session);
  13376. this.$textLayer.setSession(session);
  13377. if (!session)
  13378. return;
  13379. this.$loop.schedule(this.CHANGE_FULL);
  13380. this.session.$setFontMetrics(this.$fontMetrics);
  13381. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13382. this.onChangeNewLineMode()
  13383. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13384. };
  13385. this.updateLines = function(firstRow, lastRow, force) {
  13386. if (lastRow === undefined)
  13387. lastRow = Infinity;
  13388. if (!this.$changedLines) {
  13389. this.$changedLines = {
  13390. firstRow: firstRow,
  13391. lastRow: lastRow
  13392. };
  13393. }
  13394. else {
  13395. if (this.$changedLines.firstRow > firstRow)
  13396. this.$changedLines.firstRow = firstRow;
  13397. if (this.$changedLines.lastRow < lastRow)
  13398. this.$changedLines.lastRow = lastRow;
  13399. }
  13400. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13401. if (force)
  13402. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13403. else
  13404. return;
  13405. }
  13406. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13407. return;
  13408. this.$loop.schedule(this.CHANGE_LINES);
  13409. };
  13410. this.onChangeNewLineMode = function() {
  13411. this.$loop.schedule(this.CHANGE_TEXT);
  13412. this.$textLayer.$updateEolChar();
  13413. };
  13414. this.onChangeTabSize = function() {
  13415. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13416. this.$textLayer.onChangeTabSize();
  13417. };
  13418. this.updateText = function() {
  13419. this.$loop.schedule(this.CHANGE_TEXT);
  13420. };
  13421. this.updateFull = function(force) {
  13422. if (force)
  13423. this.$renderChanges(this.CHANGE_FULL, true);
  13424. else
  13425. this.$loop.schedule(this.CHANGE_FULL);
  13426. };
  13427. this.updateFontSize = function() {
  13428. this.$textLayer.checkForSizeChanges();
  13429. };
  13430. this.$changes = 0;
  13431. this.$updateSizeAsync = function() {
  13432. if (this.$loop.pending)
  13433. this.$size.$dirty = true;
  13434. else
  13435. this.onResize();
  13436. };
  13437. this.onResize = function(force, gutterWidth, width, height) {
  13438. if (this.resizing > 2)
  13439. return;
  13440. else if (this.resizing > 0)
  13441. this.resizing++;
  13442. else
  13443. this.resizing = force ? 1 : 0;
  13444. var el = this.container;
  13445. if (!height)
  13446. height = el.clientHeight || el.scrollHeight;
  13447. if (!width)
  13448. width = el.clientWidth || el.scrollWidth;
  13449. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13450. if (!this.$size.scrollerHeight || (!width && !height))
  13451. return this.resizing = 0;
  13452. if (force)
  13453. this.$gutterLayer.$padding = null;
  13454. if (force)
  13455. this.$renderChanges(changes | this.$changes, true);
  13456. else
  13457. this.$loop.schedule(changes | this.$changes);
  13458. if (this.resizing)
  13459. this.resizing = 0;
  13460. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13461. };
  13462. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13463. height -= (this.$extraHeight || 0);
  13464. var changes = 0;
  13465. var size = this.$size;
  13466. var oldSize = {
  13467. width: size.width,
  13468. height: size.height,
  13469. scrollerHeight: size.scrollerHeight,
  13470. scrollerWidth: size.scrollerWidth
  13471. };
  13472. if (height && (force || size.height != height)) {
  13473. size.height = height;
  13474. changes |= this.CHANGE_SIZE;
  13475. size.scrollerHeight = size.height;
  13476. if (this.$horizScroll)
  13477. size.scrollerHeight -= this.scrollBarH.getHeight();
  13478. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13479. changes = changes | this.CHANGE_SCROLL;
  13480. }
  13481. if (width && (force || size.width != width)) {
  13482. changes |= this.CHANGE_SIZE;
  13483. size.width = width;
  13484. if (gutterWidth == null)
  13485. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13486. this.gutterWidth = gutterWidth;
  13487. this.scrollBarH.element.style.left =
  13488. this.scroller.style.left = gutterWidth + "px";
  13489. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13490. this.scrollBarH.element.style.right =
  13491. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13492. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13493. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13494. changes |= this.CHANGE_FULL;
  13495. }
  13496. size.$dirty = !width || !height;
  13497. if (changes)
  13498. this._signal("resize", oldSize);
  13499. return changes;
  13500. };
  13501. this.onGutterResize = function() {
  13502. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13503. if (gutterWidth != this.gutterWidth)
  13504. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13505. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13506. this.$loop.schedule(this.CHANGE_FULL);
  13507. } else if (this.$size.$dirty) {
  13508. this.$loop.schedule(this.CHANGE_FULL);
  13509. } else {
  13510. this.$computeLayerConfig();
  13511. this.$loop.schedule(this.CHANGE_MARKER);
  13512. }
  13513. };
  13514. this.adjustWrapLimit = function() {
  13515. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13516. var limit = Math.floor(availableWidth / this.characterWidth);
  13517. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13518. };
  13519. this.setAnimatedScroll = function(shouldAnimate){
  13520. this.setOption("animatedScroll", shouldAnimate);
  13521. };
  13522. this.getAnimatedScroll = function() {
  13523. return this.$animatedScroll;
  13524. };
  13525. this.setShowInvisibles = function(showInvisibles) {
  13526. this.setOption("showInvisibles", showInvisibles);
  13527. };
  13528. this.getShowInvisibles = function() {
  13529. return this.getOption("showInvisibles");
  13530. };
  13531. this.getDisplayIndentGuides = function() {
  13532. return this.getOption("displayIndentGuides");
  13533. };
  13534. this.setDisplayIndentGuides = function(display) {
  13535. this.setOption("displayIndentGuides", display);
  13536. };
  13537. this.setShowPrintMargin = function(showPrintMargin) {
  13538. this.setOption("showPrintMargin", showPrintMargin);
  13539. };
  13540. this.getShowPrintMargin = function() {
  13541. return this.getOption("showPrintMargin");
  13542. };
  13543. this.setPrintMarginColumn = function(showPrintMargin) {
  13544. this.setOption("printMarginColumn", showPrintMargin);
  13545. };
  13546. this.getPrintMarginColumn = function() {
  13547. return this.getOption("printMarginColumn");
  13548. };
  13549. this.getShowGutter = function(){
  13550. return this.getOption("showGutter");
  13551. };
  13552. this.setShowGutter = function(show){
  13553. return this.setOption("showGutter", show);
  13554. };
  13555. this.getFadeFoldWidgets = function(){
  13556. return this.getOption("fadeFoldWidgets")
  13557. };
  13558. this.setFadeFoldWidgets = function(show) {
  13559. this.setOption("fadeFoldWidgets", show);
  13560. };
  13561. this.setHighlightGutterLine = function(shouldHighlight) {
  13562. this.setOption("highlightGutterLine", shouldHighlight);
  13563. };
  13564. this.getHighlightGutterLine = function() {
  13565. return this.getOption("highlightGutterLine");
  13566. };
  13567. this.$updateGutterLineHighlight = function() {
  13568. var pos = this.$cursorLayer.$pixelPos;
  13569. var height = this.layerConfig.lineHeight;
  13570. if (this.session.getUseWrapMode()) {
  13571. var cursor = this.session.selection.getCursor();
  13572. cursor.column = 0;
  13573. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13574. height *= this.session.getRowLength(cursor.row);
  13575. }
  13576. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13577. this.$gutterLineHighlight.style.height = height + "px";
  13578. };
  13579. this.$updatePrintMargin = function() {
  13580. if (!this.$showPrintMargin && !this.$printMarginEl)
  13581. return;
  13582. if (!this.$printMarginEl) {
  13583. var containerEl = dom.createElement("div");
  13584. containerEl.className = "ace_layer ace_print-margin-layer";
  13585. this.$printMarginEl = dom.createElement("div");
  13586. this.$printMarginEl.className = "ace_print-margin";
  13587. containerEl.appendChild(this.$printMarginEl);
  13588. this.content.insertBefore(containerEl, this.content.firstChild);
  13589. }
  13590. var style = this.$printMarginEl.style;
  13591. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13592. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13593. if (this.session && this.session.$wrap == -1)
  13594. this.adjustWrapLimit();
  13595. };
  13596. this.getContainerElement = function() {
  13597. return this.container;
  13598. };
  13599. this.getMouseEventTarget = function() {
  13600. return this.scroller;
  13601. };
  13602. this.getTextAreaContainer = function() {
  13603. return this.container;
  13604. };
  13605. this.$moveTextAreaToCursor = function() {
  13606. if (!this.$keepTextAreaAtCursor)
  13607. return;
  13608. var config = this.layerConfig;
  13609. var posTop = this.$cursorLayer.$pixelPos.top;
  13610. var posLeft = this.$cursorLayer.$pixelPos.left;
  13611. posTop -= config.offset;
  13612. var style = this.textarea.style;
  13613. var h = this.lineHeight;
  13614. if (posTop < 0 || posTop > config.height - h) {
  13615. style.top = style.left = "0";
  13616. return;
  13617. }
  13618. var w = this.characterWidth;
  13619. if (this.$composition) {
  13620. var val = this.textarea.value.replace(/^\x01+/, "");
  13621. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13622. h += 2;
  13623. }
  13624. posLeft -= this.scrollLeft;
  13625. if (posLeft > this.$size.scrollerWidth - w)
  13626. posLeft = this.$size.scrollerWidth - w;
  13627. posLeft += this.gutterWidth;
  13628. style.height = h + "px";
  13629. style.width = w + "px";
  13630. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13631. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13632. };
  13633. this.getFirstVisibleRow = function() {
  13634. return this.layerConfig.firstRow;
  13635. };
  13636. this.getFirstFullyVisibleRow = function() {
  13637. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13638. };
  13639. this.getLastFullyVisibleRow = function() {
  13640. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  13641. return this.layerConfig.firstRow - 1 + flint;
  13642. };
  13643. this.getLastVisibleRow = function() {
  13644. return this.layerConfig.lastRow;
  13645. };
  13646. this.$padding = null;
  13647. this.setPadding = function(padding) {
  13648. this.$padding = padding;
  13649. this.$textLayer.setPadding(padding);
  13650. this.$cursorLayer.setPadding(padding);
  13651. this.$markerFront.setPadding(padding);
  13652. this.$markerBack.setPadding(padding);
  13653. this.$loop.schedule(this.CHANGE_FULL);
  13654. this.$updatePrintMargin();
  13655. };
  13656. this.setScrollMargin = function(top, bottom, left, right) {
  13657. var sm = this.scrollMargin;
  13658. sm.top = top|0;
  13659. sm.bottom = bottom|0;
  13660. sm.right = right|0;
  13661. sm.left = left|0;
  13662. sm.v = sm.top + sm.bottom;
  13663. sm.h = sm.left + sm.right;
  13664. if (sm.top && this.scrollTop <= 0 && this.session)
  13665. this.session.setScrollTop(-sm.top);
  13666. this.updateFull();
  13667. };
  13668. this.getHScrollBarAlwaysVisible = function() {
  13669. return this.$hScrollBarAlwaysVisible;
  13670. };
  13671. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13672. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13673. };
  13674. this.getVScrollBarAlwaysVisible = function() {
  13675. return this.$vScrollBarAlwaysVisible;
  13676. };
  13677. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13678. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13679. };
  13680. this.$updateScrollBarV = function() {
  13681. var scrollHeight = this.layerConfig.maxHeight;
  13682. var scrollerHeight = this.$size.scrollerHeight;
  13683. if (!this.$maxLines && this.$scrollPastEnd) {
  13684. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13685. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13686. scrollHeight = this.scrollTop + scrollerHeight;
  13687. this.scrollBarV.scrollTop = null;
  13688. }
  13689. }
  13690. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13691. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13692. };
  13693. this.$updateScrollBarH = function() {
  13694. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13695. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13696. };
  13697. this.$frozen = false;
  13698. this.freeze = function() {
  13699. this.$frozen = true;
  13700. };
  13701. this.unfreeze = function() {
  13702. this.$frozen = false;
  13703. };
  13704. this.$renderChanges = function(changes, force) {
  13705. if (this.$changes) {
  13706. changes |= this.$changes;
  13707. this.$changes = 0;
  13708. }
  13709. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13710. this.$changes |= changes;
  13711. return;
  13712. }
  13713. if (this.$size.$dirty) {
  13714. this.$changes |= changes;
  13715. return this.onResize(true);
  13716. }
  13717. if (!this.lineHeight) {
  13718. this.$textLayer.checkForSizeChanges();
  13719. }
  13720. this._signal("beforeRender");
  13721. var config = this.layerConfig;
  13722. if (changes & this.CHANGE_FULL ||
  13723. changes & this.CHANGE_SIZE ||
  13724. changes & this.CHANGE_TEXT ||
  13725. changes & this.CHANGE_LINES ||
  13726. changes & this.CHANGE_SCROLL ||
  13727. changes & this.CHANGE_H_SCROLL
  13728. ) {
  13729. changes |= this.$computeLayerConfig();
  13730. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13731. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13732. if (st > 0) {
  13733. this.scrollTop = st;
  13734. changes = changes | this.CHANGE_SCROLL;
  13735. changes |= this.$computeLayerConfig();
  13736. }
  13737. }
  13738. config = this.layerConfig;
  13739. this.$updateScrollBarV();
  13740. if (changes & this.CHANGE_H_SCROLL)
  13741. this.$updateScrollBarH();
  13742. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13743. this.content.style.marginTop = (-config.offset) + "px";
  13744. this.content.style.width = config.width + 2 * this.$padding + "px";
  13745. this.content.style.height = config.minHeight + "px";
  13746. }
  13747. if (changes & this.CHANGE_H_SCROLL) {
  13748. this.content.style.marginLeft = -this.scrollLeft + "px";
  13749. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13750. }
  13751. if (changes & this.CHANGE_FULL) {
  13752. this.$textLayer.update(config);
  13753. if (this.$showGutter)
  13754. this.$gutterLayer.update(config);
  13755. this.$markerBack.update(config);
  13756. this.$markerFront.update(config);
  13757. this.$cursorLayer.update(config);
  13758. this.$moveTextAreaToCursor();
  13759. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13760. this._signal("afterRender");
  13761. return;
  13762. }
  13763. if (changes & this.CHANGE_SCROLL) {
  13764. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13765. this.$textLayer.update(config);
  13766. else
  13767. this.$textLayer.scrollLines(config);
  13768. if (this.$showGutter)
  13769. this.$gutterLayer.update(config);
  13770. this.$markerBack.update(config);
  13771. this.$markerFront.update(config);
  13772. this.$cursorLayer.update(config);
  13773. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13774. this.$moveTextAreaToCursor();
  13775. this._signal("afterRender");
  13776. return;
  13777. }
  13778. if (changes & this.CHANGE_TEXT) {
  13779. this.$textLayer.update(config);
  13780. if (this.$showGutter)
  13781. this.$gutterLayer.update(config);
  13782. }
  13783. else if (changes & this.CHANGE_LINES) {
  13784. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13785. this.$gutterLayer.update(config);
  13786. }
  13787. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13788. if (this.$showGutter)
  13789. this.$gutterLayer.update(config);
  13790. }
  13791. if (changes & this.CHANGE_CURSOR) {
  13792. this.$cursorLayer.update(config);
  13793. this.$moveTextAreaToCursor();
  13794. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13795. }
  13796. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13797. this.$markerFront.update(config);
  13798. }
  13799. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13800. this.$markerBack.update(config);
  13801. }
  13802. this._signal("afterRender");
  13803. };
  13804. this.$autosize = function() {
  13805. var height = this.session.getScreenLength() * this.lineHeight;
  13806. var maxHeight = this.$maxLines * this.lineHeight;
  13807. var desiredHeight = Math.max(
  13808. (this.$minLines||1) * this.lineHeight,
  13809. Math.min(maxHeight, height)
  13810. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13811. if (this.$horizScroll)
  13812. desiredHeight += this.scrollBarH.getHeight();
  13813. var vScroll = height > maxHeight;
  13814. if (desiredHeight != this.desiredHeight ||
  13815. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13816. if (vScroll != this.$vScroll) {
  13817. this.$vScroll = vScroll;
  13818. this.scrollBarV.setVisible(vScroll);
  13819. }
  13820. var w = this.container.clientWidth;
  13821. this.container.style.height = desiredHeight + "px";
  13822. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13823. this.desiredHeight = desiredHeight;
  13824. this._signal("autosize");
  13825. }
  13826. };
  13827. this.$computeLayerConfig = function() {
  13828. var session = this.session;
  13829. var size = this.$size;
  13830. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13831. var screenLines = this.session.getScreenLength();
  13832. var maxHeight = screenLines * this.lineHeight;
  13833. var longestLine = this.$getLongestLine();
  13834. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13835. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13836. var hScrollChanged = this.$horizScroll !== horizScroll;
  13837. if (hScrollChanged) {
  13838. this.$horizScroll = horizScroll;
  13839. this.scrollBarH.setVisible(horizScroll);
  13840. }
  13841. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  13842. if (this.$maxLines && this.lineHeight > 1)
  13843. this.$autosize();
  13844. var offset = this.scrollTop % this.lineHeight;
  13845. var minHeight = size.scrollerHeight + this.lineHeight;
  13846. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13847. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13848. : 0;
  13849. maxHeight += scrollPastEnd;
  13850. var sm = this.scrollMargin;
  13851. this.session.setScrollTop(Math.max(-sm.top,
  13852. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  13853. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  13854. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  13855. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13856. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  13857. var vScrollChanged = vScrollBefore !== vScroll;
  13858. if (vScrollChanged) {
  13859. this.$vScroll = vScroll;
  13860. this.scrollBarV.setVisible(vScroll);
  13861. }
  13862. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13863. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13864. var lastRow = firstRow + lineCount;
  13865. var firstRowScreen, firstRowHeight;
  13866. var lineHeight = this.lineHeight;
  13867. firstRow = session.screenToDocumentRow(firstRow, 0);
  13868. var foldLine = session.getFoldLine(firstRow);
  13869. if (foldLine) {
  13870. firstRow = foldLine.start.row;
  13871. }
  13872. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13873. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13874. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13875. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13876. firstRowHeight;
  13877. offset = this.scrollTop - firstRowScreen * lineHeight;
  13878. var changes = 0;
  13879. if (this.layerConfig.width != longestLine)
  13880. changes = this.CHANGE_H_SCROLL;
  13881. if (hScrollChanged || vScrollChanged) {
  13882. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13883. this._signal("scrollbarVisibilityChanged");
  13884. if (vScrollChanged)
  13885. longestLine = this.$getLongestLine();
  13886. }
  13887. this.layerConfig = {
  13888. width : longestLine,
  13889. padding : this.$padding,
  13890. firstRow : firstRow,
  13891. firstRowScreen: firstRowScreen,
  13892. lastRow : lastRow,
  13893. lineHeight : lineHeight,
  13894. characterWidth : this.characterWidth,
  13895. minHeight : minHeight,
  13896. maxHeight : maxHeight,
  13897. offset : offset,
  13898. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13899. height : this.$size.scrollerHeight
  13900. };
  13901. return changes;
  13902. };
  13903. this.$updateLines = function() {
  13904. var firstRow = this.$changedLines.firstRow;
  13905. var lastRow = this.$changedLines.lastRow;
  13906. this.$changedLines = null;
  13907. var layerConfig = this.layerConfig;
  13908. if (firstRow > layerConfig.lastRow + 1) { return; }
  13909. if (lastRow < layerConfig.firstRow) { return; }
  13910. if (lastRow === Infinity) {
  13911. if (this.$showGutter)
  13912. this.$gutterLayer.update(layerConfig);
  13913. this.$textLayer.update(layerConfig);
  13914. return;
  13915. }
  13916. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13917. return true;
  13918. };
  13919. this.$getLongestLine = function() {
  13920. var charCount = this.session.getScreenWidth();
  13921. if (this.showInvisibles && !this.session.$useWrapMode)
  13922. charCount += 1;
  13923. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13924. };
  13925. this.updateFrontMarkers = function() {
  13926. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13927. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13928. };
  13929. this.updateBackMarkers = function() {
  13930. this.$markerBack.setMarkers(this.session.getMarkers());
  13931. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  13932. };
  13933. this.addGutterDecoration = function(row, className){
  13934. this.$gutterLayer.addGutterDecoration(row, className);
  13935. };
  13936. this.removeGutterDecoration = function(row, className){
  13937. this.$gutterLayer.removeGutterDecoration(row, className);
  13938. };
  13939. this.updateBreakpoints = function(rows) {
  13940. this.$loop.schedule(this.CHANGE_GUTTER);
  13941. };
  13942. this.setAnnotations = function(annotations) {
  13943. this.$gutterLayer.setAnnotations(annotations);
  13944. this.$loop.schedule(this.CHANGE_GUTTER);
  13945. };
  13946. this.updateCursor = function() {
  13947. this.$loop.schedule(this.CHANGE_CURSOR);
  13948. };
  13949. this.hideCursor = function() {
  13950. this.$cursorLayer.hideCursor();
  13951. };
  13952. this.showCursor = function() {
  13953. this.$cursorLayer.showCursor();
  13954. };
  13955. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  13956. this.scrollCursorIntoView(anchor, offset);
  13957. this.scrollCursorIntoView(lead, offset);
  13958. };
  13959. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  13960. if (this.$size.scrollerHeight === 0)
  13961. return;
  13962. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13963. var left = pos.left;
  13964. var top = pos.top;
  13965. var topMargin = $viewMargin && $viewMargin.top || 0;
  13966. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  13967. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  13968. if (scrollTop + topMargin > top) {
  13969. if (offset)
  13970. top -= offset * this.$size.scrollerHeight;
  13971. if (top === 0)
  13972. top = -this.scrollMargin.top;
  13973. this.session.setScrollTop(top);
  13974. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  13975. if (offset)
  13976. top += offset * this.$size.scrollerHeight;
  13977. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  13978. }
  13979. var scrollLeft = this.scrollLeft;
  13980. if (scrollLeft > left) {
  13981. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  13982. left = -this.scrollMargin.left;
  13983. this.session.setScrollLeft(left);
  13984. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  13985. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  13986. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  13987. this.session.setScrollLeft(0);
  13988. }
  13989. };
  13990. this.getScrollTop = function() {
  13991. return this.session.getScrollTop();
  13992. };
  13993. this.getScrollLeft = function() {
  13994. return this.session.getScrollLeft();
  13995. };
  13996. this.getScrollTopRow = function() {
  13997. return this.scrollTop / this.lineHeight;
  13998. };
  13999. this.getScrollBottomRow = function() {
  14000. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  14001. };
  14002. this.scrollToRow = function(row) {
  14003. this.session.setScrollTop(row * this.lineHeight);
  14004. };
  14005. this.alignCursor = function(cursor, alignment) {
  14006. if (typeof cursor == "number")
  14007. cursor = {row: cursor, column: 0};
  14008. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14009. var h = this.$size.scrollerHeight - this.lineHeight;
  14010. var offset = pos.top - h * (alignment || 0);
  14011. this.session.setScrollTop(offset);
  14012. return offset;
  14013. };
  14014. this.STEPS = 8;
  14015. this.$calcSteps = function(fromValue, toValue){
  14016. var i = 0;
  14017. var l = this.STEPS;
  14018. var steps = [];
  14019. var func = function(t, x_min, dx) {
  14020. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  14021. };
  14022. for (i = 0; i < l; ++i)
  14023. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  14024. return steps;
  14025. };
  14026. this.scrollToLine = function(line, center, animate, callback) {
  14027. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  14028. var offset = pos.top;
  14029. if (center)
  14030. offset -= this.$size.scrollerHeight / 2;
  14031. var initialScroll = this.scrollTop;
  14032. this.session.setScrollTop(offset);
  14033. if (animate !== false)
  14034. this.animateScrolling(initialScroll, callback);
  14035. };
  14036. this.animateScrolling = function(fromValue, callback) {
  14037. var toValue = this.scrollTop;
  14038. if (!this.$animatedScroll)
  14039. return;
  14040. var _self = this;
  14041. if (fromValue == toValue)
  14042. return;
  14043. if (this.$scrollAnimation) {
  14044. var oldSteps = this.$scrollAnimation.steps;
  14045. if (oldSteps.length) {
  14046. fromValue = oldSteps[0];
  14047. if (fromValue == toValue)
  14048. return;
  14049. }
  14050. }
  14051. var steps = _self.$calcSteps(fromValue, toValue);
  14052. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  14053. clearInterval(this.$timer);
  14054. _self.session.setScrollTop(steps.shift());
  14055. _self.session.$scrollTop = toValue;
  14056. this.$timer = setInterval(function() {
  14057. if (steps.length) {
  14058. _self.session.setScrollTop(steps.shift());
  14059. _self.session.$scrollTop = toValue;
  14060. } else if (toValue != null) {
  14061. _self.session.$scrollTop = -1;
  14062. _self.session.setScrollTop(toValue);
  14063. toValue = null;
  14064. } else {
  14065. _self.$timer = clearInterval(_self.$timer);
  14066. _self.$scrollAnimation = null;
  14067. callback && callback();
  14068. }
  14069. }, 10);
  14070. };
  14071. this.scrollToY = function(scrollTop) {
  14072. if (this.scrollTop !== scrollTop) {
  14073. this.$loop.schedule(this.CHANGE_SCROLL);
  14074. this.scrollTop = scrollTop;
  14075. }
  14076. };
  14077. this.scrollToX = function(scrollLeft) {
  14078. if (this.scrollLeft !== scrollLeft)
  14079. this.scrollLeft = scrollLeft;
  14080. this.$loop.schedule(this.CHANGE_H_SCROLL);
  14081. };
  14082. this.scrollTo = function(x, y) {
  14083. this.session.setScrollTop(y);
  14084. this.session.setScrollLeft(y);
  14085. };
  14086. this.scrollBy = function(deltaX, deltaY) {
  14087. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  14088. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  14089. };
  14090. this.isScrollableBy = function(deltaX, deltaY) {
  14091. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  14092. return true;
  14093. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  14094. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  14095. return true;
  14096. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  14097. return true;
  14098. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  14099. - this.layerConfig.width < -1 + this.scrollMargin.right)
  14100. return true;
  14101. };
  14102. this.pixelToScreenCoordinates = function(x, y) {
  14103. var canvasPos = this.scroller.getBoundingClientRect();
  14104. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  14105. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  14106. var col = Math.round(offset);
  14107. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  14108. };
  14109. this.screenToTextCoordinates = function(x, y) {
  14110. var canvasPos = this.scroller.getBoundingClientRect();
  14111. var col = Math.round(
  14112. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  14113. );
  14114. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  14115. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  14116. };
  14117. this.textToScreenCoordinates = function(row, column) {
  14118. var canvasPos = this.scroller.getBoundingClientRect();
  14119. var pos = this.session.documentToScreenPosition(row, column);
  14120. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  14121. var y = pos.row * this.lineHeight;
  14122. return {
  14123. pageX: canvasPos.left + x - this.scrollLeft,
  14124. pageY: canvasPos.top + y - this.scrollTop
  14125. };
  14126. };
  14127. this.visualizeFocus = function() {
  14128. dom.addCssClass(this.container, "ace_focus");
  14129. };
  14130. this.visualizeBlur = function() {
  14131. dom.removeCssClass(this.container, "ace_focus");
  14132. };
  14133. this.showComposition = function(position) {
  14134. if (!this.$composition)
  14135. this.$composition = {
  14136. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  14137. cssText: this.textarea.style.cssText
  14138. };
  14139. this.$keepTextAreaAtCursor = true;
  14140. dom.addCssClass(this.textarea, "ace_composition");
  14141. this.textarea.style.cssText = "";
  14142. this.$moveTextAreaToCursor();
  14143. };
  14144. this.setCompositionText = function(text) {
  14145. this.$moveTextAreaToCursor();
  14146. };
  14147. this.hideComposition = function() {
  14148. if (!this.$composition)
  14149. return;
  14150. dom.removeCssClass(this.textarea, "ace_composition");
  14151. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  14152. this.textarea.style.cssText = this.$composition.cssText;
  14153. this.$composition = null;
  14154. };
  14155. this.setTheme = function(theme, cb) {
  14156. var _self = this;
  14157. this.$themeId = theme;
  14158. _self._dispatchEvent('themeChange',{theme:theme});
  14159. if (!theme || typeof theme == "string") {
  14160. var moduleName = theme || this.$options.theme.initialValue;
  14161. config.loadModule(["theme", moduleName], afterLoad);
  14162. } else {
  14163. afterLoad(theme);
  14164. }
  14165. function afterLoad(module) {
  14166. if (_self.$themeId != theme)
  14167. return cb && cb();
  14168. if (!module.cssClass)
  14169. return;
  14170. dom.importCssString(
  14171. module.cssText,
  14172. module.cssClass,
  14173. _self.container.ownerDocument
  14174. );
  14175. if (_self.theme)
  14176. dom.removeCssClass(_self.container, _self.theme.cssClass);
  14177. var padding = "padding" in module ? module.padding
  14178. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  14179. if (_self.$padding && padding != _self.$padding)
  14180. _self.setPadding(padding);
  14181. _self.$theme = module.cssClass;
  14182. _self.theme = module;
  14183. dom.addCssClass(_self.container, module.cssClass);
  14184. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  14185. if (_self.$size) {
  14186. _self.$size.width = 0;
  14187. _self.$updateSizeAsync();
  14188. }
  14189. _self._dispatchEvent('themeLoaded', {theme:module});
  14190. cb && cb();
  14191. }
  14192. };
  14193. this.getTheme = function() {
  14194. return this.$themeId;
  14195. };
  14196. this.setStyle = function(style, include) {
  14197. dom.setCssClass(this.container, style, include !== false);
  14198. };
  14199. this.unsetStyle = function(style) {
  14200. dom.removeCssClass(this.container, style);
  14201. };
  14202. this.setCursorStyle = function(style) {
  14203. if (this.scroller.style.cursor != style)
  14204. this.scroller.style.cursor = style;
  14205. };
  14206. this.setMouseCursor = function(cursorStyle) {
  14207. this.scroller.style.cursor = cursorStyle;
  14208. };
  14209. this.destroy = function() {
  14210. this.$textLayer.destroy();
  14211. this.$cursorLayer.destroy();
  14212. };
  14213. }).call(VirtualRenderer.prototype);
  14214. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  14215. animatedScroll: {initialValue: false},
  14216. showInvisibles: {
  14217. set: function(value) {
  14218. if (this.$textLayer.setShowInvisibles(value))
  14219. this.$loop.schedule(this.CHANGE_TEXT);
  14220. },
  14221. initialValue: false
  14222. },
  14223. showPrintMargin: {
  14224. set: function() { this.$updatePrintMargin(); },
  14225. initialValue: true
  14226. },
  14227. printMarginColumn: {
  14228. set: function() { this.$updatePrintMargin(); },
  14229. initialValue: 80
  14230. },
  14231. printMargin: {
  14232. set: function(val) {
  14233. if (typeof val == "number")
  14234. this.$printMarginColumn = val;
  14235. this.$showPrintMargin = !!val;
  14236. this.$updatePrintMargin();
  14237. },
  14238. get: function() {
  14239. return this.$showPrintMargin && this.$printMarginColumn;
  14240. }
  14241. },
  14242. showGutter: {
  14243. set: function(show){
  14244. this.$gutter.style.display = show ? "block" : "none";
  14245. this.$loop.schedule(this.CHANGE_FULL);
  14246. this.onGutterResize();
  14247. },
  14248. initialValue: true
  14249. },
  14250. fadeFoldWidgets: {
  14251. set: function(show) {
  14252. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14253. },
  14254. initialValue: false
  14255. },
  14256. showFoldWidgets: {
  14257. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14258. initialValue: true
  14259. },
  14260. showLineNumbers: {
  14261. set: function(show) {
  14262. this.$gutterLayer.setShowLineNumbers(show);
  14263. this.$loop.schedule(this.CHANGE_GUTTER);
  14264. },
  14265. initialValue: true
  14266. },
  14267. displayIndentGuides: {
  14268. set: function(show) {
  14269. if (this.$textLayer.setDisplayIndentGuides(show))
  14270. this.$loop.schedule(this.CHANGE_TEXT);
  14271. },
  14272. initialValue: true
  14273. },
  14274. highlightGutterLine: {
  14275. set: function(shouldHighlight) {
  14276. if (!this.$gutterLineHighlight) {
  14277. this.$gutterLineHighlight = dom.createElement("div");
  14278. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14279. this.$gutter.appendChild(this.$gutterLineHighlight);
  14280. return;
  14281. }
  14282. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14283. if (this.$cursorLayer.$pixelPos)
  14284. this.$updateGutterLineHighlight();
  14285. },
  14286. initialValue: false,
  14287. value: true
  14288. },
  14289. hScrollBarAlwaysVisible: {
  14290. set: function(val) {
  14291. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14292. this.$loop.schedule(this.CHANGE_SCROLL);
  14293. },
  14294. initialValue: false
  14295. },
  14296. vScrollBarAlwaysVisible: {
  14297. set: function(val) {
  14298. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14299. this.$loop.schedule(this.CHANGE_SCROLL);
  14300. },
  14301. initialValue: false
  14302. },
  14303. fontSize: {
  14304. set: function(size) {
  14305. if (typeof size == "number")
  14306. size = size + "px";
  14307. this.container.style.fontSize = size;
  14308. this.updateFontSize();
  14309. },
  14310. initialValue: 12
  14311. },
  14312. fontFamily: {
  14313. set: function(name) {
  14314. this.container.style.fontFamily = name;
  14315. this.updateFontSize();
  14316. }
  14317. },
  14318. maxLines: {
  14319. set: function(val) {
  14320. this.updateFull();
  14321. }
  14322. },
  14323. minLines: {
  14324. set: function(val) {
  14325. this.updateFull();
  14326. }
  14327. },
  14328. scrollPastEnd: {
  14329. set: function(val) {
  14330. val = +val || 0;
  14331. if (this.$scrollPastEnd == val)
  14332. return;
  14333. this.$scrollPastEnd = val;
  14334. this.$loop.schedule(this.CHANGE_SCROLL);
  14335. },
  14336. initialValue: 0,
  14337. handlesSet: true
  14338. },
  14339. fixedWidthGutter: {
  14340. set: function(val) {
  14341. this.$gutterLayer.$fixedWidth = !!val;
  14342. this.$loop.schedule(this.CHANGE_GUTTER);
  14343. }
  14344. },
  14345. theme: {
  14346. set: function(val) { this.setTheme(val) },
  14347. get: function() { return this.$themeId || this.theme; },
  14348. initialValue: "./theme/textmate",
  14349. handlesSet: true
  14350. }
  14351. });
  14352. exports.VirtualRenderer = VirtualRenderer;
  14353. });
  14354. ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
  14355. "use strict";
  14356. var oop = require("../lib/oop");
  14357. var net = require("../lib/net");
  14358. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14359. var config = require("../config");
  14360. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14361. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14362. this.changeListener = this.changeListener.bind(this);
  14363. this.onMessage = this.onMessage.bind(this);
  14364. if (require.nameToUrl && !require.toUrl)
  14365. require.toUrl = require.nameToUrl;
  14366. if (config.get("packaged") || !require.toUrl) {
  14367. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14368. } else {
  14369. var normalizePath = this.$normalizePath;
  14370. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14371. var tlns = {};
  14372. topLevelNamespaces.forEach(function(ns) {
  14373. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14374. });
  14375. }
  14376. try {
  14377. this.$worker = new Worker(workerUrl);
  14378. } catch(e) {
  14379. if (e instanceof window.DOMException) {
  14380. var blob = this.$workerBlob(workerUrl);
  14381. var URL = window.URL || window.webkitURL;
  14382. var blobURL = URL.createObjectURL(blob);
  14383. this.$worker = new Worker(blobURL);
  14384. URL.revokeObjectURL(blobURL);
  14385. } else {
  14386. throw e;
  14387. }
  14388. }
  14389. this.$worker.postMessage({
  14390. init : true,
  14391. tlns : tlns,
  14392. module : mod,
  14393. classname : classname
  14394. });
  14395. this.callbackId = 1;
  14396. this.callbacks = {};
  14397. this.$worker.onmessage = this.onMessage;
  14398. };
  14399. (function(){
  14400. oop.implement(this, EventEmitter);
  14401. this.onMessage = function(e) {
  14402. var msg = e.data;
  14403. switch(msg.type) {
  14404. case "event":
  14405. this._signal(msg.name, {data: msg.data});
  14406. break;
  14407. case "call":
  14408. var callback = this.callbacks[msg.id];
  14409. if (callback) {
  14410. callback(msg.data);
  14411. delete this.callbacks[msg.id];
  14412. }
  14413. break;
  14414. case "error":
  14415. this.reportError(msg.data);
  14416. break;
  14417. case "log":
  14418. window.console && console.log && console.log.apply(console, msg.data);
  14419. break;
  14420. }
  14421. };
  14422. this.reportError = function(err) {
  14423. window.console && console.error && console.error(err);
  14424. };
  14425. this.$normalizePath = function(path) {
  14426. return net.qualifyURL(path);
  14427. };
  14428. this.terminate = function() {
  14429. this._signal("terminate", {});
  14430. this.deltaQueue = null;
  14431. this.$worker.terminate();
  14432. this.$worker = null;
  14433. if (this.$doc)
  14434. this.$doc.off("change", this.changeListener);
  14435. this.$doc = null;
  14436. };
  14437. this.send = function(cmd, args) {
  14438. this.$worker.postMessage({command: cmd, args: args});
  14439. };
  14440. this.call = function(cmd, args, callback) {
  14441. if (callback) {
  14442. var id = this.callbackId++;
  14443. this.callbacks[id] = callback;
  14444. args.push(id);
  14445. }
  14446. this.send(cmd, args);
  14447. };
  14448. this.emit = function(event, data) {
  14449. try {
  14450. this.$worker.postMessage({event: event, data: {data: data.data}});
  14451. }
  14452. catch(ex) {
  14453. console.error(ex.stack);
  14454. }
  14455. };
  14456. this.attachToDocument = function(doc) {
  14457. if(this.$doc)
  14458. this.terminate();
  14459. this.$doc = doc;
  14460. this.call("setValue", [doc.getValue()]);
  14461. doc.on("change", this.changeListener);
  14462. };
  14463. this.changeListener = function(delta) {
  14464. if (!this.deltaQueue) {
  14465. this.deltaQueue = [];
  14466. setTimeout(this.$sendDeltaQueue, 0);
  14467. }
  14468. if (delta.action == "insert")
  14469. this.deltaQueue.push(delta.start, delta.lines);
  14470. else
  14471. this.deltaQueue.push(delta.start, delta.end);
  14472. };
  14473. this.$sendDeltaQueue = function() {
  14474. var q = this.deltaQueue;
  14475. if (!q) return;
  14476. this.deltaQueue = null;
  14477. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  14478. this.call("setValue", [this.$doc.getValue()]);
  14479. } else
  14480. this.emit("change", {data: q});
  14481. };
  14482. this.$workerBlob = function(workerUrl) {
  14483. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14484. try {
  14485. return new Blob([script], {"type": "application/javascript"});
  14486. } catch (e) { // Backwards-compatibility
  14487. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14488. var blobBuilder = new BlobBuilder();
  14489. blobBuilder.append(script);
  14490. return blobBuilder.getBlob("application/javascript");
  14491. }
  14492. };
  14493. }).call(WorkerClient.prototype);
  14494. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14495. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14496. this.changeListener = this.changeListener.bind(this);
  14497. this.callbackId = 1;
  14498. this.callbacks = {};
  14499. this.messageBuffer = [];
  14500. var main = null;
  14501. var emitSync = false;
  14502. var sender = Object.create(EventEmitter);
  14503. var _self = this;
  14504. this.$worker = {};
  14505. this.$worker.terminate = function() {};
  14506. this.$worker.postMessage = function(e) {
  14507. _self.messageBuffer.push(e);
  14508. if (main) {
  14509. if (emitSync)
  14510. setTimeout(processNext);
  14511. else
  14512. processNext();
  14513. }
  14514. };
  14515. this.setEmitSync = function(val) { emitSync = val };
  14516. var processNext = function() {
  14517. var msg = _self.messageBuffer.shift();
  14518. if (msg.command)
  14519. main[msg.command].apply(main, msg.args);
  14520. else if (msg.event)
  14521. sender._signal(msg.event, msg.data);
  14522. };
  14523. sender.postMessage = function(msg) {
  14524. _self.onMessage({data: msg});
  14525. };
  14526. sender.callback = function(data, callbackId) {
  14527. this.postMessage({type: "call", id: callbackId, data: data});
  14528. };
  14529. sender.emit = function(name, data) {
  14530. this.postMessage({type: "event", name: name, data: data});
  14531. };
  14532. config.loadModule(["worker", mod], function(Main) {
  14533. main = new Main[classname](sender);
  14534. while (_self.messageBuffer.length)
  14535. processNext();
  14536. });
  14537. };
  14538. UIWorkerClient.prototype = WorkerClient.prototype;
  14539. exports.UIWorkerClient = UIWorkerClient;
  14540. exports.WorkerClient = WorkerClient;
  14541. });
  14542. ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14543. "use strict";
  14544. var Range = require("./range").Range;
  14545. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14546. var oop = require("./lib/oop");
  14547. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14548. var _self = this;
  14549. this.length = length;
  14550. this.session = session;
  14551. this.doc = session.getDocument();
  14552. this.mainClass = mainClass;
  14553. this.othersClass = othersClass;
  14554. this.$onUpdate = this.onUpdate.bind(this);
  14555. this.doc.on("change", this.$onUpdate);
  14556. this.$others = others;
  14557. this.$onCursorChange = function() {
  14558. setTimeout(function() {
  14559. _self.onCursorChange();
  14560. });
  14561. };
  14562. this.$pos = pos;
  14563. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14564. this.$undoStackDepth = undoStack.length;
  14565. this.setup();
  14566. session.selection.on("changeCursor", this.$onCursorChange);
  14567. };
  14568. (function() {
  14569. oop.implement(this, EventEmitter);
  14570. this.setup = function() {
  14571. var _self = this;
  14572. var doc = this.doc;
  14573. var session = this.session;
  14574. var pos = this.$pos;
  14575. this.selectionBefore = session.selection.toJSON();
  14576. if (session.selection.inMultiSelectMode)
  14577. session.selection.toSingleRange();
  14578. this.pos = doc.createAnchor(pos.row, pos.column);
  14579. this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14580. this.pos.on("change", function(event) {
  14581. session.removeMarker(_self.markerId);
  14582. _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
  14583. });
  14584. this.others = [];
  14585. this.$others.forEach(function(other) {
  14586. var anchor = doc.createAnchor(other.row, other.column);
  14587. _self.others.push(anchor);
  14588. });
  14589. session.setUndoSelect(false);
  14590. };
  14591. this.showOtherMarkers = function() {
  14592. if(this.othersActive) return;
  14593. var session = this.session;
  14594. var _self = this;
  14595. this.othersActive = true;
  14596. this.others.forEach(function(anchor) {
  14597. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14598. anchor.on("change", function(event) {
  14599. session.removeMarker(anchor.markerId);
  14600. anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
  14601. });
  14602. });
  14603. };
  14604. this.hideOtherMarkers = function() {
  14605. if(!this.othersActive) return;
  14606. this.othersActive = false;
  14607. for (var i = 0; i < this.others.length; i++) {
  14608. this.session.removeMarker(this.others[i].markerId);
  14609. }
  14610. };
  14611. this.onUpdate = function(delta) {
  14612. var range = delta;
  14613. if(range.start.row !== range.end.row) return;
  14614. if(range.start.row !== this.pos.row) return;
  14615. if (this.$updating) return;
  14616. this.$updating = true;
  14617. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14618. if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
  14619. var distanceFromStart = range.start.column - this.pos.column;
  14620. this.length += lengthDiff;
  14621. if(!this.session.$fromUndo) {
  14622. if(delta.action === 'insert') {
  14623. for (var i = this.others.length - 1; i >= 0; i--) {
  14624. var otherPos = this.others[i];
  14625. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14626. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14627. newPos.column += lengthDiff;
  14628. this.doc.insertMergedLines(newPos, delta.lines);
  14629. }
  14630. } else if(delta.action === 'remove') {
  14631. for (var i = this.others.length - 1; i >= 0; i--) {
  14632. var otherPos = this.others[i];
  14633. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14634. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14635. newPos.column += lengthDiff;
  14636. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14637. }
  14638. }
  14639. if(range.start.column === this.pos.column && delta.action === 'insert') {
  14640. setTimeout(function() {
  14641. this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
  14642. for (var i = 0; i < this.others.length; i++) {
  14643. var other = this.others[i];
  14644. var newPos = {row: other.row, column: other.column - lengthDiff};
  14645. if(other.row === range.start.row && range.start.column < other.column)
  14646. newPos.column += lengthDiff;
  14647. other.setPosition(newPos.row, newPos.column);
  14648. }
  14649. }.bind(this), 0);
  14650. }
  14651. else if(range.start.column === this.pos.column && delta.action === 'remove') {
  14652. setTimeout(function() {
  14653. for (var i = 0; i < this.others.length; i++) {
  14654. var other = this.others[i];
  14655. if(other.row === range.start.row && range.start.column < other.column) {
  14656. other.setPosition(other.row, other.column - lengthDiff);
  14657. }
  14658. }
  14659. }.bind(this), 0);
  14660. }
  14661. }
  14662. this.pos._emit("change", {value: this.pos});
  14663. for (var i = 0; i < this.others.length; i++) {
  14664. this.others[i]._emit("change", {value: this.others[i]});
  14665. }
  14666. }
  14667. this.$updating = false;
  14668. };
  14669. this.onCursorChange = function(event) {
  14670. if (this.$updating || !this.session) return;
  14671. var pos = this.session.selection.getCursor();
  14672. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14673. this.showOtherMarkers();
  14674. this._emit("cursorEnter", event);
  14675. } else {
  14676. this.hideOtherMarkers();
  14677. this._emit("cursorLeave", event);
  14678. }
  14679. };
  14680. this.detach = function() {
  14681. this.session.removeMarker(this.markerId);
  14682. this.hideOtherMarkers();
  14683. this.doc.removeEventListener("change", this.$onUpdate);
  14684. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14685. this.pos.detach();
  14686. for (var i = 0; i < this.others.length; i++) {
  14687. this.others[i].detach();
  14688. }
  14689. this.session.setUndoSelect(true);
  14690. this.session = null;
  14691. };
  14692. this.cancel = function() {
  14693. if(this.$undoStackDepth === -1)
  14694. throw Error("Canceling placeholders only supported with undo manager attached to session.");
  14695. var undoManager = this.session.getUndoManager();
  14696. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14697. for (var i = 0; i < undosRequired; i++) {
  14698. undoManager.undo(true);
  14699. }
  14700. if (this.selectionBefore)
  14701. this.session.selection.fromJSON(this.selectionBefore);
  14702. };
  14703. }).call(PlaceHolder.prototype);
  14704. exports.PlaceHolder = PlaceHolder;
  14705. });
  14706. ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14707. var event = require("../lib/event");
  14708. var useragent = require("../lib/useragent");
  14709. function isSamePoint(p1, p2) {
  14710. return p1.row == p2.row && p1.column == p2.column;
  14711. }
  14712. function onMouseDown(e) {
  14713. var ev = e.domEvent;
  14714. var alt = ev.altKey;
  14715. var shift = ev.shiftKey;
  14716. var ctrl = ev.ctrlKey;
  14717. var accel = e.getAccelKey();
  14718. var button = e.getButton();
  14719. if (ctrl && useragent.isMac)
  14720. button = ev.button;
  14721. if (e.editor.inMultiSelectMode && button == 2) {
  14722. e.editor.textInput.onContextMenu(e.domEvent);
  14723. return;
  14724. }
  14725. if (!ctrl && !alt && !accel) {
  14726. if (button === 0 && e.editor.inMultiSelectMode)
  14727. e.editor.exitMultiSelectMode();
  14728. return;
  14729. }
  14730. if (button !== 0)
  14731. return;
  14732. var editor = e.editor;
  14733. var selection = editor.selection;
  14734. var isMultiSelect = editor.inMultiSelectMode;
  14735. var pos = e.getDocumentPosition();
  14736. var cursor = selection.getCursor();
  14737. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14738. var mouseX = e.x, mouseY = e.y;
  14739. var onMouseSelection = function(e) {
  14740. mouseX = e.clientX;
  14741. mouseY = e.clientY;
  14742. };
  14743. var session = editor.session;
  14744. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14745. var screenCursor = screenAnchor;
  14746. var selectionMode;
  14747. if (editor.$mouseHandler.$enableJumpToDef) {
  14748. if (ctrl && alt || accel && alt)
  14749. selectionMode = shift ? "block" : "add";
  14750. else if (alt && editor.$blockSelectEnabled)
  14751. selectionMode = "block";
  14752. } else {
  14753. if (accel && !alt) {
  14754. selectionMode = "add";
  14755. if (!isMultiSelect && shift)
  14756. return;
  14757. } else if (alt && editor.$blockSelectEnabled) {
  14758. selectionMode = "block";
  14759. }
  14760. }
  14761. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14762. editor.$mouseHandler.cancelContextMenu();
  14763. }
  14764. if (selectionMode == "add") {
  14765. if (!isMultiSelect && inSelection)
  14766. return; // dragging
  14767. if (!isMultiSelect) {
  14768. var range = selection.toOrientedRange();
  14769. editor.addSelectionMarker(range);
  14770. }
  14771. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14772. editor.$blockScrolling++;
  14773. editor.inVirtualSelectionMode = true;
  14774. if (shift) {
  14775. oldRange = null;
  14776. range = selection.ranges[0] || range;
  14777. editor.removeSelectionMarker(range);
  14778. }
  14779. editor.once("mouseup", function() {
  14780. var tmpSel = selection.toOrientedRange();
  14781. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14782. selection.substractPoint(tmpSel.cursor);
  14783. else {
  14784. if (shift) {
  14785. selection.substractPoint(range.cursor);
  14786. } else if (range) {
  14787. editor.removeSelectionMarker(range);
  14788. selection.addRange(range);
  14789. }
  14790. selection.addRange(tmpSel);
  14791. }
  14792. editor.$blockScrolling--;
  14793. editor.inVirtualSelectionMode = false;
  14794. });
  14795. } else if (selectionMode == "block") {
  14796. e.stop();
  14797. editor.inVirtualSelectionMode = true;
  14798. var initialRange;
  14799. var rectSel = [];
  14800. var blockSelect = function() {
  14801. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14802. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14803. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14804. return;
  14805. screenCursor = newCursor;
  14806. editor.$blockScrolling++;
  14807. editor.selection.moveToPosition(cursor);
  14808. editor.renderer.scrollCursorIntoView();
  14809. editor.removeSelectionMarkers(rectSel);
  14810. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14811. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14812. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14813. rectSel.forEach(editor.addSelectionMarker, editor);
  14814. editor.updateSelectionMarkers();
  14815. editor.$blockScrolling--;
  14816. };
  14817. editor.$blockScrolling++;
  14818. if (isMultiSelect && !accel) {
  14819. selection.toSingleRange();
  14820. } else if (!isMultiSelect && accel) {
  14821. initialRange = selection.toOrientedRange();
  14822. editor.addSelectionMarker(initialRange);
  14823. }
  14824. if (shift)
  14825. screenAnchor = session.documentToScreenPosition(selection.lead);
  14826. else
  14827. selection.moveToPosition(pos);
  14828. editor.$blockScrolling--;
  14829. screenCursor = {row: -1, column: -1};
  14830. var onMouseSelectionEnd = function(e) {
  14831. clearInterval(timerId);
  14832. editor.removeSelectionMarkers(rectSel);
  14833. if (!rectSel.length)
  14834. rectSel = [selection.toOrientedRange()];
  14835. editor.$blockScrolling++;
  14836. if (initialRange) {
  14837. editor.removeSelectionMarker(initialRange);
  14838. selection.toSingleRange(initialRange);
  14839. }
  14840. for (var i = 0; i < rectSel.length; i++)
  14841. selection.addRange(rectSel[i]);
  14842. editor.inVirtualSelectionMode = false;
  14843. editor.$mouseHandler.$clickSelection = null;
  14844. editor.$blockScrolling--;
  14845. };
  14846. var onSelectionInterval = blockSelect;
  14847. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14848. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14849. return e.preventDefault();
  14850. }
  14851. }
  14852. exports.onMouseDown = onMouseDown;
  14853. });
  14854. ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14855. exports.defaultCommands = [{
  14856. name: "addCursorAbove",
  14857. exec: function(editor) { editor.selectMoreLines(-1); },
  14858. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14859. scrollIntoView: "cursor",
  14860. readOnly: true
  14861. }, {
  14862. name: "addCursorBelow",
  14863. exec: function(editor) { editor.selectMoreLines(1); },
  14864. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14865. scrollIntoView: "cursor",
  14866. readOnly: true
  14867. }, {
  14868. name: "addCursorAboveSkipCurrent",
  14869. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14870. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14871. scrollIntoView: "cursor",
  14872. readOnly: true
  14873. }, {
  14874. name: "addCursorBelowSkipCurrent",
  14875. exec: function(editor) { editor.selectMoreLines(1, true); },
  14876. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14877. scrollIntoView: "cursor",
  14878. readOnly: true
  14879. }, {
  14880. name: "selectMoreBefore",
  14881. exec: function(editor) { editor.selectMore(-1); },
  14882. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14883. scrollIntoView: "cursor",
  14884. readOnly: true
  14885. }, {
  14886. name: "selectMoreAfter",
  14887. exec: function(editor) { editor.selectMore(1); },
  14888. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14889. scrollIntoView: "cursor",
  14890. readOnly: true
  14891. }, {
  14892. name: "selectNextBefore",
  14893. exec: function(editor) { editor.selectMore(-1, true); },
  14894. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14895. scrollIntoView: "cursor",
  14896. readOnly: true
  14897. }, {
  14898. name: "selectNextAfter",
  14899. exec: function(editor) { editor.selectMore(1, true); },
  14900. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14901. scrollIntoView: "cursor",
  14902. readOnly: true
  14903. }, {
  14904. name: "splitIntoLines",
  14905. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14906. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14907. readOnly: true
  14908. }, {
  14909. name: "alignCursors",
  14910. exec: function(editor) { editor.alignCursors(); },
  14911. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14912. scrollIntoView: "cursor"
  14913. }, {
  14914. name: "findAll",
  14915. exec: function(editor) { editor.findAll(); },
  14916. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14917. scrollIntoView: "cursor",
  14918. readOnly: true
  14919. }];
  14920. exports.multiSelectCommands = [{
  14921. name: "singleSelection",
  14922. bindKey: "esc",
  14923. exec: function(editor) { editor.exitMultiSelectMode(); },
  14924. scrollIntoView: "cursor",
  14925. readOnly: true,
  14926. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14927. }];
  14928. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14929. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14930. });
  14931. ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"], function(require, exports, module) {
  14932. var RangeList = require("./range_list").RangeList;
  14933. var Range = require("./range").Range;
  14934. var Selection = require("./selection").Selection;
  14935. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14936. var event = require("./lib/event");
  14937. var lang = require("./lib/lang");
  14938. var commands = require("./commands/multi_select_commands");
  14939. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14940. var Search = require("./search").Search;
  14941. var search = new Search();
  14942. function find(session, needle, dir) {
  14943. search.$options.wrap = true;
  14944. search.$options.needle = needle;
  14945. search.$options.backwards = dir == -1;
  14946. return search.find(session);
  14947. }
  14948. var EditSession = require("./edit_session").EditSession;
  14949. (function() {
  14950. this.getSelectionMarkers = function() {
  14951. return this.$selectionMarkers;
  14952. };
  14953. }).call(EditSession.prototype);
  14954. (function() {
  14955. this.ranges = null;
  14956. this.rangeList = null;
  14957. this.addRange = function(range, $blockChangeEvents) {
  14958. if (!range)
  14959. return;
  14960. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  14961. var oldRange = this.toOrientedRange();
  14962. this.rangeList.add(oldRange);
  14963. this.rangeList.add(range);
  14964. if (this.rangeList.ranges.length != 2) {
  14965. this.rangeList.removeAll();
  14966. return $blockChangeEvents || this.fromOrientedRange(range);
  14967. }
  14968. this.rangeList.removeAll();
  14969. this.rangeList.add(oldRange);
  14970. this.$onAddRange(oldRange);
  14971. }
  14972. if (!range.cursor)
  14973. range.cursor = range.end;
  14974. var removed = this.rangeList.add(range);
  14975. this.$onAddRange(range);
  14976. if (removed.length)
  14977. this.$onRemoveRange(removed);
  14978. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  14979. this._signal("multiSelect");
  14980. this.inMultiSelectMode = true;
  14981. this.session.$undoSelect = false;
  14982. this.rangeList.attach(this.session);
  14983. }
  14984. return $blockChangeEvents || this.fromOrientedRange(range);
  14985. };
  14986. this.toSingleRange = function(range) {
  14987. range = range || this.ranges[0];
  14988. var removed = this.rangeList.removeAll();
  14989. if (removed.length)
  14990. this.$onRemoveRange(removed);
  14991. range && this.fromOrientedRange(range);
  14992. };
  14993. this.substractPoint = function(pos) {
  14994. var removed = this.rangeList.substractPoint(pos);
  14995. if (removed) {
  14996. this.$onRemoveRange(removed);
  14997. return removed[0];
  14998. }
  14999. };
  15000. this.mergeOverlappingRanges = function() {
  15001. var removed = this.rangeList.merge();
  15002. if (removed.length)
  15003. this.$onRemoveRange(removed);
  15004. else if(this.ranges[0])
  15005. this.fromOrientedRange(this.ranges[0]);
  15006. };
  15007. this.$onAddRange = function(range) {
  15008. this.rangeCount = this.rangeList.ranges.length;
  15009. this.ranges.unshift(range);
  15010. this._signal("addRange", {range: range});
  15011. };
  15012. this.$onRemoveRange = function(removed) {
  15013. this.rangeCount = this.rangeList.ranges.length;
  15014. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  15015. var lastRange = this.rangeList.ranges.pop();
  15016. removed.push(lastRange);
  15017. this.rangeCount = 0;
  15018. }
  15019. for (var i = removed.length; i--; ) {
  15020. var index = this.ranges.indexOf(removed[i]);
  15021. this.ranges.splice(index, 1);
  15022. }
  15023. this._signal("removeRange", {ranges: removed});
  15024. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  15025. this.inMultiSelectMode = false;
  15026. this._signal("singleSelect");
  15027. this.session.$undoSelect = true;
  15028. this.rangeList.detach(this.session);
  15029. }
  15030. lastRange = lastRange || this.ranges[0];
  15031. if (lastRange && !lastRange.isEqual(this.getRange()))
  15032. this.fromOrientedRange(lastRange);
  15033. };
  15034. this.$initRangeList = function() {
  15035. if (this.rangeList)
  15036. return;
  15037. this.rangeList = new RangeList();
  15038. this.ranges = [];
  15039. this.rangeCount = 0;
  15040. };
  15041. this.getAllRanges = function() {
  15042. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  15043. };
  15044. this.splitIntoLines = function () {
  15045. if (this.rangeCount > 1) {
  15046. var ranges = this.rangeList.ranges;
  15047. var lastRange = ranges[ranges.length - 1];
  15048. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15049. this.toSingleRange();
  15050. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15051. } else {
  15052. var range = this.getRange();
  15053. var isBackwards = this.isBackwards();
  15054. var startRow = range.start.row;
  15055. var endRow = range.end.row;
  15056. if (startRow == endRow) {
  15057. if (isBackwards)
  15058. var start = range.end, end = range.start;
  15059. else
  15060. var start = range.start, end = range.end;
  15061. this.addRange(Range.fromPoints(end, end));
  15062. this.addRange(Range.fromPoints(start, start));
  15063. return;
  15064. }
  15065. var rectSel = [];
  15066. var r = this.getLineRange(startRow, true);
  15067. r.start.column = range.start.column;
  15068. rectSel.push(r);
  15069. for (var i = startRow + 1; i < endRow; i++)
  15070. rectSel.push(this.getLineRange(i, true));
  15071. r = this.getLineRange(endRow, true);
  15072. r.end.column = range.end.column;
  15073. rectSel.push(r);
  15074. rectSel.forEach(this.addRange, this);
  15075. }
  15076. };
  15077. this.toggleBlockSelection = function () {
  15078. if (this.rangeCount > 1) {
  15079. var ranges = this.rangeList.ranges;
  15080. var lastRange = ranges[ranges.length - 1];
  15081. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15082. this.toSingleRange();
  15083. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15084. } else {
  15085. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  15086. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  15087. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  15088. rectSel.forEach(this.addRange, this);
  15089. }
  15090. };
  15091. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  15092. var rectSel = [];
  15093. var xBackwards = screenCursor.column < screenAnchor.column;
  15094. if (xBackwards) {
  15095. var startColumn = screenCursor.column;
  15096. var endColumn = screenAnchor.column;
  15097. } else {
  15098. var startColumn = screenAnchor.column;
  15099. var endColumn = screenCursor.column;
  15100. }
  15101. var yBackwards = screenCursor.row < screenAnchor.row;
  15102. if (yBackwards) {
  15103. var startRow = screenCursor.row;
  15104. var endRow = screenAnchor.row;
  15105. } else {
  15106. var startRow = screenAnchor.row;
  15107. var endRow = screenCursor.row;
  15108. }
  15109. if (startColumn < 0)
  15110. startColumn = 0;
  15111. if (startRow < 0)
  15112. startRow = 0;
  15113. if (startRow == endRow)
  15114. includeEmptyLines = true;
  15115. for (var row = startRow; row <= endRow; row++) {
  15116. var range = Range.fromPoints(
  15117. this.session.screenToDocumentPosition(row, startColumn),
  15118. this.session.screenToDocumentPosition(row, endColumn)
  15119. );
  15120. if (range.isEmpty()) {
  15121. if (docEnd && isSamePoint(range.end, docEnd))
  15122. break;
  15123. var docEnd = range.end;
  15124. }
  15125. range.cursor = xBackwards ? range.start : range.end;
  15126. rectSel.push(range);
  15127. }
  15128. if (yBackwards)
  15129. rectSel.reverse();
  15130. if (!includeEmptyLines) {
  15131. var end = rectSel.length - 1;
  15132. while (rectSel[end].isEmpty() && end > 0)
  15133. end--;
  15134. if (end > 0) {
  15135. var start = 0;
  15136. while (rectSel[start].isEmpty())
  15137. start++;
  15138. }
  15139. for (var i = end; i >= start; i--) {
  15140. if (rectSel[i].isEmpty())
  15141. rectSel.splice(i, 1);
  15142. }
  15143. }
  15144. return rectSel;
  15145. };
  15146. }).call(Selection.prototype);
  15147. var Editor = require("./editor").Editor;
  15148. (function() {
  15149. this.updateSelectionMarkers = function() {
  15150. this.renderer.updateCursor();
  15151. this.renderer.updateBackMarkers();
  15152. };
  15153. this.addSelectionMarker = function(orientedRange) {
  15154. if (!orientedRange.cursor)
  15155. orientedRange.cursor = orientedRange.end;
  15156. var style = this.getSelectionStyle();
  15157. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  15158. this.session.$selectionMarkers.push(orientedRange);
  15159. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15160. return orientedRange;
  15161. };
  15162. this.removeSelectionMarker = function(range) {
  15163. if (!range.marker)
  15164. return;
  15165. this.session.removeMarker(range.marker);
  15166. var index = this.session.$selectionMarkers.indexOf(range);
  15167. if (index != -1)
  15168. this.session.$selectionMarkers.splice(index, 1);
  15169. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15170. };
  15171. this.removeSelectionMarkers = function(ranges) {
  15172. var markerList = this.session.$selectionMarkers;
  15173. for (var i = ranges.length; i--; ) {
  15174. var range = ranges[i];
  15175. if (!range.marker)
  15176. continue;
  15177. this.session.removeMarker(range.marker);
  15178. var index = markerList.indexOf(range);
  15179. if (index != -1)
  15180. markerList.splice(index, 1);
  15181. }
  15182. this.session.selectionMarkerCount = markerList.length;
  15183. };
  15184. this.$onAddRange = function(e) {
  15185. this.addSelectionMarker(e.range);
  15186. this.renderer.updateCursor();
  15187. this.renderer.updateBackMarkers();
  15188. };
  15189. this.$onRemoveRange = function(e) {
  15190. this.removeSelectionMarkers(e.ranges);
  15191. this.renderer.updateCursor();
  15192. this.renderer.updateBackMarkers();
  15193. };
  15194. this.$onMultiSelect = function(e) {
  15195. if (this.inMultiSelectMode)
  15196. return;
  15197. this.inMultiSelectMode = true;
  15198. this.setStyle("ace_multiselect");
  15199. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  15200. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  15201. this.renderer.updateCursor();
  15202. this.renderer.updateBackMarkers();
  15203. };
  15204. this.$onSingleSelect = function(e) {
  15205. if (this.session.multiSelect.inVirtualMode)
  15206. return;
  15207. this.inMultiSelectMode = false;
  15208. this.unsetStyle("ace_multiselect");
  15209. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  15210. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  15211. this.renderer.updateCursor();
  15212. this.renderer.updateBackMarkers();
  15213. this._emit("changeSelection");
  15214. };
  15215. this.$onMultiSelectExec = function(e) {
  15216. var command = e.command;
  15217. var editor = e.editor;
  15218. if (!editor.multiSelect)
  15219. return;
  15220. if (!command.multiSelectAction) {
  15221. var result = command.exec(editor, e.args || {});
  15222. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15223. editor.multiSelect.mergeOverlappingRanges();
  15224. } else if (command.multiSelectAction == "forEach") {
  15225. result = editor.forEachSelection(command, e.args);
  15226. } else if (command.multiSelectAction == "forEachLine") {
  15227. result = editor.forEachSelection(command, e.args, true);
  15228. } else if (command.multiSelectAction == "single") {
  15229. editor.exitMultiSelectMode();
  15230. result = command.exec(editor, e.args || {});
  15231. } else {
  15232. result = command.multiSelectAction(editor, e.args || {});
  15233. }
  15234. return result;
  15235. };
  15236. this.forEachSelection = function(cmd, args, options) {
  15237. if (this.inVirtualSelectionMode)
  15238. return;
  15239. var keepOrder = options && options.keepOrder;
  15240. var $byLines = options == true || options && options.$byLines
  15241. var session = this.session;
  15242. var selection = this.selection;
  15243. var rangeList = selection.rangeList;
  15244. var ranges = (keepOrder ? selection : rangeList).ranges;
  15245. var result;
  15246. if (!ranges.length)
  15247. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15248. var reg = selection._eventRegistry;
  15249. selection._eventRegistry = {};
  15250. var tmpSel = new Selection(session);
  15251. this.inVirtualSelectionMode = true;
  15252. for (var i = ranges.length; i--;) {
  15253. if ($byLines) {
  15254. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15255. i--;
  15256. }
  15257. tmpSel.fromOrientedRange(ranges[i]);
  15258. tmpSel.index = i;
  15259. this.selection = session.selection = tmpSel;
  15260. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15261. if (!result && cmdResult !== undefined)
  15262. result = cmdResult;
  15263. tmpSel.toOrientedRange(ranges[i]);
  15264. }
  15265. tmpSel.detach();
  15266. this.selection = session.selection = selection;
  15267. this.inVirtualSelectionMode = false;
  15268. selection._eventRegistry = reg;
  15269. selection.mergeOverlappingRanges();
  15270. var anim = this.renderer.$scrollAnimation;
  15271. this.onCursorChange();
  15272. this.onSelectionChange();
  15273. if (anim && anim.from == anim.to)
  15274. this.renderer.animateScrolling(anim.from);
  15275. return result;
  15276. };
  15277. this.exitMultiSelectMode = function() {
  15278. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15279. return;
  15280. this.multiSelect.toSingleRange();
  15281. };
  15282. this.getSelectedText = function() {
  15283. var text = "";
  15284. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15285. var ranges = this.multiSelect.rangeList.ranges;
  15286. var buf = [];
  15287. for (var i = 0; i < ranges.length; i++) {
  15288. buf.push(this.session.getTextRange(ranges[i]));
  15289. }
  15290. var nl = this.session.getDocument().getNewLineCharacter();
  15291. text = buf.join(nl);
  15292. if (text.length == (buf.length - 1) * nl.length)
  15293. text = "";
  15294. } else if (!this.selection.isEmpty()) {
  15295. text = this.session.getTextRange(this.getSelectionRange());
  15296. }
  15297. return text;
  15298. };
  15299. this.$checkMultiselectChange = function(e, anchor) {
  15300. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15301. var range = this.multiSelect.ranges[0];
  15302. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15303. return;
  15304. var pos = anchor == this.multiSelect.anchor
  15305. ? range.cursor == range.start ? range.end : range.start
  15306. : range.cursor;
  15307. if (pos.row != anchor.row
  15308. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15309. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15310. }
  15311. };
  15312. this.findAll = function(needle, options, additive) {
  15313. options = options || {};
  15314. options.needle = needle || options.needle;
  15315. if (options.needle == undefined) {
  15316. var range = this.selection.isEmpty()
  15317. ? this.selection.getWordRange()
  15318. : this.selection.getRange();
  15319. options.needle = this.session.getTextRange(range);
  15320. }
  15321. this.$search.set(options);
  15322. var ranges = this.$search.findAll(this.session);
  15323. if (!ranges.length)
  15324. return 0;
  15325. this.$blockScrolling += 1;
  15326. var selection = this.multiSelect;
  15327. if (!additive)
  15328. selection.toSingleRange(ranges[0]);
  15329. for (var i = ranges.length; i--; )
  15330. selection.addRange(ranges[i], true);
  15331. if (range && selection.rangeList.rangeAtPoint(range.start))
  15332. selection.addRange(range, true);
  15333. this.$blockScrolling -= 1;
  15334. return ranges.length;
  15335. };
  15336. this.selectMoreLines = function(dir, skip) {
  15337. var range = this.selection.toOrientedRange();
  15338. var isBackwards = range.cursor == range.end;
  15339. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15340. if (this.selection.$desiredColumn)
  15341. screenLead.column = this.selection.$desiredColumn;
  15342. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15343. if (!range.isEmpty()) {
  15344. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15345. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15346. } else {
  15347. var anchor = lead;
  15348. }
  15349. if (isBackwards) {
  15350. var newRange = Range.fromPoints(lead, anchor);
  15351. newRange.cursor = newRange.start;
  15352. } else {
  15353. var newRange = Range.fromPoints(anchor, lead);
  15354. newRange.cursor = newRange.end;
  15355. }
  15356. newRange.desiredColumn = screenLead.column;
  15357. if (!this.selection.inMultiSelectMode) {
  15358. this.selection.addRange(range);
  15359. } else {
  15360. if (skip)
  15361. var toRemove = range.cursor;
  15362. }
  15363. this.selection.addRange(newRange);
  15364. if (toRemove)
  15365. this.selection.substractPoint(toRemove);
  15366. };
  15367. this.transposeSelections = function(dir) {
  15368. var session = this.session;
  15369. var sel = session.multiSelect;
  15370. var all = sel.ranges;
  15371. for (var i = all.length; i--; ) {
  15372. var range = all[i];
  15373. if (range.isEmpty()) {
  15374. var tmp = session.getWordRange(range.start.row, range.start.column);
  15375. range.start.row = tmp.start.row;
  15376. range.start.column = tmp.start.column;
  15377. range.end.row = tmp.end.row;
  15378. range.end.column = tmp.end.column;
  15379. }
  15380. }
  15381. sel.mergeOverlappingRanges();
  15382. var words = [];
  15383. for (var i = all.length; i--; ) {
  15384. var range = all[i];
  15385. words.unshift(session.getTextRange(range));
  15386. }
  15387. if (dir < 0)
  15388. words.unshift(words.pop());
  15389. else
  15390. words.push(words.shift());
  15391. for (var i = all.length; i--; ) {
  15392. var range = all[i];
  15393. var tmp = range.clone();
  15394. session.replace(range, words[i]);
  15395. range.start.row = tmp.start.row;
  15396. range.start.column = tmp.start.column;
  15397. }
  15398. };
  15399. this.selectMore = function(dir, skip, stopAtFirst) {
  15400. var session = this.session;
  15401. var sel = session.multiSelect;
  15402. var range = sel.toOrientedRange();
  15403. if (range.isEmpty()) {
  15404. range = session.getWordRange(range.start.row, range.start.column);
  15405. range.cursor = dir == -1 ? range.start : range.end;
  15406. this.multiSelect.addRange(range);
  15407. if (stopAtFirst)
  15408. return;
  15409. }
  15410. var needle = session.getTextRange(range);
  15411. var newRange = find(session, needle, dir);
  15412. if (newRange) {
  15413. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15414. this.$blockScrolling += 1;
  15415. this.session.unfold(newRange);
  15416. this.multiSelect.addRange(newRange);
  15417. this.$blockScrolling -= 1;
  15418. this.renderer.scrollCursorIntoView(null, 0.5);
  15419. }
  15420. if (skip)
  15421. this.multiSelect.substractPoint(range.cursor);
  15422. };
  15423. this.alignCursors = function() {
  15424. var session = this.session;
  15425. var sel = session.multiSelect;
  15426. var ranges = sel.ranges;
  15427. var row = -1;
  15428. var sameRowRanges = ranges.filter(function(r) {
  15429. if (r.cursor.row == row)
  15430. return true;
  15431. row = r.cursor.row;
  15432. });
  15433. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15434. var range = this.selection.getRange();
  15435. var fr = range.start.row, lr = range.end.row;
  15436. var guessRange = fr == lr;
  15437. if (guessRange) {
  15438. var max = this.session.getLength();
  15439. var line;
  15440. do {
  15441. line = this.session.getLine(lr);
  15442. } while (/[=:]/.test(line) && ++lr < max);
  15443. do {
  15444. line = this.session.getLine(fr);
  15445. } while (/[=:]/.test(line) && --fr > 0);
  15446. if (fr < 0) fr = 0;
  15447. if (lr >= max) lr = max - 1;
  15448. }
  15449. var lines = this.session.removeFullLines(fr, lr);
  15450. lines = this.$reAlignText(lines, guessRange);
  15451. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15452. if (!guessRange) {
  15453. range.start.column = 0;
  15454. range.end.column = lines[lines.length - 1].length;
  15455. }
  15456. this.selection.setRange(range);
  15457. } else {
  15458. sameRowRanges.forEach(function(r) {
  15459. sel.substractPoint(r.cursor);
  15460. });
  15461. var maxCol = 0;
  15462. var minSpace = Infinity;
  15463. var spaceOffsets = ranges.map(function(r) {
  15464. var p = r.cursor;
  15465. var line = session.getLine(p.row);
  15466. var spaceOffset = line.substr(p.column).search(/\S/g);
  15467. if (spaceOffset == -1)
  15468. spaceOffset = 0;
  15469. if (p.column > maxCol)
  15470. maxCol = p.column;
  15471. if (spaceOffset < minSpace)
  15472. minSpace = spaceOffset;
  15473. return spaceOffset;
  15474. });
  15475. ranges.forEach(function(r, i) {
  15476. var p = r.cursor;
  15477. var l = maxCol - p.column;
  15478. var d = spaceOffsets[i] - minSpace;
  15479. if (l > d)
  15480. session.insert(p, lang.stringRepeat(" ", l - d));
  15481. else
  15482. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15483. r.start.column = r.end.column = maxCol;
  15484. r.start.row = r.end.row = p.row;
  15485. r.cursor = r.end;
  15486. });
  15487. sel.fromOrientedRange(ranges[0]);
  15488. this.renderer.updateCursor();
  15489. this.renderer.updateBackMarkers();
  15490. }
  15491. };
  15492. this.$reAlignText = function(lines, forceLeft) {
  15493. var isLeftAligned = true, isRightAligned = true;
  15494. var startW, textW, endW;
  15495. return lines.map(function(line) {
  15496. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15497. if (!m)
  15498. return [line];
  15499. if (startW == null) {
  15500. startW = m[1].length;
  15501. textW = m[2].length;
  15502. endW = m[3].length;
  15503. return m;
  15504. }
  15505. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15506. isRightAligned = false;
  15507. if (startW != m[1].length)
  15508. isLeftAligned = false;
  15509. if (startW > m[1].length)
  15510. startW = m[1].length;
  15511. if (textW < m[2].length)
  15512. textW = m[2].length;
  15513. if (endW > m[3].length)
  15514. endW = m[3].length;
  15515. return m;
  15516. }).map(forceLeft ? alignLeft :
  15517. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15518. function spaces(n) {
  15519. return lang.stringRepeat(" ", n);
  15520. }
  15521. function alignLeft(m) {
  15522. return !m[2] ? m[0] : spaces(startW) + m[2]
  15523. + spaces(textW - m[2].length + endW)
  15524. + m[4].replace(/^([=:])\s+/, "$1 ");
  15525. }
  15526. function alignRight(m) {
  15527. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15528. + spaces(endW, " ")
  15529. + m[4].replace(/^([=:])\s+/, "$1 ");
  15530. }
  15531. function unAlign(m) {
  15532. return !m[2] ? m[0] : spaces(startW) + m[2]
  15533. + spaces(endW)
  15534. + m[4].replace(/^([=:])\s+/, "$1 ");
  15535. }
  15536. };
  15537. }).call(Editor.prototype);
  15538. function isSamePoint(p1, p2) {
  15539. return p1.row == p2.row && p1.column == p2.column;
  15540. }
  15541. exports.onSessionChange = function(e) {
  15542. var session = e.session;
  15543. if (session && !session.multiSelect) {
  15544. session.$selectionMarkers = [];
  15545. session.selection.$initRangeList();
  15546. session.multiSelect = session.selection;
  15547. }
  15548. this.multiSelect = session && session.multiSelect;
  15549. var oldSession = e.oldSession;
  15550. if (oldSession) {
  15551. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15552. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15553. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15554. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15555. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15556. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15557. }
  15558. if (session) {
  15559. session.multiSelect.on("addRange", this.$onAddRange);
  15560. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15561. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15562. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15563. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15564. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15565. }
  15566. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15567. if (session.selection.inMultiSelectMode)
  15568. this.$onMultiSelect();
  15569. else
  15570. this.$onSingleSelect();
  15571. }
  15572. };
  15573. function MultiSelect(editor) {
  15574. if (editor.$multiselectOnSessionChange)
  15575. return;
  15576. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15577. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15578. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15579. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15580. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15581. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15582. editor.$multiselectOnSessionChange(editor);
  15583. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15584. editor.on("mousedown", onMouseDown);
  15585. editor.commands.addCommands(commands.defaultCommands);
  15586. addAltCursorListeners(editor);
  15587. }
  15588. function addAltCursorListeners(editor){
  15589. var el = editor.textInput.getElement();
  15590. var altCursor = false;
  15591. event.addListener(el, "keydown", function(e) {
  15592. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  15593. if (editor.$blockSelectEnabled && altDown) {
  15594. if (!altCursor) {
  15595. editor.renderer.setMouseCursor("crosshair");
  15596. altCursor = true;
  15597. }
  15598. } else if (altCursor) {
  15599. reset();
  15600. }
  15601. });
  15602. event.addListener(el, "keyup", reset);
  15603. event.addListener(el, "blur", reset);
  15604. function reset(e) {
  15605. if (altCursor) {
  15606. editor.renderer.setMouseCursor("");
  15607. altCursor = false;
  15608. }
  15609. }
  15610. }
  15611. exports.MultiSelect = MultiSelect;
  15612. require("./config").defineOptions(Editor.prototype, "editor", {
  15613. enableMultiselect: {
  15614. set: function(val) {
  15615. MultiSelect(this);
  15616. if (val) {
  15617. this.on("changeSession", this.$multiselectOnSessionChange);
  15618. this.on("mousedown", onMouseDown);
  15619. } else {
  15620. this.off("changeSession", this.$multiselectOnSessionChange);
  15621. this.off("mousedown", onMouseDown);
  15622. }
  15623. },
  15624. value: true
  15625. },
  15626. enableBlockSelect: {
  15627. set: function(val) {
  15628. this.$blockSelectEnabled = val;
  15629. },
  15630. value: true
  15631. }
  15632. });
  15633. });
  15634. ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15635. "use strict";
  15636. var Range = require("../../range").Range;
  15637. var FoldMode = exports.FoldMode = function() {};
  15638. (function() {
  15639. this.foldingStartMarker = null;
  15640. this.foldingStopMarker = null;
  15641. this.getFoldWidget = function(session, foldStyle, row) {
  15642. var line = session.getLine(row);
  15643. if (this.foldingStartMarker.test(line))
  15644. return "start";
  15645. if (foldStyle == "markbeginend"
  15646. && this.foldingStopMarker
  15647. && this.foldingStopMarker.test(line))
  15648. return "end";
  15649. return "";
  15650. };
  15651. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15652. return null;
  15653. };
  15654. this.indentationBlock = function(session, row, column) {
  15655. var re = /\S/;
  15656. var line = session.getLine(row);
  15657. var startLevel = line.search(re);
  15658. if (startLevel == -1)
  15659. return;
  15660. var startColumn = column || line.length;
  15661. var maxRow = session.getLength();
  15662. var startRow = row;
  15663. var endRow = row;
  15664. while (++row < maxRow) {
  15665. var level = session.getLine(row).search(re);
  15666. if (level == -1)
  15667. continue;
  15668. if (level <= startLevel)
  15669. break;
  15670. endRow = row;
  15671. }
  15672. if (endRow > startRow) {
  15673. var endColumn = session.getLine(endRow).length;
  15674. return new Range(startRow, startColumn, endRow, endColumn);
  15675. }
  15676. };
  15677. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15678. var start = {row: row, column: column + 1};
  15679. var end = session.$findClosingBracket(bracket, start, typeRe);
  15680. if (!end)
  15681. return;
  15682. var fw = session.foldWidgets[end.row];
  15683. if (fw == null)
  15684. fw = session.getFoldWidget(end.row);
  15685. if (fw == "start" && end.row > start.row) {
  15686. end.row --;
  15687. end.column = session.getLine(end.row).length;
  15688. }
  15689. return Range.fromPoints(start, end);
  15690. };
  15691. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15692. var end = {row: row, column: column};
  15693. var start = session.$findOpeningBracket(bracket, end);
  15694. if (!start)
  15695. return;
  15696. start.column++;
  15697. end.column--;
  15698. return Range.fromPoints(start, end);
  15699. };
  15700. }).call(FoldMode.prototype);
  15701. });
  15702. ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15703. "use strict";
  15704. exports.isDark = false;
  15705. exports.cssClass = "ace-tm";
  15706. exports.cssText = ".ace-tm .ace_gutter {\
  15707. background: #f0f0f0;\
  15708. color: #333;\
  15709. }\
  15710. .ace-tm .ace_print-margin {\
  15711. width: 1px;\
  15712. background: #e8e8e8;\
  15713. }\
  15714. .ace-tm .ace_fold {\
  15715. background-color: #6B72E6;\
  15716. }\
  15717. .ace-tm {\
  15718. background-color: #FFFFFF;\
  15719. color: black;\
  15720. }\
  15721. .ace-tm .ace_cursor {\
  15722. color: black;\
  15723. }\
  15724. .ace-tm .ace_invisible {\
  15725. color: rgb(191, 191, 191);\
  15726. }\
  15727. .ace-tm .ace_storage,\
  15728. .ace-tm .ace_keyword {\
  15729. color: blue;\
  15730. }\
  15731. .ace-tm .ace_constant {\
  15732. color: rgb(197, 6, 11);\
  15733. }\
  15734. .ace-tm .ace_constant.ace_buildin {\
  15735. color: rgb(88, 72, 246);\
  15736. }\
  15737. .ace-tm .ace_constant.ace_language {\
  15738. color: rgb(88, 92, 246);\
  15739. }\
  15740. .ace-tm .ace_constant.ace_library {\
  15741. color: rgb(6, 150, 14);\
  15742. }\
  15743. .ace-tm .ace_invalid {\
  15744. background-color: rgba(255, 0, 0, 0.1);\
  15745. color: red;\
  15746. }\
  15747. .ace-tm .ace_support.ace_function {\
  15748. color: rgb(60, 76, 114);\
  15749. }\
  15750. .ace-tm .ace_support.ace_constant {\
  15751. color: rgb(6, 150, 14);\
  15752. }\
  15753. .ace-tm .ace_support.ace_type,\
  15754. .ace-tm .ace_support.ace_class {\
  15755. color: rgb(109, 121, 222);\
  15756. }\
  15757. .ace-tm .ace_keyword.ace_operator {\
  15758. color: rgb(104, 118, 135);\
  15759. }\
  15760. .ace-tm .ace_string {\
  15761. color: rgb(3, 106, 7);\
  15762. }\
  15763. .ace-tm .ace_comment {\
  15764. color: rgb(76, 136, 107);\
  15765. }\
  15766. .ace-tm .ace_comment.ace_doc {\
  15767. color: rgb(0, 102, 255);\
  15768. }\
  15769. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15770. color: rgb(128, 159, 191);\
  15771. }\
  15772. .ace-tm .ace_constant.ace_numeric {\
  15773. color: rgb(0, 0, 205);\
  15774. }\
  15775. .ace-tm .ace_variable {\
  15776. color: rgb(49, 132, 149);\
  15777. }\
  15778. .ace-tm .ace_xml-pe {\
  15779. color: rgb(104, 104, 91);\
  15780. }\
  15781. .ace-tm .ace_entity.ace_name.ace_function {\
  15782. color: #0000A2;\
  15783. }\
  15784. .ace-tm .ace_heading {\
  15785. color: rgb(12, 7, 255);\
  15786. }\
  15787. .ace-tm .ace_list {\
  15788. color:rgb(185, 6, 144);\
  15789. }\
  15790. .ace-tm .ace_meta.ace_tag {\
  15791. color:rgb(0, 22, 142);\
  15792. }\
  15793. .ace-tm .ace_string.ace_regex {\
  15794. color: rgb(255, 0, 0)\
  15795. }\
  15796. .ace-tm .ace_marker-layer .ace_selection {\
  15797. background: rgb(181, 213, 255);\
  15798. }\
  15799. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15800. box-shadow: 0 0 3px 0px white;\
  15801. }\
  15802. .ace-tm .ace_marker-layer .ace_step {\
  15803. background: rgb(252, 255, 0);\
  15804. }\
  15805. .ace-tm .ace_marker-layer .ace_stack {\
  15806. background: rgb(164, 229, 101);\
  15807. }\
  15808. .ace-tm .ace_marker-layer .ace_bracket {\
  15809. margin: -1px 0 0 -1px;\
  15810. border: 1px solid rgb(192, 192, 192);\
  15811. }\
  15812. .ace-tm .ace_marker-layer .ace_active-line {\
  15813. background: rgba(0, 0, 0, 0.07);\
  15814. }\
  15815. .ace-tm .ace_gutter-active-line {\
  15816. background-color : #dcdcdc;\
  15817. }\
  15818. .ace-tm .ace_marker-layer .ace_selected-word {\
  15819. background: rgb(250, 250, 255);\
  15820. border: 1px solid rgb(200, 200, 250);\
  15821. }\
  15822. .ace-tm .ace_indent-guide {\
  15823. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15824. }\
  15825. ";
  15826. var dom = require("../lib/dom");
  15827. dom.importCssString(exports.cssText, exports.cssClass);
  15828. });
  15829. ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15830. "use strict";
  15831. var oop = require("./lib/oop");
  15832. var dom = require("./lib/dom");
  15833. var Range = require("./range").Range;
  15834. function LineWidgets(session) {
  15835. this.session = session;
  15836. this.session.widgetManager = this;
  15837. this.session.getRowLength = this.getRowLength;
  15838. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15839. this.updateOnChange = this.updateOnChange.bind(this);
  15840. this.renderWidgets = this.renderWidgets.bind(this);
  15841. this.measureWidgets = this.measureWidgets.bind(this);
  15842. this.session._changedWidgets = [];
  15843. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15844. this.session.on("change", this.updateOnChange);
  15845. this.session.on("changeEditor", this.$onChangeEditor);
  15846. }
  15847. (function() {
  15848. this.getRowLength = function(row) {
  15849. var h;
  15850. if (this.lineWidgets)
  15851. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15852. else
  15853. h = 0;
  15854. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15855. return 1 + h;
  15856. } else {
  15857. return this.$wrapData[row].length + 1 + h;
  15858. }
  15859. };
  15860. this.$getWidgetScreenLength = function() {
  15861. var screenRows = 0;
  15862. this.lineWidgets.forEach(function(w){
  15863. if (w && w.rowCount)
  15864. screenRows +=w.rowCount;
  15865. });
  15866. return screenRows;
  15867. };
  15868. this.$onChangeEditor = function(e) {
  15869. this.attach(e.editor);
  15870. };
  15871. this.attach = function(editor) {
  15872. if (editor && editor.widgetManager && editor.widgetManager != this)
  15873. editor.widgetManager.detach();
  15874. if (this.editor == editor)
  15875. return;
  15876. this.detach();
  15877. this.editor = editor;
  15878. if (editor) {
  15879. editor.widgetManager = this;
  15880. editor.renderer.on("beforeRender", this.measureWidgets);
  15881. editor.renderer.on("afterRender", this.renderWidgets);
  15882. }
  15883. };
  15884. this.detach = function(e) {
  15885. var editor = this.editor;
  15886. if (!editor)
  15887. return;
  15888. this.editor = null;
  15889. editor.widgetManager = null;
  15890. editor.renderer.off("beforeRender", this.measureWidgets);
  15891. editor.renderer.off("afterRender", this.renderWidgets);
  15892. var lineWidgets = this.session.lineWidgets;
  15893. lineWidgets && lineWidgets.forEach(function(w) {
  15894. if (w && w.el && w.el.parentNode) {
  15895. w._inDocument = false;
  15896. w.el.parentNode.removeChild(w.el);
  15897. }
  15898. });
  15899. };
  15900. this.updateOnChange = function(delta) {
  15901. var lineWidgets = this.session.lineWidgets;
  15902. if (!lineWidgets) return;
  15903. var startRow = delta.start.row;
  15904. var len = delta.end.row - startRow;
  15905. if (len === 0) {
  15906. } else if (delta.action == 'remove') {
  15907. var removed = lineWidgets.splice(startRow + 1, len);
  15908. removed.forEach(function(w) {
  15909. w && this.removeLineWidget(w);
  15910. }, this);
  15911. this.$updateRows();
  15912. } else {
  15913. var args = new Array(len);
  15914. args.unshift(startRow, 0);
  15915. lineWidgets.splice.apply(lineWidgets, args);
  15916. this.$updateRows();
  15917. }
  15918. };
  15919. this.$updateRows = function() {
  15920. var lineWidgets = this.session.lineWidgets;
  15921. if (!lineWidgets) return;
  15922. var noWidgets = true;
  15923. lineWidgets.forEach(function(w, i) {
  15924. if (w) {
  15925. noWidgets = false;
  15926. w.row = i;
  15927. }
  15928. });
  15929. if (noWidgets)
  15930. this.session.lineWidgets = null;
  15931. };
  15932. this.addLineWidget = function(w) {
  15933. if (!this.session.lineWidgets)
  15934. this.session.lineWidgets = new Array(this.session.getLength());
  15935. this.session.lineWidgets[w.row] = w;
  15936. var renderer = this.editor.renderer;
  15937. if (w.html && !w.el) {
  15938. w.el = dom.createElement("div");
  15939. w.el.innerHTML = w.html;
  15940. }
  15941. if (w.el) {
  15942. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  15943. w.el.style.position = "absolute";
  15944. w.el.style.zIndex = 5;
  15945. renderer.container.appendChild(w.el);
  15946. w._inDocument = true;
  15947. }
  15948. if (!w.coverGutter) {
  15949. w.el.style.zIndex = 3;
  15950. }
  15951. if (!w.pixelHeight) {
  15952. w.pixelHeight = w.el.offsetHeight;
  15953. }
  15954. if (w.rowCount == null)
  15955. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  15956. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15957. this.$updateRows();
  15958. this.renderWidgets(null, renderer);
  15959. return w;
  15960. };
  15961. this.removeLineWidget = function(w) {
  15962. w._inDocument = false;
  15963. if (w.el && w.el.parentNode)
  15964. w.el.parentNode.removeChild(w.el);
  15965. if (w.editor && w.editor.destroy) try {
  15966. w.editor.destroy();
  15967. } catch(e){}
  15968. if (this.session.lineWidgets)
  15969. this.session.lineWidgets[w.row] = undefined;
  15970. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15971. this.$updateRows();
  15972. };
  15973. this.onWidgetChanged = function(w) {
  15974. this.session._changedWidgets.push(w);
  15975. this.editor && this.editor.renderer.updateFull();
  15976. };
  15977. this.measureWidgets = function(e, renderer) {
  15978. var changedWidgets = this.session._changedWidgets;
  15979. var config = renderer.layerConfig;
  15980. if (!changedWidgets || !changedWidgets.length) return;
  15981. var min = Infinity;
  15982. for (var i = 0; i < changedWidgets.length; i++) {
  15983. var w = changedWidgets[i];
  15984. if (!w._inDocument) {
  15985. w._inDocument = true;
  15986. renderer.container.appendChild(w.el);
  15987. }
  15988. w.h = w.el.offsetHeight;
  15989. if (!w.fixedWidth) {
  15990. w.w = w.el.offsetWidth;
  15991. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  15992. }
  15993. var rowCount = w.h / config.lineHeight;
  15994. if (w.coverLine) {
  15995. rowCount -= this.session.getRowLineCount(w.row);
  15996. if (rowCount < 0)
  15997. rowCount = 0;
  15998. }
  15999. if (w.rowCount != rowCount) {
  16000. w.rowCount = rowCount;
  16001. if (w.row < min)
  16002. min = w.row;
  16003. }
  16004. }
  16005. if (min != Infinity) {
  16006. this.session._emit("changeFold", {data:{start:{row: min}}});
  16007. this.session.lineWidgetWidth = null;
  16008. }
  16009. this.session._changedWidgets = [];
  16010. };
  16011. this.renderWidgets = function(e, renderer) {
  16012. var config = renderer.layerConfig;
  16013. var lineWidgets = this.session.lineWidgets;
  16014. if (!lineWidgets)
  16015. return;
  16016. var first = Math.min(this.firstRow, config.firstRow);
  16017. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  16018. while (first > 0 && !lineWidgets[first])
  16019. first--;
  16020. this.firstRow = config.firstRow;
  16021. this.lastRow = config.lastRow;
  16022. renderer.$cursorLayer.config = config;
  16023. for (var i = first; i <= last; i++) {
  16024. var w = lineWidgets[i];
  16025. if (!w || !w.el) continue;
  16026. if (!w._inDocument) {
  16027. w._inDocument = true;
  16028. renderer.container.appendChild(w.el);
  16029. }
  16030. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  16031. if (!w.coverLine)
  16032. top += config.lineHeight * this.session.getRowLineCount(w.row);
  16033. w.el.style.top = top - config.offset + "px";
  16034. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  16035. if (!w.fixedWidth)
  16036. left -= renderer.scrollLeft;
  16037. w.el.style.left = left + "px";
  16038. if (w.fixedWidth) {
  16039. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  16040. } else {
  16041. w.el.style.right = "";
  16042. }
  16043. }
  16044. };
  16045. }).call(LineWidgets.prototype);
  16046. exports.LineWidgets = LineWidgets;
  16047. });
  16048. ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  16049. "use strict";
  16050. var LineWidgets = require("../line_widgets").LineWidgets;
  16051. var dom = require("../lib/dom");
  16052. var Range = require("../range").Range;
  16053. function binarySearch(array, needle, comparator) {
  16054. var first = 0;
  16055. var last = array.length - 1;
  16056. while (first <= last) {
  16057. var mid = (first + last) >> 1;
  16058. var c = comparator(needle, array[mid]);
  16059. if (c > 0)
  16060. first = mid + 1;
  16061. else if (c < 0)
  16062. last = mid - 1;
  16063. else
  16064. return mid;
  16065. }
  16066. return -(first + 1);
  16067. }
  16068. function findAnnotations(session, row, dir) {
  16069. var annotations = session.getAnnotations().sort(Range.comparePoints);
  16070. if (!annotations.length)
  16071. return;
  16072. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  16073. if (i < 0)
  16074. i = -i - 1;
  16075. if (i >= annotations.length)
  16076. i = dir > 0 ? 0 : annotations.length - 1;
  16077. else if (i === 0 && dir < 0)
  16078. i = annotations.length - 1;
  16079. var annotation = annotations[i];
  16080. if (!annotation || !dir)
  16081. return;
  16082. if (annotation.row === row) {
  16083. do {
  16084. annotation = annotations[i += dir];
  16085. } while (annotation && annotation.row === row);
  16086. if (!annotation)
  16087. return annotations.slice();
  16088. }
  16089. var matched = [];
  16090. row = annotation.row;
  16091. do {
  16092. matched[dir < 0 ? "unshift" : "push"](annotation);
  16093. annotation = annotations[i += dir];
  16094. } while (annotation && annotation.row == row);
  16095. return matched.length && matched;
  16096. }
  16097. exports.showErrorMarker = function(editor, dir) {
  16098. var session = editor.session;
  16099. if (!session.widgetManager) {
  16100. session.widgetManager = new LineWidgets(session);
  16101. session.widgetManager.attach(editor);
  16102. }
  16103. var pos = editor.getCursorPosition();
  16104. var row = pos.row;
  16105. var oldWidget = session.lineWidgets && session.lineWidgets[row];
  16106. if (oldWidget) {
  16107. oldWidget.destroy();
  16108. } else {
  16109. row -= dir;
  16110. }
  16111. var annotations = findAnnotations(session, row, dir);
  16112. var gutterAnno;
  16113. if (annotations) {
  16114. var annotation = annotations[0];
  16115. pos.column = (annotation.pos && typeof annotation.column != "number"
  16116. ? annotation.pos.sc
  16117. : annotation.column) || 0;
  16118. pos.row = annotation.row;
  16119. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  16120. } else if (oldWidget) {
  16121. return;
  16122. } else {
  16123. gutterAnno = {
  16124. text: ["Looks good!"],
  16125. className: "ace_ok"
  16126. };
  16127. }
  16128. editor.session.unfold(pos.row);
  16129. editor.selection.moveToPosition(pos);
  16130. var w = {
  16131. row: pos.row,
  16132. fixedWidth: true,
  16133. coverGutter: true,
  16134. el: dom.createElement("div")
  16135. };
  16136. var el = w.el.appendChild(dom.createElement("div"));
  16137. var arrow = w.el.appendChild(dom.createElement("div"));
  16138. arrow.className = "error_widget_arrow " + gutterAnno.className;
  16139. var left = editor.renderer.$cursorLayer
  16140. .getPixelPosition(pos).left;
  16141. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  16142. w.el.className = "error_widget_wrapper";
  16143. el.className = "error_widget " + gutterAnno.className;
  16144. el.innerHTML = gutterAnno.text.join("<br>");
  16145. el.appendChild(dom.createElement("div"));
  16146. var kb = function(_, hashId, keyString) {
  16147. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  16148. w.destroy();
  16149. return {command: "null"};
  16150. }
  16151. };
  16152. w.destroy = function() {
  16153. if (editor.$mouseHandler.isMousePressed)
  16154. return;
  16155. editor.keyBinding.removeKeyboardHandler(kb);
  16156. session.widgetManager.removeLineWidget(w);
  16157. editor.off("changeSelection", w.destroy);
  16158. editor.off("changeSession", w.destroy);
  16159. editor.off("mouseup", w.destroy);
  16160. editor.off("change", w.destroy);
  16161. };
  16162. editor.keyBinding.addKeyboardHandler(kb);
  16163. editor.on("changeSelection", w.destroy);
  16164. editor.on("changeSession", w.destroy);
  16165. editor.on("mouseup", w.destroy);
  16166. editor.on("change", w.destroy);
  16167. editor.session.widgetManager.addLineWidget(w);
  16168. w.el.onmousedown = editor.focus.bind(editor);
  16169. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  16170. };
  16171. dom.importCssString("\
  16172. .error_widget_wrapper {\
  16173. background: inherit;\
  16174. color: inherit;\
  16175. border:none\
  16176. }\
  16177. .error_widget {\
  16178. border-top: solid 2px;\
  16179. border-bottom: solid 2px;\
  16180. margin: 5px 0;\
  16181. padding: 10px 40px;\
  16182. white-space: pre-wrap;\
  16183. }\
  16184. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  16185. border-color: #ff5a5a\
  16186. }\
  16187. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  16188. border-color: #F1D817\
  16189. }\
  16190. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  16191. border-color: #5a5a5a\
  16192. }\
  16193. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  16194. border-color: #5aaa5a\
  16195. }\
  16196. .error_widget_arrow {\
  16197. position: absolute;\
  16198. border: solid 5px;\
  16199. border-top-color: transparent!important;\
  16200. border-right-color: transparent!important;\
  16201. border-left-color: transparent!important;\
  16202. top: -5px;\
  16203. }\
  16204. ", "");
  16205. });
  16206. ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"], function(require, exports, module) {
  16207. "use strict";
  16208. require("./lib/fixoldbrowsers");
  16209. var dom = require("./lib/dom");
  16210. var event = require("./lib/event");
  16211. var Editor = require("./editor").Editor;
  16212. var EditSession = require("./edit_session").EditSession;
  16213. var UndoManager = require("./undomanager").UndoManager;
  16214. var Renderer = require("./virtual_renderer").VirtualRenderer;
  16215. require("./worker/worker_client");
  16216. require("./keyboard/hash_handler");
  16217. require("./placeholder");
  16218. require("./multi_select");
  16219. require("./mode/folding/fold_mode");
  16220. require("./theme/textmate");
  16221. require("./ext/error_marker");
  16222. exports.config = require("./config");
  16223. exports.require = require;
  16224. exports.edit = function(el) {
  16225. if (typeof(el) == "string") {
  16226. var _id = el;
  16227. el = document.getElementById(_id);
  16228. if (!el)
  16229. throw new Error("ace.edit can't find div #" + _id);
  16230. }
  16231. if (el && el.env && el.env.editor instanceof Editor)
  16232. return el.env.editor;
  16233. var value = "";
  16234. if (el && /input|textarea/i.test(el.tagName)) {
  16235. var oldNode = el;
  16236. value = oldNode.value;
  16237. el = dom.createElement("pre");
  16238. oldNode.parentNode.replaceChild(el, oldNode);
  16239. } else if (el) {
  16240. value = dom.getInnerText(el);
  16241. el.innerHTML = '';
  16242. }
  16243. var doc = exports.createEditSession(value);
  16244. var editor = new Editor(new Renderer(el));
  16245. editor.setSession(doc);
  16246. var env = {
  16247. document: doc,
  16248. editor: editor,
  16249. onResize: editor.resize.bind(editor, null)
  16250. };
  16251. if (oldNode) env.textarea = oldNode;
  16252. event.addListener(window, "resize", env.onResize);
  16253. editor.on("destroy", function() {
  16254. event.removeListener(window, "resize", env.onResize);
  16255. env.editor.container.env = null; // prevent memory leak on old ie
  16256. });
  16257. editor.container.env = editor.env = env;
  16258. return editor;
  16259. };
  16260. exports.createEditSession = function(text, mode) {
  16261. var doc = new EditSession(text, mode);
  16262. doc.setUndoManager(new UndoManager());
  16263. return doc;
  16264. }
  16265. exports.EditSession = EditSession;
  16266. exports.UndoManager = UndoManager;
  16267. });
  16268. (function() {
  16269. ace.require(["ace/ace"], function(a) {
  16270. a && a.config.init(true);
  16271. if (!window.ace)
  16272. window.ace = a;
  16273. for (var key in a) if (a.hasOwnProperty(key))
  16274. window.ace[key] = a[key];
  16275. });
  16276. })();