ace.js 686 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /**
  31. * Define a module along with a payload
  32. * @param module a name for the payload
  33. * @param payload a function to call with (require, exports, module) params
  34. */
  35. (function() {
  36. var ACE_NAMESPACE = "";
  37. var global = (function() { return this; })();
  38. if (!global && typeof window != "undefined") global = window; // strict mode
  39. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  40. return;
  41. var define = function(module, deps, payload) {
  42. if (typeof module !== "string") {
  43. if (define.original)
  44. define.original.apply(this, arguments);
  45. else {
  46. console.error("dropping module because define wasn\'t a string.");
  47. console.trace();
  48. }
  49. return;
  50. }
  51. if (arguments.length == 2)
  52. payload = deps;
  53. if (!define.modules[module]) {
  54. define.payloads[module] = payload;
  55. define.modules[module] = null;
  56. }
  57. };
  58. define.modules = {};
  59. define.payloads = {};
  60. /**
  61. * Get at functionality define()ed using the function above
  62. */
  63. var _require = function(parentId, module, callback) {
  64. if (typeof module === "string") {
  65. var payload = lookup(parentId, module);
  66. if (payload != undefined) {
  67. callback && callback();
  68. return payload;
  69. }
  70. } else if (Object.prototype.toString.call(module) === "[object Array]") {
  71. var params = [];
  72. for (var i = 0, l = module.length; i < l; ++i) {
  73. var dep = lookup(parentId, module[i]);
  74. if (dep == undefined && require.original)
  75. return;
  76. params.push(dep);
  77. }
  78. return callback && callback.apply(null, params) || true;
  79. }
  80. };
  81. var require = function(module, callback) {
  82. var packagedModule = _require("", module, callback);
  83. if (packagedModule == undefined && require.original)
  84. return require.original.apply(this, arguments);
  85. return packagedModule;
  86. };
  87. var normalizeModule = function(parentId, moduleName) {
  88. // normalize plugin requires
  89. if (moduleName.indexOf("!") !== -1) {
  90. var chunks = moduleName.split("!");
  91. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  92. }
  93. // normalize relative requires
  94. if (moduleName.charAt(0) == ".") {
  95. var base = parentId.split("/").slice(0, -1).join("/");
  96. moduleName = base + "/" + moduleName;
  97. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  98. var previous = moduleName;
  99. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  100. }
  101. }
  102. return moduleName;
  103. };
  104. /**
  105. * Internal function to lookup moduleNames and resolve them by calling the
  106. * definition function if needed.
  107. */
  108. var lookup = function(parentId, moduleName) {
  109. moduleName = normalizeModule(parentId, moduleName);
  110. var module = define.modules[moduleName];
  111. if (!module) {
  112. module = define.payloads[moduleName];
  113. if (typeof module === 'function') {
  114. var exports = {};
  115. var mod = {
  116. id: moduleName,
  117. uri: '',
  118. exports: exports,
  119. packaged: true
  120. };
  121. var req = function(module, callback) {
  122. return _require(moduleName, module, callback);
  123. };
  124. var returnValue = module(req, exports, mod);
  125. exports = returnValue || mod.exports;
  126. define.modules[moduleName] = exports;
  127. delete define.payloads[moduleName];
  128. }
  129. module = define.modules[moduleName] = exports || module;
  130. }
  131. return module;
  132. };
  133. function exportAce(ns) {
  134. var root = global;
  135. if (ns) {
  136. if (!global[ns])
  137. global[ns] = {};
  138. root = global[ns];
  139. }
  140. if (!root.define || !root.define.packaged) {
  141. define.original = root.define;
  142. root.define = define;
  143. root.define.packaged = true;
  144. }
  145. if (!root.require || !root.require.packaged) {
  146. require.original = root.require;
  147. root.require = require;
  148. root.require.packaged = true;
  149. }
  150. }
  151. exportAce(ACE_NAMESPACE);
  152. })();
  153. define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  154. "use strict";
  155. var real = {
  156. exec: RegExp.prototype.exec,
  157. test: RegExp.prototype.test,
  158. match: String.prototype.match,
  159. replace: String.prototype.replace,
  160. split: String.prototype.split
  161. },
  162. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  163. compliantLastIndexIncrement = function () {
  164. var x = /^/g;
  165. real.test.call(x, "");
  166. return !x.lastIndex;
  167. }();
  168. if (compliantLastIndexIncrement && compliantExecNpcg)
  169. return;
  170. RegExp.prototype.exec = function (str) {
  171. var match = real.exec.apply(this, arguments),
  172. name, r2;
  173. if ( typeof(str) == 'string' && match) {
  174. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  175. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  176. real.replace.call(str.slice(match.index), r2, function () {
  177. for (var i = 1; i < arguments.length - 2; i++) {
  178. if (arguments[i] === undefined)
  179. match[i] = undefined;
  180. }
  181. });
  182. }
  183. if (this._xregexp && this._xregexp.captureNames) {
  184. for (var i = 1; i < match.length; i++) {
  185. name = this._xregexp.captureNames[i - 1];
  186. if (name)
  187. match[name] = match[i];
  188. }
  189. }
  190. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  191. this.lastIndex--;
  192. }
  193. return match;
  194. };
  195. if (!compliantLastIndexIncrement) {
  196. RegExp.prototype.test = function (str) {
  197. var match = real.exec.call(this, str);
  198. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  199. this.lastIndex--;
  200. return !!match;
  201. };
  202. }
  203. function getNativeFlags (regex) {
  204. return (regex.global ? "g" : "") +
  205. (regex.ignoreCase ? "i" : "") +
  206. (regex.multiline ? "m" : "") +
  207. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  208. (regex.sticky ? "y" : "");
  209. }
  210. function indexOf (array, item, from) {
  211. if (Array.prototype.indexOf) // Use the native array method if available
  212. return array.indexOf(item, from);
  213. for (var i = from || 0; i < array.length; i++) {
  214. if (array[i] === item)
  215. return i;
  216. }
  217. return -1;
  218. }
  219. });
  220. define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  221. function Empty() {}
  222. if (!Function.prototype.bind) {
  223. Function.prototype.bind = function bind(that) { // .length is 1
  224. var target = this;
  225. if (typeof target != "function") {
  226. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  227. }
  228. var args = slice.call(arguments, 1); // for normal call
  229. var bound = function () {
  230. if (this instanceof bound) {
  231. var result = target.apply(
  232. this,
  233. args.concat(slice.call(arguments))
  234. );
  235. if (Object(result) === result) {
  236. return result;
  237. }
  238. return this;
  239. } else {
  240. return target.apply(
  241. that,
  242. args.concat(slice.call(arguments))
  243. );
  244. }
  245. };
  246. if(target.prototype) {
  247. Empty.prototype = target.prototype;
  248. bound.prototype = new Empty();
  249. Empty.prototype = null;
  250. }
  251. return bound;
  252. };
  253. }
  254. var call = Function.prototype.call;
  255. var prototypeOfArray = Array.prototype;
  256. var prototypeOfObject = Object.prototype;
  257. var slice = prototypeOfArray.slice;
  258. var _toString = call.bind(prototypeOfObject.toString);
  259. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  260. var defineGetter;
  261. var defineSetter;
  262. var lookupGetter;
  263. var lookupSetter;
  264. var supportsAccessors;
  265. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  266. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  267. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  268. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  269. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  270. }
  271. if ([1,2].splice(0).length != 2) {
  272. if(function() { // test IE < 9 to splice bug - see issue #138
  273. function makeArray(l) {
  274. var a = new Array(l+2);
  275. a[0] = a[1] = 0;
  276. return a;
  277. }
  278. var array = [], lengthBefore;
  279. array.splice.apply(array, makeArray(20));
  280. array.splice.apply(array, makeArray(26));
  281. lengthBefore = array.length; //46
  282. array.splice(5, 0, "XXX"); // add one element
  283. lengthBefore + 1 == array.length
  284. if (lengthBefore + 1 == array.length) {
  285. return true;// has right splice implementation without bugs
  286. }
  287. }()) {//IE 6/7
  288. var array_splice = Array.prototype.splice;
  289. Array.prototype.splice = function(start, deleteCount) {
  290. if (!arguments.length) {
  291. return [];
  292. } else {
  293. return array_splice.apply(this, [
  294. start === void 0 ? 0 : start,
  295. deleteCount === void 0 ? (this.length - start) : deleteCount
  296. ].concat(slice.call(arguments, 2)))
  297. }
  298. };
  299. } else {//IE8
  300. Array.prototype.splice = function(pos, removeCount){
  301. var length = this.length;
  302. if (pos > 0) {
  303. if (pos > length)
  304. pos = length;
  305. } else if (pos == void 0) {
  306. pos = 0;
  307. } else if (pos < 0) {
  308. pos = Math.max(length + pos, 0);
  309. }
  310. if (!(pos+removeCount < length))
  311. removeCount = length - pos;
  312. var removed = this.slice(pos, pos+removeCount);
  313. var insert = slice.call(arguments, 2);
  314. var add = insert.length;
  315. if (pos === length) {
  316. if (add) {
  317. this.push.apply(this, insert);
  318. }
  319. } else {
  320. var remove = Math.min(removeCount, length - pos);
  321. var tailOldPos = pos + remove;
  322. var tailNewPos = tailOldPos + add - remove;
  323. var tailCount = length - tailOldPos;
  324. var lengthAfterRemove = length - remove;
  325. if (tailNewPos < tailOldPos) { // case A
  326. for (var i = 0; i < tailCount; ++i) {
  327. this[tailNewPos+i] = this[tailOldPos+i];
  328. }
  329. } else if (tailNewPos > tailOldPos) { // case B
  330. for (i = tailCount; i--; ) {
  331. this[tailNewPos+i] = this[tailOldPos+i];
  332. }
  333. } // else, add == remove (nothing to do)
  334. if (add && pos === lengthAfterRemove) {
  335. this.length = lengthAfterRemove; // truncate array
  336. this.push.apply(this, insert);
  337. } else {
  338. this.length = lengthAfterRemove + add; // reserves space
  339. for (i = 0; i < add; ++i) {
  340. this[pos+i] = insert[i];
  341. }
  342. }
  343. }
  344. return removed;
  345. };
  346. }
  347. }
  348. if (!Array.isArray) {
  349. Array.isArray = function isArray(obj) {
  350. return _toString(obj) == "[object Array]";
  351. };
  352. }
  353. var boxedString = Object("a"),
  354. splitString = boxedString[0] != "a" || !(0 in boxedString);
  355. if (!Array.prototype.forEach) {
  356. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. thisp = arguments[1],
  362. i = -1,
  363. length = self.length >>> 0;
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(); // TODO message
  366. }
  367. while (++i < length) {
  368. if (i in self) {
  369. fun.call(thisp, self[i], i, object);
  370. }
  371. }
  372. };
  373. }
  374. if (!Array.prototype.map) {
  375. Array.prototype.map = function map(fun /*, thisp*/) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = Array(length),
  382. thisp = arguments[1];
  383. if (_toString(fun) != "[object Function]") {
  384. throw new TypeError(fun + " is not a function");
  385. }
  386. for (var i = 0; i < length; i++) {
  387. if (i in self)
  388. result[i] = fun.call(thisp, self[i], i, object);
  389. }
  390. return result;
  391. };
  392. }
  393. if (!Array.prototype.filter) {
  394. Array.prototype.filter = function filter(fun /*, thisp */) {
  395. var object = toObject(this),
  396. self = splitString && _toString(this) == "[object String]" ?
  397. this.split("") :
  398. object,
  399. length = self.length >>> 0,
  400. result = [],
  401. value,
  402. thisp = arguments[1];
  403. if (_toString(fun) != "[object Function]") {
  404. throw new TypeError(fun + " is not a function");
  405. }
  406. for (var i = 0; i < length; i++) {
  407. if (i in self) {
  408. value = self[i];
  409. if (fun.call(thisp, value, i, object)) {
  410. result.push(value);
  411. }
  412. }
  413. }
  414. return result;
  415. };
  416. }
  417. if (!Array.prototype.every) {
  418. Array.prototype.every = function every(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && !fun.call(thisp, self[i], i, object)) {
  430. return false;
  431. }
  432. }
  433. return true;
  434. };
  435. }
  436. if (!Array.prototype.some) {
  437. Array.prototype.some = function some(fun /*, thisp */) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0,
  443. thisp = arguments[1];
  444. if (_toString(fun) != "[object Function]") {
  445. throw new TypeError(fun + " is not a function");
  446. }
  447. for (var i = 0; i < length; i++) {
  448. if (i in self && fun.call(thisp, self[i], i, object)) {
  449. return true;
  450. }
  451. }
  452. return false;
  453. };
  454. }
  455. if (!Array.prototype.reduce) {
  456. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  457. var object = toObject(this),
  458. self = splitString && _toString(this) == "[object String]" ?
  459. this.split("") :
  460. object,
  461. length = self.length >>> 0;
  462. if (_toString(fun) != "[object Function]") {
  463. throw new TypeError(fun + " is not a function");
  464. }
  465. if (!length && arguments.length == 1) {
  466. throw new TypeError("reduce of empty array with no initial value");
  467. }
  468. var i = 0;
  469. var result;
  470. if (arguments.length >= 2) {
  471. result = arguments[1];
  472. } else {
  473. do {
  474. if (i in self) {
  475. result = self[i++];
  476. break;
  477. }
  478. if (++i >= length) {
  479. throw new TypeError("reduce of empty array with no initial value");
  480. }
  481. } while (true);
  482. }
  483. for (; i < length; i++) {
  484. if (i in self) {
  485. result = fun.call(void 0, result, self[i], i, object);
  486. }
  487. }
  488. return result;
  489. };
  490. }
  491. if (!Array.prototype.reduceRight) {
  492. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  493. var object = toObject(this),
  494. self = splitString && _toString(this) == "[object String]" ?
  495. this.split("") :
  496. object,
  497. length = self.length >>> 0;
  498. if (_toString(fun) != "[object Function]") {
  499. throw new TypeError(fun + " is not a function");
  500. }
  501. if (!length && arguments.length == 1) {
  502. throw new TypeError("reduceRight of empty array with no initial value");
  503. }
  504. var result, i = length - 1;
  505. if (arguments.length >= 2) {
  506. result = arguments[1];
  507. } else {
  508. do {
  509. if (i in self) {
  510. result = self[i--];
  511. break;
  512. }
  513. if (--i < 0) {
  514. throw new TypeError("reduceRight of empty array with no initial value");
  515. }
  516. } while (true);
  517. }
  518. do {
  519. if (i in this) {
  520. result = fun.call(void 0, result, self[i], i, object);
  521. }
  522. } while (i--);
  523. return result;
  524. };
  525. }
  526. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  527. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  528. var self = splitString && _toString(this) == "[object String]" ?
  529. this.split("") :
  530. toObject(this),
  531. length = self.length >>> 0;
  532. if (!length) {
  533. return -1;
  534. }
  535. var i = 0;
  536. if (arguments.length > 1) {
  537. i = toInteger(arguments[1]);
  538. }
  539. i = i >= 0 ? i : Math.max(0, length + i);
  540. for (; i < length; i++) {
  541. if (i in self && self[i] === sought) {
  542. return i;
  543. }
  544. }
  545. return -1;
  546. };
  547. }
  548. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  549. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  550. var self = splitString && _toString(this) == "[object String]" ?
  551. this.split("") :
  552. toObject(this),
  553. length = self.length >>> 0;
  554. if (!length) {
  555. return -1;
  556. }
  557. var i = length - 1;
  558. if (arguments.length > 1) {
  559. i = Math.min(i, toInteger(arguments[1]));
  560. }
  561. i = i >= 0 ? i : length - Math.abs(i);
  562. for (; i >= 0; i--) {
  563. if (i in self && sought === self[i]) {
  564. return i;
  565. }
  566. }
  567. return -1;
  568. };
  569. }
  570. if (!Object.getPrototypeOf) {
  571. Object.getPrototypeOf = function getPrototypeOf(object) {
  572. return object.__proto__ || (
  573. object.constructor ?
  574. object.constructor.prototype :
  575. prototypeOfObject
  576. );
  577. };
  578. }
  579. if (!Object.getOwnPropertyDescriptor) {
  580. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  581. "non-object: ";
  582. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  583. if ((typeof object != "object" && typeof object != "function") || object === null)
  584. throw new TypeError(ERR_NON_OBJECT + object);
  585. if (!owns(object, property))
  586. return;
  587. var descriptor, getter, setter;
  588. descriptor = { enumerable: true, configurable: true };
  589. if (supportsAccessors) {
  590. var prototype = object.__proto__;
  591. object.__proto__ = prototypeOfObject;
  592. var getter = lookupGetter(object, property);
  593. var setter = lookupSetter(object, property);
  594. object.__proto__ = prototype;
  595. if (getter || setter) {
  596. if (getter) descriptor.get = getter;
  597. if (setter) descriptor.set = setter;
  598. return descriptor;
  599. }
  600. }
  601. descriptor.value = object[property];
  602. return descriptor;
  603. };
  604. }
  605. if (!Object.getOwnPropertyNames) {
  606. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  607. return Object.keys(object);
  608. };
  609. }
  610. if (!Object.create) {
  611. var createEmpty;
  612. if (Object.prototype.__proto__ === null) {
  613. createEmpty = function () {
  614. return { "__proto__": null };
  615. };
  616. } else {
  617. createEmpty = function () {
  618. var empty = {};
  619. for (var i in empty)
  620. empty[i] = null;
  621. empty.constructor =
  622. empty.hasOwnProperty =
  623. empty.propertyIsEnumerable =
  624. empty.isPrototypeOf =
  625. empty.toLocaleString =
  626. empty.toString =
  627. empty.valueOf =
  628. empty.__proto__ = null;
  629. return empty;
  630. }
  631. }
  632. Object.create = function create(prototype, properties) {
  633. var object;
  634. if (prototype === null) {
  635. object = createEmpty();
  636. } else {
  637. if (typeof prototype != "object")
  638. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  639. var Type = function () {};
  640. Type.prototype = prototype;
  641. object = new Type();
  642. object.__proto__ = prototype;
  643. }
  644. if (properties !== void 0)
  645. Object.defineProperties(object, properties);
  646. return object;
  647. };
  648. }
  649. function doesDefinePropertyWork(object) {
  650. try {
  651. Object.defineProperty(object, "sentinel", {});
  652. return "sentinel" in object;
  653. } catch (exception) {
  654. }
  655. }
  656. if (Object.defineProperty) {
  657. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  658. var definePropertyWorksOnDom = typeof document == "undefined" ||
  659. doesDefinePropertyWork(document.createElement("div"));
  660. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  661. var definePropertyFallback = Object.defineProperty;
  662. }
  663. }
  664. if (!Object.defineProperty || definePropertyFallback) {
  665. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  666. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  667. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  668. "on this javascript engine";
  669. Object.defineProperty = function defineProperty(object, property, descriptor) {
  670. if ((typeof object != "object" && typeof object != "function") || object === null)
  671. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  672. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  673. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  674. if (definePropertyFallback) {
  675. try {
  676. return definePropertyFallback.call(Object, object, property, descriptor);
  677. } catch (exception) {
  678. }
  679. }
  680. if (owns(descriptor, "value")) {
  681. if (supportsAccessors && (lookupGetter(object, property) ||
  682. lookupSetter(object, property)))
  683. {
  684. var prototype = object.__proto__;
  685. object.__proto__ = prototypeOfObject;
  686. delete object[property];
  687. object[property] = descriptor.value;
  688. object.__proto__ = prototype;
  689. } else {
  690. object[property] = descriptor.value;
  691. }
  692. } else {
  693. if (!supportsAccessors)
  694. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  695. if (owns(descriptor, "get"))
  696. defineGetter(object, property, descriptor.get);
  697. if (owns(descriptor, "set"))
  698. defineSetter(object, property, descriptor.set);
  699. }
  700. return object;
  701. };
  702. }
  703. if (!Object.defineProperties) {
  704. Object.defineProperties = function defineProperties(object, properties) {
  705. for (var property in properties) {
  706. if (owns(properties, property))
  707. Object.defineProperty(object, property, properties[property]);
  708. }
  709. return object;
  710. };
  711. }
  712. if (!Object.seal) {
  713. Object.seal = function seal(object) {
  714. return object;
  715. };
  716. }
  717. if (!Object.freeze) {
  718. Object.freeze = function freeze(object) {
  719. return object;
  720. };
  721. }
  722. try {
  723. Object.freeze(function () {});
  724. } catch (exception) {
  725. Object.freeze = (function freeze(freezeObject) {
  726. return function freeze(object) {
  727. if (typeof object == "function") {
  728. return object;
  729. } else {
  730. return freezeObject(object);
  731. }
  732. };
  733. })(Object.freeze);
  734. }
  735. if (!Object.preventExtensions) {
  736. Object.preventExtensions = function preventExtensions(object) {
  737. return object;
  738. };
  739. }
  740. if (!Object.isSealed) {
  741. Object.isSealed = function isSealed(object) {
  742. return false;
  743. };
  744. }
  745. if (!Object.isFrozen) {
  746. Object.isFrozen = function isFrozen(object) {
  747. return false;
  748. };
  749. }
  750. if (!Object.isExtensible) {
  751. Object.isExtensible = function isExtensible(object) {
  752. if (Object(object) === object) {
  753. throw new TypeError(); // TODO message
  754. }
  755. var name = '';
  756. while (owns(object, name)) {
  757. name += '?';
  758. }
  759. object[name] = true;
  760. var returnValue = owns(object, name);
  761. delete object[name];
  762. return returnValue;
  763. };
  764. }
  765. if (!Object.keys) {
  766. var hasDontEnumBug = true,
  767. dontEnums = [
  768. "toString",
  769. "toLocaleString",
  770. "valueOf",
  771. "hasOwnProperty",
  772. "isPrototypeOf",
  773. "propertyIsEnumerable",
  774. "constructor"
  775. ],
  776. dontEnumsLength = dontEnums.length;
  777. for (var key in {"toString": null}) {
  778. hasDontEnumBug = false;
  779. }
  780. Object.keys = function keys(object) {
  781. if (
  782. (typeof object != "object" && typeof object != "function") ||
  783. object === null
  784. ) {
  785. throw new TypeError("Object.keys called on a non-object");
  786. }
  787. var keys = [];
  788. for (var name in object) {
  789. if (owns(object, name)) {
  790. keys.push(name);
  791. }
  792. }
  793. if (hasDontEnumBug) {
  794. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  795. var dontEnum = dontEnums[i];
  796. if (owns(object, dontEnum)) {
  797. keys.push(dontEnum);
  798. }
  799. }
  800. }
  801. return keys;
  802. };
  803. }
  804. if (!Date.now) {
  805. Date.now = function now() {
  806. return new Date().getTime();
  807. };
  808. }
  809. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  810. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  811. "\u2029\uFEFF";
  812. if (!String.prototype.trim || ws.trim()) {
  813. ws = "[" + ws + "]";
  814. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  815. trimEndRegexp = new RegExp(ws + ws + "*$");
  816. String.prototype.trim = function trim() {
  817. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  818. };
  819. }
  820. function toInteger(n) {
  821. n = +n;
  822. if (n !== n) { // isNaN
  823. n = 0;
  824. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  825. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  826. }
  827. return n;
  828. }
  829. function isPrimitive(input) {
  830. var type = typeof input;
  831. return (
  832. input === null ||
  833. type === "undefined" ||
  834. type === "boolean" ||
  835. type === "number" ||
  836. type === "string"
  837. );
  838. }
  839. function toPrimitive(input) {
  840. var val, valueOf, toString;
  841. if (isPrimitive(input)) {
  842. return input;
  843. }
  844. valueOf = input.valueOf;
  845. if (typeof valueOf === "function") {
  846. val = valueOf.call(input);
  847. if (isPrimitive(val)) {
  848. return val;
  849. }
  850. }
  851. toString = input.toString;
  852. if (typeof toString === "function") {
  853. val = toString.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. throw new TypeError();
  859. }
  860. var toObject = function (o) {
  861. if (o == null) { // this matches both null and undefined
  862. throw new TypeError("can't convert "+o+" to object");
  863. }
  864. return Object(o);
  865. };
  866. });
  867. define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  868. "use strict";
  869. require("./regexp");
  870. require("./es5-shim");
  871. });
  872. define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  873. "use strict";
  874. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  875. exports.getDocumentHead = function(doc) {
  876. if (!doc)
  877. doc = document;
  878. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  879. }
  880. exports.createElement = function(tag, ns) {
  881. return document.createElementNS ?
  882. document.createElementNS(ns || XHTML_NS, tag) :
  883. document.createElement(tag);
  884. };
  885. exports.hasCssClass = function(el, name) {
  886. var classes = (el.className || "").split(/\s+/g);
  887. return classes.indexOf(name) !== -1;
  888. };
  889. exports.addCssClass = function(el, name) {
  890. if (!exports.hasCssClass(el, name)) {
  891. el.className += " " + name;
  892. }
  893. };
  894. exports.removeCssClass = function(el, name) {
  895. var classes = el.className.split(/\s+/g);
  896. while (true) {
  897. var index = classes.indexOf(name);
  898. if (index == -1) {
  899. break;
  900. }
  901. classes.splice(index, 1);
  902. }
  903. el.className = classes.join(" ");
  904. };
  905. exports.toggleCssClass = function(el, name) {
  906. var classes = el.className.split(/\s+/g), add = true;
  907. while (true) {
  908. var index = classes.indexOf(name);
  909. if (index == -1) {
  910. break;
  911. }
  912. add = false;
  913. classes.splice(index, 1);
  914. }
  915. if(add)
  916. classes.push(name);
  917. el.className = classes.join(" ");
  918. return add;
  919. };
  920. exports.setCssClass = function(node, className, include) {
  921. if (include) {
  922. exports.addCssClass(node, className);
  923. } else {
  924. exports.removeCssClass(node, className);
  925. }
  926. };
  927. exports.hasCssString = function(id, doc) {
  928. var index = 0, sheets;
  929. doc = doc || document;
  930. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  931. while (index < sheets.length)
  932. if (sheets[index++].owningElement.id === id) return true;
  933. } else if ((sheets = doc.getElementsByTagName("style"))) {
  934. while (index < sheets.length)
  935. if (sheets[index++].id === id) return true;
  936. }
  937. return false;
  938. };
  939. exports.importCssString = function importCssString(cssText, id, doc) {
  940. doc = doc || document;
  941. if (id && exports.hasCssString(id, doc))
  942. return null;
  943. var style;
  944. if (id)
  945. cssText += "\n/*# sourceURL=ace/css/" + id + " */";
  946. if (doc.createStyleSheet) {
  947. style = doc.createStyleSheet();
  948. style.cssText = cssText;
  949. if (id)
  950. style.owningElement.id = id;
  951. } else {
  952. style = 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. 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. 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. 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. 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. //var prefix = this.editor.session.getTextRange({start: this.base, end: pos});
  1423. if (!useragent.isMac && pressedKeys) {
  1424. if (pressedKeys[91] || pressedKeys[92])
  1425. hashId |= 8;
  1426. if (pressedKeys.altGr) {
  1427. if ((3 & hashId) != 3)
  1428. pressedKeys.altGr = 0;
  1429. else
  1430. return;
  1431. }
  1432. if (keyCode === 18 || keyCode === 17) {
  1433. var location = "location" in e ? e.location : e.keyLocation;
  1434. if (keyCode === 17 && location === 1) {
  1435. if (pressedKeys[keyCode] == 1)
  1436. ts = e.timeStamp;
  1437. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1438. var dt = e.timeStamp - ts;
  1439. if (dt < 50)
  1440. pressedKeys.altGr = true;
  1441. }
  1442. }
  1443. }
  1444. if (keyCode in keys.MODIFIER_KEYS) {
  1445. keyCode = -1;
  1446. }
  1447. if (hashId & 8 && (keyCode === 91 || keyCode === 93)) {
  1448. keyCode = -1;
  1449. }
  1450. if (!hashId && keyCode === 13) {
  1451. var location = "location" in e ? e.location : e.keyLocation;
  1452. if (location === 3) {
  1453. callback(e, hashId, -keyCode);
  1454. if (e.defaultPrevented)
  1455. return;
  1456. }
  1457. }
  1458. if (useragent.isChromeOS && hashId & 8) {
  1459. callback(e, hashId, keyCode);
  1460. if (e.defaultPrevented)
  1461. return;
  1462. else
  1463. hashId &= ~8;
  1464. }
  1465. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1466. return false;
  1467. }
  1468. return callback(e, hashId, keyCode);
  1469. }
  1470. var pressedKeys = null;
  1471. var ts = 0;
  1472. exports.addCommandKeyListener = function(el, callback) {
  1473. var addListener = exports.addListener;
  1474. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1475. var lastKeyDownKeyCode = null;
  1476. addListener(el, "keydown", function(e) {
  1477. lastKeyDownKeyCode = e.keyCode;
  1478. });
  1479. addListener(el, "keypress", function(e) {
  1480. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1481. });
  1482. } else {
  1483. var lastDefaultPrevented = null;
  1484. addListener(el, "keydown", function(e) {
  1485. pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
  1486. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1487. lastDefaultPrevented = e.defaultPrevented;
  1488. return result;
  1489. });
  1490. addListener(el, "keypress", function(e) {
  1491. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1492. exports.stopEvent(e);
  1493. lastDefaultPrevented = null;
  1494. }
  1495. });
  1496. addListener(el, "keyup", function(e) {
  1497. pressedKeys[e.keyCode] = null;
  1498. });
  1499. if (!pressedKeys) {
  1500. resetPressedKeys();
  1501. addListener(window, "focus", resetPressedKeys);
  1502. }
  1503. }
  1504. };
  1505. function resetPressedKeys(e) {
  1506. pressedKeys = Object.create(null);
  1507. }
  1508. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1509. var postMessageId = 1;
  1510. exports.nextTick = function(callback, win) {
  1511. win = win || window;
  1512. var messageName = "zero-timeout-message-" + postMessageId;
  1513. exports.addListener(win, "message", function listener(e) {
  1514. if (e.data == messageName) {
  1515. exports.stopPropagation(e);
  1516. exports.removeListener(win, "message", listener);
  1517. callback();
  1518. }
  1519. });
  1520. win.postMessage(messageName, "*");
  1521. };
  1522. }
  1523. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1524. || window.mozRequestAnimationFrame
  1525. || window.webkitRequestAnimationFrame
  1526. || window.msRequestAnimationFrame
  1527. || window.oRequestAnimationFrame);
  1528. if (exports.nextFrame)
  1529. exports.nextFrame = exports.nextFrame.bind(window);
  1530. else
  1531. exports.nextFrame = function(callback) {
  1532. setTimeout(callback, 17);
  1533. };
  1534. });
  1535. define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1536. "use strict";
  1537. exports.last = function(a) {
  1538. return a[a.length - 1];
  1539. };
  1540. exports.stringReverse = function(string) {
  1541. return string.split("").reverse().join("");
  1542. };
  1543. exports.stringRepeat = function (string, count) {
  1544. var result = '';
  1545. while (count > 0) {
  1546. if (count & 1)
  1547. result += string;
  1548. if (count >>= 1)
  1549. string += string;
  1550. }
  1551. return result;
  1552. };
  1553. var trimBeginRegexp = /^\s\s*/;
  1554. var trimEndRegexp = /\s\s*$/;
  1555. exports.stringTrimLeft = function (string) {
  1556. return string.replace(trimBeginRegexp, '');
  1557. };
  1558. exports.stringTrimRight = function (string) {
  1559. return string.replace(trimEndRegexp, '');
  1560. };
  1561. exports.copyObject = function(obj) {
  1562. var copy = {};
  1563. for (var key in obj) {
  1564. copy[key] = obj[key];
  1565. }
  1566. return copy;
  1567. };
  1568. exports.copyArray = function(array){
  1569. var copy = [];
  1570. for (var i=0, l=array.length; i<l; i++) {
  1571. if (array[i] && typeof array[i] == "object")
  1572. copy[i] = this.copyObject( array[i] );
  1573. else
  1574. copy[i] = array[i];
  1575. }
  1576. return copy;
  1577. };
  1578. exports.deepCopy = function deepCopy(obj) {
  1579. if (typeof obj !== "object" || !obj)
  1580. return obj;
  1581. var copy;
  1582. if (Array.isArray(obj)) {
  1583. copy = [];
  1584. for (var key = 0; key < obj.length; key++) {
  1585. copy[key] = deepCopy(obj[key]);
  1586. }
  1587. return copy;
  1588. }
  1589. var cons = obj.constructor;
  1590. if (cons === RegExp)
  1591. return obj;
  1592. copy = cons();
  1593. for (var key in obj) {
  1594. copy[key] = deepCopy(obj[key]);
  1595. }
  1596. return copy;
  1597. };
  1598. exports.arrayToMap = function(arr) {
  1599. var map = {};
  1600. for (var i=0; i<arr.length; i++) {
  1601. map[arr[i]] = 1;
  1602. }
  1603. return map;
  1604. };
  1605. exports.createMap = function(props) {
  1606. var map = Object.create(null);
  1607. for (var i in props) {
  1608. map[i] = props[i];
  1609. }
  1610. return map;
  1611. };
  1612. exports.arrayRemove = function(array, value) {
  1613. for (var i = 0; i <= array.length; i++) {
  1614. if (value === array[i]) {
  1615. array.splice(i, 1);
  1616. }
  1617. }
  1618. };
  1619. exports.escapeRegExp = function(str) {
  1620. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1621. };
  1622. exports.escapeHTML = function(str) {
  1623. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1624. };
  1625. exports.getMatchOffsets = function(string, regExp) {
  1626. var matches = [];
  1627. string.replace(regExp, function(str) {
  1628. matches.push({
  1629. offset: arguments[arguments.length-2],
  1630. length: str.length
  1631. });
  1632. });
  1633. return matches;
  1634. };
  1635. exports.deferredCall = function(fcn) {
  1636. var timer = null;
  1637. var callback = function() {
  1638. timer = null;
  1639. fcn();
  1640. };
  1641. var deferred = function(timeout) {
  1642. deferred.cancel();
  1643. timer = setTimeout(callback, timeout || 0);
  1644. return deferred;
  1645. };
  1646. deferred.schedule = deferred;
  1647. deferred.call = function() {
  1648. this.cancel();
  1649. fcn();
  1650. return deferred;
  1651. };
  1652. deferred.cancel = function() {
  1653. clearTimeout(timer);
  1654. timer = null;
  1655. return deferred;
  1656. };
  1657. deferred.isPending = function() {
  1658. return timer;
  1659. };
  1660. return deferred;
  1661. };
  1662. exports.delayedCall = function(fcn, defaultTimeout) {
  1663. var timer = null;
  1664. var callback = function() {
  1665. timer = null;
  1666. fcn();
  1667. };
  1668. var _self = function(timeout) {
  1669. if (timer == null)
  1670. timer = setTimeout(callback, timeout || defaultTimeout);
  1671. };
  1672. _self.delay = function(timeout) {
  1673. timer && clearTimeout(timer);
  1674. timer = setTimeout(callback, timeout || defaultTimeout);
  1675. };
  1676. _self.schedule = _self;
  1677. _self.call = function() {
  1678. this.cancel();
  1679. fcn();
  1680. };
  1681. _self.cancel = function() {
  1682. timer && clearTimeout(timer);
  1683. timer = null;
  1684. };
  1685. _self.isPending = function() {
  1686. return timer;
  1687. };
  1688. return _self;
  1689. };
  1690. });
  1691. define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1692. "use strict";
  1693. var event = require("../lib/event");
  1694. var useragent = require("../lib/useragent");
  1695. var dom = require("../lib/dom");
  1696. var lang = require("../lib/lang");
  1697. var BROKEN_SETDATA = useragent.isChrome < 18;
  1698. var USE_IE_MIME_TYPE = useragent.isIE;
  1699. var TextInput = function(parentNode, host) {
  1700. var text = dom.createElement("textarea");
  1701. text.className = "ace_text-input";
  1702. if (useragent.isTouchPad)
  1703. text.setAttribute("x-palm-disable-auto-cap", true);
  1704. text.setAttribute("wrap", "off");
  1705. text.setAttribute("autocorrect", "off");
  1706. text.setAttribute("autocapitalize", "off");
  1707. text.setAttribute("spellcheck", false);
  1708. text.style.opacity = "0";
  1709. if (useragent.isOldIE) text.style.top = "-1000px";
  1710. parentNode.insertBefore(text, parentNode.firstChild);
  1711. var PLACEHOLDER = "\x01\x01";
  1712. var copied = false;
  1713. var pasted = false;
  1714. var inComposition = false;
  1715. var tempStyle = '';
  1716. var isSelectionEmpty = true;
  1717. try { var isFocused = document.activeElement === text; } catch(e) {}
  1718. event.addListener(text, "blur", function(e) {
  1719. host.onBlur(e);
  1720. isFocused = false;
  1721. });
  1722. event.addListener(text, "focus", function(e) {
  1723. isFocused = true;
  1724. host.onFocus(e);
  1725. resetSelection();
  1726. });
  1727. this.focus = function() {
  1728. if (tempStyle) return text.focus();
  1729. var top = text.style.top;
  1730. text.style.position = "fixed";
  1731. text.style.top = "-1000px";
  1732. text.focus();
  1733. setTimeout(function() {
  1734. text.style.position = "";
  1735. if (text.style.top == "-1000px")
  1736. text.style.top = top;
  1737. }, 0);
  1738. };
  1739. this.blur = function() {
  1740. text.blur();
  1741. };
  1742. this.isFocused = function() {
  1743. return isFocused;
  1744. };
  1745. var syncSelection = lang.delayedCall(function() {
  1746. isFocused && resetSelection(isSelectionEmpty);
  1747. });
  1748. var syncValue = lang.delayedCall(function() {
  1749. if (!inComposition) {
  1750. text.value = PLACEHOLDER;
  1751. isFocused && resetSelection();
  1752. }
  1753. });
  1754. function resetSelection(isEmpty) {
  1755. if (inComposition)
  1756. return;
  1757. inComposition = true;
  1758. if (inputHandler) {
  1759. selectionStart = 0;
  1760. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1761. } else {
  1762. var selectionStart = isEmpty ? 2 : 1;
  1763. var selectionEnd = 2;
  1764. }
  1765. try {
  1766. text.setSelectionRange(selectionStart, selectionEnd);
  1767. } catch(e){}
  1768. inComposition = false;
  1769. }
  1770. function resetValue() {
  1771. if (inComposition)
  1772. return;
  1773. text.value = PLACEHOLDER;
  1774. if (useragent.isWebKit)
  1775. syncValue.schedule();
  1776. }
  1777. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1778. if (host.selection.isEmpty() != isSelectionEmpty) {
  1779. isSelectionEmpty = !isSelectionEmpty;
  1780. syncSelection.schedule();
  1781. }
  1782. });
  1783. resetValue();
  1784. if (isFocused)
  1785. host.onFocus();
  1786. var isAllSelected = function(text) {
  1787. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1788. };
  1789. if (!text.setSelectionRange && text.createTextRange) {
  1790. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1791. var range = this.createTextRange();
  1792. range.collapse(true);
  1793. range.moveStart('character', selectionStart);
  1794. range.moveEnd('character', selectionEnd);
  1795. range.select();
  1796. };
  1797. isAllSelected = function(text) {
  1798. try {
  1799. var range = text.ownerDocument.selection.createRange();
  1800. }catch(e) {}
  1801. if (!range || range.parentElement() != text) return false;
  1802. return range.text == text.value;
  1803. }
  1804. }
  1805. if (useragent.isOldIE) {
  1806. var inPropertyChange = false;
  1807. var onPropertyChange = function(e){
  1808. if (inPropertyChange)
  1809. return;
  1810. var data = text.value;
  1811. if (inComposition || !data || data == PLACEHOLDER)
  1812. return;
  1813. if (e && data == PLACEHOLDER[0])
  1814. return syncProperty.schedule();
  1815. sendText(data);
  1816. inPropertyChange = true;
  1817. resetValue();
  1818. inPropertyChange = false;
  1819. };
  1820. var syncProperty = lang.delayedCall(onPropertyChange);
  1821. event.addListener(text, "propertychange", onPropertyChange);
  1822. var keytable = { 13:1, 27:1 };
  1823. event.addListener(text, "keyup", function (e) {
  1824. if (inComposition && (!text.value || keytable[e.keyCode]))
  1825. setTimeout(onCompositionEnd, 0);
  1826. if ((text.value.charCodeAt(0)||0) < 129) {
  1827. return syncProperty.call();
  1828. }
  1829. inComposition ? onCompositionUpdate() : onCompositionStart();
  1830. });
  1831. event.addListener(text, "keydown", function (e) {
  1832. syncProperty.schedule(50);
  1833. });
  1834. }
  1835. var onSelect = function(e) {
  1836. if (copied) {
  1837. copied = false;
  1838. } else if (isAllSelected(text)) {
  1839. host.selectAll();
  1840. resetSelection();
  1841. } else if (inputHandler) {
  1842. resetSelection(host.selection.isEmpty());
  1843. }
  1844. };
  1845. var inputHandler = null;
  1846. this.setInputHandler = function(cb) {inputHandler = cb};
  1847. this.getInputHandler = function() {return inputHandler};
  1848. var afterContextMenu = false;
  1849. var sendText = function(data) {
  1850. if (inputHandler) {
  1851. data = inputHandler(data);
  1852. inputHandler = null;
  1853. }
  1854. if (pasted) {
  1855. resetSelection();
  1856. if (data)
  1857. host.onPaste(data);
  1858. pasted = false;
  1859. } else if (data == PLACEHOLDER.charAt(0)) {
  1860. if (afterContextMenu)
  1861. host.execCommand("del", {source: "ace"});
  1862. else // some versions of android do not fire keydown when pressing backspace
  1863. host.execCommand("backspace", {source: "ace"});
  1864. } else {
  1865. if (data.substring(0, 2) == PLACEHOLDER)
  1866. data = data.substr(2);
  1867. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1868. data = data.substr(1);
  1869. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1870. data = data.slice(0, -1);
  1871. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1872. data = data.slice(0, -1);
  1873. if (data)
  1874. host.onTextInput(data);
  1875. }
  1876. if (afterContextMenu)
  1877. afterContextMenu = false;
  1878. };
  1879. var onInput = function(e) {
  1880. if (inComposition)
  1881. return;
  1882. var data = text.value;
  1883. sendText(data);
  1884. resetValue();
  1885. };
  1886. var handleClipboardData = function(e, data) {
  1887. var clipboardData = e.clipboardData || window.clipboardData;
  1888. if (!clipboardData || BROKEN_SETDATA)
  1889. return;
  1890. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1891. if (data) {
  1892. return clipboardData.setData(mime, data) !== false;
  1893. } else {
  1894. return clipboardData.getData(mime);
  1895. }
  1896. };
  1897. var doCopy = function(e, isCut) {
  1898. var data = host.getCopyText();
  1899. if (!data)
  1900. return event.preventDefault(e);
  1901. if (handleClipboardData(e, data)) {
  1902. isCut ? host.onCut() : host.onCopy();
  1903. event.preventDefault(e);
  1904. } else {
  1905. copied = true;
  1906. text.value = data;
  1907. text.select();
  1908. setTimeout(function(){
  1909. copied = false;
  1910. resetValue();
  1911. resetSelection();
  1912. isCut ? host.onCut() : host.onCopy();
  1913. });
  1914. }
  1915. };
  1916. var onCut = function(e) {
  1917. doCopy(e, true);
  1918. };
  1919. var onCopy = function(e) {
  1920. doCopy(e, false);
  1921. };
  1922. var onPaste = function(e) {
  1923. var data = handleClipboardData(e);
  1924. if (typeof data == "string") {
  1925. if (data)
  1926. host.onPaste(data, e);
  1927. if (useragent.isIE)
  1928. setTimeout(resetSelection);
  1929. event.preventDefault(e);
  1930. }
  1931. else {
  1932. text.value = "";
  1933. pasted = true;
  1934. }
  1935. };
  1936. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1937. event.addListener(text, "select", onSelect);
  1938. event.addListener(text, "input", onInput);
  1939. event.addListener(text, "cut", onCut);
  1940. event.addListener(text, "copy", onCopy);
  1941. event.addListener(text, "paste", onPaste);
  1942. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1943. event.addListener(parentNode, "keydown", function(e) {
  1944. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1945. return;
  1946. switch (e.keyCode) {
  1947. case 67:
  1948. onCopy(e);
  1949. break;
  1950. case 86:
  1951. onPaste(e);
  1952. break;
  1953. case 88:
  1954. onCut(e);
  1955. break;
  1956. }
  1957. });
  1958. }
  1959. var onCompositionStart = function(e) {
  1960. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1961. return;
  1962. inComposition = {};
  1963. host.onCompositionStart();
  1964. setTimeout(onCompositionUpdate, 0);
  1965. host.on("mousedown", onCompositionEnd);
  1966. if (!host.selection.isEmpty()) {
  1967. host.insert("");
  1968. host.session.markUndoGroup();
  1969. host.selection.clearSelection();
  1970. }
  1971. host.session.markUndoGroup();
  1972. };
  1973. var onCompositionUpdate = function() {
  1974. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1975. return;
  1976. var val = text.value.replace(/\x01/g, "");
  1977. if (inComposition.lastValue === val) return;
  1978. host.onCompositionUpdate(val);
  1979. if (inComposition.lastValue)
  1980. host.undo();
  1981. inComposition.lastValue = val;
  1982. if (inComposition.lastValue) {
  1983. var r = host.selection.getRange();
  1984. host.insert(inComposition.lastValue);
  1985. host.session.markUndoGroup();
  1986. inComposition.range = host.selection.getRange();
  1987. host.selection.setRange(r);
  1988. host.selection.clearSelection();
  1989. }
  1990. };
  1991. var onCompositionEnd = function(e) {
  1992. if (!host.onCompositionEnd || host.$readOnly) return;
  1993. var c = inComposition;
  1994. inComposition = false;
  1995. var timer = setTimeout(function() {
  1996. timer = null;
  1997. var str = text.value.replace(/\x01/g, "");
  1998. if (inComposition)
  1999. return;
  2000. else if (str == c.lastValue)
  2001. resetValue();
  2002. else if (!c.lastValue && str) {
  2003. resetValue();
  2004. sendText(str);
  2005. }
  2006. });
  2007. inputHandler = function compositionInputHandler(str) {
  2008. if (timer)
  2009. clearTimeout(timer);
  2010. str = str.replace(/\x01/g, "");
  2011. if (str == c.lastValue)
  2012. return "";
  2013. if (c.lastValue && timer)
  2014. host.undo();
  2015. return str;
  2016. };
  2017. host.onCompositionEnd();
  2018. host.removeListener("mousedown", onCompositionEnd);
  2019. if (e.type == "compositionend" && c.range) {
  2020. host.selection.setRange(c.range);
  2021. }
  2022. };
  2023. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2024. event.addListener(text, "compositionstart", onCompositionStart);
  2025. if (useragent.isGecko) {
  2026. event.addListener(text, "text", function(){syncComposition.schedule()});
  2027. } else {
  2028. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2029. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2030. }
  2031. event.addListener(text, "compositionend", onCompositionEnd);
  2032. this.getElement = function() {
  2033. return text;
  2034. };
  2035. this.setReadOnly = function(readOnly) {
  2036. text.readOnly = readOnly;
  2037. };
  2038. this.onContextMenu = function(e) {
  2039. afterContextMenu = true;
  2040. resetSelection(host.selection.isEmpty());
  2041. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2042. this.moveToMouse(e, true);
  2043. };
  2044. this.moveToMouse = function(e, bringToFront) {
  2045. if (!bringToFront && useragent.isOldIE)
  2046. return;
  2047. if (!tempStyle)
  2048. tempStyle = text.style.cssText;
  2049. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2050. + "height:" + text.style.height + ";"
  2051. + (useragent.isIE ? "opacity:0.1;" : "");
  2052. var rect = host.container.getBoundingClientRect();
  2053. var style = dom.computedStyle(host.container);
  2054. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2055. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2056. var maxTop = rect.bottom - top - text.clientHeight -2;
  2057. var move = function(e) {
  2058. text.style.left = e.clientX - left - 2 + "px";
  2059. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2060. };
  2061. move(e);
  2062. if (e.type != "mousedown")
  2063. return;
  2064. if (host.renderer.$keepTextAreaAtCursor)
  2065. host.renderer.$keepTextAreaAtCursor = null;
  2066. if (useragent.isWin && !useragent.isOldIE)
  2067. event.capture(host.container, move, onContextMenuClose);
  2068. };
  2069. this.onContextMenuClose = onContextMenuClose;
  2070. var closeTimeout;
  2071. function onContextMenuClose() {
  2072. clearTimeout(closeTimeout);
  2073. closeTimeout = setTimeout(function () {
  2074. if (tempStyle) {
  2075. text.style.cssText = tempStyle;
  2076. tempStyle = '';
  2077. }
  2078. if (host.renderer.$keepTextAreaAtCursor == null) {
  2079. host.renderer.$keepTextAreaAtCursor = true;
  2080. host.renderer.$moveTextAreaToCursor();
  2081. }
  2082. }, useragent.isOldIE ? 200 : 0);
  2083. }
  2084. var onContextMenu = function(e) {
  2085. host.textInput.onContextMenu(e);
  2086. onContextMenuClose();
  2087. };
  2088. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2089. event.addListener(text, "contextmenu", onContextMenu);
  2090. };
  2091. exports.TextInput = TextInput;
  2092. });
  2093. define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2094. "use strict";
  2095. var dom = require("../lib/dom");
  2096. var event = require("../lib/event");
  2097. var useragent = require("../lib/useragent");
  2098. var DRAG_OFFSET = 0; // pixels
  2099. function DefaultHandlers(mouseHandler) {
  2100. mouseHandler.$clickSelection = null;
  2101. var editor = mouseHandler.editor;
  2102. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2103. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2104. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2105. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2106. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2107. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2108. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2109. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2110. exports.forEach(function(x) {
  2111. mouseHandler[x] = this[x];
  2112. }, this);
  2113. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2114. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2115. }
  2116. (function() {
  2117. this.onMouseDown = function(ev) {
  2118. var inSelection = ev.inSelection();
  2119. var pos = ev.getDocumentPosition();
  2120. this.mousedownEvent = ev;
  2121. var editor = this.editor;
  2122. var button = ev.getButton();
  2123. if (button !== 0) {
  2124. var selectionRange = editor.getSelectionRange();
  2125. var selectionEmpty = selectionRange.isEmpty();
  2126. editor.$blockScrolling++;
  2127. if (selectionEmpty)
  2128. editor.selection.moveToPosition(pos);
  2129. editor.$blockScrolling--;
  2130. editor.textInput.onContextMenu(ev.domEvent);
  2131. return; // stopping event here breaks contextmenu on ff mac
  2132. }
  2133. this.mousedownEvent.time = Date.now();
  2134. if (inSelection && !editor.isFocused()) {
  2135. editor.focus();
  2136. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2137. this.setState("focusWait");
  2138. this.captureMouse(ev);
  2139. return;
  2140. }
  2141. }
  2142. this.captureMouse(ev);
  2143. this.startSelect(pos, ev.domEvent._clicks > 1);
  2144. return ev.preventDefault();
  2145. };
  2146. this.startSelect = function(pos, waitForClickSelection) {
  2147. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2148. var editor = this.editor;
  2149. editor.$blockScrolling++;
  2150. if (this.mousedownEvent.getShiftKey())
  2151. editor.selection.selectToPosition(pos);
  2152. else if (!waitForClickSelection)
  2153. editor.selection.moveToPosition(pos);
  2154. if (!waitForClickSelection)
  2155. this.select();
  2156. if (editor.renderer.scroller.setCapture) {
  2157. editor.renderer.scroller.setCapture();
  2158. }
  2159. editor.setStyle("ace_selecting");
  2160. this.setState("select");
  2161. editor.$blockScrolling--;
  2162. };
  2163. this.select = function() {
  2164. var anchor, editor = this.editor;
  2165. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2166. editor.$blockScrolling++;
  2167. if (this.$clickSelection) {
  2168. var cmp = this.$clickSelection.comparePoint(cursor);
  2169. if (cmp == -1) {
  2170. anchor = this.$clickSelection.end;
  2171. } else if (cmp == 1) {
  2172. anchor = this.$clickSelection.start;
  2173. } else {
  2174. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2175. cursor = orientedRange.cursor;
  2176. anchor = orientedRange.anchor;
  2177. }
  2178. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2179. }
  2180. editor.selection.selectToPosition(cursor);
  2181. editor.$blockScrolling--;
  2182. editor.renderer.scrollCursorIntoView();
  2183. };
  2184. this.extendSelectionBy = function(unitName) {
  2185. var anchor, editor = this.editor;
  2186. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2187. var range = editor.selection[unitName](cursor.row, cursor.column);
  2188. editor.$blockScrolling++;
  2189. if (this.$clickSelection) {
  2190. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2191. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2192. if (cmpStart == -1 && cmpEnd <= 0) {
  2193. anchor = this.$clickSelection.end;
  2194. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2195. cursor = range.start;
  2196. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2197. anchor = this.$clickSelection.start;
  2198. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2199. cursor = range.end;
  2200. } else if (cmpStart == -1 && cmpEnd == 1) {
  2201. cursor = range.end;
  2202. anchor = range.start;
  2203. } else {
  2204. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2205. cursor = orientedRange.cursor;
  2206. anchor = orientedRange.anchor;
  2207. }
  2208. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2209. }
  2210. editor.selection.selectToPosition(cursor);
  2211. editor.$blockScrolling--;
  2212. editor.renderer.scrollCursorIntoView();
  2213. };
  2214. this.selectEnd =
  2215. this.selectAllEnd =
  2216. this.selectByWordsEnd =
  2217. this.selectByLinesEnd = function() {
  2218. this.$clickSelection = null;
  2219. this.editor.unsetStyle("ace_selecting");
  2220. if (this.editor.renderer.scroller.releaseCapture) {
  2221. this.editor.renderer.scroller.releaseCapture();
  2222. }
  2223. };
  2224. this.focusWait = function() {
  2225. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2226. var time = Date.now();
  2227. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2228. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2229. };
  2230. this.onDoubleClick = function(ev) {
  2231. var pos = ev.getDocumentPosition();
  2232. var editor = this.editor;
  2233. var session = editor.session;
  2234. var range = session.getBracketRange(pos);
  2235. if (range) {
  2236. if (range.isEmpty()) {
  2237. range.start.column--;
  2238. range.end.column++;
  2239. }
  2240. this.setState("select");
  2241. } else {
  2242. range = editor.selection.getWordRange(pos.row, pos.column);
  2243. this.setState("selectByWords");
  2244. }
  2245. this.$clickSelection = range;
  2246. this.select();
  2247. };
  2248. this.onTripleClick = function(ev) {
  2249. var pos = ev.getDocumentPosition();
  2250. var editor = this.editor;
  2251. this.setState("selectByLines");
  2252. var range = editor.getSelectionRange();
  2253. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2254. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2255. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2256. } else {
  2257. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2258. }
  2259. this.select();
  2260. };
  2261. this.onQuadClick = function(ev) {
  2262. var editor = this.editor;
  2263. editor.selectAll();
  2264. this.$clickSelection = editor.getSelectionRange();
  2265. this.setState("selectAll");
  2266. };
  2267. this.onMouseWheel = function(ev) {
  2268. if (ev.getAccelKey())
  2269. return;
  2270. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2271. ev.wheelX = ev.wheelY;
  2272. ev.wheelY = 0;
  2273. }
  2274. var t = ev.domEvent.timeStamp;
  2275. var dt = t - (this.$lastScrollTime||0);
  2276. var editor = this.editor;
  2277. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2278. if (isScrolable || dt < 200) {
  2279. this.$lastScrollTime = t;
  2280. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2281. return ev.stop();
  2282. }
  2283. };
  2284. this.onTouchMove = function (ev) {
  2285. var t = ev.domEvent.timeStamp;
  2286. var dt = t - (this.$lastScrollTime || 0);
  2287. var editor = this.editor;
  2288. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2289. if (isScrolable || dt < 200) {
  2290. this.$lastScrollTime = t;
  2291. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2292. return ev.stop();
  2293. }
  2294. };
  2295. }).call(DefaultHandlers.prototype);
  2296. exports.DefaultHandlers = DefaultHandlers;
  2297. function calcDistance(ax, ay, bx, by) {
  2298. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2299. }
  2300. function calcRangeOrientation(range, cursor) {
  2301. if (range.start.row == range.end.row)
  2302. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2303. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2304. var cmp = cursor.column - 4;
  2305. else
  2306. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2307. if (cmp < 0)
  2308. return {cursor: range.start, anchor: range.end};
  2309. else
  2310. return {cursor: range.end, anchor: range.start};
  2311. }
  2312. });
  2313. define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2314. "use strict";
  2315. var oop = require("./lib/oop");
  2316. var dom = require("./lib/dom");
  2317. function Tooltip (parentNode) {
  2318. this.isOpen = false;
  2319. this.$element = null;
  2320. this.$parentNode = parentNode;
  2321. }
  2322. (function() {
  2323. this.$init = function() {
  2324. this.$element = dom.createElement("div");
  2325. this.$element.className = "ace_tooltip";
  2326. this.$element.style.display = "none";
  2327. this.$parentNode.appendChild(this.$element);
  2328. return this.$element;
  2329. };
  2330. this.getElement = function() {
  2331. return this.$element || this.$init();
  2332. };
  2333. this.setText = function(text) {
  2334. dom.setInnerText(this.getElement(), text);
  2335. };
  2336. this.setHtml = function(html) {
  2337. this.getElement().innerHTML = html;
  2338. };
  2339. this.setPosition = function(x, y) {
  2340. this.getElement().style.left = x + "px";
  2341. this.getElement().style.top = y + "px";
  2342. };
  2343. this.setClassName = function(className) {
  2344. dom.addCssClass(this.getElement(), className);
  2345. };
  2346. this.show = function(text, x, y) {
  2347. if (text != null)
  2348. this.setText(text);
  2349. if (x != null && y != null)
  2350. this.setPosition(x, y);
  2351. if (!this.isOpen) {
  2352. this.getElement().style.display = "block";
  2353. this.isOpen = true;
  2354. }
  2355. };
  2356. this.hide = function() {
  2357. if (this.isOpen) {
  2358. this.getElement().style.display = "none";
  2359. this.isOpen = false;
  2360. }
  2361. };
  2362. this.getHeight = function() {
  2363. return this.getElement().offsetHeight;
  2364. };
  2365. this.getWidth = function() {
  2366. return this.getElement().offsetWidth;
  2367. };
  2368. }).call(Tooltip.prototype);
  2369. exports.Tooltip = Tooltip;
  2370. });
  2371. define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
  2372. "use strict";
  2373. var dom = require("../lib/dom");
  2374. var oop = require("../lib/oop");
  2375. var event = require("../lib/event");
  2376. var Tooltip = require("../tooltip").Tooltip;
  2377. function GutterHandler(mouseHandler) {
  2378. var editor = mouseHandler.editor;
  2379. var gutter = editor.renderer.$gutterLayer;
  2380. var tooltip = new GutterTooltip(editor.container);
  2381. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2382. if (!editor.isFocused() || e.getButton() != 0)
  2383. return;
  2384. var gutterRegion = gutter.getRegion(e);
  2385. if (gutterRegion == "foldWidgets")
  2386. return;
  2387. var row = e.getDocumentPosition().row;
  2388. var selection = editor.session.selection;
  2389. if (e.getShiftKey())
  2390. selection.selectTo(row, 0);
  2391. else {
  2392. if (e.domEvent.detail == 2) {
  2393. editor.selectAll();
  2394. return e.preventDefault();
  2395. }
  2396. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2397. }
  2398. mouseHandler.setState("selectByLines");
  2399. mouseHandler.captureMouse(e);
  2400. return e.preventDefault();
  2401. });
  2402. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2403. function showTooltip() {
  2404. var row = mouseEvent.getDocumentPosition().row;
  2405. var annotation = gutter.$annotations[row];
  2406. if (!annotation)
  2407. return hideTooltip();
  2408. var maxRow = editor.session.getLength();
  2409. if (row == maxRow) {
  2410. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2411. var pos = mouseEvent.$pos;
  2412. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2413. return hideTooltip();
  2414. }
  2415. if (tooltipAnnotation == annotation)
  2416. return;
  2417. tooltipAnnotation = annotation.text.join("<br/>");
  2418. tooltip.setHtml(tooltipAnnotation);
  2419. tooltip.show();
  2420. editor.on("mousewheel", hideTooltip);
  2421. if (mouseHandler.$tooltipFollowsMouse) {
  2422. moveTooltip(mouseEvent);
  2423. } else {
  2424. var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
  2425. var rect = gutterElement.getBoundingClientRect();
  2426. var style = tooltip.getElement().style;
  2427. style.left = rect.right + "px";
  2428. style.top = rect.bottom + "px";
  2429. }
  2430. }
  2431. function hideTooltip() {
  2432. if (tooltipTimeout)
  2433. tooltipTimeout = clearTimeout(tooltipTimeout);
  2434. if (tooltipAnnotation) {
  2435. tooltip.hide();
  2436. tooltipAnnotation = null;
  2437. editor.removeEventListener("mousewheel", hideTooltip);
  2438. }
  2439. }
  2440. function moveTooltip(e) {
  2441. tooltip.setPosition(e.x, e.y);
  2442. }
  2443. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2444. var target = e.domEvent.target || e.domEvent.srcElement;
  2445. if (dom.hasCssClass(target, "ace_fold-widget"))
  2446. return hideTooltip();
  2447. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2448. moveTooltip(e);
  2449. mouseEvent = e;
  2450. if (tooltipTimeout)
  2451. return;
  2452. tooltipTimeout = setTimeout(function() {
  2453. tooltipTimeout = null;
  2454. if (mouseEvent && !mouseHandler.isMousePressed)
  2455. showTooltip();
  2456. else
  2457. hideTooltip();
  2458. }, 50);
  2459. });
  2460. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2461. mouseEvent = null;
  2462. if (!tooltipAnnotation || tooltipTimeout)
  2463. return;
  2464. tooltipTimeout = setTimeout(function() {
  2465. tooltipTimeout = null;
  2466. hideTooltip();
  2467. }, 50);
  2468. });
  2469. editor.on("changeSession", hideTooltip);
  2470. }
  2471. function GutterTooltip(parentNode) {
  2472. Tooltip.call(this, parentNode);
  2473. }
  2474. oop.inherits(GutterTooltip, Tooltip);
  2475. (function(){
  2476. this.setPosition = function(x, y) {
  2477. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2478. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2479. var width = this.getWidth();
  2480. var height = this.getHeight();
  2481. x += 15;
  2482. y += 15;
  2483. if (x + width > windowWidth) {
  2484. x -= (x + width) - windowWidth;
  2485. }
  2486. if (y + height > windowHeight) {
  2487. y -= 20 + height;
  2488. }
  2489. Tooltip.prototype.setPosition.call(this, x, y);
  2490. };
  2491. }).call(GutterTooltip.prototype);
  2492. exports.GutterHandler = GutterHandler;
  2493. });
  2494. define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2495. "use strict";
  2496. var event = require("../lib/event");
  2497. var useragent = require("../lib/useragent");
  2498. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2499. this.domEvent = domEvent;
  2500. this.editor = editor;
  2501. this.x = this.clientX = domEvent.clientX;
  2502. this.y = this.clientY = domEvent.clientY;
  2503. this.$pos = null;
  2504. this.$inSelection = null;
  2505. this.propagationStopped = false;
  2506. this.defaultPrevented = false;
  2507. };
  2508. (function() {
  2509. this.stopPropagation = function() {
  2510. event.stopPropagation(this.domEvent);
  2511. this.propagationStopped = true;
  2512. };
  2513. this.preventDefault = function() {
  2514. event.preventDefault(this.domEvent);
  2515. this.defaultPrevented = true;
  2516. };
  2517. this.stop = function() {
  2518. this.stopPropagation();
  2519. this.preventDefault();
  2520. };
  2521. this.getDocumentPosition = function() {
  2522. if (this.$pos)
  2523. return this.$pos;
  2524. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2525. return this.$pos;
  2526. };
  2527. this.inSelection = function() {
  2528. if (this.$inSelection !== null)
  2529. return this.$inSelection;
  2530. var editor = this.editor;
  2531. var selectionRange = editor.getSelectionRange();
  2532. if (selectionRange.isEmpty())
  2533. this.$inSelection = false;
  2534. else {
  2535. var pos = this.getDocumentPosition();
  2536. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2537. }
  2538. return this.$inSelection;
  2539. };
  2540. this.getButton = function() {
  2541. return event.getButton(this.domEvent);
  2542. };
  2543. this.getShiftKey = function() {
  2544. return this.domEvent.shiftKey;
  2545. };
  2546. this.getAccelKey = useragent.isMac
  2547. ? function() { return this.domEvent.metaKey; }
  2548. : function() { return this.domEvent.ctrlKey; };
  2549. }).call(MouseEvent.prototype);
  2550. });
  2551. define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2552. "use strict";
  2553. var dom = require("../lib/dom");
  2554. var event = require("../lib/event");
  2555. var useragent = require("../lib/useragent");
  2556. var AUTOSCROLL_DELAY = 200;
  2557. var SCROLL_CURSOR_DELAY = 200;
  2558. var SCROLL_CURSOR_HYSTERESIS = 5;
  2559. function DragdropHandler(mouseHandler) {
  2560. var editor = mouseHandler.editor;
  2561. var blankImage = dom.createElement("img");
  2562. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2563. if (useragent.isOpera)
  2564. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2565. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2566. exports.forEach(function(x) {
  2567. mouseHandler[x] = this[x];
  2568. }, this);
  2569. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2570. var mouseTarget = editor.container;
  2571. var dragSelectionMarker, x, y;
  2572. var timerId, range;
  2573. var dragCursor, counter = 0;
  2574. var dragOperation;
  2575. var isInternal;
  2576. var autoScrollStartTime;
  2577. var cursorMovedTime;
  2578. var cursorPointOnCaretMoved;
  2579. this.onDragStart = function(e) {
  2580. if (this.cancelDrag || !mouseTarget.draggable) {
  2581. var self = this;
  2582. setTimeout(function(){
  2583. self.startSelect();
  2584. self.captureMouse(e);
  2585. }, 0);
  2586. return e.preventDefault();
  2587. }
  2588. range = editor.getSelectionRange();
  2589. var dataTransfer = e.dataTransfer;
  2590. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2591. if (useragent.isOpera) {
  2592. editor.container.appendChild(blankImage);
  2593. blankImage.scrollTop = 0;
  2594. }
  2595. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2596. if (useragent.isOpera) {
  2597. editor.container.removeChild(blankImage);
  2598. }
  2599. dataTransfer.clearData();
  2600. dataTransfer.setData("Text", editor.session.getTextRange());
  2601. isInternal = true;
  2602. this.setState("drag");
  2603. };
  2604. this.onDragEnd = function(e) {
  2605. mouseTarget.draggable = false;
  2606. isInternal = false;
  2607. this.setState(null);
  2608. if (!editor.getReadOnly()) {
  2609. var dropEffect = e.dataTransfer.dropEffect;
  2610. if (!dragOperation && dropEffect == "move")
  2611. editor.session.remove(editor.getSelectionRange());
  2612. editor.renderer.$cursorLayer.setBlinking(true);
  2613. }
  2614. this.editor.unsetStyle("ace_dragging");
  2615. this.editor.renderer.setCursorStyle("");
  2616. };
  2617. this.onDragEnter = function(e) {
  2618. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2619. return;
  2620. x = e.clientX;
  2621. y = e.clientY;
  2622. if (!dragSelectionMarker)
  2623. addDragMarker();
  2624. counter++;
  2625. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2626. return event.preventDefault(e);
  2627. };
  2628. this.onDragOver = function(e) {
  2629. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2630. return;
  2631. x = e.clientX;
  2632. y = e.clientY;
  2633. if (!dragSelectionMarker) {
  2634. addDragMarker();
  2635. counter++;
  2636. }
  2637. if (onMouseMoveTimer !== null)
  2638. onMouseMoveTimer = null;
  2639. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2640. return event.preventDefault(e);
  2641. };
  2642. this.onDragLeave = function(e) {
  2643. counter--;
  2644. if (counter <= 0 && dragSelectionMarker) {
  2645. clearDragMarker();
  2646. dragOperation = null;
  2647. return event.preventDefault(e);
  2648. }
  2649. };
  2650. this.onDrop = function(e) {
  2651. if (!dragCursor)
  2652. return;
  2653. var dataTransfer = e.dataTransfer;
  2654. if (isInternal) {
  2655. switch (dragOperation) {
  2656. case "move":
  2657. if (range.contains(dragCursor.row, dragCursor.column)) {
  2658. range = {
  2659. start: dragCursor,
  2660. end: dragCursor
  2661. };
  2662. } else {
  2663. range = editor.moveText(range, dragCursor);
  2664. }
  2665. break;
  2666. case "copy":
  2667. range = editor.moveText(range, dragCursor, true);
  2668. break;
  2669. }
  2670. } else {
  2671. var dropData = dataTransfer.getData('Text');
  2672. range = {
  2673. start: dragCursor,
  2674. end: editor.session.insert(dragCursor, dropData)
  2675. };
  2676. editor.focus();
  2677. dragOperation = null;
  2678. }
  2679. clearDragMarker();
  2680. return event.preventDefault(e);
  2681. };
  2682. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2683. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2684. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2685. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2686. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2687. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2688. function scrollCursorIntoView(cursor, prevCursor) {
  2689. var now = Date.now();
  2690. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2691. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2692. if (!cursorMovedTime || vMovement || hMovement) {
  2693. editor.$blockScrolling += 1;
  2694. editor.moveCursorToPosition(cursor);
  2695. editor.$blockScrolling -= 1;
  2696. cursorMovedTime = now;
  2697. cursorPointOnCaretMoved = {x: x, y: y};
  2698. } else {
  2699. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2700. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2701. cursorMovedTime = null;
  2702. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2703. editor.renderer.scrollCursorIntoView();
  2704. cursorMovedTime = null;
  2705. }
  2706. }
  2707. }
  2708. function autoScroll(cursor, prevCursor) {
  2709. var now = Date.now();
  2710. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2711. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2712. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2713. var offsets = {
  2714. x: {
  2715. left: x - editorRect.left,
  2716. right: editorRect.right - x
  2717. },
  2718. y: {
  2719. top: y - editorRect.top,
  2720. bottom: editorRect.bottom - y
  2721. }
  2722. };
  2723. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2724. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2725. var scrollCursor = {row: cursor.row, column: cursor.column};
  2726. if (nearestXOffset / characterWidth <= 2) {
  2727. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2728. }
  2729. if (nearestYOffset / lineHeight <= 1) {
  2730. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2731. }
  2732. var vScroll = cursor.row != scrollCursor.row;
  2733. var hScroll = cursor.column != scrollCursor.column;
  2734. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2735. if (vScroll || (hScroll && !vMovement)) {
  2736. if (!autoScrollStartTime)
  2737. autoScrollStartTime = now;
  2738. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2739. editor.renderer.scrollCursorIntoView(scrollCursor);
  2740. } else {
  2741. autoScrollStartTime = null;
  2742. }
  2743. }
  2744. function onDragInterval() {
  2745. var prevCursor = dragCursor;
  2746. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2747. scrollCursorIntoView(dragCursor, prevCursor);
  2748. autoScroll(dragCursor, prevCursor);
  2749. }
  2750. function addDragMarker() {
  2751. range = editor.selection.toOrientedRange();
  2752. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2753. editor.clearSelection();
  2754. if (editor.isFocused())
  2755. editor.renderer.$cursorLayer.setBlinking(false);
  2756. clearInterval(timerId);
  2757. onDragInterval();
  2758. timerId = setInterval(onDragInterval, 20);
  2759. counter = 0;
  2760. event.addListener(document, "mousemove", onMouseMove);
  2761. }
  2762. function clearDragMarker() {
  2763. clearInterval(timerId);
  2764. editor.session.removeMarker(dragSelectionMarker);
  2765. dragSelectionMarker = null;
  2766. editor.$blockScrolling += 1;
  2767. editor.selection.fromOrientedRange(range);
  2768. editor.$blockScrolling -= 1;
  2769. if (editor.isFocused() && !isInternal)
  2770. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2771. range = null;
  2772. dragCursor = null;
  2773. counter = 0;
  2774. autoScrollStartTime = null;
  2775. cursorMovedTime = null;
  2776. event.removeListener(document, "mousemove", onMouseMove);
  2777. }
  2778. var onMouseMoveTimer = null;
  2779. function onMouseMove() {
  2780. if (onMouseMoveTimer == null) {
  2781. onMouseMoveTimer = setTimeout(function() {
  2782. if (onMouseMoveTimer != null && dragSelectionMarker)
  2783. clearDragMarker();
  2784. }, 20);
  2785. }
  2786. }
  2787. function canAccept(dataTransfer) {
  2788. var types = dataTransfer.types;
  2789. return !types || Array.prototype.some.call(types, function(type) {
  2790. return type == 'text/plain' || type == 'Text';
  2791. });
  2792. }
  2793. function getDropEffect(e) {
  2794. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2795. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2796. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2797. var effectAllowed = "uninitialized";
  2798. try {
  2799. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2800. } catch (e) {}
  2801. var dropEffect = "none";
  2802. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2803. dropEffect = "copy";
  2804. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2805. dropEffect = "move";
  2806. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2807. dropEffect = "copy";
  2808. return dropEffect;
  2809. }
  2810. }
  2811. (function() {
  2812. this.dragWait = function() {
  2813. var interval = Date.now() - this.mousedownEvent.time;
  2814. if (interval > this.editor.getDragDelay())
  2815. this.startDrag();
  2816. };
  2817. this.dragWaitEnd = function() {
  2818. var target = this.editor.container;
  2819. target.draggable = false;
  2820. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2821. this.selectEnd();
  2822. };
  2823. this.dragReadyEnd = function(e) {
  2824. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2825. this.editor.unsetStyle("ace_dragging");
  2826. this.editor.renderer.setCursorStyle("");
  2827. this.dragWaitEnd();
  2828. };
  2829. this.startDrag = function(){
  2830. this.cancelDrag = false;
  2831. var editor = this.editor;
  2832. var target = editor.container;
  2833. target.draggable = true;
  2834. editor.renderer.$cursorLayer.setBlinking(false);
  2835. editor.setStyle("ace_dragging");
  2836. var cursorStyle = useragent.isWin ? "default" : "move";
  2837. editor.renderer.setCursorStyle(cursorStyle);
  2838. this.setState("dragReady");
  2839. };
  2840. this.onMouseDrag = function(e) {
  2841. var target = this.editor.container;
  2842. if (useragent.isIE && this.state == "dragReady") {
  2843. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2844. if (distance > 3)
  2845. target.dragDrop();
  2846. }
  2847. if (this.state === "dragWait") {
  2848. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2849. if (distance > 0) {
  2850. target.draggable = false;
  2851. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2852. }
  2853. }
  2854. };
  2855. this.onMouseDown = function(e) {
  2856. if (!this.$dragEnabled)
  2857. return;
  2858. this.mousedownEvent = e;
  2859. var editor = this.editor;
  2860. var inSelection = e.inSelection();
  2861. var button = e.getButton();
  2862. var clickCount = e.domEvent.detail || 1;
  2863. if (clickCount === 1 && button === 0 && inSelection) {
  2864. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2865. return;
  2866. this.mousedownEvent.time = Date.now();
  2867. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2868. if ("unselectable" in eventTarget)
  2869. eventTarget.unselectable = "on";
  2870. if (editor.getDragDelay()) {
  2871. if (useragent.isWebKit) {
  2872. this.cancelDrag = true;
  2873. var mouseTarget = editor.container;
  2874. mouseTarget.draggable = true;
  2875. }
  2876. this.setState("dragWait");
  2877. } else {
  2878. this.startDrag();
  2879. }
  2880. this.captureMouse(e, this.onMouseDrag.bind(this));
  2881. e.defaultPrevented = true;
  2882. }
  2883. };
  2884. }).call(DragdropHandler.prototype);
  2885. function calcDistance(ax, ay, bx, by) {
  2886. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2887. }
  2888. exports.DragdropHandler = DragdropHandler;
  2889. });
  2890. define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2891. "use strict";
  2892. var dom = require("./dom");
  2893. exports.get = function (url, callback) {
  2894. var xhr = new XMLHttpRequest();
  2895. xhr.open('GET', url, true);
  2896. xhr.onreadystatechange = function () {
  2897. if (xhr.readyState === 4) {
  2898. callback(xhr.responseText);
  2899. }
  2900. };
  2901. xhr.send(null);
  2902. };
  2903. exports.loadScript = function(path, callback) {
  2904. var head = dom.getDocumentHead();
  2905. var s = document.createElement('script');
  2906. //path = COMMON.contentPath+"/res/framework/ace/src/"+path;
  2907. s.src = path;
  2908. head.appendChild(s);
  2909. s.onload = s.onreadystatechange = function(_, isAbort) {
  2910. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2911. s = s.onload = s.onreadystatechange = null;
  2912. if (!isAbort)
  2913. callback();
  2914. }
  2915. };
  2916. };
  2917. exports.qualifyURL = function(url) {
  2918. var a = document.createElement('a');
  2919. a.href = url;
  2920. return a.href;
  2921. }
  2922. });
  2923. define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2924. "use strict";
  2925. var EventEmitter = {};
  2926. var stopPropagation = function() { this.propagationStopped = true; };
  2927. var preventDefault = function() { this.defaultPrevented = true; };
  2928. EventEmitter._emit =
  2929. EventEmitter._dispatchEvent = function(eventName, e) {
  2930. this._eventRegistry || (this._eventRegistry = {});
  2931. this._defaultHandlers || (this._defaultHandlers = {});
  2932. var listeners = this._eventRegistry[eventName] || [];
  2933. var defaultHandler = this._defaultHandlers[eventName];
  2934. if (!listeners.length && !defaultHandler)
  2935. return;
  2936. if (typeof e != "object" || !e)
  2937. e = {};
  2938. if (!e.type)
  2939. e.type = eventName;
  2940. if (!e.stopPropagation)
  2941. e.stopPropagation = stopPropagation;
  2942. if (!e.preventDefault)
  2943. e.preventDefault = preventDefault;
  2944. listeners = listeners.slice();
  2945. for (var i=0; i<listeners.length; i++) {
  2946. listeners[i](e, this);
  2947. if (e.propagationStopped)
  2948. break;
  2949. }
  2950. if (defaultHandler && !e.defaultPrevented)
  2951. return defaultHandler(e, this);
  2952. };
  2953. EventEmitter._signal = function(eventName, e) {
  2954. var listeners = (this._eventRegistry || {})[eventName];
  2955. if (!listeners)
  2956. return;
  2957. listeners = listeners.slice();
  2958. for (var i=0; i<listeners.length; i++)
  2959. listeners[i](e, this);
  2960. };
  2961. EventEmitter.once = function(eventName, callback) {
  2962. var _self = this;
  2963. callback && this.addEventListener(eventName, function newCallback() {
  2964. _self.removeEventListener(eventName, newCallback);
  2965. callback.apply(null, arguments);
  2966. });
  2967. };
  2968. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2969. var handlers = this._defaultHandlers
  2970. if (!handlers)
  2971. handlers = this._defaultHandlers = {_disabled_: {}};
  2972. if (handlers[eventName]) {
  2973. var old = handlers[eventName];
  2974. var disabled = handlers._disabled_[eventName];
  2975. if (!disabled)
  2976. handlers._disabled_[eventName] = disabled = [];
  2977. disabled.push(old);
  2978. var i = disabled.indexOf(callback);
  2979. if (i != -1)
  2980. disabled.splice(i, 1);
  2981. }
  2982. handlers[eventName] = callback;
  2983. };
  2984. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  2985. var handlers = this._defaultHandlers
  2986. if (!handlers)
  2987. return;
  2988. var disabled = handlers._disabled_[eventName];
  2989. if (handlers[eventName] == callback) {
  2990. var old = handlers[eventName];
  2991. if (disabled)
  2992. this.setDefaultHandler(eventName, disabled.pop());
  2993. } else if (disabled) {
  2994. var i = disabled.indexOf(callback);
  2995. if (i != -1)
  2996. disabled.splice(i, 1);
  2997. }
  2998. };
  2999. EventEmitter.on =
  3000. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  3001. this._eventRegistry = this._eventRegistry || {};
  3002. var listeners = this._eventRegistry[eventName];
  3003. if (!listeners)
  3004. listeners = this._eventRegistry[eventName] = [];
  3005. if (listeners.indexOf(callback) == -1)
  3006. listeners[capturing ? "unshift" : "push"](callback);
  3007. return callback;
  3008. };
  3009. EventEmitter.off =
  3010. EventEmitter.removeListener =
  3011. EventEmitter.removeEventListener = function(eventName, callback) {
  3012. this._eventRegistry = this._eventRegistry || {};
  3013. var listeners = this._eventRegistry[eventName];
  3014. if (!listeners)
  3015. return;
  3016. var index = listeners.indexOf(callback);
  3017. if (index !== -1)
  3018. listeners.splice(index, 1);
  3019. };
  3020. EventEmitter.removeAllListeners = function(eventName) {
  3021. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3022. };
  3023. exports.EventEmitter = EventEmitter;
  3024. });
  3025. define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3026. "no use strict";
  3027. var oop = require("./oop");
  3028. var EventEmitter = require("./event_emitter").EventEmitter;
  3029. var optionsProvider = {
  3030. setOptions: function(optList) {
  3031. Object.keys(optList).forEach(function(key) {
  3032. this.setOption(key, optList[key]);
  3033. }, this);
  3034. },
  3035. getOptions: function(optionNames) {
  3036. var result = {};
  3037. if (!optionNames) {
  3038. optionNames = Object.keys(this.$options);
  3039. } else if (!Array.isArray(optionNames)) {
  3040. result = optionNames;
  3041. optionNames = Object.keys(result);
  3042. }
  3043. optionNames.forEach(function(key) {
  3044. result[key] = this.getOption(key);
  3045. }, this);
  3046. return result;
  3047. },
  3048. setOption: function(name, value) {
  3049. if (this["$" + name] === value)
  3050. return;
  3051. var opt = this.$options[name];
  3052. if (!opt) {
  3053. return warn('misspelled option "' + name + '"');
  3054. }
  3055. if (opt.forwardTo)
  3056. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3057. if (!opt.handlesSet)
  3058. this["$" + name] = value;
  3059. if (opt && opt.set)
  3060. opt.set.call(this, value);
  3061. },
  3062. getOption: function(name) {
  3063. var opt = this.$options[name];
  3064. if (!opt) {
  3065. return warn('misspelled option "' + name + '"');
  3066. }
  3067. if (opt.forwardTo)
  3068. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3069. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3070. }
  3071. };
  3072. function warn(message) {
  3073. if (typeof console != "undefined" && console.warn)
  3074. console.warn.apply(console, arguments);
  3075. }
  3076. function reportError(msg, data) {
  3077. var e = new Error(msg);
  3078. e.data = data;
  3079. if (typeof console == "object" && console.error)
  3080. console.error(e);
  3081. setTimeout(function() { throw e; });
  3082. }
  3083. var AppConfig = function() {
  3084. this.$defaultOptions = {};
  3085. };
  3086. (function() {
  3087. oop.implement(this, EventEmitter);
  3088. this.defineOptions = function(obj, path, options) {
  3089. if (!obj.$options)
  3090. this.$defaultOptions[path] = obj.$options = {};
  3091. Object.keys(options).forEach(function(key) {
  3092. var opt = options[key];
  3093. if (typeof opt == "string")
  3094. opt = {forwardTo: opt};
  3095. opt.name || (opt.name = key);
  3096. obj.$options[opt.name] = opt;
  3097. if ("initialValue" in opt)
  3098. obj["$" + opt.name] = opt.initialValue;
  3099. });
  3100. oop.implement(obj, optionsProvider);
  3101. return this;
  3102. };
  3103. this.resetOptions = function(obj) {
  3104. Object.keys(obj.$options).forEach(function(key) {
  3105. var opt = obj.$options[key];
  3106. if ("value" in opt)
  3107. obj.setOption(key, opt.value);
  3108. });
  3109. };
  3110. this.setDefaultValue = function(path, name, value) {
  3111. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3112. if (opts[name]) {
  3113. if (opts.forwardTo)
  3114. this.setDefaultValue(opts.forwardTo, name, value);
  3115. else
  3116. opts[name].value = value;
  3117. }
  3118. };
  3119. this.setDefaultValues = function(path, optionHash) {
  3120. Object.keys(optionHash).forEach(function(key) {
  3121. this.setDefaultValue(path, key, optionHash[key]);
  3122. }, this);
  3123. };
  3124. this.warn = warn;
  3125. this.reportError = reportError;
  3126. }).call(AppConfig.prototype);
  3127. exports.AppConfig = AppConfig;
  3128. });
  3129. define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3130. "no use strict";
  3131. var lang = require("./lib/lang");
  3132. var oop = require("./lib/oop");
  3133. var net = require("./lib/net");
  3134. var AppConfig = require("./lib/app_config").AppConfig;
  3135. module.exports = exports = new AppConfig();
  3136. var global = (function() {
  3137. return this || typeof window != "undefined" && window;
  3138. })();
  3139. var options = {
  3140. packaged: false,
  3141. workerPath: null,
  3142. modePath: null,
  3143. themePath: null,
  3144. basePath: "",
  3145. suffix: ".js",
  3146. $moduleUrls: {}
  3147. };
  3148. exports.get = function(key) {
  3149. if (!options.hasOwnProperty(key))
  3150. throw new Error("Unknown config key: " + key);
  3151. return options[key];
  3152. };
  3153. exports.set = function(key, value) {
  3154. if (!options.hasOwnProperty(key))
  3155. throw new Error("Unknown config key: " + key);
  3156. options[key] = value;
  3157. };
  3158. exports.all = function() {
  3159. return lang.copyObject(options);
  3160. };
  3161. exports.moduleUrl = function(name, component) {
  3162. if (options.$moduleUrls[name])
  3163. return options.$moduleUrls[name];
  3164. var parts = name.split("/");
  3165. component = component || parts[parts.length - 2] || "";
  3166. var sep = component == "snippets" ? "/" : "-";
  3167. var base = parts[parts.length - 1];
  3168. if (component == "worker" && sep == "-") {
  3169. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3170. base = base.replace(re, "");
  3171. }
  3172. if ((!base || base == component) && parts.length > 1)
  3173. base = parts[parts.length - 2];
  3174. var path = options[component + "Path"];
  3175. if (path == null) {
  3176. path = options.basePath;
  3177. } else if (sep == "/") {
  3178. component = sep = "";
  3179. }
  3180. if (path && path.slice(-1) != "/")
  3181. path += "/";
  3182. return path + component + sep + base + this.get("suffix");
  3183. };
  3184. exports.setModuleUrl = function(name, subst) {
  3185. return options.$moduleUrls[name] = subst;
  3186. };
  3187. exports.$loading = {};
  3188. exports.loadModule = function(moduleName, onLoad) {
  3189. var module, moduleType;
  3190. if (Array.isArray(moduleName)) {
  3191. moduleType = moduleName[0];
  3192. moduleName = moduleName[1];
  3193. }
  3194. try {
  3195. module = require(moduleName);
  3196. } catch (e) {}
  3197. if (module && !exports.$loading[moduleName])
  3198. return onLoad && onLoad(module);
  3199. if (!exports.$loading[moduleName])
  3200. exports.$loading[moduleName] = [];
  3201. exports.$loading[moduleName].push(onLoad);
  3202. if (exports.$loading[moduleName].length > 1)
  3203. return;
  3204. var afterLoad = function() {
  3205. require([moduleName], function(module) {
  3206. exports._emit("load.module", {name: moduleName, module: module});
  3207. var listeners = exports.$loading[moduleName];
  3208. exports.$loading[moduleName] = null;
  3209. listeners.forEach(function(onLoad) {
  3210. onLoad && onLoad(module);
  3211. });
  3212. });
  3213. };
  3214. if (!exports.get("packaged"))
  3215. return afterLoad();
  3216. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3217. };
  3218. init(true);function init(packaged) {
  3219. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3220. if (!global.document)
  3221. return "";
  3222. var scriptOptions = {};
  3223. var scriptUrl = "";
  3224. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3225. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3226. var scripts = currentDocument.getElementsByTagName("script");
  3227. for (var i=0; i<scripts.length; i++) {
  3228. var script = scripts[i];
  3229. var src = script.src || script.getAttribute("src");
  3230. if (!src)
  3231. continue;
  3232. var attributes = script.attributes;
  3233. for (var j=0, l=attributes.length; j < l; j++) {
  3234. var attr = attributes[j];
  3235. if (attr.name.indexOf("data-ace-") === 0) {
  3236. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3237. }
  3238. }
  3239. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3240. if (m)
  3241. scriptUrl = m[1];
  3242. }
  3243. if (scriptUrl) {
  3244. scriptOptions.base = scriptOptions.base || scriptUrl;
  3245. scriptOptions.packaged = true;
  3246. }
  3247. scriptOptions.basePath = scriptOptions.base;
  3248. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3249. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3250. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3251. delete scriptOptions.base;
  3252. for (var key in scriptOptions)
  3253. if (typeof scriptOptions[key] !== "undefined")
  3254. exports.set(key, scriptOptions[key]);
  3255. };
  3256. exports.init = init;
  3257. function deHyphenate(str) {
  3258. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3259. }
  3260. });
  3261. 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) {
  3262. "use strict";
  3263. var event = require("../lib/event");
  3264. var useragent = require("../lib/useragent");
  3265. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3266. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3267. var MouseEvent = require("./mouse_event").MouseEvent;
  3268. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3269. var config = require("../config");
  3270. var MouseHandler = function(editor) {
  3271. var _self = this;
  3272. this.editor = editor;
  3273. new DefaultHandlers(this);
  3274. new DefaultGutterHandler(this);
  3275. new DragdropHandler(this);
  3276. var focusEditor = function(e) {
  3277. if (!document.hasFocus || !document.hasFocus())
  3278. window.focus();
  3279. editor.focus();
  3280. };
  3281. var mouseTarget = editor.renderer.getMouseEventTarget();
  3282. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3283. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3284. event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
  3285. if (editor.renderer.scrollBarV) {
  3286. event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
  3287. event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
  3288. if (useragent.isIE) {
  3289. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3290. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3291. }
  3292. }
  3293. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3294. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3295. var gutterEl = editor.renderer.$gutter;
  3296. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3297. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3298. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3299. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3300. event.addListener(mouseTarget, "mousedown", focusEditor);
  3301. event.addListener(gutterEl, "mousedown", function(e) {
  3302. editor.focus();
  3303. return event.preventDefault(e);
  3304. });
  3305. editor.on("mousemove", function(e){
  3306. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3307. return;
  3308. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3309. var range = editor.session.selection.getRange();
  3310. var renderer = editor.renderer;
  3311. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3312. renderer.setCursorStyle("default");
  3313. } else {
  3314. renderer.setCursorStyle("");
  3315. }
  3316. });
  3317. };
  3318. (function() {
  3319. this.onMouseEvent = function(name, e) {
  3320. this.editor._emit(name, new MouseEvent(e, this.editor));
  3321. };
  3322. this.onMouseMove = function(name, e) {
  3323. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3324. if (!listeners || !listeners.length)
  3325. return;
  3326. this.editor._emit(name, new MouseEvent(e, this.editor));
  3327. };
  3328. this.onMouseWheel = function(name, e) {
  3329. var mouseEvent = new MouseEvent(e, this.editor);
  3330. mouseEvent.speed = this.$scrollSpeed * 2;
  3331. mouseEvent.wheelX = e.wheelX;
  3332. mouseEvent.wheelY = e.wheelY;
  3333. this.editor._emit(name, mouseEvent);
  3334. };
  3335. this.onTouchMove = function (name, e) {
  3336. var mouseEvent = new MouseEvent(e, this.editor);
  3337. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3338. mouseEvent.wheelX = e.wheelX;
  3339. mouseEvent.wheelY = e.wheelY;
  3340. this.editor._emit(name, mouseEvent);
  3341. };
  3342. this.setState = function(state) {
  3343. this.state = state;
  3344. };
  3345. this.captureMouse = function(ev, mouseMoveHandler) {
  3346. this.x = ev.x;
  3347. this.y = ev.y;
  3348. this.isMousePressed = true;
  3349. var renderer = this.editor.renderer;
  3350. if (renderer.$keepTextAreaAtCursor)
  3351. renderer.$keepTextAreaAtCursor = null;
  3352. var self = this;
  3353. var onMouseMove = function(e) {
  3354. if (!e) return;
  3355. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3356. return self.releaseMouse();
  3357. self.x = e.clientX;
  3358. self.y = e.clientY;
  3359. mouseMoveHandler && mouseMoveHandler(e);
  3360. self.mouseEvent = new MouseEvent(e, self.editor);
  3361. self.$mouseMoved = true;
  3362. };
  3363. var onCaptureEnd = function(e) {
  3364. clearInterval(timerId);
  3365. onCaptureInterval();
  3366. self[self.state + "End"] && self[self.state + "End"](e);
  3367. self.state = "";
  3368. if (renderer.$keepTextAreaAtCursor == null) {
  3369. renderer.$keepTextAreaAtCursor = true;
  3370. renderer.$moveTextAreaToCursor();
  3371. }
  3372. self.isMousePressed = false;
  3373. self.$onCaptureMouseMove = self.releaseMouse = null;
  3374. e && self.onMouseEvent("mouseup", e);
  3375. };
  3376. var onCaptureInterval = function() {
  3377. self[self.state] && self[self.state]();
  3378. self.$mouseMoved = false;
  3379. };
  3380. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3381. return setTimeout(function() {onCaptureEnd(ev);});
  3382. }
  3383. self.$onCaptureMouseMove = onMouseMove;
  3384. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3385. var timerId = setInterval(onCaptureInterval, 20);
  3386. };
  3387. this.releaseMouse = null;
  3388. this.cancelContextMenu = function() {
  3389. var stop = function(e) {
  3390. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3391. return;
  3392. this.editor.off("nativecontextmenu", stop);
  3393. if (e && e.domEvent)
  3394. event.stopEvent(e.domEvent);
  3395. }.bind(this);
  3396. setTimeout(stop, 10);
  3397. this.editor.on("nativecontextmenu", stop);
  3398. };
  3399. }).call(MouseHandler.prototype);
  3400. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3401. scrollSpeed: {initialValue: 2},
  3402. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3403. dragEnabled: {initialValue: true},
  3404. focusTimout: {initialValue: 0},
  3405. tooltipFollowsMouse: {initialValue: true}
  3406. });
  3407. exports.MouseHandler = MouseHandler;
  3408. });
  3409. define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3410. "use strict";
  3411. function FoldHandler(editor) {
  3412. editor.on("click", function(e) {
  3413. var position = e.getDocumentPosition();
  3414. var session = editor.session;
  3415. var fold = session.getFoldAt(position.row, position.column, 1);
  3416. if (fold) {
  3417. if (e.getAccelKey())
  3418. session.removeFold(fold);
  3419. else
  3420. session.expandFold(fold);
  3421. e.stop();
  3422. }
  3423. });
  3424. editor.on("gutterclick", function(e) {
  3425. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3426. if (gutterRegion == "foldWidgets") {
  3427. var row = e.getDocumentPosition().row;
  3428. var session = editor.session;
  3429. if (session.foldWidgets && session.foldWidgets[row])
  3430. editor.session.onFoldWidgetClick(row, e);
  3431. if (!editor.isFocused())
  3432. editor.focus();
  3433. e.stop();
  3434. }
  3435. });
  3436. editor.on("gutterdblclick", function(e) {
  3437. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3438. if (gutterRegion == "foldWidgets") {
  3439. var row = e.getDocumentPosition().row;
  3440. var session = editor.session;
  3441. var data = session.getParentFoldRangeData(row, true);
  3442. var range = data.range || data.firstRange;
  3443. if (range) {
  3444. row = range.start.row;
  3445. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3446. if (fold) {
  3447. session.removeFold(fold);
  3448. } else {
  3449. session.addFold("...", range);
  3450. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3451. }
  3452. }
  3453. e.stop();
  3454. }
  3455. });
  3456. }
  3457. exports.FoldHandler = FoldHandler;
  3458. });
  3459. define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3460. "use strict";
  3461. var keyUtil = require("../lib/keys");
  3462. var event = require("../lib/event");
  3463. var KeyBinding = function(editor) {
  3464. this.$editor = editor;
  3465. this.$data = {editor: editor};
  3466. this.$handlers = [];
  3467. this.$exports = exports;
  3468. this.setDefaultHandler(editor.commands);
  3469. };
  3470. (function() {
  3471. this.setDefaultHandler = function(kb) {
  3472. this.removeKeyboardHandler(this.$defaultHandler);
  3473. this.$defaultHandler = kb;
  3474. this.addKeyboardHandler(kb, 0);
  3475. };
  3476. this.setKeyboardHandler = function(kb) {
  3477. var h = this.$handlers;
  3478. if (h[h.length - 1] == kb)
  3479. return;
  3480. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3481. this.removeKeyboardHandler(h[h.length - 1]);
  3482. this.addKeyboardHandler(kb, 1);
  3483. };
  3484. this.addKeyboardHandler = function(kb, pos) {
  3485. if (!kb)
  3486. return;
  3487. if (typeof kb == "function" && !kb.handleKeyboard)
  3488. kb.handleKeyboard = kb;
  3489. var i = this.$handlers.indexOf(kb);
  3490. if (i != -1)
  3491. this.$handlers.splice(i, 1);
  3492. if (pos == undefined)
  3493. this.$handlers.push(kb);
  3494. else
  3495. this.$handlers.splice(pos, 0, kb);
  3496. if (i == -1 && kb.attach)
  3497. kb.attach(this.$editor);
  3498. };
  3499. this.removeKeyboardHandler = function(kb) {
  3500. var i = this.$handlers.indexOf(kb);
  3501. if (i == -1)
  3502. return false;
  3503. this.$handlers.splice(i, 1);
  3504. kb.detach && kb.detach(this.$editor);
  3505. return true;
  3506. };
  3507. this.getKeyboardHandler = function() {
  3508. return this.$handlers[this.$handlers.length - 1];
  3509. };
  3510. this.getStatusText = function() {
  3511. var data = this.$data;
  3512. var editor = data.editor;
  3513. return this.$handlers.map(function(h) {
  3514. return h.getStatusText && h.getStatusText(editor, data) || "";
  3515. }).filter(Boolean).join(" ");
  3516. };
  3517. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3518. var toExecute;
  3519. var success = false;
  3520. var commands = this.$editor.commands;
  3521. //if (keyCode == 190){
  3522. commands.exec(commands.byName["startAutocomplete"], this.$editor, null, e);
  3523. //}
  3524. for (var i = this.$handlers.length; i--;) {
  3525. toExecute = this.$handlers[i].handleKeyboard(
  3526. this.$data, hashId, keyString, keyCode, e
  3527. );
  3528. if (!toExecute || !toExecute.command)
  3529. continue;
  3530. if (toExecute.command == "null") {
  3531. success = true;
  3532. } else {
  3533. debugger;
  3534. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3535. }
  3536. if (success && e && hashId != -1 &&
  3537. toExecute.passEvent != true && toExecute.command.passEvent != true
  3538. ) {
  3539. event.stopEvent(e);
  3540. }
  3541. if (success)
  3542. break;
  3543. }
  3544. return success;
  3545. };
  3546. this.onCommandKey = function(e, hashId, keyCode) {
  3547. // if (keyCode == 190){
  3548. // var editor = this.$editor;
  3549. // if (!editor.completer)
  3550. // var Autocomplete = require("../autocomplete").Autocomplete;
  3551. // editor.completer = new require("../autocomplete").Autocomplete();
  3552. // editor.completer.showPopup(this.editor);
  3553. // }
  3554. var keyString = keyUtil.keyCodeToString(keyCode);
  3555. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3556. };
  3557. this.onTextInput = function(text) {
  3558. var success = this.$callKeyboardHandlers(-1, text);
  3559. if (!success)
  3560. this.$editor.commands.exec("insertstring", this.$editor, text);
  3561. };
  3562. }).call(KeyBinding.prototype);
  3563. exports.KeyBinding = KeyBinding;
  3564. });
  3565. define("ace/range",["require","exports","module"], function(require, exports, module) {
  3566. "use strict";
  3567. var comparePoints = function(p1, p2) {
  3568. return p1.row - p2.row || p1.column - p2.column;
  3569. };
  3570. var Range = function(startRow, startColumn, endRow, endColumn) {
  3571. this.start = {
  3572. row: startRow,
  3573. column: startColumn
  3574. };
  3575. this.end = {
  3576. row: endRow,
  3577. column: endColumn
  3578. };
  3579. };
  3580. (function() {
  3581. this.isEqual = function(range) {
  3582. return this.start.row === range.start.row &&
  3583. this.end.row === range.end.row &&
  3584. this.start.column === range.start.column &&
  3585. this.end.column === range.end.column;
  3586. };
  3587. this.toString = function() {
  3588. return ("Range: [" + this.start.row + "/" + this.start.column +
  3589. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3590. };
  3591. this.contains = function(row, column) {
  3592. return this.compare(row, column) == 0;
  3593. };
  3594. this.compareRange = function(range) {
  3595. var cmp,
  3596. end = range.end,
  3597. start = range.start;
  3598. cmp = this.compare(end.row, end.column);
  3599. if (cmp == 1) {
  3600. cmp = this.compare(start.row, start.column);
  3601. if (cmp == 1) {
  3602. return 2;
  3603. } else if (cmp == 0) {
  3604. return 1;
  3605. } else {
  3606. return 0;
  3607. }
  3608. } else if (cmp == -1) {
  3609. return -2;
  3610. } else {
  3611. cmp = this.compare(start.row, start.column);
  3612. if (cmp == -1) {
  3613. return -1;
  3614. } else if (cmp == 1) {
  3615. return 42;
  3616. } else {
  3617. return 0;
  3618. }
  3619. }
  3620. };
  3621. this.comparePoint = function(p) {
  3622. return this.compare(p.row, p.column);
  3623. };
  3624. this.containsRange = function(range) {
  3625. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3626. };
  3627. this.intersects = function(range) {
  3628. var cmp = this.compareRange(range);
  3629. return (cmp == -1 || cmp == 0 || cmp == 1);
  3630. };
  3631. this.isEnd = function(row, column) {
  3632. return this.end.row == row && this.end.column == column;
  3633. };
  3634. this.isStart = function(row, column) {
  3635. return this.start.row == row && this.start.column == column;
  3636. };
  3637. this.setStart = function(row, column) {
  3638. if (typeof row == "object") {
  3639. this.start.column = row.column;
  3640. this.start.row = row.row;
  3641. } else {
  3642. this.start.row = row;
  3643. this.start.column = column;
  3644. }
  3645. };
  3646. this.setEnd = function(row, column) {
  3647. if (typeof row == "object") {
  3648. this.end.column = row.column;
  3649. this.end.row = row.row;
  3650. } else {
  3651. this.end.row = row;
  3652. this.end.column = column;
  3653. }
  3654. };
  3655. this.inside = function(row, column) {
  3656. if (this.compare(row, column) == 0) {
  3657. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3658. return false;
  3659. } else {
  3660. return true;
  3661. }
  3662. }
  3663. return false;
  3664. };
  3665. this.insideStart = function(row, column) {
  3666. if (this.compare(row, column) == 0) {
  3667. if (this.isEnd(row, column)) {
  3668. return false;
  3669. } else {
  3670. return true;
  3671. }
  3672. }
  3673. return false;
  3674. };
  3675. this.insideEnd = function(row, column) {
  3676. if (this.compare(row, column) == 0) {
  3677. if (this.isStart(row, column)) {
  3678. return false;
  3679. } else {
  3680. return true;
  3681. }
  3682. }
  3683. return false;
  3684. };
  3685. this.compare = function(row, column) {
  3686. if (!this.isMultiLine()) {
  3687. if (row === this.start.row) {
  3688. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3689. };
  3690. }
  3691. if (row < this.start.row)
  3692. return -1;
  3693. if (row > this.end.row)
  3694. return 1;
  3695. if (this.start.row === row)
  3696. return column >= this.start.column ? 0 : -1;
  3697. if (this.end.row === row)
  3698. return column <= this.end.column ? 0 : 1;
  3699. return 0;
  3700. };
  3701. this.compareStart = function(row, column) {
  3702. if (this.start.row == row && this.start.column == column) {
  3703. return -1;
  3704. } else {
  3705. return this.compare(row, column);
  3706. }
  3707. };
  3708. this.compareEnd = function(row, column) {
  3709. if (this.end.row == row && this.end.column == column) {
  3710. return 1;
  3711. } else {
  3712. return this.compare(row, column);
  3713. }
  3714. };
  3715. this.compareInside = function(row, column) {
  3716. if (this.end.row == row && this.end.column == column) {
  3717. return 1;
  3718. } else if (this.start.row == row && this.start.column == column) {
  3719. return -1;
  3720. } else {
  3721. return this.compare(row, column);
  3722. }
  3723. };
  3724. this.clipRows = function(firstRow, lastRow) {
  3725. if (this.end.row > lastRow)
  3726. var end = {row: lastRow + 1, column: 0};
  3727. else if (this.end.row < firstRow)
  3728. var end = {row: firstRow, column: 0};
  3729. if (this.start.row > lastRow)
  3730. var start = {row: lastRow + 1, column: 0};
  3731. else if (this.start.row < firstRow)
  3732. var start = {row: firstRow, column: 0};
  3733. return Range.fromPoints(start || this.start, end || this.end);
  3734. };
  3735. this.extend = function(row, column) {
  3736. var cmp = this.compare(row, column);
  3737. if (cmp == 0)
  3738. return this;
  3739. else if (cmp == -1)
  3740. var start = {row: row, column: column};
  3741. else
  3742. var end = {row: row, column: column};
  3743. return Range.fromPoints(start || this.start, end || this.end);
  3744. };
  3745. this.isEmpty = function() {
  3746. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3747. };
  3748. this.isMultiLine = function() {
  3749. return (this.start.row !== this.end.row);
  3750. };
  3751. this.clone = function() {
  3752. return Range.fromPoints(this.start, this.end);
  3753. };
  3754. this.collapseRows = function() {
  3755. if (this.end.column == 0)
  3756. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3757. else
  3758. return new Range(this.start.row, 0, this.end.row, 0)
  3759. };
  3760. this.toScreenRange = function(session) {
  3761. var screenPosStart = session.documentToScreenPosition(this.start);
  3762. var screenPosEnd = session.documentToScreenPosition(this.end);
  3763. return new Range(
  3764. screenPosStart.row, screenPosStart.column,
  3765. screenPosEnd.row, screenPosEnd.column
  3766. );
  3767. };
  3768. this.moveBy = function(row, column) {
  3769. this.start.row += row;
  3770. this.start.column += column;
  3771. this.end.row += row;
  3772. this.end.column += column;
  3773. };
  3774. }).call(Range.prototype);
  3775. Range.fromPoints = function(start, end) {
  3776. return new Range(start.row, start.column, end.row, end.column);
  3777. };
  3778. Range.comparePoints = comparePoints;
  3779. Range.comparePoints = function(p1, p2) {
  3780. return p1.row - p2.row || p1.column - p2.column;
  3781. };
  3782. exports.Range = Range;
  3783. });
  3784. define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3785. "use strict";
  3786. var oop = require("./lib/oop");
  3787. var lang = require("./lib/lang");
  3788. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3789. var Range = require("./range").Range;
  3790. var Selection = function(session) {
  3791. this.session = session;
  3792. this.doc = session.getDocument();
  3793. this.clearSelection();
  3794. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3795. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3796. var self = this;
  3797. this.lead.on("change", function(e) {
  3798. self._emit("changeCursor");
  3799. if (!self.$isEmpty)
  3800. self._emit("changeSelection");
  3801. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3802. self.$desiredColumn = null;
  3803. });
  3804. this.selectionAnchor.on("change", function() {
  3805. if (!self.$isEmpty)
  3806. self._emit("changeSelection");
  3807. });
  3808. };
  3809. (function() {
  3810. oop.implement(this, EventEmitter);
  3811. this.isEmpty = function() {
  3812. return (this.$isEmpty || (
  3813. this.anchor.row == this.lead.row &&
  3814. this.anchor.column == this.lead.column
  3815. ));
  3816. };
  3817. this.isMultiLine = function() {
  3818. if (this.isEmpty()) {
  3819. return false;
  3820. }
  3821. return this.getRange().isMultiLine();
  3822. };
  3823. this.getCursor = function() {
  3824. return this.lead.getPosition();
  3825. };
  3826. this.setSelectionAnchor = function(row, column) {
  3827. this.anchor.setPosition(row, column);
  3828. if (this.$isEmpty) {
  3829. this.$isEmpty = false;
  3830. this._emit("changeSelection");
  3831. }
  3832. };
  3833. this.getSelectionAnchor = function() {
  3834. if (this.$isEmpty)
  3835. return this.getSelectionLead();
  3836. else
  3837. return this.anchor.getPosition();
  3838. };
  3839. this.getSelectionLead = function() {
  3840. return this.lead.getPosition();
  3841. };
  3842. this.shiftSelection = function(columns) {
  3843. if (this.$isEmpty) {
  3844. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3845. return;
  3846. }
  3847. var anchor = this.getSelectionAnchor();
  3848. var lead = this.getSelectionLead();
  3849. var isBackwards = this.isBackwards();
  3850. if (!isBackwards || anchor.column !== 0)
  3851. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3852. if (isBackwards || lead.column !== 0) {
  3853. this.$moveSelection(function() {
  3854. this.moveCursorTo(lead.row, lead.column + columns);
  3855. });
  3856. }
  3857. };
  3858. this.isBackwards = function() {
  3859. var anchor = this.anchor;
  3860. var lead = this.lead;
  3861. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3862. };
  3863. this.getRange = function() {
  3864. var anchor = this.anchor;
  3865. var lead = this.lead;
  3866. if (this.isEmpty())
  3867. return Range.fromPoints(lead, lead);
  3868. if (this.isBackwards()) {
  3869. return Range.fromPoints(lead, anchor);
  3870. }
  3871. else {
  3872. return Range.fromPoints(anchor, lead);
  3873. }
  3874. };
  3875. this.clearSelection = function() {
  3876. if (!this.$isEmpty) {
  3877. this.$isEmpty = true;
  3878. this._emit("changeSelection");
  3879. }
  3880. };
  3881. this.selectAll = function() {
  3882. var lastRow = this.doc.getLength() - 1;
  3883. this.setSelectionAnchor(0, 0);
  3884. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3885. };
  3886. this.setRange =
  3887. this.setSelectionRange = function(range, reverse) {
  3888. if (reverse) {
  3889. this.setSelectionAnchor(range.end.row, range.end.column);
  3890. this.selectTo(range.start.row, range.start.column);
  3891. } else {
  3892. this.setSelectionAnchor(range.start.row, range.start.column);
  3893. this.selectTo(range.end.row, range.end.column);
  3894. }
  3895. if (this.getRange().isEmpty())
  3896. this.$isEmpty = true;
  3897. this.$desiredColumn = null;
  3898. };
  3899. this.$moveSelection = function(mover) {
  3900. var lead = this.lead;
  3901. if (this.$isEmpty)
  3902. this.setSelectionAnchor(lead.row, lead.column);
  3903. mover.call(this);
  3904. };
  3905. this.selectTo = function(row, column) {
  3906. this.$moveSelection(function() {
  3907. this.moveCursorTo(row, column);
  3908. });
  3909. };
  3910. this.selectToPosition = function(pos) {
  3911. this.$moveSelection(function() {
  3912. this.moveCursorToPosition(pos);
  3913. });
  3914. };
  3915. this.moveTo = function(row, column) {
  3916. this.clearSelection();
  3917. this.moveCursorTo(row, column);
  3918. };
  3919. this.moveToPosition = function(pos) {
  3920. this.clearSelection();
  3921. this.moveCursorToPosition(pos);
  3922. };
  3923. this.selectUp = function() {
  3924. this.$moveSelection(this.moveCursorUp);
  3925. };
  3926. this.selectDown = function() {
  3927. this.$moveSelection(this.moveCursorDown);
  3928. };
  3929. this.selectRight = function() {
  3930. this.$moveSelection(this.moveCursorRight);
  3931. };
  3932. this.selectLeft = function() {
  3933. this.$moveSelection(this.moveCursorLeft);
  3934. };
  3935. this.selectLineStart = function() {
  3936. this.$moveSelection(this.moveCursorLineStart);
  3937. };
  3938. this.selectLineEnd = function() {
  3939. this.$moveSelection(this.moveCursorLineEnd);
  3940. };
  3941. this.selectFileEnd = function() {
  3942. this.$moveSelection(this.moveCursorFileEnd);
  3943. };
  3944. this.selectFileStart = function() {
  3945. this.$moveSelection(this.moveCursorFileStart);
  3946. };
  3947. this.selectWordRight = function() {
  3948. this.$moveSelection(this.moveCursorWordRight);
  3949. };
  3950. this.selectWordLeft = function() {
  3951. this.$moveSelection(this.moveCursorWordLeft);
  3952. };
  3953. this.getWordRange = function(row, column) {
  3954. if (typeof column == "undefined") {
  3955. var cursor = row || this.lead;
  3956. row = cursor.row;
  3957. column = cursor.column;
  3958. }
  3959. return this.session.getWordRange(row, column);
  3960. };
  3961. this.selectWord = function() {
  3962. this.setSelectionRange(this.getWordRange());
  3963. };
  3964. this.selectAWord = function() {
  3965. var cursor = this.getCursor();
  3966. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3967. this.setSelectionRange(range);
  3968. };
  3969. this.getLineRange = function(row, excludeLastChar) {
  3970. var rowStart = typeof row == "number" ? row : this.lead.row;
  3971. var rowEnd;
  3972. var foldLine = this.session.getFoldLine(rowStart);
  3973. if (foldLine) {
  3974. rowStart = foldLine.start.row;
  3975. rowEnd = foldLine.end.row;
  3976. } else {
  3977. rowEnd = rowStart;
  3978. }
  3979. if (excludeLastChar === true)
  3980. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3981. else
  3982. return new Range(rowStart, 0, rowEnd + 1, 0);
  3983. };
  3984. this.selectLine = function() {
  3985. this.setSelectionRange(this.getLineRange());
  3986. };
  3987. this.moveCursorUp = function() {
  3988. this.moveCursorBy(-1, 0);
  3989. };
  3990. this.moveCursorDown = function() {
  3991. this.moveCursorBy(1, 0);
  3992. };
  3993. this.moveCursorLeft = function() {
  3994. var cursor = this.lead.getPosition(),
  3995. fold;
  3996. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  3997. this.moveCursorTo(fold.start.row, fold.start.column);
  3998. } else if (cursor.column === 0) {
  3999. if (cursor.row > 0) {
  4000. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  4001. }
  4002. }
  4003. else {
  4004. var tabSize = this.session.getTabSize();
  4005. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  4006. this.moveCursorBy(0, -tabSize);
  4007. else
  4008. this.moveCursorBy(0, -1);
  4009. }
  4010. };
  4011. this.moveCursorRight = function() {
  4012. var cursor = this.lead.getPosition(),
  4013. fold;
  4014. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4015. this.moveCursorTo(fold.end.row, fold.end.column);
  4016. }
  4017. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4018. if (this.lead.row < this.doc.getLength() - 1) {
  4019. this.moveCursorTo(this.lead.row + 1, 0);
  4020. }
  4021. }
  4022. else {
  4023. var tabSize = this.session.getTabSize();
  4024. var cursor = this.lead;
  4025. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  4026. this.moveCursorBy(0, tabSize);
  4027. else
  4028. this.moveCursorBy(0, 1);
  4029. }
  4030. };
  4031. this.moveCursorLineStart = function() {
  4032. var row = this.lead.row;
  4033. var column = this.lead.column;
  4034. var screenRow = this.session.documentToScreenRow(row, column);
  4035. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4036. var beforeCursor = this.session.getDisplayLine(
  4037. row, null, firstColumnPosition.row,
  4038. firstColumnPosition.column
  4039. );
  4040. var leadingSpace = beforeCursor.match(/^\s*/);
  4041. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4042. firstColumnPosition.column += leadingSpace[0].length;
  4043. this.moveCursorToPosition(firstColumnPosition);
  4044. };
  4045. this.moveCursorLineEnd = function() {
  4046. var lead = this.lead;
  4047. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4048. if (this.lead.column == lineEnd.column) {
  4049. var line = this.session.getLine(lineEnd.row);
  4050. if (lineEnd.column == line.length) {
  4051. var textEnd = line.search(/\s+$/);
  4052. if (textEnd > 0)
  4053. lineEnd.column = textEnd;
  4054. }
  4055. }
  4056. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4057. };
  4058. this.moveCursorFileEnd = function() {
  4059. var row = this.doc.getLength() - 1;
  4060. var column = this.doc.getLine(row).length;
  4061. this.moveCursorTo(row, column);
  4062. };
  4063. this.moveCursorFileStart = function() {
  4064. this.moveCursorTo(0, 0);
  4065. };
  4066. this.moveCursorLongWordRight = function() {
  4067. var row = this.lead.row;
  4068. var column = this.lead.column;
  4069. var line = this.doc.getLine(row);
  4070. var rightOfCursor = line.substring(column);
  4071. var match;
  4072. this.session.nonTokenRe.lastIndex = 0;
  4073. this.session.tokenRe.lastIndex = 0;
  4074. var fold = this.session.getFoldAt(row, column, 1);
  4075. if (fold) {
  4076. this.moveCursorTo(fold.end.row, fold.end.column);
  4077. return;
  4078. }
  4079. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4080. column += this.session.nonTokenRe.lastIndex;
  4081. this.session.nonTokenRe.lastIndex = 0;
  4082. rightOfCursor = line.substring(column);
  4083. }
  4084. if (column >= line.length) {
  4085. this.moveCursorTo(row, line.length);
  4086. this.moveCursorRight();
  4087. if (row < this.doc.getLength() - 1)
  4088. this.moveCursorWordRight();
  4089. return;
  4090. }
  4091. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4092. column += this.session.tokenRe.lastIndex;
  4093. this.session.tokenRe.lastIndex = 0;
  4094. }
  4095. this.moveCursorTo(row, column);
  4096. };
  4097. this.moveCursorLongWordLeft = function() {
  4098. var row = this.lead.row;
  4099. var column = this.lead.column;
  4100. var fold;
  4101. if (fold = this.session.getFoldAt(row, column, -1)) {
  4102. this.moveCursorTo(fold.start.row, fold.start.column);
  4103. return;
  4104. }
  4105. var str = this.session.getFoldStringAt(row, column, -1);
  4106. if (str == null) {
  4107. str = this.doc.getLine(row).substring(0, column);
  4108. }
  4109. var leftOfCursor = lang.stringReverse(str);
  4110. var match;
  4111. this.session.nonTokenRe.lastIndex = 0;
  4112. this.session.tokenRe.lastIndex = 0;
  4113. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4114. column -= this.session.nonTokenRe.lastIndex;
  4115. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4116. this.session.nonTokenRe.lastIndex = 0;
  4117. }
  4118. if (column <= 0) {
  4119. this.moveCursorTo(row, 0);
  4120. this.moveCursorLeft();
  4121. if (row > 0)
  4122. this.moveCursorWordLeft();
  4123. return;
  4124. }
  4125. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4126. column -= this.session.tokenRe.lastIndex;
  4127. this.session.tokenRe.lastIndex = 0;
  4128. }
  4129. this.moveCursorTo(row, column);
  4130. };
  4131. this.$shortWordEndIndex = function(rightOfCursor) {
  4132. var match, index = 0, ch;
  4133. var whitespaceRe = /\s/;
  4134. var tokenRe = this.session.tokenRe;
  4135. tokenRe.lastIndex = 0;
  4136. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4137. index = this.session.tokenRe.lastIndex;
  4138. } else {
  4139. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4140. index ++;
  4141. if (index < 1) {
  4142. tokenRe.lastIndex = 0;
  4143. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4144. tokenRe.lastIndex = 0;
  4145. index ++;
  4146. if (whitespaceRe.test(ch)) {
  4147. if (index > 2) {
  4148. index--;
  4149. break;
  4150. } else {
  4151. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4152. index ++;
  4153. if (index > 2)
  4154. break;
  4155. }
  4156. }
  4157. }
  4158. }
  4159. }
  4160. tokenRe.lastIndex = 0;
  4161. return index;
  4162. };
  4163. this.moveCursorShortWordRight = function() {
  4164. var row = this.lead.row;
  4165. var column = this.lead.column;
  4166. var line = this.doc.getLine(row);
  4167. var rightOfCursor = line.substring(column);
  4168. var fold = this.session.getFoldAt(row, column, 1);
  4169. if (fold)
  4170. return this.moveCursorTo(fold.end.row, fold.end.column);
  4171. if (column == line.length) {
  4172. var l = this.doc.getLength();
  4173. do {
  4174. row++;
  4175. rightOfCursor = this.doc.getLine(row);
  4176. } while (row < l && /^\s*$/.test(rightOfCursor));
  4177. if (!/^\s+/.test(rightOfCursor))
  4178. rightOfCursor = "";
  4179. column = 0;
  4180. }
  4181. var index = this.$shortWordEndIndex(rightOfCursor);
  4182. this.moveCursorTo(row, column + index);
  4183. };
  4184. this.moveCursorShortWordLeft = function() {
  4185. var row = this.lead.row;
  4186. var column = this.lead.column;
  4187. var fold;
  4188. if (fold = this.session.getFoldAt(row, column, -1))
  4189. return this.moveCursorTo(fold.start.row, fold.start.column);
  4190. var line = this.session.getLine(row).substring(0, column);
  4191. if (column === 0) {
  4192. do {
  4193. row--;
  4194. line = this.doc.getLine(row);
  4195. } while (row > 0 && /^\s*$/.test(line));
  4196. column = line.length;
  4197. if (!/\s+$/.test(line))
  4198. line = "";
  4199. }
  4200. var leftOfCursor = lang.stringReverse(line);
  4201. var index = this.$shortWordEndIndex(leftOfCursor);
  4202. return this.moveCursorTo(row, column - index);
  4203. };
  4204. this.moveCursorWordRight = function() {
  4205. if (this.session.$selectLongWords)
  4206. this.moveCursorLongWordRight();
  4207. else
  4208. this.moveCursorShortWordRight();
  4209. };
  4210. this.moveCursorWordLeft = function() {
  4211. if (this.session.$selectLongWords)
  4212. this.moveCursorLongWordLeft();
  4213. else
  4214. this.moveCursorShortWordLeft();
  4215. };
  4216. this.moveCursorBy = function(rows, chars) {
  4217. var screenPos = this.session.documentToScreenPosition(
  4218. this.lead.row,
  4219. this.lead.column
  4220. );
  4221. if (chars === 0) {
  4222. if (this.$desiredColumn)
  4223. screenPos.column = this.$desiredColumn;
  4224. else
  4225. this.$desiredColumn = screenPos.column;
  4226. }
  4227. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4228. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4229. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row])
  4230. docPos.row++;
  4231. }
  4232. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4233. };
  4234. this.moveCursorToPosition = function(position) {
  4235. this.moveCursorTo(position.row, position.column);
  4236. };
  4237. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4238. var fold = this.session.getFoldAt(row, column, 1);
  4239. if (fold) {
  4240. row = fold.start.row;
  4241. column = fold.start.column;
  4242. }
  4243. this.$keepDesiredColumnOnChange = true;
  4244. this.lead.setPosition(row, column);
  4245. this.$keepDesiredColumnOnChange = false;
  4246. if (!keepDesiredColumn)
  4247. this.$desiredColumn = null;
  4248. };
  4249. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4250. var pos = this.session.screenToDocumentPosition(row, column);
  4251. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4252. };
  4253. this.detach = function() {
  4254. this.lead.detach();
  4255. this.anchor.detach();
  4256. this.session = this.doc = null;
  4257. };
  4258. this.fromOrientedRange = function(range) {
  4259. this.setSelectionRange(range, range.cursor == range.start);
  4260. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4261. };
  4262. this.toOrientedRange = function(range) {
  4263. var r = this.getRange();
  4264. if (range) {
  4265. range.start.column = r.start.column;
  4266. range.start.row = r.start.row;
  4267. range.end.column = r.end.column;
  4268. range.end.row = r.end.row;
  4269. } else {
  4270. range = r;
  4271. }
  4272. range.cursor = this.isBackwards() ? range.start : range.end;
  4273. range.desiredColumn = this.$desiredColumn;
  4274. return range;
  4275. };
  4276. this.getRangeOfMovements = function(func) {
  4277. var start = this.getCursor();
  4278. try {
  4279. func.call(null, this);
  4280. var end = this.getCursor();
  4281. return Range.fromPoints(start,end);
  4282. } catch(e) {
  4283. return Range.fromPoints(start,start);
  4284. } finally {
  4285. this.moveCursorToPosition(start);
  4286. }
  4287. };
  4288. this.toJSON = function() {
  4289. if (this.rangeCount) {
  4290. var data = this.ranges.map(function(r) {
  4291. var r1 = r.clone();
  4292. r1.isBackwards = r.cursor == r.start;
  4293. return r1;
  4294. });
  4295. } else {
  4296. var data = this.getRange();
  4297. data.isBackwards = this.isBackwards();
  4298. }
  4299. return data;
  4300. };
  4301. this.fromJSON = function(data) {
  4302. if (data.start == undefined) {
  4303. if (this.rangeList) {
  4304. this.toSingleRange(data[0]);
  4305. for (var i = data.length; i--; ) {
  4306. var r = Range.fromPoints(data[i].start, data[i].end);
  4307. if (data[i].isBackwards)
  4308. r.cursor = r.start;
  4309. this.addRange(r, true);
  4310. }
  4311. return;
  4312. } else
  4313. data = data[0];
  4314. }
  4315. if (this.rangeList)
  4316. this.toSingleRange(data);
  4317. this.setSelectionRange(data, data.isBackwards);
  4318. };
  4319. this.isEqual = function(data) {
  4320. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4321. return false;
  4322. if (!data.length || !this.ranges)
  4323. return this.getRange().isEqual(data);
  4324. for (var i = this.ranges.length; i--; ) {
  4325. if (!this.ranges[i].isEqual(data[i]))
  4326. return false;
  4327. }
  4328. return true;
  4329. };
  4330. }).call(Selection.prototype);
  4331. exports.Selection = Selection;
  4332. });
  4333. define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4334. "use strict";
  4335. var config = require("./config");
  4336. var MAX_TOKEN_COUNT = 2000;
  4337. var Tokenizer = function(rules) {
  4338. this.states = rules;
  4339. this.regExps = {};
  4340. this.matchMappings = {};
  4341. for (var key in this.states) {
  4342. var state = this.states[key];
  4343. var ruleRegExps = [];
  4344. var matchTotal = 0;
  4345. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4346. var flag = "g";
  4347. var splitterRurles = [];
  4348. for (var i = 0; i < state.length; i++) {
  4349. var rule = state[i];
  4350. if (rule.defaultToken)
  4351. mapping.defaultToken = rule.defaultToken;
  4352. if (rule.caseInsensitive)
  4353. flag = "gi";
  4354. if (rule.regex == null)
  4355. continue;
  4356. if (rule.regex instanceof RegExp)
  4357. rule.regex = rule.regex.toString().slice(1, -1);
  4358. var adjustedregex = rule.regex;
  4359. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4360. if (Array.isArray(rule.token)) {
  4361. if (rule.token.length == 1 || matchcount == 1) {
  4362. rule.token = rule.token[0];
  4363. } else if (matchcount - 1 != rule.token.length) {
  4364. this.reportError("number of classes and regexp groups doesn't match", {
  4365. rule: rule,
  4366. groupCount: matchcount - 1
  4367. });
  4368. rule.token = rule.token[0];
  4369. } else {
  4370. rule.tokenArray = rule.token;
  4371. rule.token = null;
  4372. rule.onMatch = this.$arrayTokens;
  4373. }
  4374. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4375. if (matchcount > 1)
  4376. rule.onMatch = this.$applyToken;
  4377. else
  4378. rule.onMatch = rule.token;
  4379. }
  4380. if (matchcount > 1) {
  4381. if (/\\\d/.test(rule.regex)) {
  4382. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4383. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4384. });
  4385. } else {
  4386. matchcount = 1;
  4387. adjustedregex = this.removeCapturingGroups(rule.regex);
  4388. }
  4389. if (!rule.splitRegex && typeof rule.token != "string")
  4390. splitterRurles.push(rule); // flag will be known only at the very end
  4391. }
  4392. mapping[matchTotal] = i;
  4393. matchTotal += matchcount;
  4394. ruleRegExps.push(adjustedregex);
  4395. if (!rule.onMatch)
  4396. rule.onMatch = null;
  4397. }
  4398. if (!ruleRegExps.length) {
  4399. mapping[0] = 0;
  4400. ruleRegExps.push("$");
  4401. }
  4402. splitterRurles.forEach(function(rule) {
  4403. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4404. }, this);
  4405. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4406. }
  4407. };
  4408. (function() {
  4409. this.$setMaxTokenCount = function(m) {
  4410. MAX_TOKEN_COUNT = m | 0;
  4411. };
  4412. this.$applyToken = function(str) {
  4413. var values = this.splitRegex.exec(str).slice(1);
  4414. var types = this.token.apply(this, values);
  4415. if (typeof types === "string")
  4416. return [{type: types, value: str}];
  4417. var tokens = [];
  4418. for (var i = 0, l = types.length; i < l; i++) {
  4419. if (values[i])
  4420. tokens[tokens.length] = {
  4421. type: types[i],
  4422. value: values[i]
  4423. };
  4424. }
  4425. return tokens;
  4426. },
  4427. this.$arrayTokens = function(str) {
  4428. if (!str)
  4429. return [];
  4430. var values = this.splitRegex.exec(str);
  4431. if (!values)
  4432. return "text";
  4433. var tokens = [];
  4434. var types = this.tokenArray;
  4435. for (var i = 0, l = types.length; i < l; i++) {
  4436. if (values[i + 1])
  4437. tokens[tokens.length] = {
  4438. type: types[i],
  4439. value: values[i + 1]
  4440. };
  4441. }
  4442. return tokens;
  4443. };
  4444. this.removeCapturingGroups = function(src) {
  4445. var r = src.replace(
  4446. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4447. function(x, y) {return y ? "(?:" : x;}
  4448. );
  4449. return r;
  4450. };
  4451. this.createSplitterRegexp = function(src, flag) {
  4452. if (src.indexOf("(?=") != -1) {
  4453. var stack = 0;
  4454. var inChClass = false;
  4455. var lastCapture = {};
  4456. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4457. m, esc, parenOpen, parenClose, square, index
  4458. ) {
  4459. if (inChClass) {
  4460. inChClass = square != "]";
  4461. } else if (square) {
  4462. inChClass = true;
  4463. } else if (parenClose) {
  4464. if (stack == lastCapture.stack) {
  4465. lastCapture.end = index+1;
  4466. lastCapture.stack = -1;
  4467. }
  4468. stack--;
  4469. } else if (parenOpen) {
  4470. stack++;
  4471. if (parenOpen.length != 1) {
  4472. lastCapture.stack = stack
  4473. lastCapture.start = index;
  4474. }
  4475. }
  4476. return m;
  4477. });
  4478. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4479. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4480. }
  4481. return new RegExp(src, (flag||"").replace("g", ""));
  4482. };
  4483. this.getLineTokens = function(line, startState) {
  4484. if (startState && typeof startState != "string") {
  4485. var stack = startState.slice(0);
  4486. startState = stack[0];
  4487. if (startState === "#tmp") {
  4488. stack.shift()
  4489. startState = stack.shift()
  4490. }
  4491. } else
  4492. var stack = [];
  4493. var currentState = startState || "start";
  4494. var state = this.states[currentState];
  4495. if (!state) {
  4496. currentState = "start";
  4497. state = this.states[currentState];
  4498. }
  4499. var mapping = this.matchMappings[currentState];
  4500. var re = this.regExps[currentState];
  4501. re.lastIndex = 0;
  4502. var match, tokens = [];
  4503. var lastIndex = 0;
  4504. var matchAttempts = 0;
  4505. var token = {type: null, value: ""};
  4506. while (match = re.exec(line)) {
  4507. var type = mapping.defaultToken;
  4508. var rule = null;
  4509. var value = match[0];
  4510. var index = re.lastIndex;
  4511. if (index - value.length > lastIndex) {
  4512. var skipped = line.substring(lastIndex, index - value.length);
  4513. if (token.type == type) {
  4514. token.value += skipped;
  4515. } else {
  4516. if (token.type)
  4517. tokens.push(token);
  4518. token = {type: type, value: skipped};
  4519. }
  4520. }
  4521. for (var i = 0; i < match.length-2; i++) {
  4522. if (match[i + 1] === undefined)
  4523. continue;
  4524. rule = state[mapping[i]];
  4525. if (rule.onMatch)
  4526. type = rule.onMatch(value, currentState, stack);
  4527. else
  4528. type = rule.token;
  4529. if (rule.next) {
  4530. if (typeof rule.next == "string") {
  4531. currentState = rule.next;
  4532. } else {
  4533. currentState = rule.next(currentState, stack);
  4534. }
  4535. state = this.states[currentState];
  4536. if (!state) {
  4537. this.reportError("state doesn't exist", currentState);
  4538. currentState = "start";
  4539. state = this.states[currentState];
  4540. }
  4541. mapping = this.matchMappings[currentState];
  4542. lastIndex = index;
  4543. re = this.regExps[currentState];
  4544. re.lastIndex = index;
  4545. }
  4546. break;
  4547. }
  4548. if (value) {
  4549. if (typeof type === "string") {
  4550. if ((!rule || rule.merge !== false) && token.type === type) {
  4551. token.value += value;
  4552. } else {
  4553. if (token.type)
  4554. tokens.push(token);
  4555. token = {type: type, value: value};
  4556. }
  4557. } else if (type) {
  4558. if (token.type)
  4559. tokens.push(token);
  4560. token = {type: null, value: ""};
  4561. for (var i = 0; i < type.length; i++)
  4562. tokens.push(type[i]);
  4563. }
  4564. }
  4565. if (lastIndex == line.length)
  4566. break;
  4567. lastIndex = index;
  4568. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4569. if (matchAttempts > 2 * line.length) {
  4570. this.reportError("infinite loop with in ace tokenizer", {
  4571. startState: startState,
  4572. line: line
  4573. });
  4574. }
  4575. while (lastIndex < line.length) {
  4576. if (token.type)
  4577. tokens.push(token);
  4578. token = {
  4579. value: line.substring(lastIndex, lastIndex += 2000),
  4580. type: "overflow"
  4581. };
  4582. }
  4583. currentState = "start";
  4584. stack = [];
  4585. break;
  4586. }
  4587. }
  4588. if (token.type)
  4589. tokens.push(token);
  4590. if (stack.length > 1) {
  4591. if (stack[0] !== currentState)
  4592. stack.unshift("#tmp", currentState);
  4593. }
  4594. return {
  4595. tokens : tokens,
  4596. state : stack.length ? stack : currentState
  4597. };
  4598. };
  4599. this.reportError = config.reportError;
  4600. }).call(Tokenizer.prototype);
  4601. exports.Tokenizer = Tokenizer;
  4602. });
  4603. define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4604. "use strict";
  4605. var lang = require("../lib/lang");
  4606. var TextHighlightRules = function() {
  4607. this.$rules = {
  4608. "start" : [{
  4609. token : "empty_line",
  4610. regex : '^$'
  4611. }, {
  4612. defaultToken : "text"
  4613. }]
  4614. };
  4615. };
  4616. (function() {
  4617. this.addRules = function(rules, prefix) {
  4618. if (!prefix) {
  4619. for (var key in rules)
  4620. this.$rules[key] = rules[key];
  4621. return;
  4622. }
  4623. for (var key in rules) {
  4624. var state = rules[key];
  4625. for (var i = 0; i < state.length; i++) {
  4626. var rule = state[i];
  4627. if (rule.next || rule.onMatch) {
  4628. if (typeof rule.next != "string") {
  4629. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4630. rule.nextState = prefix + rule.nextState;
  4631. } else {
  4632. if (rule.next.indexOf(prefix) !== 0)
  4633. rule.next = prefix + rule.next;
  4634. }
  4635. }
  4636. }
  4637. this.$rules[prefix + key] = state;
  4638. }
  4639. };
  4640. this.getRules = function() {
  4641. return this.$rules;
  4642. };
  4643. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4644. var embedRules = typeof HighlightRules == "function"
  4645. ? new HighlightRules().getRules()
  4646. : HighlightRules;
  4647. if (states) {
  4648. for (var i = 0; i < states.length; i++)
  4649. states[i] = prefix + states[i];
  4650. } else {
  4651. states = [];
  4652. for (var key in embedRules)
  4653. states.push(prefix + key);
  4654. }
  4655. this.addRules(embedRules, prefix);
  4656. if (escapeRules) {
  4657. var addRules = Array.prototype[append ? "push" : "unshift"];
  4658. for (var i = 0; i < states.length; i++)
  4659. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4660. }
  4661. if (!this.$embeds)
  4662. this.$embeds = [];
  4663. this.$embeds.push(prefix);
  4664. };
  4665. this.getEmbeds = function() {
  4666. return this.$embeds;
  4667. };
  4668. var pushState = function(currentState, stack) {
  4669. if (currentState != "start" || stack.length)
  4670. stack.unshift(this.nextState, currentState);
  4671. return this.nextState;
  4672. };
  4673. var popState = function(currentState, stack) {
  4674. stack.shift();
  4675. return stack.shift() || "start";
  4676. };
  4677. this.normalizeRules = function() {
  4678. var id = 0;
  4679. var rules = this.$rules;
  4680. function processState(key) {
  4681. var state = rules[key];
  4682. state.processed = true;
  4683. for (var i = 0; i < state.length; i++) {
  4684. var rule = state[i];
  4685. if (!rule.regex && rule.start) {
  4686. rule.regex = rule.start;
  4687. if (!rule.next)
  4688. rule.next = [];
  4689. rule.next.push({
  4690. defaultToken: rule.token
  4691. }, {
  4692. token: rule.token + ".end",
  4693. regex: rule.end || rule.start,
  4694. next: "pop"
  4695. });
  4696. rule.token = rule.token + ".start";
  4697. rule.push = true;
  4698. }
  4699. var next = rule.next || rule.push;
  4700. if (next && Array.isArray(next)) {
  4701. var stateName = rule.stateName;
  4702. if (!stateName) {
  4703. stateName = rule.token;
  4704. if (typeof stateName != "string")
  4705. stateName = stateName[0] || "";
  4706. if (rules[stateName])
  4707. stateName += id++;
  4708. }
  4709. rules[stateName] = next;
  4710. rule.next = stateName;
  4711. processState(stateName);
  4712. } else if (next == "pop") {
  4713. rule.next = popState;
  4714. }
  4715. if (rule.push) {
  4716. rule.nextState = rule.next || rule.push;
  4717. rule.next = pushState;
  4718. delete rule.push;
  4719. }
  4720. if (rule.rules) {
  4721. for (var r in rule.rules) {
  4722. if (rules[r]) {
  4723. if (rules[r].push)
  4724. rules[r].push.apply(rules[r], rule.rules[r]);
  4725. } else {
  4726. rules[r] = rule.rules[r];
  4727. }
  4728. }
  4729. }
  4730. if (rule.include || typeof rule == "string") {
  4731. var includeName = rule.include || rule;
  4732. var toInsert = rules[includeName];
  4733. } else if (Array.isArray(rule))
  4734. toInsert = rule;
  4735. if (toInsert) {
  4736. var args = [i, 1].concat(toInsert);
  4737. if (rule.noEscape)
  4738. args = args.filter(function(x) {return !x.next;});
  4739. state.splice.apply(state, args);
  4740. i--;
  4741. toInsert = null;
  4742. }
  4743. if (rule.keywordMap) {
  4744. rule.token = this.createKeywordMapper(
  4745. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4746. );
  4747. delete rule.defaultToken;
  4748. }
  4749. }
  4750. }
  4751. Object.keys(rules).forEach(processState, this);
  4752. };
  4753. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4754. var keywords = Object.create(null);
  4755. Object.keys(map).forEach(function(className) {
  4756. var a = map[className];
  4757. if (ignoreCase)
  4758. a = a.toLowerCase();
  4759. var list = a.split(splitChar || "|");
  4760. for (var i = list.length; i--; )
  4761. keywords[list[i]] = className;
  4762. });
  4763. if (Object.getPrototypeOf(keywords)) {
  4764. keywords.__proto__ = null;
  4765. }
  4766. this.$keywordList = Object.keys(keywords);
  4767. map = null;
  4768. return ignoreCase
  4769. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4770. : function(value) {return keywords[value] || defaultToken };
  4771. };
  4772. this.getKeywords = function() {
  4773. return this.$keywords;
  4774. };
  4775. }).call(TextHighlightRules.prototype);
  4776. exports.TextHighlightRules = TextHighlightRules;
  4777. });
  4778. define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4779. "use strict";
  4780. var Behaviour = function() {
  4781. this.$behaviours = {};
  4782. };
  4783. (function () {
  4784. this.add = function (name, action, callback) {
  4785. switch (undefined) {
  4786. case this.$behaviours:
  4787. this.$behaviours = {};
  4788. case this.$behaviours[name]:
  4789. this.$behaviours[name] = {};
  4790. }
  4791. this.$behaviours[name][action] = callback;
  4792. }
  4793. this.addBehaviours = function (behaviours) {
  4794. for (var key in behaviours) {
  4795. for (var action in behaviours[key]) {
  4796. this.add(key, action, behaviours[key][action]);
  4797. }
  4798. }
  4799. }
  4800. this.remove = function (name) {
  4801. if (this.$behaviours && this.$behaviours[name]) {
  4802. delete this.$behaviours[name];
  4803. }
  4804. }
  4805. this.inherit = function (mode, filter) {
  4806. if (typeof mode === "function") {
  4807. var behaviours = new mode().getBehaviours(filter);
  4808. } else {
  4809. var behaviours = mode.getBehaviours(filter);
  4810. }
  4811. this.addBehaviours(behaviours);
  4812. }
  4813. this.getBehaviours = function (filter) {
  4814. if (!filter) {
  4815. return this.$behaviours;
  4816. } else {
  4817. var ret = {}
  4818. for (var i = 0; i < filter.length; i++) {
  4819. if (this.$behaviours[filter[i]]) {
  4820. ret[filter[i]] = this.$behaviours[filter[i]];
  4821. }
  4822. }
  4823. return ret;
  4824. }
  4825. }
  4826. }).call(Behaviour.prototype);
  4827. exports.Behaviour = Behaviour;
  4828. });
  4829. define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4830. "use strict";
  4831. exports.packages = {};
  4832. addUnicodePackage({
  4833. 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",
  4834. 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",
  4835. 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",
  4836. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4837. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4838. 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",
  4839. 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",
  4840. 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",
  4841. 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",
  4842. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4843. 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",
  4844. 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",
  4845. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4846. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4847. 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",
  4848. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4849. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4850. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4851. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4852. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4853. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4854. 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",
  4855. 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",
  4856. 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",
  4857. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4858. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4859. 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",
  4860. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4861. Zs: "002000A01680180E2000-200A202F205F3000",
  4862. Zl: "2028",
  4863. Zp: "2029",
  4864. 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",
  4865. Cc: "0000-001F007F-009F",
  4866. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4867. Co: "E000-F8FF",
  4868. Cs: "D800-DFFF",
  4869. 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"
  4870. });
  4871. function addUnicodePackage (pack) {
  4872. var codePoint = /\w{4}/g;
  4873. for (var name in pack)
  4874. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4875. };
  4876. });
  4877. define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4878. "use strict";
  4879. var TokenIterator = function(session, initialRow, initialColumn) {
  4880. this.$session = session;
  4881. this.$row = initialRow;
  4882. this.$rowTokens = session.getTokens(initialRow);
  4883. var token = session.getTokenAt(initialRow, initialColumn);
  4884. this.$tokenIndex = token ? token.index : -1;
  4885. };
  4886. (function() {
  4887. this.stepBackward = function() {
  4888. this.$tokenIndex -= 1;
  4889. while (this.$tokenIndex < 0) {
  4890. this.$row -= 1;
  4891. if (this.$row < 0) {
  4892. this.$row = 0;
  4893. return null;
  4894. }
  4895. this.$rowTokens = this.$session.getTokens(this.$row);
  4896. this.$tokenIndex = this.$rowTokens.length - 1;
  4897. }
  4898. return this.$rowTokens[this.$tokenIndex];
  4899. };
  4900. this.stepForward = function() {
  4901. this.$tokenIndex += 1;
  4902. var rowCount;
  4903. while (this.$tokenIndex >= this.$rowTokens.length) {
  4904. this.$row += 1;
  4905. if (!rowCount)
  4906. rowCount = this.$session.getLength();
  4907. if (this.$row >= rowCount) {
  4908. this.$row = rowCount - 1;
  4909. return null;
  4910. }
  4911. this.$rowTokens = this.$session.getTokens(this.$row);
  4912. this.$tokenIndex = 0;
  4913. }
  4914. return this.$rowTokens[this.$tokenIndex];
  4915. };
  4916. this.getCurrentToken = function () {
  4917. return this.$rowTokens[this.$tokenIndex];
  4918. };
  4919. this.getCurrentTokenRow = function () {
  4920. return this.$row;
  4921. };
  4922. this.getCurrentTokenColumn = function() {
  4923. var rowTokens = this.$rowTokens;
  4924. var tokenIndex = this.$tokenIndex;
  4925. var column = rowTokens[tokenIndex].start;
  4926. if (column !== undefined)
  4927. return column;
  4928. column = 0;
  4929. while (tokenIndex > 0) {
  4930. tokenIndex -= 1;
  4931. column += rowTokens[tokenIndex].value.length;
  4932. }
  4933. return column;
  4934. };
  4935. this.getCurrentTokenPosition = function() {
  4936. return {row: this.$row, column: this.getCurrentTokenColumn()};
  4937. };
  4938. }).call(TokenIterator.prototype);
  4939. exports.TokenIterator = TokenIterator;
  4940. });
  4941. 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) {
  4942. "use strict";
  4943. var Tokenizer = require("../tokenizer").Tokenizer;
  4944. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4945. var Behaviour = require("./behaviour").Behaviour;
  4946. var unicode = require("../unicode");
  4947. var lang = require("../lib/lang");
  4948. var TokenIterator = require("../token_iterator").TokenIterator;
  4949. var Range = require("../range").Range;
  4950. var Mode = function() {
  4951. this.HighlightRules = TextHighlightRules;
  4952. this.$behaviour = new Behaviour();
  4953. };
  4954. (function() {
  4955. this.tokenRe = new RegExp("^["
  4956. + unicode.packages.L
  4957. + unicode.packages.Mn + unicode.packages.Mc
  4958. + unicode.packages.Nd
  4959. + unicode.packages.Pc + "\\$_]+", "g"
  4960. );
  4961. this.nonTokenRe = new RegExp("^(?:[^"
  4962. + unicode.packages.L
  4963. + unicode.packages.Mn + unicode.packages.Mc
  4964. + unicode.packages.Nd
  4965. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4966. );
  4967. this.getTokenizer = function() {
  4968. if (!this.$tokenizer) {
  4969. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4970. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4971. }
  4972. return this.$tokenizer;
  4973. };
  4974. this.lineCommentStart = "";
  4975. this.blockComment = "";
  4976. this.toggleCommentLines = function(state, session, startRow, endRow) {
  4977. var doc = session.doc;
  4978. var ignoreBlankLines = true;
  4979. var shouldRemove = true;
  4980. var minIndent = Infinity;
  4981. var tabSize = session.getTabSize();
  4982. var insertAtTabStop = false;
  4983. if (!this.lineCommentStart) {
  4984. if (!this.blockComment)
  4985. return false;
  4986. var lineCommentStart = this.blockComment.start;
  4987. var lineCommentEnd = this.blockComment.end;
  4988. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  4989. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  4990. var comment = function(line, i) {
  4991. if (testRemove(line, i))
  4992. return;
  4993. if (!ignoreBlankLines || /\S/.test(line)) {
  4994. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  4995. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4996. }
  4997. };
  4998. var uncomment = function(line, i) {
  4999. var m;
  5000. if (m = line.match(regexpEnd))
  5001. doc.removeInLine(i, line.length - m[0].length, line.length);
  5002. if (m = line.match(regexpStart))
  5003. doc.removeInLine(i, m[1].length, m[0].length);
  5004. };
  5005. var testRemove = function(line, row) {
  5006. if (regexpStart.test(line))
  5007. return true;
  5008. var tokens = session.getTokens(row);
  5009. for (var i = 0; i < tokens.length; i++) {
  5010. if (tokens[i].type === 'comment')
  5011. return true;
  5012. }
  5013. };
  5014. } else {
  5015. if (Array.isArray(this.lineCommentStart)) {
  5016. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  5017. var lineCommentStart = this.lineCommentStart[0];
  5018. } else {
  5019. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  5020. var lineCommentStart = this.lineCommentStart;
  5021. }
  5022. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  5023. insertAtTabStop = session.getUseSoftTabs();
  5024. var uncomment = function(line, i) {
  5025. var m = line.match(regexpStart);
  5026. if (!m) return;
  5027. var start = m[1].length, end = m[0].length;
  5028. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  5029. end--;
  5030. doc.removeInLine(i, start, end);
  5031. };
  5032. var commentWithSpace = lineCommentStart + " ";
  5033. var comment = function(line, i) {
  5034. if (!ignoreBlankLines || /\S/.test(line)) {
  5035. if (shouldInsertSpace(line, minIndent, minIndent))
  5036. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  5037. else
  5038. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5039. }
  5040. };
  5041. var testRemove = function(line, i) {
  5042. return regexpStart.test(line);
  5043. };
  5044. var shouldInsertSpace = function(line, before, after) {
  5045. var spaces = 0;
  5046. while (before-- && line.charAt(before) == " ")
  5047. spaces++;
  5048. if (spaces % tabSize != 0)
  5049. return false;
  5050. var spaces = 0;
  5051. while (line.charAt(after++) == " ")
  5052. spaces++;
  5053. if (tabSize > 2)
  5054. return spaces % tabSize != tabSize - 1;
  5055. else
  5056. return spaces % tabSize == 0;
  5057. return true;
  5058. };
  5059. }
  5060. function iter(fun) {
  5061. for (var i = startRow; i <= endRow; i++)
  5062. fun(doc.getLine(i), i);
  5063. }
  5064. var minEmptyLength = Infinity;
  5065. iter(function(line, i) {
  5066. var indent = line.search(/\S/);
  5067. if (indent !== -1) {
  5068. if (indent < minIndent)
  5069. minIndent = indent;
  5070. if (shouldRemove && !testRemove(line, i))
  5071. shouldRemove = false;
  5072. } else if (minEmptyLength > line.length) {
  5073. minEmptyLength = line.length;
  5074. }
  5075. });
  5076. if (minIndent == Infinity) {
  5077. minIndent = minEmptyLength;
  5078. ignoreBlankLines = false;
  5079. shouldRemove = false;
  5080. }
  5081. if (insertAtTabStop && minIndent % tabSize != 0)
  5082. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5083. iter(shouldRemove ? uncomment : comment);
  5084. };
  5085. this.toggleBlockComment = function(state, session, range, cursor) {
  5086. var comment = this.blockComment;
  5087. if (!comment)
  5088. return;
  5089. if (!comment.start && comment[0])
  5090. comment = comment[0];
  5091. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5092. var token = iterator.getCurrentToken();
  5093. var sel = session.selection;
  5094. var initialRange = session.selection.toOrientedRange();
  5095. var startRow, colDiff;
  5096. if (token && /comment/.test(token.type)) {
  5097. var startRange, endRange;
  5098. while (token && /comment/.test(token.type)) {
  5099. var i = token.value.indexOf(comment.start);
  5100. if (i != -1) {
  5101. var row = iterator.getCurrentTokenRow();
  5102. var column = iterator.getCurrentTokenColumn() + i;
  5103. startRange = new Range(row, column, row, column + comment.start.length);
  5104. break;
  5105. }
  5106. token = iterator.stepBackward();
  5107. }
  5108. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5109. var token = iterator.getCurrentToken();
  5110. while (token && /comment/.test(token.type)) {
  5111. var i = token.value.indexOf(comment.end);
  5112. if (i != -1) {
  5113. var row = iterator.getCurrentTokenRow();
  5114. var column = iterator.getCurrentTokenColumn() + i;
  5115. endRange = new Range(row, column, row, column + comment.end.length);
  5116. break;
  5117. }
  5118. token = iterator.stepForward();
  5119. }
  5120. if (endRange)
  5121. session.remove(endRange);
  5122. if (startRange) {
  5123. session.remove(startRange);
  5124. startRow = startRange.start.row;
  5125. colDiff = -comment.start.length;
  5126. }
  5127. } else {
  5128. colDiff = comment.start.length;
  5129. startRow = range.start.row;
  5130. session.insert(range.end, comment.end);
  5131. session.insert(range.start, comment.start);
  5132. }
  5133. if (initialRange.start.row == startRow)
  5134. initialRange.start.column += colDiff;
  5135. if (initialRange.end.row == startRow)
  5136. initialRange.end.column += colDiff;
  5137. session.selection.fromOrientedRange(initialRange);
  5138. };
  5139. this.getNextLineIndent = function(state, line, tab) {
  5140. return this.$getIndent(line);
  5141. };
  5142. this.checkOutdent = function(state, line, input) {
  5143. return false;
  5144. };
  5145. this.autoOutdent = function(state, doc, row) {
  5146. };
  5147. this.$getIndent = function(line) {
  5148. return line.match(/^\s*/)[0];
  5149. };
  5150. this.createWorker = function(session) {
  5151. return null;
  5152. };
  5153. this.createModeDelegates = function (mapping) {
  5154. this.$embeds = [];
  5155. this.$modes = {};
  5156. for (var i in mapping) {
  5157. if (mapping[i]) {
  5158. this.$embeds.push(i);
  5159. this.$modes[i] = new mapping[i]();
  5160. }
  5161. }
  5162. var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
  5163. 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
  5164. for (var i = 0; i < delegations.length; i++) {
  5165. (function(scope) {
  5166. var functionName = delegations[i];
  5167. var defaultHandler = scope[functionName];
  5168. scope[delegations[i]] = function() {
  5169. return this.$delegator(functionName, arguments, defaultHandler);
  5170. };
  5171. } (this));
  5172. }
  5173. };
  5174. this.$delegator = function(method, args, defaultHandler) {
  5175. var state = args[0];
  5176. if (typeof state != "string")
  5177. state = state[0];
  5178. for (var i = 0; i < this.$embeds.length; i++) {
  5179. if (!this.$modes[this.$embeds[i]]) continue;
  5180. var split = state.split(this.$embeds[i]);
  5181. if (!split[0] && split[1]) {
  5182. args[0] = split[1];
  5183. var mode = this.$modes[this.$embeds[i]];
  5184. return mode[method].apply(mode, args);
  5185. }
  5186. }
  5187. var ret = defaultHandler.apply(this, args);
  5188. return defaultHandler ? ret : undefined;
  5189. };
  5190. this.transformAction = function(state, action, editor, session, param) {
  5191. if (this.$behaviour) {
  5192. var behaviours = this.$behaviour.getBehaviours();
  5193. for (var key in behaviours) {
  5194. if (behaviours[key][action]) {
  5195. var ret = behaviours[key][action].apply(this, arguments);
  5196. if (ret) {
  5197. return ret;
  5198. }
  5199. }
  5200. }
  5201. }
  5202. };
  5203. this.getKeywords = function(append) {
  5204. if (!this.completionKeywords) {
  5205. var rules = this.$tokenizer.rules;
  5206. var completionKeywords = [];
  5207. for (var rule in rules) {
  5208. var ruleItr = rules[rule];
  5209. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5210. if (typeof ruleItr[r].token === "string") {
  5211. if (/keyword|support|storage/.test(ruleItr[r].token))
  5212. completionKeywords.push(ruleItr[r].regex);
  5213. }
  5214. else if (typeof ruleItr[r].token === "object") {
  5215. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5216. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5217. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5218. completionKeywords.push(rule.substr(1, rule.length - 2));
  5219. }
  5220. }
  5221. }
  5222. }
  5223. }
  5224. this.completionKeywords = completionKeywords;
  5225. }
  5226. if (!append)
  5227. return this.$keywordList;
  5228. return completionKeywords.concat(this.$keywordList || []);
  5229. };
  5230. this.$createKeywordList = function() {
  5231. if (!this.$highlightRules)
  5232. this.getTokenizer();
  5233. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5234. };
  5235. this.getCompletions = function(state, session, pos, prefix) {
  5236. var keywords = this.$keywordList || this.$createKeywordList();
  5237. return keywords.map(function(word) {
  5238. return {
  5239. name: word,
  5240. value: word,
  5241. score: 0,
  5242. meta: "keyword"
  5243. };
  5244. });
  5245. };
  5246. this.$id = "ace/mode/text";
  5247. }).call(Mode.prototype);
  5248. exports.Mode = Mode;
  5249. });
  5250. define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  5251. "use strict";
  5252. function throwDeltaError(delta, errorText){
  5253. console.log("Invalid Delta:", delta);
  5254. throw "Invalid Delta: " + errorText;
  5255. }
  5256. function positionInDocument(docLines, position) {
  5257. return position.row >= 0 && position.row < docLines.length &&
  5258. position.column >= 0 && position.column <= docLines[position.row].length;
  5259. }
  5260. function validateDelta(docLines, delta) {
  5261. if (delta.action != "insert" && delta.action != "remove")
  5262. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  5263. if (!(delta.lines instanceof Array))
  5264. throwDeltaError(delta, "delta.lines must be an Array");
  5265. if (!delta.start || !delta.end)
  5266. throwDeltaError(delta, "delta.start/end must be an present");
  5267. var start = delta.start;
  5268. if (!positionInDocument(docLines, delta.start))
  5269. throwDeltaError(delta, "delta.start must be contained in document");
  5270. var end = delta.end;
  5271. if (delta.action == "remove" && !positionInDocument(docLines, end))
  5272. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  5273. var numRangeRows = end.row - start.row;
  5274. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  5275. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  5276. throwDeltaError(delta, "delta.range must match delta lines");
  5277. }
  5278. exports.applyDelta = function(docLines, delta, doNotValidate) {
  5279. var row = delta.start.row;
  5280. var startColumn = delta.start.column;
  5281. var line = docLines[row] || "";
  5282. switch (delta.action) {
  5283. case "insert":
  5284. var lines = delta.lines;
  5285. if (lines.length === 1) {
  5286. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  5287. } else {
  5288. var args = [row, 1].concat(delta.lines);
  5289. docLines.splice.apply(docLines, args);
  5290. docLines[row] = line.substring(0, startColumn) + docLines[row];
  5291. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  5292. }
  5293. break;
  5294. case "remove":
  5295. var endColumn = delta.end.column;
  5296. var endRow = delta.end.row;
  5297. if (row === endRow) {
  5298. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  5299. } else {
  5300. docLines.splice(
  5301. row, endRow - row + 1,
  5302. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  5303. );
  5304. }
  5305. break;
  5306. }
  5307. }
  5308. });
  5309. define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5310. "use strict";
  5311. var oop = require("./lib/oop");
  5312. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5313. var Anchor = exports.Anchor = function(doc, row, column) {
  5314. this.$onChange = this.onChange.bind(this);
  5315. this.attach(doc);
  5316. if (typeof column == "undefined")
  5317. this.setPosition(row.row, row.column);
  5318. else
  5319. this.setPosition(row, column);
  5320. };
  5321. (function() {
  5322. oop.implement(this, EventEmitter);
  5323. this.getPosition = function() {
  5324. return this.$clipPositionToDocument(this.row, this.column);
  5325. };
  5326. this.getDocument = function() {
  5327. return this.document;
  5328. };
  5329. this.$insertRight = false;
  5330. this.onChange = function(delta) {
  5331. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  5332. return;
  5333. if (delta.start.row > this.row)
  5334. return;
  5335. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  5336. this.setPosition(point.row, point.column, true);
  5337. };
  5338. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  5339. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  5340. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  5341. }
  5342. function $getTransformedPoint(delta, point, moveIfEqual) {
  5343. var deltaIsInsert = delta.action == "insert";
  5344. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  5345. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  5346. var deltaStart = delta.start;
  5347. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  5348. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  5349. return {
  5350. row: point.row,
  5351. column: point.column
  5352. };
  5353. }
  5354. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  5355. return {
  5356. row: point.row + deltaRowShift,
  5357. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  5358. };
  5359. }
  5360. return {
  5361. row: deltaStart.row,
  5362. column: deltaStart.column
  5363. };
  5364. }
  5365. this.setPosition = function(row, column, noClip) {
  5366. var pos;
  5367. if (noClip) {
  5368. pos = {
  5369. row: row,
  5370. column: column
  5371. };
  5372. } else {
  5373. pos = this.$clipPositionToDocument(row, column);
  5374. }
  5375. if (this.row == pos.row && this.column == pos.column)
  5376. return;
  5377. var old = {
  5378. row: this.row,
  5379. column: this.column
  5380. };
  5381. this.row = pos.row;
  5382. this.column = pos.column;
  5383. this._signal("change", {
  5384. old: old,
  5385. value: pos
  5386. });
  5387. };
  5388. this.detach = function() {
  5389. this.document.removeEventListener("change", this.$onChange);
  5390. };
  5391. this.attach = function(doc) {
  5392. this.document = doc || this.document;
  5393. this.document.on("change", this.$onChange);
  5394. };
  5395. this.$clipPositionToDocument = function(row, column) {
  5396. var pos = {};
  5397. if (row >= this.document.getLength()) {
  5398. pos.row = Math.max(0, this.document.getLength() - 1);
  5399. pos.column = this.document.getLine(pos.row).length;
  5400. }
  5401. else if (row < 0) {
  5402. pos.row = 0;
  5403. pos.column = 0;
  5404. }
  5405. else {
  5406. pos.row = row;
  5407. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5408. }
  5409. if (column < 0)
  5410. pos.column = 0;
  5411. return pos;
  5412. };
  5413. }).call(Anchor.prototype);
  5414. });
  5415. define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5416. "use strict";
  5417. var oop = require("./lib/oop");
  5418. var applyDelta = require("./apply_delta").applyDelta;
  5419. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5420. var Range = require("./range").Range;
  5421. var Anchor = require("./anchor").Anchor;
  5422. var Document = function(textOrLines) {
  5423. this.$lines = [""];
  5424. if (textOrLines.length === 0) {
  5425. this.$lines = [""];
  5426. } else if (Array.isArray(textOrLines)) {
  5427. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  5428. } else {
  5429. this.insert({row: 0, column:0}, textOrLines);
  5430. }
  5431. };
  5432. (function() {
  5433. oop.implement(this, EventEmitter);
  5434. this.setValue = function(text) {
  5435. var len = this.getLength() - 1;
  5436. this.remove(new Range(0, 0, len, this.getLine(len).length));
  5437. this.insert({row: 0, column: 0}, text);
  5438. };
  5439. this.getValue = function() {
  5440. return this.getAllLines().join(this.getNewLineCharacter());
  5441. };
  5442. this.createAnchor = function(row, column) {
  5443. return new Anchor(this, row, column);
  5444. };
  5445. if ("aaa".split(/a/).length === 0) {
  5446. this.$split = function(text) {
  5447. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5448. };
  5449. } else {
  5450. this.$split = function(text) {
  5451. return text.split(/\r\n|\r|\n/);
  5452. };
  5453. }
  5454. this.$detectNewLine = function(text) {
  5455. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5456. this.$autoNewLine = match ? match[1] : "\n";
  5457. this._signal("changeNewLineMode");
  5458. };
  5459. this.getNewLineCharacter = function() {
  5460. switch (this.$newLineMode) {
  5461. case "windows":
  5462. return "\r\n";
  5463. case "unix":
  5464. return "\n";
  5465. default:
  5466. return this.$autoNewLine || "\n";
  5467. }
  5468. };
  5469. this.$autoNewLine = "";
  5470. this.$newLineMode = "auto";
  5471. this.setNewLineMode = function(newLineMode) {
  5472. if (this.$newLineMode === newLineMode)
  5473. return;
  5474. this.$newLineMode = newLineMode;
  5475. this._signal("changeNewLineMode");
  5476. };
  5477. this.getNewLineMode = function() {
  5478. return this.$newLineMode;
  5479. };
  5480. this.isNewLine = function(text) {
  5481. return (text == "\r\n" || text == "\r" || text == "\n");
  5482. };
  5483. this.getLine = function(row) {
  5484. return this.$lines[row] || "";
  5485. };
  5486. this.getLines = function(firstRow, lastRow) {
  5487. return this.$lines.slice(firstRow, lastRow + 1);
  5488. };
  5489. this.getAllLines = function() {
  5490. return this.getLines(0, this.getLength());
  5491. };
  5492. this.getLength = function() {
  5493. return this.$lines.length;
  5494. };
  5495. this.getTextRange = function(range) {
  5496. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  5497. };
  5498. this.getLinesForRange = function(range) {
  5499. var lines;
  5500. if (range.start.row === range.end.row) {
  5501. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  5502. } else {
  5503. lines = this.getLines(range.start.row, range.end.row);
  5504. lines[0] = (lines[0] || "").substring(range.start.column);
  5505. var l = lines.length - 1;
  5506. if (range.end.row - range.start.row == l)
  5507. lines[l] = lines[l].substring(0, range.end.column);
  5508. }
  5509. return lines;
  5510. };
  5511. this.insertLines = function(row, lines) {
  5512. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  5513. return this.insertFullLines(row, lines);
  5514. };
  5515. this.removeLines = function(firstRow, lastRow) {
  5516. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  5517. return this.removeFullLines(firstRow, lastRow);
  5518. };
  5519. this.insertNewLine = function(position) {
  5520. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
  5521. return this.insertMergedLines(position, ["", ""]);
  5522. };
  5523. this.insert = function(position, text) {
  5524. if (this.getLength() <= 1)
  5525. this.$detectNewLine(text);
  5526. return this.insertMergedLines(position, this.$split(text));
  5527. };
  5528. this.insertInLine = function(position, text) {
  5529. var start = this.clippedPos(position.row, position.column);
  5530. var end = this.pos(position.row, position.column + text.length);
  5531. this.applyDelta({
  5532. start: start,
  5533. end: end,
  5534. action: "insert",
  5535. lines: [text]
  5536. }, true);
  5537. return this.clonePos(end);
  5538. };
  5539. this.clippedPos = function(row, column) {
  5540. var length = this.getLength();
  5541. if (row === undefined) {
  5542. row = length;
  5543. } else if (row < 0) {
  5544. row = 0;
  5545. } else if (row >= length) {
  5546. row = length - 1;
  5547. column = undefined;
  5548. }
  5549. var line = this.getLine(row);
  5550. if (column == undefined)
  5551. column = line.length;
  5552. column = Math.min(Math.max(column, 0), line.length);
  5553. return {row: row, column: column};
  5554. };
  5555. this.clonePos = function(pos) {
  5556. return {row: pos.row, column: pos.column};
  5557. };
  5558. this.pos = function(row, column) {
  5559. return {row: row, column: column};
  5560. };
  5561. this.$clipPosition = function(position) {
  5562. var length = this.getLength();
  5563. if (position.row >= length) {
  5564. position.row = Math.max(0, length - 1);
  5565. position.column = this.getLine(length - 1).length;
  5566. } else {
  5567. position.row = Math.max(0, position.row);
  5568. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  5569. }
  5570. return position;
  5571. };
  5572. this.insertFullLines = function(row, lines) {
  5573. row = Math.min(Math.max(row, 0), this.getLength());
  5574. var column = 0;
  5575. if (row < this.getLength()) {
  5576. lines = lines.concat([""]);
  5577. column = 0;
  5578. } else {
  5579. lines = [""].concat(lines);
  5580. row--;
  5581. column = this.$lines[row].length;
  5582. }
  5583. this.insertMergedLines({row: row, column: column}, lines);
  5584. };
  5585. this.insertMergedLines = function(position, lines) {
  5586. var start = this.clippedPos(position.row, position.column);
  5587. var end = {
  5588. row: start.row + lines.length - 1,
  5589. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  5590. };
  5591. this.applyDelta({
  5592. start: start,
  5593. end: end,
  5594. action: "insert",
  5595. lines: lines
  5596. });
  5597. return this.clonePos(end);
  5598. };
  5599. this.remove = function(range) {
  5600. var start = this.clippedPos(range.start.row, range.start.column);
  5601. var end = this.clippedPos(range.end.row, range.end.column);
  5602. this.applyDelta({
  5603. start: start,
  5604. end: end,
  5605. action: "remove",
  5606. lines: this.getLinesForRange({start: start, end: end})
  5607. });
  5608. return this.clonePos(start);
  5609. };
  5610. this.removeInLine = function(row, startColumn, endColumn) {
  5611. var start = this.clippedPos(row, startColumn);
  5612. var end = this.clippedPos(row, endColumn);
  5613. this.applyDelta({
  5614. start: start,
  5615. end: end,
  5616. action: "remove",
  5617. lines: this.getLinesForRange({start: start, end: end})
  5618. }, true);
  5619. return this.clonePos(start);
  5620. };
  5621. this.removeFullLines = function(firstRow, lastRow) {
  5622. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  5623. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  5624. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  5625. var deleteLastNewLine = lastRow < this.getLength() - 1;
  5626. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  5627. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  5628. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  5629. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  5630. var range = new Range(startRow, startCol, endRow, endCol);
  5631. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  5632. this.applyDelta({
  5633. start: range.start,
  5634. end: range.end,
  5635. action: "remove",
  5636. lines: this.getLinesForRange(range)
  5637. });
  5638. return deletedLines;
  5639. };
  5640. this.removeNewLine = function(row) {
  5641. if (row < this.getLength() - 1 && row >= 0) {
  5642. this.applyDelta({
  5643. start: this.pos(row, this.getLine(row).length),
  5644. end: this.pos(row + 1, 0),
  5645. action: "remove",
  5646. lines: ["", ""]
  5647. });
  5648. }
  5649. };
  5650. this.replace = function(range, text) {
  5651. if (!range instanceof Range)
  5652. range = Range.fromPoints(range.start, range.end);
  5653. if (text.length === 0 && range.isEmpty())
  5654. return range.start;
  5655. if (text == this.getTextRange(range))
  5656. return range.end;
  5657. this.remove(range);
  5658. var end;
  5659. if (text) {
  5660. end = this.insert(range.start, text);
  5661. }
  5662. else {
  5663. end = range.start;
  5664. }
  5665. return end;
  5666. };
  5667. this.applyDeltas = function(deltas) {
  5668. for (var i=0; i<deltas.length; i++) {
  5669. this.applyDelta(deltas[i]);
  5670. }
  5671. };
  5672. this.revertDeltas = function(deltas) {
  5673. for (var i=deltas.length-1; i>=0; i--) {
  5674. this.revertDelta(deltas[i]);
  5675. }
  5676. };
  5677. this.applyDelta = function(delta, doNotValidate) {
  5678. var isInsert = delta.action == "insert";
  5679. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  5680. : !Range.comparePoints(delta.start, delta.end)) {
  5681. return;
  5682. }
  5683. if (isInsert && delta.lines.length > 20000)
  5684. this.$splitAndapplyLargeDelta(delta, 20000);
  5685. applyDelta(this.$lines, delta, doNotValidate);
  5686. this._signal("change", delta);
  5687. };
  5688. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  5689. var lines = delta.lines;
  5690. var l = lines.length;
  5691. var row = delta.start.row;
  5692. var column = delta.start.column;
  5693. var from = 0, to = 0;
  5694. do {
  5695. from = to;
  5696. to += MAX - 1;
  5697. var chunk = lines.slice(from, to);
  5698. if (to > l) {
  5699. delta.lines = chunk;
  5700. delta.start.row = row + from;
  5701. delta.start.column = column;
  5702. break;
  5703. }
  5704. chunk.push("");
  5705. this.applyDelta({
  5706. start: this.pos(row + from, column),
  5707. end: this.pos(row + to, column = 0),
  5708. action: delta.action,
  5709. lines: chunk
  5710. }, true);
  5711. } while(true);
  5712. };
  5713. this.revertDelta = function(delta) {
  5714. this.applyDelta({
  5715. start: this.clonePos(delta.start),
  5716. end: this.clonePos(delta.end),
  5717. action: (delta.action == "insert" ? "remove" : "insert"),
  5718. lines: delta.lines.slice()
  5719. });
  5720. };
  5721. this.indexToPosition = function(index, startRow) {
  5722. var lines = this.$lines || this.getAllLines();
  5723. var newlineLength = this.getNewLineCharacter().length;
  5724. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5725. index -= lines[i].length + newlineLength;
  5726. if (index < 0)
  5727. return {row: i, column: index + lines[i].length + newlineLength};
  5728. }
  5729. return {row: l-1, column: lines[l-1].length};
  5730. };
  5731. this.positionToIndex = function(pos, startRow) {
  5732. var lines = this.$lines || this.getAllLines();
  5733. var newlineLength = this.getNewLineCharacter().length;
  5734. var index = 0;
  5735. var row = Math.min(pos.row, lines.length);
  5736. for (var i = startRow || 0; i < row; ++i)
  5737. index += lines[i].length + newlineLength;
  5738. return index + pos.column;
  5739. };
  5740. }).call(Document.prototype);
  5741. exports.Document = Document;
  5742. });
  5743. define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5744. "use strict";
  5745. var oop = require("./lib/oop");
  5746. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5747. var BackgroundTokenizer = function(tokenizer, editor) {
  5748. this.running = false;
  5749. this.lines = [];
  5750. this.states = [];
  5751. this.currentLine = 0;
  5752. this.tokenizer = tokenizer;
  5753. var self = this;
  5754. this.$worker = function() {
  5755. if (!self.running) { return; }
  5756. var workerStart = new Date();
  5757. var currentLine = self.currentLine;
  5758. var endLine = -1;
  5759. var doc = self.doc;
  5760. var startLine = currentLine;
  5761. while (self.lines[currentLine])
  5762. currentLine++;
  5763. var len = doc.getLength();
  5764. var processedLines = 0;
  5765. self.running = false;
  5766. while (currentLine < len) {
  5767. self.$tokenizeRow(currentLine);
  5768. endLine = currentLine;
  5769. do {
  5770. currentLine++;
  5771. } while (self.lines[currentLine]);
  5772. processedLines ++;
  5773. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5774. self.running = setTimeout(self.$worker, 20);
  5775. break;
  5776. }
  5777. }
  5778. self.currentLine = currentLine;
  5779. if (startLine <= endLine)
  5780. self.fireUpdateEvent(startLine, endLine);
  5781. };
  5782. };
  5783. (function(){
  5784. oop.implement(this, EventEmitter);
  5785. this.setTokenizer = function(tokenizer) {
  5786. this.tokenizer = tokenizer;
  5787. this.lines = [];
  5788. this.states = [];
  5789. this.start(0);
  5790. };
  5791. this.setDocument = function(doc) {
  5792. this.doc = doc;
  5793. this.lines = [];
  5794. this.states = [];
  5795. this.stop();
  5796. };
  5797. this.fireUpdateEvent = function(firstRow, lastRow) {
  5798. var data = {
  5799. first: firstRow,
  5800. last: lastRow
  5801. };
  5802. this._signal("update", {data: data});
  5803. };
  5804. this.start = function(startRow) {
  5805. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5806. this.lines.splice(this.currentLine, this.lines.length);
  5807. this.states.splice(this.currentLine, this.states.length);
  5808. this.stop();
  5809. this.running = setTimeout(this.$worker, 700);
  5810. };
  5811. this.scheduleStart = function() {
  5812. if (!this.running)
  5813. this.running = setTimeout(this.$worker, 700);
  5814. }
  5815. this.$updateOnChange = function(delta) {
  5816. var startRow = delta.start.row;
  5817. var len = delta.end.row - startRow;
  5818. if (len === 0) {
  5819. this.lines[startRow] = null;
  5820. } else if (delta.action == "remove") {
  5821. this.lines.splice(startRow, len + 1, null);
  5822. this.states.splice(startRow, len + 1, null);
  5823. } else {
  5824. var args = Array(len + 1);
  5825. args.unshift(startRow, 1);
  5826. this.lines.splice.apply(this.lines, args);
  5827. this.states.splice.apply(this.states, args);
  5828. }
  5829. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5830. this.stop();
  5831. };
  5832. this.stop = function() {
  5833. if (this.running)
  5834. clearTimeout(this.running);
  5835. this.running = false;
  5836. };
  5837. this.getTokens = function(row) {
  5838. return this.lines[row] || this.$tokenizeRow(row);
  5839. };
  5840. this.getState = function(row) {
  5841. if (this.currentLine == row)
  5842. this.$tokenizeRow(row);
  5843. return this.states[row] || "start";
  5844. };
  5845. this.$tokenizeRow = function(row) {
  5846. var line = this.doc.getLine(row);
  5847. var state = this.states[row - 1];
  5848. var data = this.tokenizer.getLineTokens(line, state, row);
  5849. if (this.states[row] + "" !== data.state + "") {
  5850. this.states[row] = data.state;
  5851. this.lines[row + 1] = null;
  5852. if (this.currentLine > row + 1)
  5853. this.currentLine = row + 1;
  5854. } else if (this.currentLine == row) {
  5855. this.currentLine = row + 1;
  5856. }
  5857. return this.lines[row] = data.tokens;
  5858. };
  5859. }).call(BackgroundTokenizer.prototype);
  5860. exports.BackgroundTokenizer = BackgroundTokenizer;
  5861. });
  5862. define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5863. "use strict";
  5864. var lang = require("./lib/lang");
  5865. var oop = require("./lib/oop");
  5866. var Range = require("./range").Range;
  5867. var SearchHighlight = function(regExp, clazz, type) {
  5868. this.setRegexp(regExp);
  5869. this.clazz = clazz;
  5870. this.type = type || "text";
  5871. };
  5872. (function() {
  5873. this.MAX_RANGES = 500;
  5874. this.setRegexp = function(regExp) {
  5875. if (this.regExp+"" == regExp+"")
  5876. return;
  5877. this.regExp = regExp;
  5878. this.cache = [];
  5879. };
  5880. this.update = function(html, markerLayer, session, config) {
  5881. if (!this.regExp)
  5882. return;
  5883. var start = config.firstRow, end = config.lastRow;
  5884. for (var i = start; i <= end; i++) {
  5885. var ranges = this.cache[i];
  5886. if (ranges == null) {
  5887. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5888. if (ranges.length > this.MAX_RANGES)
  5889. ranges = ranges.slice(0, this.MAX_RANGES);
  5890. ranges = ranges.map(function(match) {
  5891. return new Range(i, match.offset, i, match.offset + match.length);
  5892. });
  5893. this.cache[i] = ranges.length ? ranges : "";
  5894. }
  5895. for (var j = ranges.length; j --; ) {
  5896. markerLayer.drawSingleLineMarker(
  5897. html, ranges[j].toScreenRange(session), this.clazz, config);
  5898. }
  5899. }
  5900. };
  5901. }).call(SearchHighlight.prototype);
  5902. exports.SearchHighlight = SearchHighlight;
  5903. });
  5904. define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5905. "use strict";
  5906. var Range = require("../range").Range;
  5907. function FoldLine(foldData, folds) {
  5908. this.foldData = foldData;
  5909. if (Array.isArray(folds)) {
  5910. this.folds = folds;
  5911. } else {
  5912. folds = this.folds = [ folds ];
  5913. }
  5914. var last = folds[folds.length - 1];
  5915. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5916. last.end.row, last.end.column);
  5917. this.start = this.range.start;
  5918. this.end = this.range.end;
  5919. this.folds.forEach(function(fold) {
  5920. fold.setFoldLine(this);
  5921. }, this);
  5922. }
  5923. (function() {
  5924. this.shiftRow = function(shift) {
  5925. this.start.row += shift;
  5926. this.end.row += shift;
  5927. this.folds.forEach(function(fold) {
  5928. fold.start.row += shift;
  5929. fold.end.row += shift;
  5930. });
  5931. };
  5932. this.addFold = function(fold) {
  5933. if (fold.sameRow) {
  5934. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5935. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5936. }
  5937. this.folds.push(fold);
  5938. this.folds.sort(function(a, b) {
  5939. return -a.range.compareEnd(b.start.row, b.start.column);
  5940. });
  5941. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5942. this.end.row = fold.end.row;
  5943. this.end.column = fold.end.column;
  5944. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5945. this.start.row = fold.start.row;
  5946. this.start.column = fold.start.column;
  5947. }
  5948. } else if (fold.start.row == this.end.row) {
  5949. this.folds.push(fold);
  5950. this.end.row = fold.end.row;
  5951. this.end.column = fold.end.column;
  5952. } else if (fold.end.row == this.start.row) {
  5953. this.folds.unshift(fold);
  5954. this.start.row = fold.start.row;
  5955. this.start.column = fold.start.column;
  5956. } else {
  5957. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5958. }
  5959. fold.foldLine = this;
  5960. };
  5961. this.containsRow = function(row) {
  5962. return row >= this.start.row && row <= this.end.row;
  5963. };
  5964. this.walk = function(callback, endRow, endColumn) {
  5965. var lastEnd = 0,
  5966. folds = this.folds,
  5967. fold,
  5968. cmp, stop, isNewRow = true;
  5969. if (endRow == null) {
  5970. endRow = this.end.row;
  5971. endColumn = this.end.column;
  5972. }
  5973. for (var i = 0; i < folds.length; i++) {
  5974. fold = folds[i];
  5975. cmp = fold.range.compareStart(endRow, endColumn);
  5976. if (cmp == -1) {
  5977. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5978. return;
  5979. }
  5980. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  5981. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  5982. if (stop || cmp === 0) {
  5983. return;
  5984. }
  5985. isNewRow = !fold.sameRow;
  5986. lastEnd = fold.end.column;
  5987. }
  5988. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5989. };
  5990. this.getNextFoldTo = function(row, column) {
  5991. var fold, cmp;
  5992. for (var i = 0; i < this.folds.length; i++) {
  5993. fold = this.folds[i];
  5994. cmp = fold.range.compareEnd(row, column);
  5995. if (cmp == -1) {
  5996. return {
  5997. fold: fold,
  5998. kind: "after"
  5999. };
  6000. } else if (cmp === 0) {
  6001. return {
  6002. fold: fold,
  6003. kind: "inside"
  6004. };
  6005. }
  6006. }
  6007. return null;
  6008. };
  6009. this.addRemoveChars = function(row, column, len) {
  6010. var ret = this.getNextFoldTo(row, column),
  6011. fold, folds;
  6012. if (ret) {
  6013. fold = ret.fold;
  6014. if (ret.kind == "inside"
  6015. && fold.start.column != column
  6016. && fold.start.row != row)
  6017. {
  6018. window.console && window.console.log(row, column, fold);
  6019. } else if (fold.start.row == row) {
  6020. folds = this.folds;
  6021. var i = folds.indexOf(fold);
  6022. if (i === 0) {
  6023. this.start.column += len;
  6024. }
  6025. for (i; i < folds.length; i++) {
  6026. fold = folds[i];
  6027. fold.start.column += len;
  6028. if (!fold.sameRow) {
  6029. return;
  6030. }
  6031. fold.end.column += len;
  6032. }
  6033. this.end.column += len;
  6034. }
  6035. }
  6036. };
  6037. this.split = function(row, column) {
  6038. var pos = this.getNextFoldTo(row, column);
  6039. if (!pos || pos.kind == "inside")
  6040. return null;
  6041. var fold = pos.fold;
  6042. var folds = this.folds;
  6043. var foldData = this.foldData;
  6044. var i = folds.indexOf(fold);
  6045. var foldBefore = folds[i - 1];
  6046. this.end.row = foldBefore.end.row;
  6047. this.end.column = foldBefore.end.column;
  6048. folds = folds.splice(i, folds.length - i);
  6049. var newFoldLine = new FoldLine(foldData, folds);
  6050. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  6051. return newFoldLine;
  6052. };
  6053. this.merge = function(foldLineNext) {
  6054. var folds = foldLineNext.folds;
  6055. for (var i = 0; i < folds.length; i++) {
  6056. this.addFold(folds[i]);
  6057. }
  6058. var foldData = this.foldData;
  6059. foldData.splice(foldData.indexOf(foldLineNext), 1);
  6060. };
  6061. this.toString = function() {
  6062. var ret = [this.range.toString() + ": [" ];
  6063. this.folds.forEach(function(fold) {
  6064. ret.push(" " + fold.toString());
  6065. });
  6066. ret.push("]");
  6067. return ret.join("\n");
  6068. };
  6069. this.idxToPosition = function(idx) {
  6070. var lastFoldEndColumn = 0;
  6071. for (var i = 0; i < this.folds.length; i++) {
  6072. var fold = this.folds[i];
  6073. idx -= fold.start.column - lastFoldEndColumn;
  6074. if (idx < 0) {
  6075. return {
  6076. row: fold.start.row,
  6077. column: fold.start.column + idx
  6078. };
  6079. }
  6080. idx -= fold.placeholder.length;
  6081. if (idx < 0) {
  6082. return fold.start;
  6083. }
  6084. lastFoldEndColumn = fold.end.column;
  6085. }
  6086. return {
  6087. row: this.end.row,
  6088. column: this.end.column + idx
  6089. };
  6090. };
  6091. }).call(FoldLine.prototype);
  6092. exports.FoldLine = FoldLine;
  6093. });
  6094. define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  6095. "use strict";
  6096. var Range = require("./range").Range;
  6097. var comparePoints = Range.comparePoints;
  6098. var RangeList = function() {
  6099. this.ranges = [];
  6100. };
  6101. (function() {
  6102. this.comparePoints = comparePoints;
  6103. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6104. var list = this.ranges;
  6105. for (var i = startIndex || 0; i < list.length; i++) {
  6106. var range = list[i];
  6107. var cmpEnd = comparePoints(pos, range.end);
  6108. if (cmpEnd > 0)
  6109. continue;
  6110. var cmpStart = comparePoints(pos, range.start);
  6111. if (cmpEnd === 0)
  6112. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6113. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6114. return i;
  6115. return -i-1;
  6116. }
  6117. return -i - 1;
  6118. };
  6119. this.add = function(range) {
  6120. var excludeEdges = !range.isEmpty();
  6121. var startIndex = this.pointIndex(range.start, excludeEdges);
  6122. if (startIndex < 0)
  6123. startIndex = -startIndex - 1;
  6124. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6125. if (endIndex < 0)
  6126. endIndex = -endIndex - 1;
  6127. else
  6128. endIndex++;
  6129. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6130. };
  6131. this.addList = function(list) {
  6132. var removed = [];
  6133. for (var i = list.length; i--; ) {
  6134. removed.push.call(removed, this.add(list[i]));
  6135. }
  6136. return removed;
  6137. };
  6138. this.substractPoint = function(pos) {
  6139. var i = this.pointIndex(pos);
  6140. if (i >= 0)
  6141. return this.ranges.splice(i, 1);
  6142. };
  6143. this.merge = function() {
  6144. var removed = [];
  6145. var list = this.ranges;
  6146. list = list.sort(function(a, b) {
  6147. return comparePoints(a.start, b.start);
  6148. });
  6149. var next = list[0], range;
  6150. for (var i = 1; i < list.length; i++) {
  6151. range = next;
  6152. next = list[i];
  6153. var cmp = comparePoints(range.end, next.start);
  6154. if (cmp < 0)
  6155. continue;
  6156. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6157. continue;
  6158. if (comparePoints(range.end, next.end) < 0) {
  6159. range.end.row = next.end.row;
  6160. range.end.column = next.end.column;
  6161. }
  6162. list.splice(i, 1);
  6163. removed.push(next);
  6164. next = range;
  6165. i--;
  6166. }
  6167. this.ranges = list;
  6168. return removed;
  6169. };
  6170. this.contains = function(row, column) {
  6171. return this.pointIndex({row: row, column: column}) >= 0;
  6172. };
  6173. this.containsPoint = function(pos) {
  6174. return this.pointIndex(pos) >= 0;
  6175. };
  6176. this.rangeAtPoint = function(pos) {
  6177. var i = this.pointIndex(pos);
  6178. if (i >= 0)
  6179. return this.ranges[i];
  6180. };
  6181. this.clipRows = function(startRow, endRow) {
  6182. var list = this.ranges;
  6183. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6184. return [];
  6185. var startIndex = this.pointIndex({row: startRow, column: 0});
  6186. if (startIndex < 0)
  6187. startIndex = -startIndex - 1;
  6188. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6189. if (endIndex < 0)
  6190. endIndex = -endIndex - 1;
  6191. var clipped = [];
  6192. for (var i = startIndex; i < endIndex; i++) {
  6193. clipped.push(list[i]);
  6194. }
  6195. return clipped;
  6196. };
  6197. this.removeAll = function() {
  6198. return this.ranges.splice(0, this.ranges.length);
  6199. };
  6200. this.attach = function(session) {
  6201. if (this.session)
  6202. this.detach();
  6203. this.session = session;
  6204. this.onChange = this.$onChange.bind(this);
  6205. this.session.on('change', this.onChange);
  6206. };
  6207. this.detach = function() {
  6208. if (!this.session)
  6209. return;
  6210. this.session.removeListener('change', this.onChange);
  6211. this.session = null;
  6212. };
  6213. this.$onChange = function(delta) {
  6214. if (delta.action == "insert"){
  6215. var start = delta.start;
  6216. var end = delta.end;
  6217. } else {
  6218. var end = delta.start;
  6219. var start = delta.end;
  6220. }
  6221. var startRow = start.row;
  6222. var endRow = end.row;
  6223. var lineDif = endRow - startRow;
  6224. var colDiff = -start.column + end.column;
  6225. var ranges = this.ranges;
  6226. for (var i = 0, n = ranges.length; i < n; i++) {
  6227. var r = ranges[i];
  6228. if (r.end.row < startRow)
  6229. continue;
  6230. if (r.start.row > startRow)
  6231. break;
  6232. if (r.start.row == startRow && r.start.column >= start.column ) {
  6233. if (r.start.column == start.column && this.$insertRight) {
  6234. } else {
  6235. r.start.column += colDiff;
  6236. r.start.row += lineDif;
  6237. }
  6238. }
  6239. if (r.end.row == startRow && r.end.column >= start.column) {
  6240. if (r.end.column == start.column && this.$insertRight) {
  6241. continue;
  6242. }
  6243. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6244. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6245. r.end.column -= colDiff;
  6246. }
  6247. r.end.column += colDiff;
  6248. r.end.row += lineDif;
  6249. }
  6250. }
  6251. if (lineDif != 0 && i < n) {
  6252. for (; i < n; i++) {
  6253. var r = ranges[i];
  6254. r.start.row += lineDif;
  6255. r.end.row += lineDif;
  6256. }
  6257. }
  6258. };
  6259. }).call(RangeList.prototype);
  6260. exports.RangeList = RangeList;
  6261. });
  6262. define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6263. "use strict";
  6264. var Range = require("../range").Range;
  6265. var RangeList = require("../range_list").RangeList;
  6266. var oop = require("../lib/oop")
  6267. var Fold = exports.Fold = function(range, placeholder) {
  6268. this.foldLine = null;
  6269. this.placeholder = placeholder;
  6270. this.range = range;
  6271. this.start = range.start;
  6272. this.end = range.end;
  6273. this.sameRow = range.start.row == range.end.row;
  6274. this.subFolds = this.ranges = [];
  6275. };
  6276. oop.inherits(Fold, RangeList);
  6277. (function() {
  6278. this.toString = function() {
  6279. return '"' + this.placeholder + '" ' + this.range.toString();
  6280. };
  6281. this.setFoldLine = function(foldLine) {
  6282. this.foldLine = foldLine;
  6283. this.subFolds.forEach(function(fold) {
  6284. fold.setFoldLine(foldLine);
  6285. });
  6286. };
  6287. this.clone = function() {
  6288. var range = this.range.clone();
  6289. var fold = new Fold(range, this.placeholder);
  6290. this.subFolds.forEach(function(subFold) {
  6291. fold.subFolds.push(subFold.clone());
  6292. });
  6293. fold.collapseChildren = this.collapseChildren;
  6294. return fold;
  6295. };
  6296. this.addSubFold = function(fold) {
  6297. if (this.range.isEqual(fold))
  6298. return;
  6299. if (!this.range.containsRange(fold))
  6300. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6301. consumeRange(fold, this.start);
  6302. var row = fold.start.row, column = fold.start.column;
  6303. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6304. cmp = this.subFolds[i].range.compare(row, column);
  6305. if (cmp != 1)
  6306. break;
  6307. }
  6308. var afterStart = this.subFolds[i];
  6309. if (cmp == 0)
  6310. return afterStart.addSubFold(fold);
  6311. var row = fold.range.end.row, column = fold.range.end.column;
  6312. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6313. cmp = this.subFolds[j].range.compare(row, column);
  6314. if (cmp != 1)
  6315. break;
  6316. }
  6317. var afterEnd = this.subFolds[j];
  6318. if (cmp == 0)
  6319. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6320. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6321. fold.setFoldLine(this.foldLine);
  6322. return fold;
  6323. };
  6324. this.restoreRange = function(range) {
  6325. return restoreRange(range, this.start);
  6326. };
  6327. }).call(Fold.prototype);
  6328. function consumePoint(point, anchor) {
  6329. point.row -= anchor.row;
  6330. if (point.row == 0)
  6331. point.column -= anchor.column;
  6332. }
  6333. function consumeRange(range, anchor) {
  6334. consumePoint(range.start, anchor);
  6335. consumePoint(range.end, anchor);
  6336. }
  6337. function restorePoint(point, anchor) {
  6338. if (point.row == 0)
  6339. point.column += anchor.column;
  6340. point.row += anchor.row;
  6341. }
  6342. function restoreRange(range, anchor) {
  6343. restorePoint(range.start, anchor);
  6344. restorePoint(range.end, anchor);
  6345. }
  6346. });
  6347. 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) {
  6348. "use strict";
  6349. var Range = require("../range").Range;
  6350. var FoldLine = require("./fold_line").FoldLine;
  6351. var Fold = require("./fold").Fold;
  6352. var TokenIterator = require("../token_iterator").TokenIterator;
  6353. function Folding() {
  6354. this.getFoldAt = function(row, column, side) {
  6355. var foldLine = this.getFoldLine(row);
  6356. if (!foldLine)
  6357. return null;
  6358. var folds = foldLine.folds;
  6359. for (var i = 0; i < folds.length; i++) {
  6360. var fold = folds[i];
  6361. if (fold.range.contains(row, column)) {
  6362. if (side == 1 && fold.range.isEnd(row, column)) {
  6363. continue;
  6364. } else if (side == -1 && fold.range.isStart(row, column)) {
  6365. continue;
  6366. }
  6367. return fold;
  6368. }
  6369. }
  6370. };
  6371. this.getFoldsInRange = function(range) {
  6372. var start = range.start;
  6373. var end = range.end;
  6374. var foldLines = this.$foldData;
  6375. var foundFolds = [];
  6376. start.column += 1;
  6377. end.column -= 1;
  6378. for (var i = 0; i < foldLines.length; i++) {
  6379. var cmp = foldLines[i].range.compareRange(range);
  6380. if (cmp == 2) {
  6381. continue;
  6382. }
  6383. else if (cmp == -2) {
  6384. break;
  6385. }
  6386. var folds = foldLines[i].folds;
  6387. for (var j = 0; j < folds.length; j++) {
  6388. var fold = folds[j];
  6389. cmp = fold.range.compareRange(range);
  6390. if (cmp == -2) {
  6391. break;
  6392. } else if (cmp == 2) {
  6393. continue;
  6394. } else
  6395. if (cmp == 42) {
  6396. break;
  6397. }
  6398. foundFolds.push(fold);
  6399. }
  6400. }
  6401. start.column -= 1;
  6402. end.column += 1;
  6403. return foundFolds;
  6404. };
  6405. this.getFoldsInRangeList = function(ranges) {
  6406. if (Array.isArray(ranges)) {
  6407. var folds = [];
  6408. ranges.forEach(function(range) {
  6409. folds = folds.concat(this.getFoldsInRange(range));
  6410. }, this);
  6411. } else {
  6412. var folds = this.getFoldsInRange(ranges);
  6413. }
  6414. return folds;
  6415. }
  6416. this.getAllFolds = function() {
  6417. var folds = [];
  6418. var foldLines = this.$foldData;
  6419. for (var i = 0; i < foldLines.length; i++)
  6420. for (var j = 0; j < foldLines[i].folds.length; j++)
  6421. folds.push(foldLines[i].folds[j]);
  6422. return folds;
  6423. };
  6424. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6425. foldLine = foldLine || this.getFoldLine(row);
  6426. if (!foldLine)
  6427. return null;
  6428. var lastFold = {
  6429. end: { column: 0 }
  6430. };
  6431. var str, fold;
  6432. for (var i = 0; i < foldLine.folds.length; i++) {
  6433. fold = foldLine.folds[i];
  6434. var cmp = fold.range.compareEnd(row, column);
  6435. if (cmp == -1) {
  6436. str = this
  6437. .getLine(fold.start.row)
  6438. .substring(lastFold.end.column, fold.start.column);
  6439. break;
  6440. }
  6441. else if (cmp === 0) {
  6442. return null;
  6443. }
  6444. lastFold = fold;
  6445. }
  6446. if (!str)
  6447. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6448. if (trim == -1)
  6449. return str.substring(0, column - lastFold.end.column);
  6450. else if (trim == 1)
  6451. return str.substring(column - lastFold.end.column);
  6452. else
  6453. return str;
  6454. };
  6455. this.getFoldLine = function(docRow, startFoldLine) {
  6456. var foldData = this.$foldData;
  6457. var i = 0;
  6458. if (startFoldLine)
  6459. i = foldData.indexOf(startFoldLine);
  6460. if (i == -1)
  6461. i = 0;
  6462. for (i; i < foldData.length; i++) {
  6463. var foldLine = foldData[i];
  6464. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6465. return foldLine;
  6466. } else if (foldLine.end.row > docRow) {
  6467. return null;
  6468. }
  6469. }
  6470. return null;
  6471. };
  6472. this.getNextFoldLine = function(docRow, startFoldLine) {
  6473. var foldData = this.$foldData;
  6474. var i = 0;
  6475. if (startFoldLine)
  6476. i = foldData.indexOf(startFoldLine);
  6477. if (i == -1)
  6478. i = 0;
  6479. for (i; i < foldData.length; i++) {
  6480. var foldLine = foldData[i];
  6481. if (foldLine.end.row >= docRow) {
  6482. return foldLine;
  6483. }
  6484. }
  6485. return null;
  6486. };
  6487. this.getFoldedRowCount = function(first, last) {
  6488. var foldData = this.$foldData, rowCount = last-first+1;
  6489. for (var i = 0; i < foldData.length; i++) {
  6490. var foldLine = foldData[i],
  6491. end = foldLine.end.row,
  6492. start = foldLine.start.row;
  6493. if (end >= last) {
  6494. if(start < last) {
  6495. if(start >= first)
  6496. rowCount -= last-start;
  6497. else
  6498. rowCount = 0;//in one fold
  6499. }
  6500. break;
  6501. } else if(end >= first){
  6502. if (start >= first) //fold inside range
  6503. rowCount -= end-start;
  6504. else
  6505. rowCount -= end-first+1;
  6506. }
  6507. }
  6508. return rowCount;
  6509. };
  6510. this.$addFoldLine = function(foldLine) {
  6511. this.$foldData.push(foldLine);
  6512. this.$foldData.sort(function(a, b) {
  6513. return a.start.row - b.start.row;
  6514. });
  6515. return foldLine;
  6516. };
  6517. this.addFold = function(placeholder, range) {
  6518. var foldData = this.$foldData;
  6519. var added = false;
  6520. var fold;
  6521. if (placeholder instanceof Fold)
  6522. fold = placeholder;
  6523. else {
  6524. fold = new Fold(range, placeholder);
  6525. fold.collapseChildren = range.collapseChildren;
  6526. }
  6527. this.$clipRangeToDocument(fold.range);
  6528. var startRow = fold.start.row;
  6529. var startColumn = fold.start.column;
  6530. var endRow = fold.end.row;
  6531. var endColumn = fold.end.column;
  6532. if (!(startRow < endRow ||
  6533. startRow == endRow && startColumn <= endColumn - 2))
  6534. throw new Error("The range has to be at least 2 characters width");
  6535. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6536. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6537. if (startFold && endFold == startFold)
  6538. return startFold.addSubFold(fold);
  6539. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6540. this.removeFold(startFold);
  6541. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6542. this.removeFold(endFold);
  6543. var folds = this.getFoldsInRange(fold.range);
  6544. if (folds.length > 0) {
  6545. this.removeFolds(folds);
  6546. folds.forEach(function(subFold) {
  6547. fold.addSubFold(subFold);
  6548. });
  6549. }
  6550. for (var i = 0; i < foldData.length; i++) {
  6551. var foldLine = foldData[i];
  6552. if (endRow == foldLine.start.row) {
  6553. foldLine.addFold(fold);
  6554. added = true;
  6555. break;
  6556. } else if (startRow == foldLine.end.row) {
  6557. foldLine.addFold(fold);
  6558. added = true;
  6559. if (!fold.sameRow) {
  6560. var foldLineNext = foldData[i + 1];
  6561. if (foldLineNext && foldLineNext.start.row == endRow) {
  6562. foldLine.merge(foldLineNext);
  6563. break;
  6564. }
  6565. }
  6566. break;
  6567. } else if (endRow <= foldLine.start.row) {
  6568. break;
  6569. }
  6570. }
  6571. if (!added)
  6572. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6573. if (this.$useWrapMode)
  6574. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6575. else
  6576. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6577. this.$modified = true;
  6578. this._emit("changeFold", { data: fold, action: "add" });
  6579. return fold;
  6580. };
  6581. this.addFolds = function(folds) {
  6582. folds.forEach(function(fold) {
  6583. this.addFold(fold);
  6584. }, this);
  6585. };
  6586. this.removeFold = function(fold) {
  6587. var foldLine = fold.foldLine;
  6588. var startRow = foldLine.start.row;
  6589. var endRow = foldLine.end.row;
  6590. var foldLines = this.$foldData;
  6591. var folds = foldLine.folds;
  6592. if (folds.length == 1) {
  6593. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6594. } else
  6595. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6596. folds.pop();
  6597. foldLine.end.row = folds[folds.length - 1].end.row;
  6598. foldLine.end.column = folds[folds.length - 1].end.column;
  6599. } else
  6600. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6601. folds.shift();
  6602. foldLine.start.row = folds[0].start.row;
  6603. foldLine.start.column = folds[0].start.column;
  6604. } else
  6605. if (fold.sameRow) {
  6606. folds.splice(folds.indexOf(fold), 1);
  6607. } else
  6608. {
  6609. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6610. folds = newFoldLine.folds;
  6611. folds.shift();
  6612. newFoldLine.start.row = folds[0].start.row;
  6613. newFoldLine.start.column = folds[0].start.column;
  6614. }
  6615. if (!this.$updating) {
  6616. if (this.$useWrapMode)
  6617. this.$updateWrapData(startRow, endRow);
  6618. else
  6619. this.$updateRowLengthCache(startRow, endRow);
  6620. }
  6621. this.$modified = true;
  6622. this._emit("changeFold", { data: fold, action: "remove" });
  6623. };
  6624. this.removeFolds = function(folds) {
  6625. var cloneFolds = [];
  6626. for (var i = 0; i < folds.length; i++) {
  6627. cloneFolds.push(folds[i]);
  6628. }
  6629. cloneFolds.forEach(function(fold) {
  6630. this.removeFold(fold);
  6631. }, this);
  6632. this.$modified = true;
  6633. };
  6634. this.expandFold = function(fold) {
  6635. this.removeFold(fold);
  6636. fold.subFolds.forEach(function(subFold) {
  6637. fold.restoreRange(subFold);
  6638. this.addFold(subFold);
  6639. }, this);
  6640. if (fold.collapseChildren > 0) {
  6641. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6642. }
  6643. fold.subFolds = [];
  6644. };
  6645. this.expandFolds = function(folds) {
  6646. folds.forEach(function(fold) {
  6647. this.expandFold(fold);
  6648. }, this);
  6649. };
  6650. this.unfold = function(location, expandInner) {
  6651. var range, folds;
  6652. if (location == null) {
  6653. range = new Range(0, 0, this.getLength(), 0);
  6654. expandInner = true;
  6655. } else if (typeof location == "number")
  6656. range = new Range(location, 0, location, this.getLine(location).length);
  6657. else if ("row" in location)
  6658. range = Range.fromPoints(location, location);
  6659. else
  6660. range = location;
  6661. folds = this.getFoldsInRangeList(range);
  6662. if (expandInner) {
  6663. this.removeFolds(folds);
  6664. } else {
  6665. var subFolds = folds;
  6666. while (subFolds.length) {
  6667. this.expandFolds(subFolds);
  6668. subFolds = this.getFoldsInRangeList(range);
  6669. }
  6670. }
  6671. if (folds.length)
  6672. return folds;
  6673. };
  6674. this.isRowFolded = function(docRow, startFoldRow) {
  6675. return !!this.getFoldLine(docRow, startFoldRow);
  6676. };
  6677. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6678. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6679. return foldLine ? foldLine.end.row : docRow;
  6680. };
  6681. this.getRowFoldStart = function(docRow, startFoldRow) {
  6682. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6683. return foldLine ? foldLine.start.row : docRow;
  6684. };
  6685. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6686. if (startRow == null)
  6687. startRow = foldLine.start.row;
  6688. if (startColumn == null)
  6689. startColumn = 0;
  6690. if (endRow == null)
  6691. endRow = foldLine.end.row;
  6692. if (endColumn == null)
  6693. endColumn = this.getLine(endRow).length;
  6694. var doc = this.doc;
  6695. var textLine = "";
  6696. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6697. if (row < startRow)
  6698. return;
  6699. if (row == startRow) {
  6700. if (column < startColumn)
  6701. return;
  6702. lastColumn = Math.max(startColumn, lastColumn);
  6703. }
  6704. if (placeholder != null) {
  6705. textLine += placeholder;
  6706. } else {
  6707. textLine += doc.getLine(row).substring(lastColumn, column);
  6708. }
  6709. }, endRow, endColumn);
  6710. return textLine;
  6711. };
  6712. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6713. var foldLine = this.getFoldLine(row);
  6714. if (!foldLine) {
  6715. var line;
  6716. line = this.doc.getLine(row);
  6717. return line.substring(startColumn || 0, endColumn || line.length);
  6718. } else {
  6719. return this.getFoldDisplayLine(
  6720. foldLine, row, endColumn, startRow, startColumn);
  6721. }
  6722. };
  6723. this.$cloneFoldData = function() {
  6724. var fd = [];
  6725. fd = this.$foldData.map(function(foldLine) {
  6726. var folds = foldLine.folds.map(function(fold) {
  6727. return fold.clone();
  6728. });
  6729. return new FoldLine(fd, folds);
  6730. });
  6731. return fd;
  6732. };
  6733. this.toggleFold = function(tryToUnfold) {
  6734. var selection = this.selection;
  6735. var range = selection.getRange();
  6736. var fold;
  6737. var bracketPos;
  6738. if (range.isEmpty()) {
  6739. var cursor = range.start;
  6740. fold = this.getFoldAt(cursor.row, cursor.column);
  6741. if (fold) {
  6742. this.expandFold(fold);
  6743. return;
  6744. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6745. if (range.comparePoint(bracketPos) == 1) {
  6746. range.end = bracketPos;
  6747. } else {
  6748. range.start = bracketPos;
  6749. range.start.column++;
  6750. range.end.column--;
  6751. }
  6752. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6753. if (range.comparePoint(bracketPos) == 1)
  6754. range.end = bracketPos;
  6755. else
  6756. range.start = bracketPos;
  6757. range.start.column++;
  6758. } else {
  6759. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6760. }
  6761. } else {
  6762. var folds = this.getFoldsInRange(range);
  6763. if (tryToUnfold && folds.length) {
  6764. this.expandFolds(folds);
  6765. return;
  6766. } else if (folds.length == 1 ) {
  6767. fold = folds[0];
  6768. }
  6769. }
  6770. if (!fold)
  6771. fold = this.getFoldAt(range.start.row, range.start.column);
  6772. if (fold && fold.range.toString() == range.toString()) {
  6773. this.expandFold(fold);
  6774. return;
  6775. }
  6776. var placeholder = "...";
  6777. if (!range.isMultiLine()) {
  6778. placeholder = this.getTextRange(range);
  6779. if(placeholder.length < 4)
  6780. return;
  6781. placeholder = placeholder.trim().substring(0, 2) + "..";
  6782. }
  6783. this.addFold(placeholder, range);
  6784. };
  6785. this.getCommentFoldRange = function(row, column, dir) {
  6786. var iterator = new TokenIterator(this, row, column);
  6787. var token = iterator.getCurrentToken();
  6788. if (token && /^comment|string/.test(token.type)) {
  6789. var range = new Range();
  6790. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6791. if (dir != 1) {
  6792. do {
  6793. token = iterator.stepBackward();
  6794. } while(token && re.test(token.type));
  6795. iterator.stepForward();
  6796. }
  6797. range.start.row = iterator.getCurrentTokenRow();
  6798. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6799. iterator = new TokenIterator(this, row, column);
  6800. if (dir != -1) {
  6801. do {
  6802. token = iterator.stepForward();
  6803. } while(token && re.test(token.type));
  6804. token = iterator.stepBackward();
  6805. } else
  6806. token = iterator.getCurrentToken();
  6807. range.end.row = iterator.getCurrentTokenRow();
  6808. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6809. return range;
  6810. }
  6811. };
  6812. this.foldAll = function(startRow, endRow, depth) {
  6813. if (depth == undefined)
  6814. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6815. var foldWidgets = this.foldWidgets;
  6816. if (!foldWidgets)
  6817. return; // mode doesn't support folding
  6818. endRow = endRow || this.getLength();
  6819. startRow = startRow || 0;
  6820. for (var row = startRow; row < endRow; row++) {
  6821. if (foldWidgets[row] == null)
  6822. foldWidgets[row] = this.getFoldWidget(row);
  6823. if (foldWidgets[row] != "start")
  6824. continue;
  6825. var range = this.getFoldWidgetRange(row);
  6826. if (range && range.isMultiLine()
  6827. && range.end.row <= endRow
  6828. && range.start.row >= startRow
  6829. ) {
  6830. row = range.end.row;
  6831. try {
  6832. var fold = this.addFold("...", range);
  6833. if (fold)
  6834. fold.collapseChildren = depth;
  6835. } catch(e) {}
  6836. }
  6837. }
  6838. };
  6839. this.$foldStyles = {
  6840. "manual": 1,
  6841. "markbegin": 1,
  6842. "markbeginend": 1
  6843. };
  6844. this.$foldStyle = "markbegin";
  6845. this.setFoldStyle = function(style) {
  6846. if (!this.$foldStyles[style])
  6847. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6848. if (this.$foldStyle == style)
  6849. return;
  6850. this.$foldStyle = style;
  6851. if (style == "manual")
  6852. this.unfold();
  6853. var mode = this.$foldMode;
  6854. this.$setFolding(null);
  6855. this.$setFolding(mode);
  6856. };
  6857. this.$setFolding = function(foldMode) {
  6858. if (this.$foldMode == foldMode)
  6859. return;
  6860. this.$foldMode = foldMode;
  6861. this.off('change', this.$updateFoldWidgets);
  6862. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6863. this._emit("changeAnnotation");
  6864. if (!foldMode || this.$foldStyle == "manual") {
  6865. this.foldWidgets = null;
  6866. return;
  6867. }
  6868. this.foldWidgets = [];
  6869. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6870. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6871. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6872. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6873. this.on('change', this.$updateFoldWidgets);
  6874. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6875. };
  6876. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6877. var fw = this.foldWidgets;
  6878. if (!fw || (ignoreCurrent && fw[row]))
  6879. return {};
  6880. var i = row - 1, firstRange;
  6881. while (i >= 0) {
  6882. var c = fw[i];
  6883. if (c == null)
  6884. c = fw[i] = this.getFoldWidget(i);
  6885. if (c == "start") {
  6886. var range = this.getFoldWidgetRange(i);
  6887. if (!firstRange)
  6888. firstRange = range;
  6889. if (range && range.end.row >= row)
  6890. break;
  6891. }
  6892. i--;
  6893. }
  6894. return {
  6895. range: i !== -1 && range,
  6896. firstRange: firstRange
  6897. };
  6898. }
  6899. this.onFoldWidgetClick = function(row, e) {
  6900. e = e.domEvent;
  6901. var options = {
  6902. children: e.shiftKey,
  6903. all: e.ctrlKey || e.metaKey,
  6904. siblings: e.altKey
  6905. };
  6906. var range = this.$toggleFoldWidget(row, options);
  6907. if (!range) {
  6908. var el = (e.target || e.srcElement)
  6909. if (el && /ace_fold-widget/.test(el.className))
  6910. el.className += " ace_invalid";
  6911. }
  6912. };
  6913. this.$toggleFoldWidget = function(row, options) {
  6914. if (!this.getFoldWidget)
  6915. return;
  6916. var type = this.getFoldWidget(row);
  6917. var line = this.getLine(row);
  6918. var dir = type === "end" ? -1 : 1;
  6919. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6920. if (fold) {
  6921. if (options.children || options.all)
  6922. this.removeFold(fold);
  6923. else
  6924. this.expandFold(fold);
  6925. return;
  6926. }
  6927. var range = this.getFoldWidgetRange(row, true);
  6928. if (range && !range.isMultiLine()) {
  6929. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6930. if (fold && range.isEqual(fold.range)) {
  6931. this.removeFold(fold);
  6932. return;
  6933. }
  6934. }
  6935. if (options.siblings) {
  6936. var data = this.getParentFoldRangeData(row);
  6937. if (data.range) {
  6938. var startRow = data.range.start.row + 1;
  6939. var endRow = data.range.end.row;
  6940. }
  6941. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6942. } else if (options.children) {
  6943. endRow = range ? range.end.row : this.getLength();
  6944. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  6945. } else if (range) {
  6946. if (options.all)
  6947. range.collapseChildren = 10000;
  6948. this.addFold("...", range);
  6949. }
  6950. return range;
  6951. };
  6952. this.toggleFoldWidget = function(toggleParent) {
  6953. var row = this.selection.getCursor().row;
  6954. row = this.getRowFoldStart(row);
  6955. var range = this.$toggleFoldWidget(row, {});
  6956. if (range)
  6957. return;
  6958. var data = this.getParentFoldRangeData(row, true);
  6959. range = data.range || data.firstRange;
  6960. if (range) {
  6961. row = range.start.row;
  6962. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6963. if (fold) {
  6964. this.removeFold(fold);
  6965. } else {
  6966. this.addFold("...", range);
  6967. }
  6968. }
  6969. };
  6970. this.updateFoldWidgets = function(delta) {
  6971. var firstRow = delta.start.row;
  6972. var len = delta.end.row - firstRow;
  6973. if (len === 0) {
  6974. this.foldWidgets[firstRow] = null;
  6975. } else if (delta.action == 'remove') {
  6976. this.foldWidgets.splice(firstRow, len + 1, null);
  6977. } else {
  6978. var args = Array(len + 1);
  6979. args.unshift(firstRow, 1);
  6980. this.foldWidgets.splice.apply(this.foldWidgets, args);
  6981. }
  6982. };
  6983. this.tokenizerUpdateFoldWidgets = function(e) {
  6984. var rows = e.data;
  6985. if (rows.first != rows.last) {
  6986. if (this.foldWidgets.length > rows.first)
  6987. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  6988. }
  6989. }
  6990. }
  6991. exports.Folding = Folding;
  6992. });
  6993. define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  6994. "use strict";
  6995. var TokenIterator = require("../token_iterator").TokenIterator;
  6996. var Range = require("../range").Range;
  6997. function BracketMatch() {
  6998. this.findMatchingBracket = function(position, chr) {
  6999. if (position.column == 0) return null;
  7000. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  7001. if (charBeforeCursor == "") return null;
  7002. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  7003. if (!match)
  7004. return null;
  7005. if (match[1])
  7006. return this.$findClosingBracket(match[1], position);
  7007. else
  7008. return this.$findOpeningBracket(match[2], position);
  7009. };
  7010. this.getBracketRange = function(pos) {
  7011. var line = this.getLine(pos.row);
  7012. var before = true, range;
  7013. var chr = line.charAt(pos.column-1);
  7014. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7015. if (!match) {
  7016. chr = line.charAt(pos.column);
  7017. pos = {row: pos.row, column: pos.column + 1};
  7018. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7019. before = false;
  7020. }
  7021. if (!match)
  7022. return null;
  7023. if (match[1]) {
  7024. var bracketPos = this.$findClosingBracket(match[1], pos);
  7025. if (!bracketPos)
  7026. return null;
  7027. range = Range.fromPoints(pos, bracketPos);
  7028. if (!before) {
  7029. range.end.column++;
  7030. range.start.column--;
  7031. }
  7032. range.cursor = range.end;
  7033. } else {
  7034. var bracketPos = this.$findOpeningBracket(match[2], pos);
  7035. if (!bracketPos)
  7036. return null;
  7037. range = Range.fromPoints(bracketPos, pos);
  7038. if (!before) {
  7039. range.start.column++;
  7040. range.end.column--;
  7041. }
  7042. range.cursor = range.start;
  7043. }
  7044. return range;
  7045. };
  7046. this.$brackets = {
  7047. ")": "(",
  7048. "(": ")",
  7049. "]": "[",
  7050. "[": "]",
  7051. "{": "}",
  7052. "}": "{"
  7053. };
  7054. this.$findOpeningBracket = function(bracket, position, typeRe) {
  7055. var openBracket = this.$brackets[bracket];
  7056. var depth = 1;
  7057. var iterator = new TokenIterator(this, position.row, position.column);
  7058. var token = iterator.getCurrentToken();
  7059. if (!token)
  7060. token = iterator.stepForward();
  7061. if (!token)
  7062. return;
  7063. if (!typeRe){
  7064. typeRe = new RegExp(
  7065. "(\\.?" +
  7066. token.type.replace(".", "\\.").replace("rparen", ".paren")
  7067. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  7068. + ")+"
  7069. );
  7070. }
  7071. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  7072. var value = token.value;
  7073. while (true) {
  7074. while (valueIndex >= 0) {
  7075. var chr = value.charAt(valueIndex);
  7076. if (chr == openBracket) {
  7077. depth -= 1;
  7078. if (depth == 0) {
  7079. return {row: iterator.getCurrentTokenRow(),
  7080. column: valueIndex + iterator.getCurrentTokenColumn()};
  7081. }
  7082. }
  7083. else if (chr == bracket) {
  7084. depth += 1;
  7085. }
  7086. valueIndex -= 1;
  7087. }
  7088. do {
  7089. token = iterator.stepBackward();
  7090. } while (token && !typeRe.test(token.type));
  7091. if (token == null)
  7092. break;
  7093. value = token.value;
  7094. valueIndex = value.length - 1;
  7095. }
  7096. return null;
  7097. };
  7098. this.$findClosingBracket = function(bracket, position, typeRe) {
  7099. var closingBracket = this.$brackets[bracket];
  7100. var depth = 1;
  7101. var iterator = new TokenIterator(this, position.row, position.column);
  7102. var token = iterator.getCurrentToken();
  7103. if (!token)
  7104. token = iterator.stepForward();
  7105. if (!token)
  7106. return;
  7107. if (!typeRe){
  7108. typeRe = new RegExp(
  7109. "(\\.?" +
  7110. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7111. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  7112. + ")+"
  7113. );
  7114. }
  7115. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7116. while (true) {
  7117. var value = token.value;
  7118. var valueLength = value.length;
  7119. while (valueIndex < valueLength) {
  7120. var chr = value.charAt(valueIndex);
  7121. if (chr == closingBracket) {
  7122. depth -= 1;
  7123. if (depth == 0) {
  7124. return {row: iterator.getCurrentTokenRow(),
  7125. column: valueIndex + iterator.getCurrentTokenColumn()};
  7126. }
  7127. }
  7128. else if (chr == bracket) {
  7129. depth += 1;
  7130. }
  7131. valueIndex += 1;
  7132. }
  7133. do {
  7134. token = iterator.stepForward();
  7135. } while (token && !typeRe.test(token.type));
  7136. if (token == null)
  7137. break;
  7138. valueIndex = 0;
  7139. }
  7140. return null;
  7141. };
  7142. }
  7143. exports.BracketMatch = BracketMatch;
  7144. });
  7145. 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) {
  7146. "use strict";
  7147. var oop = require("./lib/oop");
  7148. var lang = require("./lib/lang");
  7149. var config = require("./config");
  7150. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7151. var Selection = require("./selection").Selection;
  7152. var TextMode = require("./mode/text").Mode;
  7153. var Range = require("./range").Range;
  7154. var Document = require("./document").Document;
  7155. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7156. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7157. var EditSession = function(text, mode) {
  7158. this.$breakpoints = [];
  7159. this.$decorations = [];
  7160. this.$frontMarkers = {};
  7161. this.$backMarkers = {};
  7162. this.$markerId = 1;
  7163. this.$undoSelect = true;
  7164. this.$foldData = [];
  7165. this.$foldData.toString = function() {
  7166. return this.join("\n");
  7167. };
  7168. this.on("changeFold", this.onChangeFold.bind(this));
  7169. this.$onChange = this.onChange.bind(this);
  7170. if (typeof text != "object" || !text.getLine)
  7171. text = new Document(text);
  7172. this.setDocument(text);
  7173. this.selection = new Selection(this);
  7174. config.resetOptions(this);
  7175. this.setMode(mode);
  7176. config._signal("session", this);
  7177. };
  7178. (function() {
  7179. oop.implement(this, EventEmitter);
  7180. this.setDocument = function(doc) {
  7181. if (this.doc)
  7182. this.doc.removeListener("change", this.$onChange);
  7183. this.doc = doc;
  7184. doc.on("change", this.$onChange);
  7185. if (this.bgTokenizer)
  7186. this.bgTokenizer.setDocument(this.getDocument());
  7187. this.resetCaches();
  7188. };
  7189. this.getDocument = function() {
  7190. return this.doc;
  7191. };
  7192. this.$resetRowCache = function(docRow) {
  7193. if (!docRow) {
  7194. this.$docRowCache = [];
  7195. this.$screenRowCache = [];
  7196. return;
  7197. }
  7198. var l = this.$docRowCache.length;
  7199. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7200. if (l > i) {
  7201. this.$docRowCache.splice(i, l);
  7202. this.$screenRowCache.splice(i, l);
  7203. }
  7204. };
  7205. this.$getRowCacheIndex = function(cacheArray, val) {
  7206. var low = 0;
  7207. var hi = cacheArray.length - 1;
  7208. while (low <= hi) {
  7209. var mid = (low + hi) >> 1;
  7210. var c = cacheArray[mid];
  7211. if (val > c)
  7212. low = mid + 1;
  7213. else if (val < c)
  7214. hi = mid - 1;
  7215. else
  7216. return mid;
  7217. }
  7218. return low -1;
  7219. };
  7220. this.resetCaches = function() {
  7221. this.$modified = true;
  7222. this.$wrapData = [];
  7223. this.$rowLengthCache = [];
  7224. this.$resetRowCache(0);
  7225. if (this.bgTokenizer)
  7226. this.bgTokenizer.start(0);
  7227. };
  7228. this.onChangeFold = function(e) {
  7229. var fold = e.data;
  7230. this.$resetRowCache(fold.start.row);
  7231. };
  7232. this.onChange = function(delta) {
  7233. this.$modified = true;
  7234. this.$resetRowCache(delta.start.row);
  7235. var removedFolds = this.$updateInternalDataOnChange(delta);
  7236. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7237. this.$deltasDoc.push(delta);
  7238. if (removedFolds && removedFolds.length != 0) {
  7239. this.$deltasFold.push({
  7240. action: "removeFolds",
  7241. folds: removedFolds
  7242. });
  7243. }
  7244. this.$informUndoManager.schedule();
  7245. }
  7246. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7247. this._signal("change", delta);
  7248. };
  7249. this.setValue = function(text) {
  7250. this.doc.setValue(text);
  7251. this.selection.moveTo(0, 0);
  7252. this.$resetRowCache(0);
  7253. this.$deltas = [];
  7254. this.$deltasDoc = [];
  7255. this.$deltasFold = [];
  7256. this.setUndoManager(this.$undoManager);
  7257. this.getUndoManager().reset();
  7258. };
  7259. this.getValue =
  7260. this.toString = function() {
  7261. return this.doc.getValue();
  7262. };
  7263. this.getSelection = function() {
  7264. return this.selection;
  7265. };
  7266. this.getState = function(row) {
  7267. return this.bgTokenizer.getState(row);
  7268. };
  7269. this.getTokens = function(row) {
  7270. return this.bgTokenizer.getTokens(row);
  7271. };
  7272. this.getTokenAt = function(row, column) {
  7273. var tokens = this.bgTokenizer.getTokens(row);
  7274. var token, c = 0;
  7275. if (column == null) {
  7276. i = tokens.length - 1;
  7277. c = this.getLine(row).length;
  7278. } else {
  7279. for (var i = 0; i < tokens.length; i++) {
  7280. c += tokens[i].value.length;
  7281. if (c >= column)
  7282. break;
  7283. }
  7284. }
  7285. token = tokens[i];
  7286. if (!token)
  7287. return null;
  7288. token.index = i;
  7289. token.start = c - token.value.length;
  7290. return token;
  7291. };
  7292. this.setUndoManager = function(undoManager) {
  7293. this.$undoManager = undoManager;
  7294. this.$deltas = [];
  7295. this.$deltasDoc = [];
  7296. this.$deltasFold = [];
  7297. if (this.$informUndoManager)
  7298. this.$informUndoManager.cancel();
  7299. if (undoManager) {
  7300. var self = this;
  7301. this.$syncInformUndoManager = function() {
  7302. self.$informUndoManager.cancel();
  7303. if (self.$deltasFold.length) {
  7304. self.$deltas.push({
  7305. group: "fold",
  7306. deltas: self.$deltasFold
  7307. });
  7308. self.$deltasFold = [];
  7309. }
  7310. if (self.$deltasDoc.length) {
  7311. self.$deltas.push({
  7312. group: "doc",
  7313. deltas: self.$deltasDoc
  7314. });
  7315. self.$deltasDoc = [];
  7316. }
  7317. if (self.$deltas.length > 0) {
  7318. undoManager.execute({
  7319. action: "aceupdate",
  7320. args: [self.$deltas, self],
  7321. merge: self.mergeUndoDeltas
  7322. });
  7323. }
  7324. self.mergeUndoDeltas = false;
  7325. self.$deltas = [];
  7326. };
  7327. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7328. }
  7329. };
  7330. this.markUndoGroup = function() {
  7331. if (this.$syncInformUndoManager)
  7332. this.$syncInformUndoManager();
  7333. };
  7334. this.$defaultUndoManager = {
  7335. undo: function() {},
  7336. redo: function() {},
  7337. reset: function() {}
  7338. };
  7339. this.getUndoManager = function() {
  7340. return this.$undoManager || this.$defaultUndoManager;
  7341. };
  7342. this.getTabString = function() {
  7343. if (this.getUseSoftTabs()) {
  7344. return lang.stringRepeat(" ", this.getTabSize());
  7345. } else {
  7346. return "\t";
  7347. }
  7348. };
  7349. this.setUseSoftTabs = function(val) {
  7350. this.setOption("useSoftTabs", val);
  7351. };
  7352. this.getUseSoftTabs = function() {
  7353. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7354. };
  7355. this.setTabSize = function(tabSize) {
  7356. this.setOption("tabSize", tabSize);
  7357. };
  7358. this.getTabSize = function() {
  7359. return this.$tabSize;
  7360. };
  7361. this.isTabStop = function(position) {
  7362. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7363. };
  7364. this.$overwrite = false;
  7365. this.setOverwrite = function(overwrite) {
  7366. this.setOption("overwrite", overwrite);
  7367. };
  7368. this.getOverwrite = function() {
  7369. return this.$overwrite;
  7370. };
  7371. this.toggleOverwrite = function() {
  7372. this.setOverwrite(!this.$overwrite);
  7373. };
  7374. this.addGutterDecoration = function(row, className) {
  7375. if (!this.$decorations[row])
  7376. this.$decorations[row] = "";
  7377. this.$decorations[row] += " " + className;
  7378. this._signal("changeBreakpoint", {});
  7379. };
  7380. this.removeGutterDecoration = function(row, className) {
  7381. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7382. this._signal("changeBreakpoint", {});
  7383. };
  7384. this.getBreakpoints = function() {
  7385. return this.$breakpoints;
  7386. };
  7387. this.setBreakpoints = function(rows) {
  7388. this.$breakpoints = [];
  7389. for (var i=0; i<rows.length; i++) {
  7390. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7391. }
  7392. this._signal("changeBreakpoint", {});
  7393. };
  7394. this.clearBreakpoints = function() {
  7395. this.$breakpoints = [];
  7396. this._signal("changeBreakpoint", {});
  7397. };
  7398. this.setBreakpoint = function(row, className) {
  7399. if (className === undefined)
  7400. className = "ace_breakpoint";
  7401. if (className)
  7402. this.$breakpoints[row] = className;
  7403. else
  7404. delete this.$breakpoints[row];
  7405. this._signal("changeBreakpoint", {});
  7406. };
  7407. this.clearBreakpoint = function(row) {
  7408. delete this.$breakpoints[row];
  7409. this._signal("changeBreakpoint", {});
  7410. };
  7411. this.addMarker = function(range, clazz, type, inFront) {
  7412. var id = this.$markerId++;
  7413. var marker = {
  7414. range : range,
  7415. type : type || "line",
  7416. renderer: typeof type == "function" ? type : null,
  7417. clazz : clazz,
  7418. inFront: !!inFront,
  7419. id: id
  7420. };
  7421. if (inFront) {
  7422. this.$frontMarkers[id] = marker;
  7423. this._signal("changeFrontMarker");
  7424. } else {
  7425. this.$backMarkers[id] = marker;
  7426. this._signal("changeBackMarker");
  7427. }
  7428. return id;
  7429. };
  7430. this.addDynamicMarker = function(marker, inFront) {
  7431. if (!marker.update)
  7432. return;
  7433. var id = this.$markerId++;
  7434. marker.id = id;
  7435. marker.inFront = !!inFront;
  7436. if (inFront) {
  7437. this.$frontMarkers[id] = marker;
  7438. this._signal("changeFrontMarker");
  7439. } else {
  7440. this.$backMarkers[id] = marker;
  7441. this._signal("changeBackMarker");
  7442. }
  7443. return marker;
  7444. };
  7445. this.removeMarker = function(markerId) {
  7446. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7447. if (!marker)
  7448. return;
  7449. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7450. if (marker) {
  7451. delete (markers[markerId]);
  7452. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7453. }
  7454. };
  7455. this.getMarkers = function(inFront) {
  7456. return inFront ? this.$frontMarkers : this.$backMarkers;
  7457. };
  7458. this.highlight = function(re) {
  7459. if (!this.$searchHighlight) {
  7460. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7461. this.$searchHighlight = this.addDynamicMarker(highlight);
  7462. }
  7463. this.$searchHighlight.setRegexp(re);
  7464. };
  7465. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7466. if (typeof endRow != "number") {
  7467. clazz = endRow;
  7468. endRow = startRow;
  7469. }
  7470. if (!clazz)
  7471. clazz = "ace_step";
  7472. var range = new Range(startRow, 0, endRow, Infinity);
  7473. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7474. return range;
  7475. };
  7476. this.setAnnotations = function(annotations) {
  7477. this.$annotations = annotations;
  7478. this._signal("changeAnnotation", {});
  7479. };
  7480. this.getAnnotations = function() {
  7481. return this.$annotations || [];
  7482. };
  7483. this.clearAnnotations = function() {
  7484. this.setAnnotations([]);
  7485. };
  7486. this.$detectNewLine = function(text) {
  7487. var match = text.match(/^.*?(\r?\n)/m);
  7488. if (match) {
  7489. this.$autoNewLine = match[1];
  7490. } else {
  7491. this.$autoNewLine = "\n";
  7492. }
  7493. };
  7494. this.getWordRange = function(row, column) {
  7495. var line = this.getLine(row);
  7496. var inToken = false;
  7497. if (column > 0)
  7498. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7499. if (!inToken)
  7500. inToken = !!line.charAt(column).match(this.tokenRe);
  7501. if (inToken)
  7502. var re = this.tokenRe;
  7503. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7504. var re = /\s/;
  7505. else
  7506. var re = this.nonTokenRe;
  7507. var start = column;
  7508. if (start > 0) {
  7509. do {
  7510. start--;
  7511. }
  7512. while (start >= 0 && line.charAt(start).match(re));
  7513. start++;
  7514. }
  7515. var end = column;
  7516. while (end < line.length && line.charAt(end).match(re)) {
  7517. end++;
  7518. }
  7519. return new Range(row, start, row, end);
  7520. };
  7521. this.getAWordRange = function(row, column) {
  7522. var wordRange = this.getWordRange(row, column);
  7523. var line = this.getLine(wordRange.end.row);
  7524. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7525. wordRange.end.column += 1;
  7526. }
  7527. return wordRange;
  7528. };
  7529. this.setNewLineMode = function(newLineMode) {
  7530. this.doc.setNewLineMode(newLineMode);
  7531. };
  7532. this.getNewLineMode = function() {
  7533. return this.doc.getNewLineMode();
  7534. };
  7535. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7536. this.getUseWorker = function() { return this.$useWorker; };
  7537. this.onReloadTokenizer = function(e) {
  7538. var rows = e.data;
  7539. this.bgTokenizer.start(rows.first);
  7540. this._signal("tokenizerUpdate", e);
  7541. };
  7542. this.$modes = {};
  7543. this.$mode = null;
  7544. this.$modeId = null;
  7545. this.setMode = function(mode, cb) {
  7546. if (mode && typeof mode === "object") {
  7547. if (mode.getTokenizer)
  7548. return this.$onChangeMode(mode);
  7549. var options = mode;
  7550. var path = options.path;
  7551. } else {
  7552. path = mode || "ace/mode/text";
  7553. }
  7554. if (!this.$modes["ace/mode/text"])
  7555. this.$modes["ace/mode/text"] = new TextMode();
  7556. if (this.$modes[path] && !options) {
  7557. this.$onChangeMode(this.$modes[path]);
  7558. cb && cb();
  7559. return;
  7560. }
  7561. this.$modeId = path;
  7562. config.loadModule(["mode", path], function(m) {
  7563. if (this.$modeId !== path)
  7564. return cb && cb();
  7565. if (this.$modes[path] && !options) {
  7566. this.$onChangeMode(this.$modes[path]);
  7567. } else if (m && m.Mode) {
  7568. m = new m.Mode(options);
  7569. if (!options) {
  7570. this.$modes[path] = m;
  7571. m.$id = path;
  7572. }
  7573. this.$onChangeMode(m);
  7574. }
  7575. cb && cb();
  7576. }.bind(this));
  7577. if (!this.$mode)
  7578. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7579. };
  7580. this.$onChangeMode = function(mode, $isPlaceholder) {
  7581. if (!$isPlaceholder)
  7582. this.$modeId = mode.$id;
  7583. if (this.$mode === mode)
  7584. return;
  7585. this.$mode = mode;
  7586. this.$stopWorker();
  7587. if (this.$useWorker)
  7588. this.$startWorker();
  7589. var tokenizer = mode.getTokenizer();
  7590. if(tokenizer.addEventListener !== undefined) {
  7591. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7592. tokenizer.addEventListener("update", onReloadTokenizer);
  7593. }
  7594. if (!this.bgTokenizer) {
  7595. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7596. var _self = this;
  7597. this.bgTokenizer.addEventListener("update", function(e) {
  7598. _self._signal("tokenizerUpdate", e);
  7599. });
  7600. } else {
  7601. this.bgTokenizer.setTokenizer(tokenizer);
  7602. }
  7603. this.bgTokenizer.setDocument(this.getDocument());
  7604. this.tokenRe = mode.tokenRe;
  7605. this.nonTokenRe = mode.nonTokenRe;
  7606. if (!$isPlaceholder) {
  7607. if (mode.attachToSession)
  7608. mode.attachToSession(this);
  7609. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7610. this.$setFolding(mode.foldingRules);
  7611. this.bgTokenizer.start(0);
  7612. this._emit("changeMode");
  7613. }
  7614. };
  7615. this.$stopWorker = function() {
  7616. if (this.$worker) {
  7617. this.$worker.terminate();
  7618. this.$worker = null;
  7619. }
  7620. };
  7621. this.$startWorker = function() {
  7622. try {
  7623. this.$worker = this.$mode.createWorker(this);
  7624. } catch (e) {
  7625. config.warn("Could not load worker", e);
  7626. this.$worker = null;
  7627. }
  7628. };
  7629. this.getMode = function() {
  7630. return this.$mode;
  7631. };
  7632. this.$scrollTop = 0;
  7633. this.setScrollTop = function(scrollTop) {
  7634. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7635. return;
  7636. this.$scrollTop = scrollTop;
  7637. this._signal("changeScrollTop", scrollTop);
  7638. };
  7639. this.getScrollTop = function() {
  7640. return this.$scrollTop;
  7641. };
  7642. this.$scrollLeft = 0;
  7643. this.setScrollLeft = function(scrollLeft) {
  7644. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7645. return;
  7646. this.$scrollLeft = scrollLeft;
  7647. this._signal("changeScrollLeft", scrollLeft);
  7648. };
  7649. this.getScrollLeft = function() {
  7650. return this.$scrollLeft;
  7651. };
  7652. this.getScreenWidth = function() {
  7653. this.$computeWidth();
  7654. if (this.lineWidgets)
  7655. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7656. return this.screenWidth;
  7657. };
  7658. this.getLineWidgetMaxWidth = function() {
  7659. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7660. var width = 0;
  7661. this.lineWidgets.forEach(function(w) {
  7662. if (w && w.screenWidth > width)
  7663. width = w.screenWidth;
  7664. });
  7665. return this.lineWidgetWidth = width;
  7666. };
  7667. this.$computeWidth = function(force) {
  7668. if (this.$modified || force) {
  7669. this.$modified = false;
  7670. if (this.$useWrapMode)
  7671. return this.screenWidth = this.$wrapLimit;
  7672. var lines = this.doc.getAllLines();
  7673. var cache = this.$rowLengthCache;
  7674. var longestScreenLine = 0;
  7675. var foldIndex = 0;
  7676. var foldLine = this.$foldData[foldIndex];
  7677. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7678. var len = lines.length;
  7679. for (var i = 0; i < len; i++) {
  7680. if (i > foldStart) {
  7681. i = foldLine.end.row + 1;
  7682. if (i >= len)
  7683. break;
  7684. foldLine = this.$foldData[foldIndex++];
  7685. foldStart = foldLine ? foldLine.start.row : Infinity;
  7686. }
  7687. if (cache[i] == null)
  7688. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7689. if (cache[i] > longestScreenLine)
  7690. longestScreenLine = cache[i];
  7691. }
  7692. this.screenWidth = longestScreenLine;
  7693. }
  7694. };
  7695. this.getLine = function(row) {
  7696. return this.doc.getLine(row);
  7697. };
  7698. this.getLines = function(firstRow, lastRow) {
  7699. return this.doc.getLines(firstRow, lastRow);
  7700. };
  7701. this.getLength = function() {
  7702. return this.doc.getLength();
  7703. };
  7704. this.getTextRange = function(range) {
  7705. return this.doc.getTextRange(range || this.selection.getRange());
  7706. };
  7707. this.insert = function(position, text) {
  7708. return this.doc.insert(position, text);
  7709. };
  7710. this.remove = function(range) {
  7711. return this.doc.remove(range);
  7712. };
  7713. this.removeFullLines = function(firstRow, lastRow){
  7714. return this.doc.removeFullLines(firstRow, lastRow);
  7715. };
  7716. this.undoChanges = function(deltas, dontSelect) {
  7717. if (!deltas.length)
  7718. return;
  7719. this.$fromUndo = true;
  7720. var lastUndoRange = null;
  7721. for (var i = deltas.length - 1; i != -1; i--) {
  7722. var delta = deltas[i];
  7723. if (delta.group == "doc") {
  7724. this.doc.revertDeltas(delta.deltas);
  7725. lastUndoRange =
  7726. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7727. } else {
  7728. delta.deltas.forEach(function(foldDelta) {
  7729. this.addFolds(foldDelta.folds);
  7730. }, this);
  7731. }
  7732. }
  7733. this.$fromUndo = false;
  7734. lastUndoRange &&
  7735. this.$undoSelect &&
  7736. !dontSelect &&
  7737. this.selection.setSelectionRange(lastUndoRange);
  7738. return lastUndoRange;
  7739. };
  7740. this.redoChanges = function(deltas, dontSelect) {
  7741. if (!deltas.length)
  7742. return;
  7743. this.$fromUndo = true;
  7744. var lastUndoRange = null;
  7745. for (var i = 0; i < deltas.length; i++) {
  7746. var delta = deltas[i];
  7747. if (delta.group == "doc") {
  7748. this.doc.applyDeltas(delta.deltas);
  7749. lastUndoRange =
  7750. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7751. }
  7752. }
  7753. this.$fromUndo = false;
  7754. lastUndoRange &&
  7755. this.$undoSelect &&
  7756. !dontSelect &&
  7757. this.selection.setSelectionRange(lastUndoRange);
  7758. return lastUndoRange;
  7759. };
  7760. this.setUndoSelect = function(enable) {
  7761. this.$undoSelect = enable;
  7762. };
  7763. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7764. function isInsert(delta) {
  7765. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  7766. }
  7767. var delta = deltas[0];
  7768. var range, point;
  7769. var lastDeltaIsInsert = false;
  7770. if (isInsert(delta)) {
  7771. range = Range.fromPoints(delta.start, delta.end);
  7772. lastDeltaIsInsert = true;
  7773. } else {
  7774. range = Range.fromPoints(delta.start, delta.start);
  7775. lastDeltaIsInsert = false;
  7776. }
  7777. for (var i = 1; i < deltas.length; i++) {
  7778. delta = deltas[i];
  7779. if (isInsert(delta)) {
  7780. point = delta.start;
  7781. if (range.compare(point.row, point.column) == -1) {
  7782. range.setStart(point);
  7783. }
  7784. point = delta.end;
  7785. if (range.compare(point.row, point.column) == 1) {
  7786. range.setEnd(point);
  7787. }
  7788. lastDeltaIsInsert = true;
  7789. } else {
  7790. point = delta.start;
  7791. if (range.compare(point.row, point.column) == -1) {
  7792. range = Range.fromPoints(delta.start, delta.start);
  7793. }
  7794. lastDeltaIsInsert = false;
  7795. }
  7796. }
  7797. if (lastUndoRange != null) {
  7798. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7799. lastUndoRange.start.column += range.end.column - range.start.column;
  7800. lastUndoRange.end.column += range.end.column - range.start.column;
  7801. }
  7802. var cmp = lastUndoRange.compareRange(range);
  7803. if (cmp == 1) {
  7804. range.setStart(lastUndoRange.start);
  7805. } else if (cmp == -1) {
  7806. range.setEnd(lastUndoRange.end);
  7807. }
  7808. }
  7809. return range;
  7810. };
  7811. this.replace = function(range, text) {
  7812. return this.doc.replace(range, text);
  7813. };
  7814. this.moveText = function(fromRange, toPosition, copy) {
  7815. var text = this.getTextRange(fromRange);
  7816. var folds = this.getFoldsInRange(fromRange);
  7817. var toRange = Range.fromPoints(toPosition, toPosition);
  7818. if (!copy) {
  7819. this.remove(fromRange);
  7820. var rowDiff = fromRange.start.row - fromRange.end.row;
  7821. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7822. if (collDiff) {
  7823. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7824. toRange.start.column += collDiff;
  7825. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7826. toRange.end.column += collDiff;
  7827. }
  7828. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7829. toRange.start.row += rowDiff;
  7830. toRange.end.row += rowDiff;
  7831. }
  7832. }
  7833. toRange.end = this.insert(toRange.start, text);
  7834. if (folds.length) {
  7835. var oldStart = fromRange.start;
  7836. var newStart = toRange.start;
  7837. var rowDiff = newStart.row - oldStart.row;
  7838. var collDiff = newStart.column - oldStart.column;
  7839. this.addFolds(folds.map(function(x) {
  7840. x = x.clone();
  7841. if (x.start.row == oldStart.row)
  7842. x.start.column += collDiff;
  7843. if (x.end.row == oldStart.row)
  7844. x.end.column += collDiff;
  7845. x.start.row += rowDiff;
  7846. x.end.row += rowDiff;
  7847. return x;
  7848. }));
  7849. }
  7850. return toRange;
  7851. };
  7852. this.indentRows = function(startRow, endRow, indentString) {
  7853. indentString = indentString.replace(/\t/g, this.getTabString());
  7854. for (var row=startRow; row<=endRow; row++)
  7855. this.doc.insertInLine({row: row, column: 0}, indentString);
  7856. };
  7857. this.outdentRows = function (range) {
  7858. var rowRange = range.collapseRows();
  7859. var deleteRange = new Range(0, 0, 0, 0);
  7860. var size = this.getTabSize();
  7861. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7862. var line = this.getLine(i);
  7863. deleteRange.start.row = i;
  7864. deleteRange.end.row = i;
  7865. for (var j = 0; j < size; ++j)
  7866. if (line.charAt(j) != ' ')
  7867. break;
  7868. if (j < size && line.charAt(j) == '\t') {
  7869. deleteRange.start.column = j;
  7870. deleteRange.end.column = j + 1;
  7871. } else {
  7872. deleteRange.start.column = 0;
  7873. deleteRange.end.column = j;
  7874. }
  7875. this.remove(deleteRange);
  7876. }
  7877. };
  7878. this.$moveLines = function(firstRow, lastRow, dir) {
  7879. firstRow = this.getRowFoldStart(firstRow);
  7880. lastRow = this.getRowFoldEnd(lastRow);
  7881. if (dir < 0) {
  7882. var row = this.getRowFoldStart(firstRow + dir);
  7883. if (row < 0) return 0;
  7884. var diff = row-firstRow;
  7885. } else if (dir > 0) {
  7886. var row = this.getRowFoldEnd(lastRow + dir);
  7887. if (row > this.doc.getLength()-1) return 0;
  7888. var diff = row-lastRow;
  7889. } else {
  7890. firstRow = this.$clipRowToDocument(firstRow);
  7891. lastRow = this.$clipRowToDocument(lastRow);
  7892. var diff = lastRow - firstRow + 1;
  7893. }
  7894. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7895. var folds = this.getFoldsInRange(range).map(function(x){
  7896. x = x.clone();
  7897. x.start.row += diff;
  7898. x.end.row += diff;
  7899. return x;
  7900. });
  7901. var lines = dir == 0
  7902. ? this.doc.getLines(firstRow, lastRow)
  7903. : this.doc.removeFullLines(firstRow, lastRow);
  7904. this.doc.insertFullLines(firstRow+diff, lines);
  7905. folds.length && this.addFolds(folds);
  7906. return diff;
  7907. };
  7908. this.moveLinesUp = function(firstRow, lastRow) {
  7909. return this.$moveLines(firstRow, lastRow, -1);
  7910. };
  7911. this.moveLinesDown = function(firstRow, lastRow) {
  7912. return this.$moveLines(firstRow, lastRow, 1);
  7913. };
  7914. this.duplicateLines = function(firstRow, lastRow) {
  7915. return this.$moveLines(firstRow, lastRow, 0);
  7916. };
  7917. this.$clipRowToDocument = function(row) {
  7918. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7919. };
  7920. this.$clipColumnToRow = function(row, column) {
  7921. if (column < 0)
  7922. return 0;
  7923. return Math.min(this.doc.getLine(row).length, column);
  7924. };
  7925. this.$clipPositionToDocument = function(row, column) {
  7926. column = Math.max(0, column);
  7927. if (row < 0) {
  7928. row = 0;
  7929. column = 0;
  7930. } else {
  7931. var len = this.doc.getLength();
  7932. if (row >= len) {
  7933. row = len - 1;
  7934. column = this.doc.getLine(len-1).length;
  7935. } else {
  7936. column = Math.min(this.doc.getLine(row).length, column);
  7937. }
  7938. }
  7939. return {
  7940. row: row,
  7941. column: column
  7942. };
  7943. };
  7944. this.$clipRangeToDocument = function(range) {
  7945. if (range.start.row < 0) {
  7946. range.start.row = 0;
  7947. range.start.column = 0;
  7948. } else {
  7949. range.start.column = this.$clipColumnToRow(
  7950. range.start.row,
  7951. range.start.column
  7952. );
  7953. }
  7954. var len = this.doc.getLength() - 1;
  7955. if (range.end.row > len) {
  7956. range.end.row = len;
  7957. range.end.column = this.doc.getLine(len).length;
  7958. } else {
  7959. range.end.column = this.$clipColumnToRow(
  7960. range.end.row,
  7961. range.end.column
  7962. );
  7963. }
  7964. return range;
  7965. };
  7966. this.$wrapLimit = 80;
  7967. this.$useWrapMode = false;
  7968. this.$wrapLimitRange = {
  7969. min : null,
  7970. max : null
  7971. };
  7972. this.setUseWrapMode = function(useWrapMode) {
  7973. if (useWrapMode != this.$useWrapMode) {
  7974. this.$useWrapMode = useWrapMode;
  7975. this.$modified = true;
  7976. this.$resetRowCache(0);
  7977. if (useWrapMode) {
  7978. var len = this.getLength();
  7979. this.$wrapData = Array(len);
  7980. this.$updateWrapData(0, len - 1);
  7981. }
  7982. this._signal("changeWrapMode");
  7983. }
  7984. };
  7985. this.getUseWrapMode = function() {
  7986. return this.$useWrapMode;
  7987. };
  7988. this.setWrapLimitRange = function(min, max) {
  7989. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  7990. this.$wrapLimitRange = { min: min, max: max };
  7991. this.$modified = true;
  7992. if (this.$useWrapMode)
  7993. this._signal("changeWrapMode");
  7994. }
  7995. };
  7996. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  7997. var limits = this.$wrapLimitRange;
  7998. if (limits.max < 0)
  7999. limits = {min: $printMargin, max: $printMargin};
  8000. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  8001. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  8002. this.$wrapLimit = wrapLimit;
  8003. this.$modified = true;
  8004. if (this.$useWrapMode) {
  8005. this.$updateWrapData(0, this.getLength() - 1);
  8006. this.$resetRowCache(0);
  8007. this._signal("changeWrapLimit");
  8008. }
  8009. return true;
  8010. }
  8011. return false;
  8012. };
  8013. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  8014. if (min)
  8015. wrapLimit = Math.max(min, wrapLimit);
  8016. if (max)
  8017. wrapLimit = Math.min(max, wrapLimit);
  8018. return wrapLimit;
  8019. };
  8020. this.getWrapLimit = function() {
  8021. return this.$wrapLimit;
  8022. };
  8023. this.setWrapLimit = function (limit) {
  8024. this.setWrapLimitRange(limit, limit);
  8025. };
  8026. this.getWrapLimitRange = function() {
  8027. return {
  8028. min : this.$wrapLimitRange.min,
  8029. max : this.$wrapLimitRange.max
  8030. };
  8031. };
  8032. this.$updateInternalDataOnChange = function(delta) {
  8033. var useWrapMode = this.$useWrapMode;
  8034. var action = delta.action;
  8035. var start = delta.start;
  8036. var end = delta.end;
  8037. var firstRow = start.row;
  8038. var lastRow = end.row;
  8039. var len = lastRow - firstRow;
  8040. var removedFolds = null;
  8041. this.$updating = true;
  8042. if (len != 0) {
  8043. if (action === "remove") {
  8044. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  8045. var foldLines = this.$foldData;
  8046. removedFolds = this.getFoldsInRange(delta);
  8047. this.removeFolds(removedFolds);
  8048. var foldLine = this.getFoldLine(end.row);
  8049. var idx = 0;
  8050. if (foldLine) {
  8051. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  8052. foldLine.shiftRow(-len);
  8053. var foldLineBefore = this.getFoldLine(firstRow);
  8054. if (foldLineBefore && foldLineBefore !== foldLine) {
  8055. foldLineBefore.merge(foldLine);
  8056. foldLine = foldLineBefore;
  8057. }
  8058. idx = foldLines.indexOf(foldLine) + 1;
  8059. }
  8060. for (idx; idx < foldLines.length; idx++) {
  8061. var foldLine = foldLines[idx];
  8062. if (foldLine.start.row >= end.row) {
  8063. foldLine.shiftRow(-len);
  8064. }
  8065. }
  8066. lastRow = firstRow;
  8067. } else {
  8068. var args = Array(len);
  8069. args.unshift(firstRow, 0);
  8070. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  8071. arr.splice.apply(arr, args);
  8072. var foldLines = this.$foldData;
  8073. var foldLine = this.getFoldLine(firstRow);
  8074. var idx = 0;
  8075. if (foldLine) {
  8076. var cmp = foldLine.range.compareInside(start.row, start.column);
  8077. if (cmp == 0) {
  8078. foldLine = foldLine.split(start.row, start.column);
  8079. if (foldLine) {
  8080. foldLine.shiftRow(len);
  8081. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  8082. }
  8083. } else
  8084. if (cmp == -1) {
  8085. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8086. foldLine.shiftRow(len);
  8087. }
  8088. idx = foldLines.indexOf(foldLine) + 1;
  8089. }
  8090. for (idx; idx < foldLines.length; idx++) {
  8091. var foldLine = foldLines[idx];
  8092. if (foldLine.start.row >= firstRow) {
  8093. foldLine.shiftRow(len);
  8094. }
  8095. }
  8096. }
  8097. } else {
  8098. len = Math.abs(delta.start.column - delta.end.column);
  8099. if (action === "remove") {
  8100. removedFolds = this.getFoldsInRange(delta);
  8101. this.removeFolds(removedFolds);
  8102. len = -len;
  8103. }
  8104. var foldLine = this.getFoldLine(firstRow);
  8105. if (foldLine) {
  8106. foldLine.addRemoveChars(firstRow, start.column, len);
  8107. }
  8108. }
  8109. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8110. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8111. }
  8112. this.$updating = false;
  8113. if (useWrapMode)
  8114. this.$updateWrapData(firstRow, lastRow);
  8115. else
  8116. this.$updateRowLengthCache(firstRow, lastRow);
  8117. return removedFolds;
  8118. };
  8119. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8120. this.$rowLengthCache[firstRow] = null;
  8121. this.$rowLengthCache[lastRow] = null;
  8122. };
  8123. this.$updateWrapData = function(firstRow, lastRow) {
  8124. var lines = this.doc.getAllLines();
  8125. var tabSize = this.getTabSize();
  8126. var wrapData = this.$wrapData;
  8127. var wrapLimit = this.$wrapLimit;
  8128. var tokens;
  8129. var foldLine;
  8130. var row = firstRow;
  8131. lastRow = Math.min(lastRow, lines.length - 1);
  8132. while (row <= lastRow) {
  8133. foldLine = this.getFoldLine(row, foldLine);
  8134. if (!foldLine) {
  8135. tokens = this.$getDisplayTokens(lines[row]);
  8136. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8137. row ++;
  8138. } else {
  8139. tokens = [];
  8140. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8141. var walkTokens;
  8142. if (placeholder != null) {
  8143. walkTokens = this.$getDisplayTokens(
  8144. placeholder, tokens.length);
  8145. walkTokens[0] = PLACEHOLDER_START;
  8146. for (var i = 1; i < walkTokens.length; i++) {
  8147. walkTokens[i] = PLACEHOLDER_BODY;
  8148. }
  8149. } else {
  8150. walkTokens = this.$getDisplayTokens(
  8151. lines[row].substring(lastColumn, column),
  8152. tokens.length);
  8153. }
  8154. tokens = tokens.concat(walkTokens);
  8155. }.bind(this),
  8156. foldLine.end.row,
  8157. lines[foldLine.end.row].length + 1
  8158. );
  8159. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8160. row = foldLine.end.row + 1;
  8161. }
  8162. }
  8163. };
  8164. var CHAR = 1,
  8165. CHAR_EXT = 2,
  8166. PLACEHOLDER_START = 3,
  8167. PLACEHOLDER_BODY = 4,
  8168. PUNCTUATION = 9,
  8169. SPACE = 10,
  8170. TAB = 11,
  8171. TAB_SPACE = 12;
  8172. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  8173. if (tokens.length == 0) {
  8174. return [];
  8175. }
  8176. var splits = [];
  8177. var displayLength = tokens.length;
  8178. var lastSplit = 0, lastDocSplit = 0;
  8179. var isCode = this.$wrapAsCode;
  8180. var indentedSoftWrap = this.$indentedSoftWrap;
  8181. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  8182. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  8183. function getWrapIndent() {
  8184. var indentation = 0;
  8185. if (maxIndent === 0)
  8186. return indentation;
  8187. if (indentedSoftWrap) {
  8188. for (var i = 0; i < tokens.length; i++) {
  8189. var token = tokens[i];
  8190. if (token == SPACE)
  8191. indentation += 1;
  8192. else if (token == TAB)
  8193. indentation += tabSize;
  8194. else if (token == TAB_SPACE)
  8195. continue;
  8196. else
  8197. break;
  8198. }
  8199. }
  8200. if (isCode && indentedSoftWrap !== false)
  8201. indentation += tabSize;
  8202. return Math.min(indentation, maxIndent);
  8203. }
  8204. function addSplit(screenPos) {
  8205. var displayed = tokens.slice(lastSplit, screenPos);
  8206. var len = displayed.length;
  8207. displayed.join("").
  8208. replace(/12/g, function() {
  8209. len -= 1;
  8210. }).
  8211. replace(/2/g, function() {
  8212. len -= 1;
  8213. });
  8214. if (!splits.length) {
  8215. indent = getWrapIndent();
  8216. splits.indent = indent;
  8217. }
  8218. lastDocSplit += len;
  8219. splits.push(lastDocSplit);
  8220. lastSplit = screenPos;
  8221. }
  8222. var indent = 0;
  8223. while (displayLength - lastSplit > wrapLimit - indent) {
  8224. var split = lastSplit + wrapLimit - indent;
  8225. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8226. addSplit(split);
  8227. continue;
  8228. }
  8229. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8230. for (split; split != lastSplit - 1; split--) {
  8231. if (tokens[split] == PLACEHOLDER_START) {
  8232. break;
  8233. }
  8234. }
  8235. if (split > lastSplit) {
  8236. addSplit(split);
  8237. continue;
  8238. }
  8239. split = lastSplit + wrapLimit;
  8240. for (split; split < tokens.length; split++) {
  8241. if (tokens[split] != PLACEHOLDER_BODY) {
  8242. break;
  8243. }
  8244. }
  8245. if (split == tokens.length) {
  8246. break; // Breaks the while-loop.
  8247. }
  8248. addSplit(split);
  8249. continue;
  8250. }
  8251. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  8252. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8253. split --;
  8254. }
  8255. if (isCode) {
  8256. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8257. split --;
  8258. }
  8259. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8260. split --;
  8261. }
  8262. } else {
  8263. while (split > minSplit && tokens[split] < SPACE) {
  8264. split --;
  8265. }
  8266. }
  8267. if (split > minSplit) {
  8268. addSplit(++split);
  8269. continue;
  8270. }
  8271. split = lastSplit + wrapLimit;
  8272. if (tokens[split] == CHAR_EXT)
  8273. split--;
  8274. addSplit(split - indent);
  8275. }
  8276. return splits;
  8277. };
  8278. this.$getDisplayTokens = function(str, offset) {
  8279. var arr = [];
  8280. var tabSize;
  8281. offset = offset || 0;
  8282. for (var i = 0; i < str.length; i++) {
  8283. var c = str.charCodeAt(i);
  8284. if (c == 9) {
  8285. tabSize = this.getScreenTabSize(arr.length + offset);
  8286. arr.push(TAB);
  8287. for (var n = 1; n < tabSize; n++) {
  8288. arr.push(TAB_SPACE);
  8289. }
  8290. }
  8291. else if (c == 32) {
  8292. arr.push(SPACE);
  8293. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8294. arr.push(PUNCTUATION);
  8295. }
  8296. else if (c >= 0x1100 && isFullWidth(c)) {
  8297. arr.push(CHAR, CHAR_EXT);
  8298. } else {
  8299. arr.push(CHAR);
  8300. }
  8301. }
  8302. return arr;
  8303. };
  8304. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8305. if (maxScreenColumn == 0)
  8306. return [0, 0];
  8307. if (maxScreenColumn == null)
  8308. maxScreenColumn = Infinity;
  8309. screenColumn = screenColumn || 0;
  8310. var c, column;
  8311. for (column = 0; column < str.length; column++) {
  8312. c = str.charCodeAt(column);
  8313. if (c == 9) {
  8314. screenColumn += this.getScreenTabSize(screenColumn);
  8315. }
  8316. else if (c >= 0x1100 && isFullWidth(c)) {
  8317. screenColumn += 2;
  8318. } else {
  8319. screenColumn += 1;
  8320. }
  8321. if (screenColumn > maxScreenColumn) {
  8322. break;
  8323. }
  8324. }
  8325. return [screenColumn, column];
  8326. };
  8327. this.lineWidgets = null;
  8328. this.getRowLength = function(row) {
  8329. if (this.lineWidgets)
  8330. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8331. else
  8332. h = 0
  8333. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8334. return 1 + h;
  8335. } else {
  8336. return this.$wrapData[row].length + 1 + h;
  8337. }
  8338. };
  8339. this.getRowLineCount = function(row) {
  8340. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8341. return 1;
  8342. } else {
  8343. return this.$wrapData[row].length + 1;
  8344. }
  8345. };
  8346. this.getRowWrapIndent = function(screenRow) {
  8347. if (this.$useWrapMode) {
  8348. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8349. var splits = this.$wrapData[pos.row];
  8350. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  8351. } else {
  8352. return 0;
  8353. }
  8354. }
  8355. this.getScreenLastRowColumn = function(screenRow) {
  8356. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8357. return this.documentToScreenColumn(pos.row, pos.column);
  8358. };
  8359. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8360. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8361. return this.getScreenLastRowColumn(screenRow);
  8362. };
  8363. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8364. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8365. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8366. };
  8367. this.getRowSplitData = function(row) {
  8368. if (!this.$useWrapMode) {
  8369. return undefined;
  8370. } else {
  8371. return this.$wrapData[row];
  8372. }
  8373. };
  8374. this.getScreenTabSize = function(screenColumn) {
  8375. return this.$tabSize - screenColumn % this.$tabSize;
  8376. };
  8377. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8378. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8379. };
  8380. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8381. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8382. };
  8383. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8384. if (screenRow < 0)
  8385. return {row: 0, column: 0};
  8386. var line;
  8387. var docRow = 0;
  8388. var docColumn = 0;
  8389. var column;
  8390. var row = 0;
  8391. var rowLength = 0;
  8392. var rowCache = this.$screenRowCache;
  8393. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8394. var l = rowCache.length;
  8395. if (l && i >= 0) {
  8396. var row = rowCache[i];
  8397. var docRow = this.$docRowCache[i];
  8398. var doCache = screenRow > rowCache[l - 1];
  8399. } else {
  8400. var doCache = !l;
  8401. }
  8402. var maxRow = this.getLength() - 1;
  8403. var foldLine = this.getNextFoldLine(docRow);
  8404. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8405. while (row <= screenRow) {
  8406. rowLength = this.getRowLength(docRow);
  8407. if (row + rowLength > screenRow || docRow >= maxRow) {
  8408. break;
  8409. } else {
  8410. row += rowLength;
  8411. docRow++;
  8412. if (docRow > foldStart) {
  8413. docRow = foldLine.end.row+1;
  8414. foldLine = this.getNextFoldLine(docRow, foldLine);
  8415. foldStart = foldLine ? foldLine.start.row : Infinity;
  8416. }
  8417. }
  8418. if (doCache) {
  8419. this.$docRowCache.push(docRow);
  8420. this.$screenRowCache.push(row);
  8421. }
  8422. }
  8423. if (foldLine && foldLine.start.row <= docRow) {
  8424. line = this.getFoldDisplayLine(foldLine);
  8425. docRow = foldLine.start.row;
  8426. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8427. return {
  8428. row: maxRow,
  8429. column: this.getLine(maxRow).length
  8430. };
  8431. } else {
  8432. line = this.getLine(docRow);
  8433. foldLine = null;
  8434. }
  8435. var wrapIndent = 0;
  8436. if (this.$useWrapMode) {
  8437. var splits = this.$wrapData[docRow];
  8438. if (splits) {
  8439. var splitIndex = Math.floor(screenRow - row);
  8440. column = splits[splitIndex];
  8441. if(splitIndex > 0 && splits.length) {
  8442. wrapIndent = splits.indent;
  8443. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8444. line = line.substring(docColumn);
  8445. }
  8446. }
  8447. }
  8448. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  8449. if (this.$useWrapMode && docColumn >= column)
  8450. docColumn = column - 1;
  8451. if (foldLine)
  8452. return foldLine.idxToPosition(docColumn);
  8453. return {row: docRow, column: docColumn};
  8454. };
  8455. this.documentToScreenPosition = function(docRow, docColumn) {
  8456. if (typeof docColumn === "undefined")
  8457. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8458. else
  8459. pos = this.$clipPositionToDocument(docRow, docColumn);
  8460. docRow = pos.row;
  8461. docColumn = pos.column;
  8462. var screenRow = 0;
  8463. var foldStartRow = null;
  8464. var fold = null;
  8465. fold = this.getFoldAt(docRow, docColumn, 1);
  8466. if (fold) {
  8467. docRow = fold.start.row;
  8468. docColumn = fold.start.column;
  8469. }
  8470. var rowEnd, row = 0;
  8471. var rowCache = this.$docRowCache;
  8472. var i = this.$getRowCacheIndex(rowCache, docRow);
  8473. var l = rowCache.length;
  8474. if (l && i >= 0) {
  8475. var row = rowCache[i];
  8476. var screenRow = this.$screenRowCache[i];
  8477. var doCache = docRow > rowCache[l - 1];
  8478. } else {
  8479. var doCache = !l;
  8480. }
  8481. var foldLine = this.getNextFoldLine(row);
  8482. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8483. while (row < docRow) {
  8484. if (row >= foldStart) {
  8485. rowEnd = foldLine.end.row + 1;
  8486. if (rowEnd > docRow)
  8487. break;
  8488. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8489. foldStart = foldLine ?foldLine.start.row :Infinity;
  8490. }
  8491. else {
  8492. rowEnd = row + 1;
  8493. }
  8494. screenRow += this.getRowLength(row);
  8495. row = rowEnd;
  8496. if (doCache) {
  8497. this.$docRowCache.push(row);
  8498. this.$screenRowCache.push(screenRow);
  8499. }
  8500. }
  8501. var textLine = "";
  8502. if (foldLine && row >= foldStart) {
  8503. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8504. foldStartRow = foldLine.start.row;
  8505. } else {
  8506. textLine = this.getLine(docRow).substring(0, docColumn);
  8507. foldStartRow = docRow;
  8508. }
  8509. var wrapIndent = 0;
  8510. if (this.$useWrapMode) {
  8511. var wrapRow = this.$wrapData[foldStartRow];
  8512. if (wrapRow) {
  8513. var screenRowOffset = 0;
  8514. while (textLine.length >= wrapRow[screenRowOffset]) {
  8515. screenRow ++;
  8516. screenRowOffset++;
  8517. }
  8518. textLine = textLine.substring(
  8519. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8520. );
  8521. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  8522. }
  8523. }
  8524. return {
  8525. row: screenRow,
  8526. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  8527. };
  8528. };
  8529. this.documentToScreenColumn = function(row, docColumn) {
  8530. return this.documentToScreenPosition(row, docColumn).column;
  8531. };
  8532. this.documentToScreenRow = function(docRow, docColumn) {
  8533. return this.documentToScreenPosition(docRow, docColumn).row;
  8534. };
  8535. this.getScreenLength = function() {
  8536. var screenRows = 0;
  8537. var fold = null;
  8538. if (!this.$useWrapMode) {
  8539. screenRows = this.getLength();
  8540. var foldData = this.$foldData;
  8541. for (var i = 0; i < foldData.length; i++) {
  8542. fold = foldData[i];
  8543. screenRows -= fold.end.row - fold.start.row;
  8544. }
  8545. } else {
  8546. var lastRow = this.$wrapData.length;
  8547. var row = 0, i = 0;
  8548. var fold = this.$foldData[i++];
  8549. var foldStart = fold ? fold.start.row :Infinity;
  8550. while (row < lastRow) {
  8551. var splits = this.$wrapData[row];
  8552. screenRows += splits ? splits.length + 1 : 1;
  8553. row ++;
  8554. if (row > foldStart) {
  8555. row = fold.end.row+1;
  8556. fold = this.$foldData[i++];
  8557. foldStart = fold ?fold.start.row :Infinity;
  8558. }
  8559. }
  8560. }
  8561. if (this.lineWidgets)
  8562. screenRows += this.$getWidgetScreenLength();
  8563. return screenRows;
  8564. };
  8565. this.$setFontMetrics = function(fm) {
  8566. };
  8567. this.destroy = function() {
  8568. if (this.bgTokenizer) {
  8569. this.bgTokenizer.setDocument(null);
  8570. this.bgTokenizer = null;
  8571. }
  8572. this.$stopWorker();
  8573. };
  8574. function isFullWidth(c) {
  8575. if (c < 0x1100)
  8576. return false;
  8577. return c >= 0x1100 && c <= 0x115F ||
  8578. c >= 0x11A3 && c <= 0x11A7 ||
  8579. c >= 0x11FA && c <= 0x11FF ||
  8580. c >= 0x2329 && c <= 0x232A ||
  8581. c >= 0x2E80 && c <= 0x2E99 ||
  8582. c >= 0x2E9B && c <= 0x2EF3 ||
  8583. c >= 0x2F00 && c <= 0x2FD5 ||
  8584. c >= 0x2FF0 && c <= 0x2FFB ||
  8585. c >= 0x3000 && c <= 0x303E ||
  8586. c >= 0x3041 && c <= 0x3096 ||
  8587. c >= 0x3099 && c <= 0x30FF ||
  8588. c >= 0x3105 && c <= 0x312D ||
  8589. c >= 0x3131 && c <= 0x318E ||
  8590. c >= 0x3190 && c <= 0x31BA ||
  8591. c >= 0x31C0 && c <= 0x31E3 ||
  8592. c >= 0x31F0 && c <= 0x321E ||
  8593. c >= 0x3220 && c <= 0x3247 ||
  8594. c >= 0x3250 && c <= 0x32FE ||
  8595. c >= 0x3300 && c <= 0x4DBF ||
  8596. c >= 0x4E00 && c <= 0xA48C ||
  8597. c >= 0xA490 && c <= 0xA4C6 ||
  8598. c >= 0xA960 && c <= 0xA97C ||
  8599. c >= 0xAC00 && c <= 0xD7A3 ||
  8600. c >= 0xD7B0 && c <= 0xD7C6 ||
  8601. c >= 0xD7CB && c <= 0xD7FB ||
  8602. c >= 0xF900 && c <= 0xFAFF ||
  8603. c >= 0xFE10 && c <= 0xFE19 ||
  8604. c >= 0xFE30 && c <= 0xFE52 ||
  8605. c >= 0xFE54 && c <= 0xFE66 ||
  8606. c >= 0xFE68 && c <= 0xFE6B ||
  8607. c >= 0xFF01 && c <= 0xFF60 ||
  8608. c >= 0xFFE0 && c <= 0xFFE6;
  8609. };
  8610. }).call(EditSession.prototype);
  8611. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8612. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8613. config.defineOptions(EditSession.prototype, "session", {
  8614. wrap: {
  8615. set: function(value) {
  8616. if (!value || value == "off")
  8617. value = false;
  8618. else if (value == "free")
  8619. value = true;
  8620. else if (value == "printMargin")
  8621. value = -1;
  8622. else if (typeof value == "string")
  8623. value = parseInt(value, 10) || false;
  8624. if (this.$wrap == value)
  8625. return;
  8626. this.$wrap = value;
  8627. if (!value) {
  8628. this.setUseWrapMode(false);
  8629. } else {
  8630. var col = typeof value == "number" ? value : null;
  8631. this.setWrapLimitRange(col, col);
  8632. this.setUseWrapMode(true);
  8633. }
  8634. },
  8635. get: function() {
  8636. if (this.getUseWrapMode()) {
  8637. if (this.$wrap == -1)
  8638. return "printMargin";
  8639. if (!this.getWrapLimitRange().min)
  8640. return "free";
  8641. return this.$wrap;
  8642. }
  8643. return "off";
  8644. },
  8645. handlesSet: true
  8646. },
  8647. wrapMethod: {
  8648. set: function(val) {
  8649. val = val == "auto"
  8650. ? this.$mode.type != "text"
  8651. : val != "text";
  8652. if (val != this.$wrapAsCode) {
  8653. this.$wrapAsCode = val;
  8654. if (this.$useWrapMode) {
  8655. this.$modified = true;
  8656. this.$resetRowCache(0);
  8657. this.$updateWrapData(0, this.getLength() - 1);
  8658. }
  8659. }
  8660. },
  8661. initialValue: "auto"
  8662. },
  8663. indentedSoftWrap: { initialValue: true },
  8664. firstLineNumber: {
  8665. set: function() {this._signal("changeBreakpoint");},
  8666. initialValue: 1
  8667. },
  8668. useWorker: {
  8669. set: function(useWorker) {
  8670. this.$useWorker = useWorker;
  8671. this.$stopWorker();
  8672. if (useWorker)
  8673. this.$startWorker();
  8674. },
  8675. initialValue: true
  8676. },
  8677. useSoftTabs: {initialValue: true},
  8678. tabSize: {
  8679. set: function(tabSize) {
  8680. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8681. this.$modified = true;
  8682. this.$rowLengthCache = [];
  8683. this.$tabSize = tabSize;
  8684. this._signal("changeTabSize");
  8685. },
  8686. initialValue: 4,
  8687. handlesSet: true
  8688. },
  8689. overwrite: {
  8690. set: function(val) {this._signal("changeOverwrite");},
  8691. initialValue: false
  8692. },
  8693. newLineMode: {
  8694. set: function(val) {this.doc.setNewLineMode(val)},
  8695. get: function() {return this.doc.getNewLineMode()},
  8696. handlesSet: true
  8697. },
  8698. mode: {
  8699. set: function(val) { this.setMode(val) },
  8700. get: function() { return this.$modeId }
  8701. }
  8702. });
  8703. exports.EditSession = EditSession;
  8704. });
  8705. define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8706. "use strict";
  8707. var lang = require("./lib/lang");
  8708. var oop = require("./lib/oop");
  8709. var Range = require("./range").Range;
  8710. var Search = function() {
  8711. this.$options = {};
  8712. };
  8713. (function() {
  8714. this.set = function(options) {
  8715. oop.mixin(this.$options, options);
  8716. return this;
  8717. };
  8718. this.getOptions = function() {
  8719. return lang.copyObject(this.$options);
  8720. };
  8721. this.setOptions = function(options) {
  8722. this.$options = options;
  8723. };
  8724. this.find = function(session) {
  8725. var options = this.$options;
  8726. var iterator = this.$matchIterator(session, options);
  8727. if (!iterator)
  8728. return false;
  8729. var firstRange = null;
  8730. iterator.forEach(function(range, row, offset) {
  8731. if (!range.start) {
  8732. var column = range.offset + (offset || 0);
  8733. firstRange = new Range(row, column, row, column + range.length);
  8734. if (!range.length && options.start && options.start.start
  8735. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8736. ) {
  8737. firstRange = null;
  8738. return false;
  8739. }
  8740. } else
  8741. firstRange = range;
  8742. return true;
  8743. });
  8744. return firstRange;
  8745. };
  8746. this.findAll = function(session) {
  8747. var options = this.$options;
  8748. if (!options.needle)
  8749. return [];
  8750. this.$assembleRegExp(options);
  8751. var range = options.range;
  8752. var lines = range
  8753. ? session.getLines(range.start.row, range.end.row)
  8754. : session.doc.getAllLines();
  8755. var ranges = [];
  8756. var re = options.re;
  8757. if (options.$isMultiLine) {
  8758. var len = re.length;
  8759. var maxRow = lines.length - len;
  8760. var prevRange;
  8761. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8762. for (var j = 0; j < len; j++)
  8763. if (lines[row + j].search(re[j]) == -1)
  8764. continue outer;
  8765. var startLine = lines[row];
  8766. var line = lines[row + len - 1];
  8767. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8768. var endIndex = line.match(re[len - 1])[0].length;
  8769. if (prevRange && prevRange.end.row === row &&
  8770. prevRange.end.column > startIndex
  8771. ) {
  8772. continue;
  8773. }
  8774. ranges.push(prevRange = new Range(
  8775. row, startIndex, row + len - 1, endIndex
  8776. ));
  8777. if (len > 2)
  8778. row = row + len - 2;
  8779. }
  8780. } else {
  8781. for (var i = 0; i < lines.length; i++) {
  8782. var matches = lang.getMatchOffsets(lines[i], re);
  8783. for (var j = 0; j < matches.length; j++) {
  8784. var match = matches[j];
  8785. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8786. }
  8787. }
  8788. }
  8789. if (range) {
  8790. var startColumn = range.start.column;
  8791. var endColumn = range.start.column;
  8792. var i = 0, j = ranges.length - 1;
  8793. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8794. i++;
  8795. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8796. j--;
  8797. ranges = ranges.slice(i, j + 1);
  8798. for (i = 0, j = ranges.length; i < j; i++) {
  8799. ranges[i].start.row += range.start.row;
  8800. ranges[i].end.row += range.start.row;
  8801. }
  8802. }
  8803. return ranges;
  8804. };
  8805. this.replace = function(input, replacement) {
  8806. var options = this.$options;
  8807. var re = this.$assembleRegExp(options);
  8808. if (options.$isMultiLine)
  8809. return replacement;
  8810. if (!re)
  8811. return;
  8812. var match = re.exec(input);
  8813. if (!match || match[0].length != input.length)
  8814. return null;
  8815. replacement = input.replace(re, replacement);
  8816. if (options.preserveCase) {
  8817. replacement = replacement.split("");
  8818. for (var i = Math.min(input.length, input.length); i--; ) {
  8819. var ch = input[i];
  8820. if (ch && ch.toLowerCase() != ch)
  8821. replacement[i] = replacement[i].toUpperCase();
  8822. else
  8823. replacement[i] = replacement[i].toLowerCase();
  8824. }
  8825. replacement = replacement.join("");
  8826. }
  8827. return replacement;
  8828. };
  8829. this.$matchIterator = function(session, options) {
  8830. var re = this.$assembleRegExp(options);
  8831. if (!re)
  8832. return false;
  8833. var callback;
  8834. if (options.$isMultiLine) {
  8835. var len = re.length;
  8836. var matchIterator = function(line, row, offset) {
  8837. var startIndex = line.search(re[0]);
  8838. if (startIndex == -1)
  8839. return;
  8840. for (var i = 1; i < len; i++) {
  8841. line = session.getLine(row + i);
  8842. if (line.search(re[i]) == -1)
  8843. return;
  8844. }
  8845. var endIndex = line.match(re[len - 1])[0].length;
  8846. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8847. if (re.offset == 1) {
  8848. range.start.row--;
  8849. range.start.column = Number.MAX_VALUE;
  8850. } else if (offset)
  8851. range.start.column += offset;
  8852. if (callback(range))
  8853. return true;
  8854. };
  8855. } else if (options.backwards) {
  8856. var matchIterator = function(line, row, startIndex) {
  8857. var matches = lang.getMatchOffsets(line, re);
  8858. for (var i = matches.length-1; i >= 0; i--)
  8859. if (callback(matches[i], row, startIndex))
  8860. return true;
  8861. };
  8862. } else {
  8863. var matchIterator = function(line, row, startIndex) {
  8864. var matches = lang.getMatchOffsets(line, re);
  8865. for (var i = 0; i < matches.length; i++)
  8866. if (callback(matches[i], row, startIndex))
  8867. return true;
  8868. };
  8869. }
  8870. var lineIterator = this.$lineIterator(session, options);
  8871. return {
  8872. forEach: function(_callback) {
  8873. callback = _callback;
  8874. lineIterator.forEach(matchIterator);
  8875. }
  8876. };
  8877. };
  8878. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8879. if (options.needle instanceof RegExp)
  8880. return options.re = options.needle;
  8881. var needle = options.needle;
  8882. if (!options.needle)
  8883. return options.re = false;
  8884. if (!options.regExp)
  8885. needle = lang.escapeRegExp(needle);
  8886. if (options.wholeWord)
  8887. needle = "\\b" + needle + "\\b";
  8888. var modifier = options.caseSensitive ? "gm" : "gmi";
  8889. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8890. if (options.$isMultiLine)
  8891. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8892. try {
  8893. var re = new RegExp(needle, modifier);
  8894. } catch(e) {
  8895. re = false;
  8896. }
  8897. return options.re = re;
  8898. };
  8899. this.$assembleMultilineRegExp = function(needle, modifier) {
  8900. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8901. var re = [];
  8902. for (var i = 0; i < parts.length; i++) try {
  8903. re.push(new RegExp(parts[i], modifier));
  8904. } catch(e) {
  8905. return false;
  8906. }
  8907. if (parts[0] == "") {
  8908. re.shift();
  8909. re.offset = 1;
  8910. } else {
  8911. re.offset = 0;
  8912. }
  8913. return re;
  8914. };
  8915. this.$lineIterator = function(session, options) {
  8916. var backwards = options.backwards == true;
  8917. var skipCurrent = options.skipCurrent != false;
  8918. var range = options.range;
  8919. var start = options.start;
  8920. if (!start)
  8921. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8922. if (start.start)
  8923. start = start[skipCurrent != backwards ? "end" : "start"];
  8924. var firstRow = range ? range.start.row : 0;
  8925. var lastRow = range ? range.end.row : session.getLength() - 1;
  8926. var forEach = backwards ? function(callback) {
  8927. var row = start.row;
  8928. var line = session.getLine(row).substring(0, start.column);
  8929. if (callback(line, row))
  8930. return;
  8931. for (row--; row >= firstRow; row--)
  8932. if (callback(session.getLine(row), row))
  8933. return;
  8934. if (options.wrap == false)
  8935. return;
  8936. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8937. if (callback(session.getLine(row), row))
  8938. return;
  8939. } : function(callback) {
  8940. var row = start.row;
  8941. var line = session.getLine(row).substr(start.column);
  8942. if (callback(line, row, start.column))
  8943. return;
  8944. for (row = row+1; row <= lastRow; row++)
  8945. if (callback(session.getLine(row), row))
  8946. return;
  8947. if (options.wrap == false)
  8948. return;
  8949. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8950. if (callback(session.getLine(row), row))
  8951. return;
  8952. };
  8953. return {forEach: forEach};
  8954. };
  8955. }).call(Search.prototype);
  8956. exports.Search = Search;
  8957. });
  8958. define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  8959. "use strict";
  8960. var keyUtil = require("../lib/keys");
  8961. var useragent = require("../lib/useragent");
  8962. var KEY_MODS = keyUtil.KEY_MODS;
  8963. function HashHandler(config, platform) {
  8964. this.platform = platform || (useragent.isMac ? "mac" : "win");
  8965. this.commands = {};
  8966. this.commandKeyBinding = {};
  8967. this.addCommands(config);
  8968. this.$singleCommand = true;
  8969. }
  8970. function MultiHashHandler(config, platform) {
  8971. HashHandler.call(this, config, platform);
  8972. this.$singleCommand = false;
  8973. }
  8974. MultiHashHandler.prototype = HashHandler.prototype;
  8975. (function() {
  8976. this.addCommand = function(command) {
  8977. if (this.commands[command.name])
  8978. this.removeCommand(command);
  8979. this.commands[command.name] = command;
  8980. if (command.bindKey)
  8981. this._buildKeyHash(command);
  8982. };
  8983. this.removeCommand = function(command, keepCommand) {
  8984. var name = command && (typeof command === 'string' ? command : command.name);
  8985. command = this.commands[name];
  8986. if (!keepCommand)
  8987. delete this.commands[name];
  8988. var ckb = this.commandKeyBinding;
  8989. for (var keyId in ckb) {
  8990. var cmdGroup = ckb[keyId];
  8991. if (cmdGroup == command) {
  8992. delete ckb[keyId];
  8993. } else if (Array.isArray(cmdGroup)) {
  8994. var i = cmdGroup.indexOf(command);
  8995. if (i != -1) {
  8996. cmdGroup.splice(i, 1);
  8997. if (cmdGroup.length == 1)
  8998. ckb[keyId] = cmdGroup[0];
  8999. }
  9000. }
  9001. }
  9002. };
  9003. this.bindKey = function(key, command, position) {
  9004. if (typeof key == "object") {
  9005. if (position == undefined)
  9006. position = key.position;
  9007. key = key[this.platform];
  9008. }
  9009. if (!key)
  9010. return;
  9011. if (typeof command == "function")
  9012. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  9013. key.split("|").forEach(function(keyPart) {
  9014. var chain = "";
  9015. if (keyPart.indexOf(" ") != -1) {
  9016. var parts = keyPart.split(/\s+/);
  9017. keyPart = parts.pop();
  9018. parts.forEach(function(keyPart) {
  9019. var binding = this.parseKeys(keyPart);
  9020. var id = KEY_MODS[binding.hashId] + binding.key;
  9021. chain += (chain ? " " : "") + id;
  9022. this._addCommandToBinding(chain, "chainKeys");
  9023. }, this);
  9024. chain += " ";
  9025. }
  9026. var binding = this.parseKeys(keyPart);
  9027. var id = KEY_MODS[binding.hashId] + binding.key;
  9028. this._addCommandToBinding(chain + id, command, position);
  9029. }, this);
  9030. };
  9031. function getPosition(command) {
  9032. return typeof command == "object" && command.bindKey
  9033. && command.bindKey.position || 0;
  9034. }
  9035. this._addCommandToBinding = function(keyId, command, position) {
  9036. var ckb = this.commandKeyBinding, i;
  9037. if (!command) {
  9038. delete ckb[keyId];
  9039. } else if (!ckb[keyId] || this.$singleCommand) {
  9040. ckb[keyId] = command;
  9041. } else {
  9042. if (!Array.isArray(ckb[keyId])) {
  9043. ckb[keyId] = [ckb[keyId]];
  9044. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  9045. ckb[keyId].splice(i, 1);
  9046. }
  9047. if (typeof position != "number") {
  9048. if (position || command.isDefault)
  9049. position = -100;
  9050. else
  9051. position = getPosition(command);
  9052. }
  9053. var commands = ckb[keyId];
  9054. for (i = 0; i < commands.length; i++) {
  9055. var other = commands[i];
  9056. var otherPos = getPosition(other);
  9057. if (otherPos > position)
  9058. break;
  9059. }
  9060. commands.splice(i, 0, command);
  9061. }
  9062. };
  9063. this.addCommands = function(commands) {
  9064. commands && Object.keys(commands).forEach(function(name) {
  9065. var command = commands[name];
  9066. if (!command)
  9067. return;
  9068. if (typeof command === "string")
  9069. return this.bindKey(command, name);
  9070. if (typeof command === "function")
  9071. command = { exec: command };
  9072. if (typeof command !== "object")
  9073. return;
  9074. if (!command.name)
  9075. command.name = name;
  9076. this.addCommand(command);
  9077. }, this);
  9078. };
  9079. this.removeCommands = function(commands) {
  9080. Object.keys(commands).forEach(function(name) {
  9081. this.removeCommand(commands[name]);
  9082. }, this);
  9083. };
  9084. this.bindKeys = function(keyList) {
  9085. Object.keys(keyList).forEach(function(key) {
  9086. this.bindKey(key, keyList[key]);
  9087. }, this);
  9088. };
  9089. this._buildKeyHash = function(command) {
  9090. this.bindKey(command.bindKey, command);
  9091. };
  9092. this.parseKeys = function(keys) {
  9093. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  9094. var key = parts.pop();
  9095. var keyCode = keyUtil[key];
  9096. if (keyUtil.FUNCTION_KEYS[keyCode])
  9097. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  9098. else if (!parts.length)
  9099. return {key: key, hashId: -1};
  9100. else if (parts.length == 1 && parts[0] == "shift")
  9101. return {key: key.toUpperCase(), hashId: -1};
  9102. var hashId = 0;
  9103. for (var i = parts.length; i--;) {
  9104. var modifier = keyUtil.KEY_MODS[parts[i]];
  9105. if (modifier == null) {
  9106. if (typeof console != "undefined")
  9107. console.error("invalid modifier " + parts[i] + " in " + keys);
  9108. return false;
  9109. }
  9110. hashId |= modifier;
  9111. }
  9112. return {key: key, hashId: hashId};
  9113. };
  9114. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9115. var key = KEY_MODS[hashId] + keyString;
  9116. return this.commandKeyBinding[key];
  9117. };
  9118. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9119. var key = KEY_MODS[hashId] + keyString;
  9120. var command = this.commandKeyBinding[key];
  9121. if (data.$keyChain) {
  9122. data.$keyChain += " " + key;
  9123. command = this.commandKeyBinding[data.$keyChain] || command;
  9124. }
  9125. if (command) {
  9126. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  9127. data.$keyChain = data.$keyChain || key;
  9128. return {command: "null"};
  9129. }
  9130. }
  9131. if (data.$keyChain) {
  9132. if ((!hashId || hashId == 4) && keyString.length == 1)
  9133. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  9134. else if (hashId == -1 || keyCode > 0)
  9135. data.$keyChain = ""; // reset keyChain
  9136. }
  9137. return {command: command};
  9138. };
  9139. this.getStatusText = function(editor, data) {
  9140. return data.$keyChain || "";
  9141. };
  9142. }).call(HashHandler.prototype);
  9143. exports.HashHandler = HashHandler;
  9144. exports.MultiHashHandler = MultiHashHandler;
  9145. });
  9146. define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  9147. "use strict";
  9148. var oop = require("../lib/oop");
  9149. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  9150. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  9151. var CommandManager = function(platform, commands) {
  9152. MultiHashHandler.call(this, commands, platform);
  9153. this.byName = this.commands;
  9154. this.setDefaultHandler("exec", function(e) {
  9155. return e.command.exec(e.editor, e.args || {});
  9156. });
  9157. };
  9158. oop.inherits(CommandManager, MultiHashHandler);
  9159. (function() {
  9160. oop.implement(this, EventEmitter);
  9161. this.exec = function(command, editor, args) {
  9162. if (Array.isArray(command)) {
  9163. for (var i = command.length; i--; ) {
  9164. if (this.exec(command[i], editor, args)) return true;
  9165. }
  9166. return false;
  9167. }
  9168. if (typeof command === "string")
  9169. command = this.commands[command];
  9170. if (!command)
  9171. return false;
  9172. if (editor && editor.$readOnly && !command.readOnly)
  9173. return false;
  9174. var e = {editor: editor, command: command, args: args};
  9175. e.returnValue = this._emit("exec", e);
  9176. this._signal("afterExec", e);
  9177. return e.returnValue === false ? false : true;
  9178. };
  9179. this.toggleRecording = function(editor) {
  9180. if (this.$inReplay)
  9181. return;
  9182. editor && editor._emit("changeStatus");
  9183. if (this.recording) {
  9184. this.macro.pop();
  9185. this.removeEventListener("exec", this.$addCommandToMacro);
  9186. if (!this.macro.length)
  9187. this.macro = this.oldMacro;
  9188. return this.recording = false;
  9189. }
  9190. if (!this.$addCommandToMacro) {
  9191. this.$addCommandToMacro = function(e) {
  9192. this.macro.push([e.command, e.args]);
  9193. }.bind(this);
  9194. }
  9195. this.oldMacro = this.macro;
  9196. this.macro = [];
  9197. this.on("exec", this.$addCommandToMacro);
  9198. return this.recording = true;
  9199. };
  9200. this.replay = function(editor) {
  9201. if (this.$inReplay || !this.macro)
  9202. return;
  9203. if (this.recording)
  9204. return this.toggleRecording(editor);
  9205. try {
  9206. this.$inReplay = true;
  9207. this.macro.forEach(function(x) {
  9208. if (typeof x == "string")
  9209. this.exec(x, editor);
  9210. else
  9211. this.exec(x[0], editor, x[1]);
  9212. }, this);
  9213. } finally {
  9214. this.$inReplay = false;
  9215. }
  9216. };
  9217. this.trimMacro = function(m) {
  9218. return m.map(function(x){
  9219. if (typeof x[0] != "string")
  9220. x[0] = x[0].name;
  9221. if (!x[1])
  9222. x = x[0];
  9223. return x;
  9224. });
  9225. };
  9226. }).call(CommandManager.prototype);
  9227. exports.CommandManager = CommandManager;
  9228. });
  9229. define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9230. "use strict";
  9231. var lang = require("../lib/lang");
  9232. var config = require("../config");
  9233. var Range = require("../range").Range;
  9234. function bindKey(win, mac) {
  9235. return {win: win, mac: mac};
  9236. }
  9237. exports.commands = [{
  9238. name: "showSettingsMenu",
  9239. bindKey: bindKey("Ctrl-,", "Command-,"),
  9240. exec: function(editor) {
  9241. config.loadModule("ace/ext/settings_menu", function(module) {
  9242. module.init(editor);
  9243. editor.showSettingsMenu();
  9244. });
  9245. },
  9246. readOnly: true
  9247. }, {
  9248. name: "goToNextError",
  9249. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9250. exec: function(editor) {
  9251. config.loadModule("ace/ext/error_marker", function(module) {
  9252. module.showErrorMarker(editor, 1);
  9253. });
  9254. },
  9255. scrollIntoView: "animate",
  9256. readOnly: true
  9257. }, {
  9258. name: "goToPreviousError",
  9259. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9260. exec: function(editor) {
  9261. config.loadModule("ace/ext/error_marker", function(module) {
  9262. module.showErrorMarker(editor, -1);
  9263. });
  9264. },
  9265. scrollIntoView: "animate",
  9266. readOnly: true
  9267. }, {
  9268. name: "selectall",
  9269. bindKey: bindKey("Ctrl-A", "Command-A"),
  9270. exec: function(editor) { editor.selectAll(); },
  9271. readOnly: true
  9272. }, {
  9273. name: "centerselection",
  9274. bindKey: bindKey(null, "Ctrl-L"),
  9275. exec: function(editor) { editor.centerSelection(); },
  9276. readOnly: true
  9277. }, {
  9278. name: "gotoline",
  9279. bindKey: bindKey("Ctrl-L", "Command-L"),
  9280. exec: function(editor) {
  9281. var line = parseInt(prompt("Enter line number:"), 10);
  9282. if (!isNaN(line)) {
  9283. editor.gotoLine(line);
  9284. }
  9285. },
  9286. readOnly: true
  9287. }, {
  9288. name: "fold",
  9289. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9290. exec: function(editor) { editor.session.toggleFold(false); },
  9291. multiSelectAction: "forEach",
  9292. scrollIntoView: "center",
  9293. readOnly: true
  9294. }, {
  9295. name: "unfold",
  9296. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9297. exec: function(editor) { editor.session.toggleFold(true); },
  9298. multiSelectAction: "forEach",
  9299. scrollIntoView: "center",
  9300. readOnly: true
  9301. }, {
  9302. name: "toggleFoldWidget",
  9303. bindKey: bindKey("F2", "F2"),
  9304. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9305. multiSelectAction: "forEach",
  9306. scrollIntoView: "center",
  9307. readOnly: true
  9308. }, {
  9309. name: "toggleParentFoldWidget",
  9310. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9311. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9312. multiSelectAction: "forEach",
  9313. scrollIntoView: "center",
  9314. readOnly: true
  9315. }, {
  9316. name: "foldall",
  9317. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9318. exec: function(editor) { editor.session.foldAll(); },
  9319. scrollIntoView: "center",
  9320. readOnly: true
  9321. }, {
  9322. name: "foldOther",
  9323. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9324. exec: function(editor) {
  9325. editor.session.foldAll();
  9326. editor.session.unfold(editor.selection.getAllRanges());
  9327. },
  9328. scrollIntoView: "center",
  9329. readOnly: true
  9330. }, {
  9331. name: "unfoldall",
  9332. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9333. exec: function(editor) { editor.session.unfold(); },
  9334. scrollIntoView: "center",
  9335. readOnly: true
  9336. }, {
  9337. name: "findnext",
  9338. bindKey: bindKey("Ctrl-K", "Command-G"),
  9339. exec: function(editor) { editor.findNext(); },
  9340. multiSelectAction: "forEach",
  9341. scrollIntoView: "center",
  9342. readOnly: true
  9343. }, {
  9344. name: "findprevious",
  9345. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9346. exec: function(editor) { editor.findPrevious(); },
  9347. multiSelectAction: "forEach",
  9348. scrollIntoView: "center",
  9349. readOnly: true
  9350. }, {
  9351. name: "selectOrFindNext",
  9352. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9353. exec: function(editor) {
  9354. if (editor.selection.isEmpty())
  9355. editor.selection.selectWord();
  9356. else
  9357. editor.findNext();
  9358. },
  9359. readOnly: true
  9360. }, {
  9361. name: "selectOrFindPrevious",
  9362. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9363. exec: function(editor) {
  9364. if (editor.selection.isEmpty())
  9365. editor.selection.selectWord();
  9366. else
  9367. editor.findPrevious();
  9368. },
  9369. readOnly: true
  9370. }, {
  9371. name: "find",
  9372. bindKey: bindKey("Ctrl-F", "Command-F"),
  9373. exec: function(editor) {
  9374. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9375. },
  9376. readOnly: true
  9377. }, {
  9378. name: "overwrite",
  9379. bindKey: "Insert",
  9380. exec: function(editor) { editor.toggleOverwrite(); },
  9381. readOnly: true
  9382. }, {
  9383. name: "selecttostart",
  9384. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9385. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9386. multiSelectAction: "forEach",
  9387. readOnly: true,
  9388. scrollIntoView: "animate",
  9389. aceCommandGroup: "fileJump"
  9390. }, {
  9391. name: "gotostart",
  9392. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9393. exec: function(editor) { editor.navigateFileStart(); },
  9394. multiSelectAction: "forEach",
  9395. readOnly: true,
  9396. scrollIntoView: "animate",
  9397. aceCommandGroup: "fileJump"
  9398. }, {
  9399. name: "selectup",
  9400. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9401. exec: function(editor) { editor.getSelection().selectUp(); },
  9402. multiSelectAction: "forEach",
  9403. scrollIntoView: "cursor",
  9404. readOnly: true
  9405. }, {
  9406. name: "golineup",
  9407. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9408. exec: function(editor, args) { editor.navigateUp(args.times); },
  9409. multiSelectAction: "forEach",
  9410. scrollIntoView: "cursor",
  9411. readOnly: true
  9412. }, {
  9413. name: "selecttoend",
  9414. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9415. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9416. multiSelectAction: "forEach",
  9417. readOnly: true,
  9418. scrollIntoView: "animate",
  9419. aceCommandGroup: "fileJump"
  9420. }, {
  9421. name: "gotoend",
  9422. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9423. exec: function(editor) { editor.navigateFileEnd(); },
  9424. multiSelectAction: "forEach",
  9425. readOnly: true,
  9426. scrollIntoView: "animate",
  9427. aceCommandGroup: "fileJump"
  9428. }, {
  9429. name: "selectdown",
  9430. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9431. exec: function(editor) { editor.getSelection().selectDown(); },
  9432. multiSelectAction: "forEach",
  9433. scrollIntoView: "cursor",
  9434. readOnly: true
  9435. }, {
  9436. name: "golinedown",
  9437. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9438. exec: function(editor, args) { editor.navigateDown(args.times); },
  9439. multiSelectAction: "forEach",
  9440. scrollIntoView: "cursor",
  9441. readOnly: true
  9442. }, {
  9443. name: "selectwordleft",
  9444. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9445. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9446. multiSelectAction: "forEach",
  9447. scrollIntoView: "cursor",
  9448. readOnly: true
  9449. }, {
  9450. name: "gotowordleft",
  9451. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9452. exec: function(editor) { editor.navigateWordLeft(); },
  9453. multiSelectAction: "forEach",
  9454. scrollIntoView: "cursor",
  9455. readOnly: true
  9456. }, {
  9457. name: "selecttolinestart",
  9458. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9459. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9460. multiSelectAction: "forEach",
  9461. scrollIntoView: "cursor",
  9462. readOnly: true
  9463. }, {
  9464. name: "gotolinestart",
  9465. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9466. exec: function(editor) { editor.navigateLineStart(); },
  9467. multiSelectAction: "forEach",
  9468. scrollIntoView: "cursor",
  9469. readOnly: true
  9470. }, {
  9471. name: "selectleft",
  9472. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9473. exec: function(editor) { editor.getSelection().selectLeft(); },
  9474. multiSelectAction: "forEach",
  9475. scrollIntoView: "cursor",
  9476. readOnly: true
  9477. }, {
  9478. name: "gotoleft",
  9479. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9480. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9481. multiSelectAction: "forEach",
  9482. scrollIntoView: "cursor",
  9483. readOnly: true
  9484. }, {
  9485. name: "selectwordright",
  9486. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9487. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9488. multiSelectAction: "forEach",
  9489. scrollIntoView: "cursor",
  9490. readOnly: true
  9491. }, {
  9492. name: "gotowordright",
  9493. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9494. exec: function(editor) { editor.navigateWordRight(); },
  9495. multiSelectAction: "forEach",
  9496. scrollIntoView: "cursor",
  9497. readOnly: true
  9498. }, {
  9499. name: "selecttolineend",
  9500. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9501. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9502. multiSelectAction: "forEach",
  9503. scrollIntoView: "cursor",
  9504. readOnly: true
  9505. }, {
  9506. name: "gotolineend",
  9507. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9508. exec: function(editor) { editor.navigateLineEnd(); },
  9509. multiSelectAction: "forEach",
  9510. scrollIntoView: "cursor",
  9511. readOnly: true
  9512. }, {
  9513. name: "selectright",
  9514. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9515. exec: function(editor) { editor.getSelection().selectRight(); },
  9516. multiSelectAction: "forEach",
  9517. scrollIntoView: "cursor",
  9518. readOnly: true
  9519. }, {
  9520. name: "gotoright",
  9521. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9522. exec: function(editor, args) { editor.navigateRight(args.times); },
  9523. multiSelectAction: "forEach",
  9524. scrollIntoView: "cursor",
  9525. readOnly: true
  9526. }, {
  9527. name: "selectpagedown",
  9528. bindKey: "Shift-PageDown",
  9529. exec: function(editor) { editor.selectPageDown(); },
  9530. readOnly: true
  9531. }, {
  9532. name: "pagedown",
  9533. bindKey: bindKey(null, "Option-PageDown"),
  9534. exec: function(editor) { editor.scrollPageDown(); },
  9535. readOnly: true
  9536. }, {
  9537. name: "gotopagedown",
  9538. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9539. exec: function(editor) { editor.gotoPageDown(); },
  9540. readOnly: true
  9541. }, {
  9542. name: "selectpageup",
  9543. bindKey: "Shift-PageUp",
  9544. exec: function(editor) { editor.selectPageUp(); },
  9545. readOnly: true
  9546. }, {
  9547. name: "pageup",
  9548. bindKey: bindKey(null, "Option-PageUp"),
  9549. exec: function(editor) { editor.scrollPageUp(); },
  9550. readOnly: true
  9551. }, {
  9552. name: "gotopageup",
  9553. bindKey: "PageUp",
  9554. exec: function(editor) { editor.gotoPageUp(); },
  9555. readOnly: true
  9556. }, {
  9557. name: "scrollup",
  9558. bindKey: bindKey("Ctrl-Up", null),
  9559. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9560. readOnly: true
  9561. }, {
  9562. name: "scrolldown",
  9563. bindKey: bindKey("Ctrl-Down", null),
  9564. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9565. readOnly: true
  9566. }, {
  9567. name: "selectlinestart",
  9568. bindKey: "Shift-Home",
  9569. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9570. multiSelectAction: "forEach",
  9571. scrollIntoView: "cursor",
  9572. readOnly: true
  9573. }, {
  9574. name: "selectlineend",
  9575. bindKey: "Shift-End",
  9576. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9577. multiSelectAction: "forEach",
  9578. scrollIntoView: "cursor",
  9579. readOnly: true
  9580. }, {
  9581. name: "togglerecording",
  9582. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9583. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9584. readOnly: true
  9585. }, {
  9586. name: "replaymacro",
  9587. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9588. exec: function(editor) { editor.commands.replay(editor); },
  9589. readOnly: true
  9590. }, {
  9591. name: "jumptomatching",
  9592. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9593. exec: function(editor) { editor.jumpToMatching(); },
  9594. multiSelectAction: "forEach",
  9595. scrollIntoView: "animate",
  9596. readOnly: true
  9597. }, {
  9598. name: "selecttomatching",
  9599. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9600. exec: function(editor) { editor.jumpToMatching(true); },
  9601. multiSelectAction: "forEach",
  9602. scrollIntoView: "animate",
  9603. readOnly: true
  9604. }, {
  9605. name: "expandToMatching",
  9606. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9607. exec: function(editor) { editor.jumpToMatching(true, true); },
  9608. multiSelectAction: "forEach",
  9609. scrollIntoView: "animate",
  9610. readOnly: true
  9611. }, {
  9612. name: "passKeysToBrowser",
  9613. bindKey: bindKey(null, null),
  9614. exec: function() {},
  9615. passEvent: true,
  9616. readOnly: true
  9617. }, {
  9618. name: "copy",
  9619. exec: function(editor) {
  9620. },
  9621. readOnly: true
  9622. },
  9623. {
  9624. name: "cut",
  9625. exec: function(editor) {
  9626. var range = editor.getSelectionRange();
  9627. editor._emit("cut", range);
  9628. if (!editor.selection.isEmpty()) {
  9629. editor.session.remove(range);
  9630. editor.clearSelection();
  9631. }
  9632. },
  9633. scrollIntoView: "cursor",
  9634. multiSelectAction: "forEach"
  9635. }, {
  9636. name: "paste",
  9637. exec: function(editor, args) {
  9638. editor.$handlePaste(args);
  9639. },
  9640. scrollIntoView: "cursor"
  9641. }, {
  9642. name: "removeline",
  9643. bindKey: bindKey("Ctrl-D", "Command-D"),
  9644. exec: function(editor) { editor.removeLines(); },
  9645. scrollIntoView: "cursor",
  9646. multiSelectAction: "forEachLine"
  9647. }, {
  9648. name: "duplicateSelection",
  9649. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9650. exec: function(editor) { editor.duplicateSelection(); },
  9651. scrollIntoView: "cursor",
  9652. multiSelectAction: "forEach"
  9653. }, {
  9654. name: "sortlines",
  9655. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9656. exec: function(editor) { editor.sortLines(); },
  9657. scrollIntoView: "selection",
  9658. multiSelectAction: "forEachLine"
  9659. }, {
  9660. name: "togglecomment",
  9661. bindKey: bindKey("Ctrl-/", "Command-/"),
  9662. exec: function(editor) { editor.toggleCommentLines(); },
  9663. multiSelectAction: "forEachLine",
  9664. scrollIntoView: "selectionPart"
  9665. }, {
  9666. name: "toggleBlockComment",
  9667. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9668. exec: function(editor) { editor.toggleBlockComment(); },
  9669. multiSelectAction: "forEach",
  9670. scrollIntoView: "selectionPart"
  9671. }, {
  9672. name: "modifyNumberUp",
  9673. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9674. exec: function(editor) { editor.modifyNumber(1); },
  9675. scrollIntoView: "cursor",
  9676. multiSelectAction: "forEach"
  9677. }, {
  9678. name: "modifyNumberDown",
  9679. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9680. exec: function(editor) { editor.modifyNumber(-1); },
  9681. scrollIntoView: "cursor",
  9682. multiSelectAction: "forEach"
  9683. }, {
  9684. name: "replace",
  9685. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9686. exec: function(editor) {
  9687. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9688. }
  9689. }, {
  9690. name: "undo",
  9691. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9692. exec: function(editor) { editor.undo(); }
  9693. }, {
  9694. name: "redo",
  9695. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9696. exec: function(editor) { editor.redo(); }
  9697. }, {
  9698. name: "copylinesup",
  9699. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9700. exec: function(editor) { editor.copyLinesUp(); },
  9701. scrollIntoView: "cursor"
  9702. }, {
  9703. name: "movelinesup",
  9704. bindKey: bindKey("Alt-Up", "Option-Up"),
  9705. exec: function(editor) { editor.moveLinesUp(); },
  9706. scrollIntoView: "cursor"
  9707. }, {
  9708. name: "copylinesdown",
  9709. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9710. exec: function(editor) { editor.copyLinesDown(); },
  9711. scrollIntoView: "cursor"
  9712. }, {
  9713. name: "movelinesdown",
  9714. bindKey: bindKey("Alt-Down", "Option-Down"),
  9715. exec: function(editor) { editor.moveLinesDown(); },
  9716. scrollIntoView: "cursor"
  9717. }, {
  9718. name: "del",
  9719. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9720. exec: function(editor) { editor.remove("right"); },
  9721. multiSelectAction: "forEach",
  9722. scrollIntoView: "cursor"
  9723. }, {
  9724. name: "backspace",
  9725. bindKey: bindKey(
  9726. "Shift-Backspace|Backspace",
  9727. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9728. ),
  9729. exec: function(editor) { editor.remove("left"); },
  9730. multiSelectAction: "forEach",
  9731. scrollIntoView: "cursor"
  9732. }, {
  9733. name: "cut_or_delete",
  9734. bindKey: bindKey("Shift-Delete", null),
  9735. exec: function(editor) {
  9736. if (editor.selection.isEmpty()) {
  9737. editor.remove("left");
  9738. } else {
  9739. return false;
  9740. }
  9741. },
  9742. multiSelectAction: "forEach",
  9743. scrollIntoView: "cursor"
  9744. }, {
  9745. name: "removetolinestart",
  9746. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9747. exec: function(editor) { editor.removeToLineStart(); },
  9748. multiSelectAction: "forEach",
  9749. scrollIntoView: "cursor"
  9750. }, {
  9751. name: "removetolineend",
  9752. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9753. exec: function(editor) { editor.removeToLineEnd(); },
  9754. multiSelectAction: "forEach",
  9755. scrollIntoView: "cursor"
  9756. }, {
  9757. name: "removewordleft",
  9758. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9759. exec: function(editor) { editor.removeWordLeft(); },
  9760. multiSelectAction: "forEach",
  9761. scrollIntoView: "cursor"
  9762. }, {
  9763. name: "removewordright",
  9764. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9765. exec: function(editor) { editor.removeWordRight(); },
  9766. multiSelectAction: "forEach",
  9767. scrollIntoView: "cursor"
  9768. }, {
  9769. name: "outdent",
  9770. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9771. exec: function(editor) { editor.blockOutdent(); },
  9772. multiSelectAction: "forEach",
  9773. scrollIntoView: "selectionPart"
  9774. }, {
  9775. name: "indent",
  9776. bindKey: bindKey("Tab", "Tab"),
  9777. exec: function(editor) { editor.indent(); },
  9778. multiSelectAction: "forEach",
  9779. scrollIntoView: "selectionPart"
  9780. }, {
  9781. name: "blockoutdent",
  9782. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9783. exec: function(editor) { editor.blockOutdent(); },
  9784. multiSelectAction: "forEachLine",
  9785. scrollIntoView: "selectionPart"
  9786. }, {
  9787. name: "blockindent",
  9788. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9789. exec: function(editor) { editor.blockIndent(); },
  9790. multiSelectAction: "forEachLine",
  9791. scrollIntoView: "selectionPart"
  9792. }, {
  9793. name: "insertstring",
  9794. exec: function(editor, str) { editor.insert(str); },
  9795. multiSelectAction: "forEach",
  9796. scrollIntoView: "cursor"
  9797. }, {
  9798. name: "inserttext",
  9799. exec: function(editor, args) {
  9800. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9801. },
  9802. multiSelectAction: "forEach",
  9803. scrollIntoView: "cursor"
  9804. }, {
  9805. name: "splitline",
  9806. bindKey: bindKey(null, "Ctrl-O"),
  9807. exec: function(editor) { editor.splitLine(); },
  9808. multiSelectAction: "forEach",
  9809. scrollIntoView: "cursor"
  9810. }, {
  9811. name: "transposeletters",
  9812. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9813. exec: function(editor) { editor.transposeLetters(); },
  9814. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9815. scrollIntoView: "cursor"
  9816. }, {
  9817. name: "touppercase",
  9818. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9819. exec: function(editor) { editor.toUpperCase(); },
  9820. multiSelectAction: "forEach",
  9821. scrollIntoView: "cursor"
  9822. }, {
  9823. name: "tolowercase",
  9824. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9825. exec: function(editor) { editor.toLowerCase(); },
  9826. multiSelectAction: "forEach",
  9827. scrollIntoView: "cursor"
  9828. }, {
  9829. name: "expandtoline",
  9830. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9831. exec: function(editor) {
  9832. var range = editor.selection.getRange();
  9833. range.start.column = range.end.column = 0;
  9834. range.end.row++;
  9835. editor.selection.setRange(range, false);
  9836. },
  9837. multiSelectAction: "forEach",
  9838. scrollIntoView: "cursor",
  9839. readOnly: true
  9840. }, {
  9841. name: "joinlines",
  9842. bindKey: bindKey(null, null),
  9843. exec: function(editor) {
  9844. var isBackwards = editor.selection.isBackwards();
  9845. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9846. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9847. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9848. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9849. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9850. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9851. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9852. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9853. if (curLine.length !== 0) {
  9854. curLine = " " + curLine;
  9855. }
  9856. insertLine += curLine;
  9857. }
  9858. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9859. insertLine += editor.session.doc.getNewLineCharacter();
  9860. }
  9861. editor.clearSelection();
  9862. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9863. if (selectedCount > 0) {
  9864. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9865. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9866. } else {
  9867. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9868. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9869. }
  9870. },
  9871. multiSelectAction: "forEach",
  9872. readOnly: true
  9873. }, {
  9874. name: "invertSelection",
  9875. bindKey: bindKey(null, null),
  9876. exec: function(editor) {
  9877. var endRow = editor.session.doc.getLength() - 1;
  9878. var endCol = editor.session.doc.getLine(endRow).length;
  9879. var ranges = editor.selection.rangeList.ranges;
  9880. var newRanges = [];
  9881. if (ranges.length < 1) {
  9882. ranges = [editor.selection.getRange()];
  9883. }
  9884. for (var i = 0; i < ranges.length; i++) {
  9885. if (i == (ranges.length - 1)) {
  9886. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9887. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9888. }
  9889. }
  9890. if (i === 0) {
  9891. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9892. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9893. }
  9894. } else {
  9895. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9896. }
  9897. }
  9898. editor.exitMultiSelectMode();
  9899. editor.clearSelection();
  9900. for(var i = 0; i < newRanges.length; i++) {
  9901. editor.selection.addRange(newRanges[i], false);
  9902. }
  9903. },
  9904. readOnly: true,
  9905. scrollIntoView: "none"
  9906. }];
  9907. });
  9908. 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) {
  9909. "use strict";
  9910. require("./lib/fixoldbrowsers");
  9911. var oop = require("./lib/oop");
  9912. var dom = require("./lib/dom");
  9913. var lang = require("./lib/lang");
  9914. var useragent = require("./lib/useragent");
  9915. var TextInput = require("./keyboard/textinput").TextInput;
  9916. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9917. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9918. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9919. var EditSession = require("./edit_session").EditSession;
  9920. var Search = require("./search").Search;
  9921. var Range = require("./range").Range;
  9922. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9923. var CommandManager = require("./commands/command_manager").CommandManager;
  9924. var defaultCommands = require("./commands/default_commands").commands;
  9925. var config = require("./config");
  9926. var TokenIterator = require("./token_iterator").TokenIterator;
  9927. var Editor = function(renderer, session) {
  9928. var container = renderer.getContainerElement();
  9929. this.container = container;
  9930. this.renderer = renderer;
  9931. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9932. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9933. this.renderer.textarea = this.textInput.getElement();
  9934. this.keyBinding = new KeyBinding(this);
  9935. this.$mouseHandler = new MouseHandler(this);
  9936. new FoldHandler(this);
  9937. this.$blockScrolling = 0;
  9938. this.$search = new Search().set({
  9939. wrap: true
  9940. });
  9941. this.$historyTracker = this.$historyTracker.bind(this);
  9942. this.commands.on("exec", this.$historyTracker);
  9943. this.$initOperationListeners();
  9944. this._$emitInputEvent = lang.delayedCall(function() {
  9945. this._signal("input", {});
  9946. if (this.session && this.session.bgTokenizer)
  9947. this.session.bgTokenizer.scheduleStart();
  9948. }.bind(this));
  9949. this.on("change", function(_, _self) {
  9950. _self._$emitInputEvent.schedule(31);
  9951. });
  9952. this.setSession(session || new EditSession(""));
  9953. config.resetOptions(this);
  9954. config._signal("editor", this);
  9955. };
  9956. (function(){
  9957. oop.implement(this, EventEmitter);
  9958. this.$initOperationListeners = function() {
  9959. function last(a) {return a[a.length - 1]}
  9960. this.selections = [];
  9961. this.commands.on("exec", this.startOperation.bind(this), true);
  9962. this.commands.on("afterExec", this.endOperation.bind(this), true);
  9963. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  9964. this.on("change", function() {
  9965. this.curOp || this.startOperation();
  9966. this.curOp.docChanged = true;
  9967. }.bind(this), true);
  9968. this.on("changeSelection", function() {
  9969. this.curOp || this.startOperation();
  9970. this.curOp.selectionChanged = true;
  9971. }.bind(this), true);
  9972. };
  9973. this.curOp = null;
  9974. this.prevOp = {};
  9975. this.startOperation = function(commadEvent) {
  9976. if (this.curOp) {
  9977. if (!commadEvent || this.curOp.command)
  9978. return;
  9979. this.prevOp = this.curOp;
  9980. }
  9981. if (!commadEvent) {
  9982. this.previousCommand = null;
  9983. commadEvent = {};
  9984. }
  9985. this.$opResetTimer.schedule();
  9986. this.curOp = {
  9987. command: commadEvent.command || {},
  9988. args: commadEvent.args,
  9989. scrollTop: this.renderer.scrollTop
  9990. };
  9991. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  9992. this.$blockScrolling++;
  9993. };
  9994. this.endOperation = function(e) {
  9995. if (this.curOp) {
  9996. if (e && e.returnValue === false)
  9997. return this.curOp = null;
  9998. this._signal("beforeEndOperation");
  9999. var command = this.curOp.command;
  10000. if (command.name && this.$blockScrolling > 0)
  10001. this.$blockScrolling--;
  10002. var scrollIntoView = command && command.scrollIntoView;
  10003. if (scrollIntoView) {
  10004. switch (scrollIntoView) {
  10005. case "center-animate":
  10006. scrollIntoView = "animate";
  10007. case "center":
  10008. this.renderer.scrollCursorIntoView(null, 0.5);
  10009. break;
  10010. case "animate":
  10011. case "cursor":
  10012. this.renderer.scrollCursorIntoView();
  10013. break;
  10014. case "selectionPart":
  10015. var range = this.selection.getRange();
  10016. var config = this.renderer.layerConfig;
  10017. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  10018. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  10019. }
  10020. break;
  10021. default:
  10022. break;
  10023. }
  10024. if (scrollIntoView == "animate")
  10025. this.renderer.animateScrolling(this.curOp.scrollTop);
  10026. }
  10027. this.prevOp = this.curOp;
  10028. this.curOp = null;
  10029. }
  10030. };
  10031. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  10032. this.$historyTracker = function(e) {
  10033. if (!this.$mergeUndoDeltas)
  10034. return;
  10035. var prev = this.prevOp;
  10036. var mergeableCommands = this.$mergeableCommands;
  10037. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  10038. if (e.command.name == "insertstring") {
  10039. var text = e.args;
  10040. if (this.mergeNextCommand === undefined)
  10041. this.mergeNextCommand = true;
  10042. shouldMerge = shouldMerge
  10043. && this.mergeNextCommand // previous command allows to coalesce with
  10044. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  10045. this.mergeNextCommand = true;
  10046. } else {
  10047. shouldMerge = shouldMerge
  10048. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  10049. }
  10050. if (
  10051. this.$mergeUndoDeltas != "always"
  10052. && Date.now() - this.sequenceStartTime > 2000
  10053. ) {
  10054. shouldMerge = false; // the sequence is too long
  10055. }
  10056. if (shouldMerge)
  10057. this.session.mergeUndoDeltas = true;
  10058. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  10059. this.sequenceStartTime = Date.now();
  10060. };
  10061. this.setKeyboardHandler = function(keyboardHandler, cb) {
  10062. if (keyboardHandler && typeof keyboardHandler === "string") {
  10063. this.$keybindingId = keyboardHandler;
  10064. var _self = this;
  10065. config.loadModule(["keybinding", keyboardHandler], function(module) {
  10066. if (_self.$keybindingId == keyboardHandler)
  10067. _self.keyBinding.setKeyboardHandler(module && module.handler);
  10068. cb && cb();
  10069. });
  10070. } else {
  10071. this.$keybindingId = null;
  10072. this.keyBinding.setKeyboardHandler(keyboardHandler);
  10073. cb && cb();
  10074. }
  10075. };
  10076. this.getKeyboardHandler = function() {
  10077. return this.keyBinding.getKeyboardHandler();
  10078. };
  10079. this.setSession = function(session) {
  10080. if (this.session == session)
  10081. return;
  10082. if (this.curOp) this.endOperation();
  10083. this.curOp = {};
  10084. var oldSession = this.session;
  10085. if (oldSession) {
  10086. this.session.removeEventListener("change", this.$onDocumentChange);
  10087. this.session.removeEventListener("changeMode", this.$onChangeMode);
  10088. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10089. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  10090. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10091. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  10092. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  10093. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10094. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  10095. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10096. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  10097. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  10098. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  10099. this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10100. var selection = this.session.getSelection();
  10101. selection.removeEventListener("changeCursor", this.$onCursorChange);
  10102. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  10103. }
  10104. this.session = session;
  10105. if (session) {
  10106. this.$onDocumentChange = this.onDocumentChange.bind(this);
  10107. session.addEventListener("change", this.$onDocumentChange);
  10108. this.renderer.setSession(session);
  10109. this.$onChangeMode = this.onChangeMode.bind(this);
  10110. session.addEventListener("changeMode", this.$onChangeMode);
  10111. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  10112. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  10113. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  10114. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  10115. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  10116. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  10117. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  10118. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  10119. this.$onChangeFold = this.onChangeFold.bind(this);
  10120. session.addEventListener("changeFold", this.$onChangeFold);
  10121. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  10122. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  10123. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  10124. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  10125. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  10126. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  10127. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  10128. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  10129. this.$onCursorChange = this.onCursorChange.bind(this);
  10130. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  10131. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  10132. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  10133. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  10134. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  10135. this.selection = session.getSelection();
  10136. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  10137. this.$onSelectionChange = this.onSelectionChange.bind(this);
  10138. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  10139. this.onChangeMode();
  10140. this.$blockScrolling += 1;
  10141. this.onCursorChange();
  10142. this.$blockScrolling -= 1;
  10143. this.onScrollTopChange();
  10144. this.onScrollLeftChange();
  10145. this.onSelectionChange();
  10146. this.onChangeFrontMarker();
  10147. this.onChangeBackMarker();
  10148. this.onChangeBreakpoint();
  10149. this.onChangeAnnotation();
  10150. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  10151. this.renderer.updateFull();
  10152. } else {
  10153. this.selection = null;
  10154. this.renderer.setSession(session);
  10155. }
  10156. this._signal("changeSession", {
  10157. session: session,
  10158. oldSession: oldSession
  10159. });
  10160. this.curOp = null;
  10161. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  10162. session && session._signal("changeEditor", {editor: this});
  10163. };
  10164. this.getSession = function() {
  10165. return this.session;
  10166. };
  10167. this.setValue = function(val, cursorPos) {
  10168. this.session.doc.setValue(val);
  10169. if (!cursorPos)
  10170. this.selectAll();
  10171. else if (cursorPos == 1)
  10172. this.navigateFileEnd();
  10173. else if (cursorPos == -1)
  10174. this.navigateFileStart();
  10175. return val;
  10176. };
  10177. this.getValue = function() {
  10178. return this.session.getValue();
  10179. };
  10180. this.getSelection = function() {
  10181. return this.selection;
  10182. };
  10183. this.resize = function(force) {
  10184. this.renderer.onResize(force);
  10185. };
  10186. this.setTheme = function(theme, cb) {
  10187. this.renderer.setTheme(theme, cb);
  10188. };
  10189. this.getTheme = function() {
  10190. return this.renderer.getTheme();
  10191. };
  10192. this.setStyle = function(style) {
  10193. this.renderer.setStyle(style);
  10194. };
  10195. this.unsetStyle = function(style) {
  10196. this.renderer.unsetStyle(style);
  10197. };
  10198. this.getFontSize = function () {
  10199. return this.getOption("fontSize") ||
  10200. dom.computedStyle(this.container, "fontSize");
  10201. };
  10202. this.setFontSize = function(size) {
  10203. this.setOption("fontSize", size);
  10204. };
  10205. this.$highlightBrackets = function() {
  10206. if (this.session.$bracketHighlight) {
  10207. this.session.removeMarker(this.session.$bracketHighlight);
  10208. this.session.$bracketHighlight = null;
  10209. }
  10210. if (this.$highlightPending) {
  10211. return;
  10212. }
  10213. var self = this;
  10214. this.$highlightPending = true;
  10215. setTimeout(function() {
  10216. self.$highlightPending = false;
  10217. var session = self.session;
  10218. if (!session || !session.bgTokenizer) return;
  10219. var pos = session.findMatchingBracket(self.getCursorPosition());
  10220. if (pos) {
  10221. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10222. } else if (session.$mode.getMatching) {
  10223. var range = session.$mode.getMatching(self.session);
  10224. }
  10225. if (range)
  10226. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10227. }, 50);
  10228. };
  10229. this.$highlightTags = function() {
  10230. if (this.$highlightTagPending)
  10231. return;
  10232. var self = this;
  10233. this.$highlightTagPending = true;
  10234. setTimeout(function() {
  10235. self.$highlightTagPending = false;
  10236. var session = self.session;
  10237. if (!session || !session.bgTokenizer) return;
  10238. var pos = self.getCursorPosition();
  10239. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10240. var token = iterator.getCurrentToken();
  10241. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10242. session.removeMarker(session.$tagHighlight);
  10243. session.$tagHighlight = null;
  10244. return;
  10245. }
  10246. if (token.type.indexOf("tag-open") != -1) {
  10247. token = iterator.stepForward();
  10248. if (!token)
  10249. return;
  10250. }
  10251. var tag = token.value;
  10252. var depth = 0;
  10253. var prevToken = iterator.stepBackward();
  10254. if (prevToken.value == '<'){
  10255. do {
  10256. prevToken = token;
  10257. token = iterator.stepForward();
  10258. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10259. if (prevToken.value === '<'){
  10260. depth++;
  10261. } else if (prevToken.value === '</'){
  10262. depth--;
  10263. }
  10264. }
  10265. } while (token && depth >= 0);
  10266. } else {
  10267. do {
  10268. token = prevToken;
  10269. prevToken = iterator.stepBackward();
  10270. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10271. if (prevToken.value === '<') {
  10272. depth++;
  10273. } else if (prevToken.value === '</') {
  10274. depth--;
  10275. }
  10276. }
  10277. } while (prevToken && depth <= 0);
  10278. iterator.stepForward();
  10279. }
  10280. if (!token) {
  10281. session.removeMarker(session.$tagHighlight);
  10282. session.$tagHighlight = null;
  10283. return;
  10284. }
  10285. var row = iterator.getCurrentTokenRow();
  10286. var column = iterator.getCurrentTokenColumn();
  10287. var range = new Range(row, column, row, column+token.value.length);
  10288. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10289. session.removeMarker(session.$tagHighlight);
  10290. session.$tagHighlight = null;
  10291. }
  10292. if (range && !session.$tagHighlight)
  10293. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10294. }, 50);
  10295. };
  10296. this.focus = function() {
  10297. var _self = this;
  10298. setTimeout(function() {
  10299. _self.textInput.focus();
  10300. });
  10301. this.textInput.focus();
  10302. };
  10303. this.isFocused = function() {
  10304. return this.textInput.isFocused();
  10305. };
  10306. this.blur = function() {
  10307. this.textInput.blur();
  10308. };
  10309. this.onFocus = function(e) {
  10310. if (this.$isFocused)
  10311. return;
  10312. this.$isFocused = true;
  10313. this.renderer.showCursor();
  10314. this.renderer.visualizeFocus();
  10315. this._emit("focus", e);
  10316. };
  10317. this.onBlur = function(e) {
  10318. if (!this.$isFocused)
  10319. return;
  10320. this.$isFocused = false;
  10321. this.renderer.hideCursor();
  10322. this.renderer.visualizeBlur();
  10323. this._emit("blur", e);
  10324. };
  10325. this.$cursorChange = function() {
  10326. this.renderer.updateCursor();
  10327. };
  10328. this.onDocumentChange = function(delta) {
  10329. var wrap = this.session.$useWrapMode;
  10330. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  10331. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  10332. this._signal("change", delta);
  10333. this.$cursorChange();
  10334. this.$updateHighlightActiveLine();
  10335. };
  10336. this.onTokenizerUpdate = function(e) {
  10337. var rows = e.data;
  10338. this.renderer.updateLines(rows.first, rows.last);
  10339. };
  10340. this.onScrollTopChange = function() {
  10341. this.renderer.scrollToY(this.session.getScrollTop());
  10342. };
  10343. this.onScrollLeftChange = function() {
  10344. this.renderer.scrollToX(this.session.getScrollLeft());
  10345. };
  10346. this.onCursorChange = function() {
  10347. this.$cursorChange();
  10348. if (!this.$blockScrolling) {
  10349. config.warn("Automatically scrolling cursor into view after selection change",
  10350. "this will be disabled in the next version",
  10351. "set editor.$blockScrolling = Infinity to disable this message"
  10352. );
  10353. this.renderer.scrollCursorIntoView();
  10354. }
  10355. this.$highlightBrackets();
  10356. this.$highlightTags();
  10357. this.$updateHighlightActiveLine();
  10358. this._signal("changeSelection");
  10359. };
  10360. this.$updateHighlightActiveLine = function() {
  10361. var session = this.getSession();
  10362. var highlight;
  10363. if (this.$highlightActiveLine) {
  10364. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10365. highlight = this.getCursorPosition();
  10366. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10367. highlight = false;
  10368. }
  10369. if (session.$highlightLineMarker && !highlight) {
  10370. session.removeMarker(session.$highlightLineMarker.id);
  10371. session.$highlightLineMarker = null;
  10372. } else if (!session.$highlightLineMarker && highlight) {
  10373. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10374. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10375. session.$highlightLineMarker = range;
  10376. } else if (highlight) {
  10377. session.$highlightLineMarker.start.row = highlight.row;
  10378. session.$highlightLineMarker.end.row = highlight.row;
  10379. session.$highlightLineMarker.start.column = highlight.column;
  10380. session._signal("changeBackMarker");
  10381. }
  10382. };
  10383. this.onSelectionChange = function(e) {
  10384. var session = this.session;
  10385. if (session.$selectionMarker) {
  10386. session.removeMarker(session.$selectionMarker);
  10387. }
  10388. session.$selectionMarker = null;
  10389. if (!this.selection.isEmpty()) {
  10390. var range = this.selection.getRange();
  10391. var style = this.getSelectionStyle();
  10392. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10393. } else {
  10394. this.$updateHighlightActiveLine();
  10395. }
  10396. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10397. this.session.highlight(re);
  10398. this._signal("changeSelection");
  10399. };
  10400. this.$getSelectionHighLightRegexp = function() {
  10401. var session = this.session;
  10402. var selection = this.getSelectionRange();
  10403. if (selection.isEmpty() || selection.isMultiLine())
  10404. return;
  10405. var startOuter = selection.start.column - 1;
  10406. var endOuter = selection.end.column + 1;
  10407. var line = session.getLine(selection.start.row);
  10408. var lineCols = line.length;
  10409. var needle = line.substring(Math.max(startOuter, 0),
  10410. Math.min(endOuter, lineCols));
  10411. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10412. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10413. return;
  10414. needle = line.substring(selection.start.column, selection.end.column);
  10415. if (!/^[\w\d]+$/.test(needle))
  10416. return;
  10417. var re = this.$search.$assembleRegExp({
  10418. wholeWord: true,
  10419. caseSensitive: true,
  10420. needle: needle
  10421. });
  10422. return re;
  10423. };
  10424. this.onChangeFrontMarker = function() {
  10425. this.renderer.updateFrontMarkers();
  10426. };
  10427. this.onChangeBackMarker = function() {
  10428. this.renderer.updateBackMarkers();
  10429. };
  10430. this.onChangeBreakpoint = function() {
  10431. this.renderer.updateBreakpoints();
  10432. };
  10433. this.onChangeAnnotation = function() {
  10434. this.renderer.setAnnotations(this.session.getAnnotations());
  10435. };
  10436. this.onChangeMode = function(e) {
  10437. this.renderer.updateText();
  10438. this._emit("changeMode", e);
  10439. };
  10440. this.onChangeWrapLimit = function() {
  10441. this.renderer.updateFull();
  10442. };
  10443. this.onChangeWrapMode = function() {
  10444. this.renderer.onResize(true);
  10445. };
  10446. this.onChangeFold = function() {
  10447. this.$updateHighlightActiveLine();
  10448. this.renderer.updateFull();
  10449. };
  10450. this.getSelectedText = function() {
  10451. return this.session.getTextRange(this.getSelectionRange());
  10452. };
  10453. this.getCopyText = function() {
  10454. var text = this.getSelectedText();
  10455. this._signal("copy", text);
  10456. return text;
  10457. };
  10458. this.onCopy = function() {
  10459. this.commands.exec("copy", this);
  10460. };
  10461. this.onCut = function() {
  10462. this.commands.exec("cut", this);
  10463. };
  10464. this.onPaste = function(text, event) {
  10465. var e = {text: text, event: event};
  10466. this.commands.exec("paste", this, e);
  10467. };
  10468. this.$handlePaste = function(e) {
  10469. if (typeof e == "string")
  10470. e = {text: e};
  10471. this._signal("paste", e);
  10472. var text = e.text;
  10473. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10474. this.insert(text);
  10475. } else {
  10476. var lines = text.split(/\r\n|\r|\n/);
  10477. var ranges = this.selection.rangeList.ranges;
  10478. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10479. return this.commands.exec("insertstring", this, text);
  10480. for (var i = ranges.length; i--;) {
  10481. var range = ranges[i];
  10482. if (!range.isEmpty())
  10483. this.session.remove(range);
  10484. this.session.insert(range.start, lines[i]);
  10485. }
  10486. }
  10487. };
  10488. this.execCommand = function(command, args) {
  10489. return this.commands.exec(command, this, args);
  10490. };
  10491. this.insert = function(text, pasted) {
  10492. var session = this.session;
  10493. var mode = session.getMode();
  10494. var cursor = this.getCursorPosition();
  10495. if (this.getBehavioursEnabled() && !pasted) {
  10496. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10497. if (transform) {
  10498. if (text !== transform.text) {
  10499. this.session.mergeUndoDeltas = false;
  10500. this.$mergeNextCommand = false;
  10501. }
  10502. text = transform.text;
  10503. }
  10504. }
  10505. if (text == "\t")
  10506. text = this.session.getTabString();
  10507. if (!this.selection.isEmpty()) {
  10508. var range = this.getSelectionRange();
  10509. cursor = this.session.remove(range);
  10510. this.clearSelection();
  10511. }
  10512. else if (this.session.getOverwrite()) {
  10513. var range = new Range.fromPoints(cursor, cursor);
  10514. range.end.column += text.length;
  10515. this.session.remove(range);
  10516. }
  10517. if (text == "\n" || text == "\r\n") {
  10518. var line = session.getLine(cursor.row);
  10519. if (cursor.column > line.search(/\S|$/)) {
  10520. var d = line.substr(cursor.column).search(/\S|$/);
  10521. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10522. }
  10523. }
  10524. this.clearSelection();
  10525. var start = cursor.column;
  10526. var lineState = session.getState(cursor.row);
  10527. var line = session.getLine(cursor.row);
  10528. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10529. var end = session.insert(cursor, text);
  10530. if (transform && transform.selection) {
  10531. if (transform.selection.length == 2) { // Transform relative to the current column
  10532. this.selection.setSelectionRange(
  10533. new Range(cursor.row, start + transform.selection[0],
  10534. cursor.row, start + transform.selection[1]));
  10535. } else { // Transform relative to the current row.
  10536. this.selection.setSelectionRange(
  10537. new Range(cursor.row + transform.selection[0],
  10538. transform.selection[1],
  10539. cursor.row + transform.selection[2],
  10540. transform.selection[3]));
  10541. }
  10542. }
  10543. if (session.getDocument().isNewLine(text)) {
  10544. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10545. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10546. }
  10547. if (shouldOutdent)
  10548. mode.autoOutdent(lineState, session, cursor.row);
  10549. };
  10550. this.onTextInput = function(text) {
  10551. this.keyBinding.onTextInput(text);
  10552. };
  10553. this.onCommandKey = function(e, hashId, keyCode) {
  10554. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10555. };
  10556. this.setOverwrite = function(overwrite) {
  10557. this.session.setOverwrite(overwrite);
  10558. };
  10559. this.getOverwrite = function() {
  10560. return this.session.getOverwrite();
  10561. };
  10562. this.toggleOverwrite = function() {
  10563. this.session.toggleOverwrite();
  10564. };
  10565. this.setScrollSpeed = function(speed) {
  10566. this.setOption("scrollSpeed", speed);
  10567. };
  10568. this.getScrollSpeed = function() {
  10569. return this.getOption("scrollSpeed");
  10570. };
  10571. this.setDragDelay = function(dragDelay) {
  10572. this.setOption("dragDelay", dragDelay);
  10573. };
  10574. this.getDragDelay = function() {
  10575. return this.getOption("dragDelay");
  10576. };
  10577. this.setSelectionStyle = function(val) {
  10578. this.setOption("selectionStyle", val);
  10579. };
  10580. this.getSelectionStyle = function() {
  10581. return this.getOption("selectionStyle");
  10582. };
  10583. this.setHighlightActiveLine = function(shouldHighlight) {
  10584. this.setOption("highlightActiveLine", shouldHighlight);
  10585. };
  10586. this.getHighlightActiveLine = function() {
  10587. return this.getOption("highlightActiveLine");
  10588. };
  10589. this.setHighlightGutterLine = function(shouldHighlight) {
  10590. this.setOption("highlightGutterLine", shouldHighlight);
  10591. };
  10592. this.getHighlightGutterLine = function() {
  10593. return this.getOption("highlightGutterLine");
  10594. };
  10595. this.setHighlightSelectedWord = function(shouldHighlight) {
  10596. this.setOption("highlightSelectedWord", shouldHighlight);
  10597. };
  10598. this.getHighlightSelectedWord = function() {
  10599. return this.$highlightSelectedWord;
  10600. };
  10601. this.setAnimatedScroll = function(shouldAnimate){
  10602. this.renderer.setAnimatedScroll(shouldAnimate);
  10603. };
  10604. this.getAnimatedScroll = function(){
  10605. return this.renderer.getAnimatedScroll();
  10606. };
  10607. this.setShowInvisibles = function(showInvisibles) {
  10608. this.renderer.setShowInvisibles(showInvisibles);
  10609. };
  10610. this.getShowInvisibles = function() {
  10611. return this.renderer.getShowInvisibles();
  10612. };
  10613. this.setDisplayIndentGuides = function(display) {
  10614. this.renderer.setDisplayIndentGuides(display);
  10615. };
  10616. this.getDisplayIndentGuides = function() {
  10617. return this.renderer.getDisplayIndentGuides();
  10618. };
  10619. this.setShowPrintMargin = function(showPrintMargin) {
  10620. this.renderer.setShowPrintMargin(showPrintMargin);
  10621. };
  10622. this.getShowPrintMargin = function() {
  10623. return this.renderer.getShowPrintMargin();
  10624. };
  10625. this.setPrintMarginColumn = function(showPrintMargin) {
  10626. this.renderer.setPrintMarginColumn(showPrintMargin);
  10627. };
  10628. this.getPrintMarginColumn = function() {
  10629. return this.renderer.getPrintMarginColumn();
  10630. };
  10631. this.setReadOnly = function(readOnly) {
  10632. this.setOption("readOnly", readOnly);
  10633. };
  10634. this.getReadOnly = function() {
  10635. return this.getOption("readOnly");
  10636. };
  10637. this.setBehavioursEnabled = function (enabled) {
  10638. this.setOption("behavioursEnabled", enabled);
  10639. };
  10640. this.getBehavioursEnabled = function () {
  10641. return this.getOption("behavioursEnabled");
  10642. };
  10643. this.setWrapBehavioursEnabled = function (enabled) {
  10644. this.setOption("wrapBehavioursEnabled", enabled);
  10645. };
  10646. this.getWrapBehavioursEnabled = function () {
  10647. return this.getOption("wrapBehavioursEnabled");
  10648. };
  10649. this.setShowFoldWidgets = function(show) {
  10650. this.setOption("showFoldWidgets", show);
  10651. };
  10652. this.getShowFoldWidgets = function() {
  10653. return this.getOption("showFoldWidgets");
  10654. };
  10655. this.setFadeFoldWidgets = function(fade) {
  10656. this.setOption("fadeFoldWidgets", fade);
  10657. };
  10658. this.getFadeFoldWidgets = function() {
  10659. return this.getOption("fadeFoldWidgets");
  10660. };
  10661. this.remove = function(dir) {
  10662. if (this.selection.isEmpty()){
  10663. if (dir == "left")
  10664. this.selection.selectLeft();
  10665. else
  10666. this.selection.selectRight();
  10667. }
  10668. var range = this.getSelectionRange();
  10669. if (this.getBehavioursEnabled()) {
  10670. var session = this.session;
  10671. var state = session.getState(range.start.row);
  10672. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10673. if (range.end.column === 0) {
  10674. var text = session.getTextRange(range);
  10675. if (text[text.length - 1] == "\n") {
  10676. var line = session.getLine(range.end.row);
  10677. if (/^\s+$/.test(line)) {
  10678. range.end.column = line.length;
  10679. }
  10680. }
  10681. }
  10682. if (new_range)
  10683. range = new_range;
  10684. }
  10685. this.session.remove(range);
  10686. this.clearSelection();
  10687. };
  10688. this.removeWordRight = function() {
  10689. if (this.selection.isEmpty())
  10690. this.selection.selectWordRight();
  10691. this.session.remove(this.getSelectionRange());
  10692. this.clearSelection();
  10693. };
  10694. this.removeWordLeft = function() {
  10695. if (this.selection.isEmpty())
  10696. this.selection.selectWordLeft();
  10697. this.session.remove(this.getSelectionRange());
  10698. this.clearSelection();
  10699. };
  10700. this.removeToLineStart = function() {
  10701. if (this.selection.isEmpty())
  10702. this.selection.selectLineStart();
  10703. this.session.remove(this.getSelectionRange());
  10704. this.clearSelection();
  10705. };
  10706. this.removeToLineEnd = function() {
  10707. if (this.selection.isEmpty())
  10708. this.selection.selectLineEnd();
  10709. var range = this.getSelectionRange();
  10710. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10711. range.end.column = 0;
  10712. range.end.row++;
  10713. }
  10714. this.session.remove(range);
  10715. this.clearSelection();
  10716. };
  10717. this.splitLine = function() {
  10718. if (!this.selection.isEmpty()) {
  10719. this.session.remove(this.getSelectionRange());
  10720. this.clearSelection();
  10721. }
  10722. var cursor = this.getCursorPosition();
  10723. this.insert("\n");
  10724. this.moveCursorToPosition(cursor);
  10725. };
  10726. this.transposeLetters = function() {
  10727. if (!this.selection.isEmpty()) {
  10728. return;
  10729. }
  10730. var cursor = this.getCursorPosition();
  10731. var column = cursor.column;
  10732. if (column === 0)
  10733. return;
  10734. var line = this.session.getLine(cursor.row);
  10735. var swap, range;
  10736. if (column < line.length) {
  10737. swap = line.charAt(column) + line.charAt(column-1);
  10738. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10739. }
  10740. else {
  10741. swap = line.charAt(column-1) + line.charAt(column-2);
  10742. range = new Range(cursor.row, column-2, cursor.row, column);
  10743. }
  10744. this.session.replace(range, swap);
  10745. };
  10746. this.toLowerCase = function() {
  10747. var originalRange = this.getSelectionRange();
  10748. if (this.selection.isEmpty()) {
  10749. this.selection.selectWord();
  10750. }
  10751. var range = this.getSelectionRange();
  10752. var text = this.session.getTextRange(range);
  10753. this.session.replace(range, text.toLowerCase());
  10754. this.selection.setSelectionRange(originalRange);
  10755. };
  10756. this.toUpperCase = function() {
  10757. var originalRange = this.getSelectionRange();
  10758. if (this.selection.isEmpty()) {
  10759. this.selection.selectWord();
  10760. }
  10761. var range = this.getSelectionRange();
  10762. var text = this.session.getTextRange(range);
  10763. this.session.replace(range, text.toUpperCase());
  10764. this.selection.setSelectionRange(originalRange);
  10765. };
  10766. this.indent = function() {
  10767. var session = this.session;
  10768. var range = this.getSelectionRange();
  10769. if (range.start.row < range.end.row) {
  10770. var rows = this.$getSelectedRows();
  10771. session.indentRows(rows.first, rows.last, "\t");
  10772. return;
  10773. } else if (range.start.column < range.end.column) {
  10774. var text = session.getTextRange(range);
  10775. if (!/^\s+$/.test(text)) {
  10776. var rows = this.$getSelectedRows();
  10777. session.indentRows(rows.first, rows.last, "\t");
  10778. return;
  10779. }
  10780. }
  10781. var line = session.getLine(range.start.row);
  10782. var position = range.start;
  10783. var size = session.getTabSize();
  10784. var column = session.documentToScreenColumn(position.row, position.column);
  10785. if (this.session.getUseSoftTabs()) {
  10786. var count = (size - column % size);
  10787. var indentString = lang.stringRepeat(" ", count);
  10788. } else {
  10789. var count = column % size;
  10790. while (line[range.start.column] == " " && count) {
  10791. range.start.column--;
  10792. count--;
  10793. }
  10794. this.selection.setSelectionRange(range);
  10795. indentString = "\t";
  10796. }
  10797. return this.insert(indentString);
  10798. };
  10799. this.blockIndent = function() {
  10800. var rows = this.$getSelectedRows();
  10801. this.session.indentRows(rows.first, rows.last, "\t");
  10802. };
  10803. this.blockOutdent = function() {
  10804. var selection = this.session.getSelection();
  10805. this.session.outdentRows(selection.getRange());
  10806. };
  10807. this.sortLines = function() {
  10808. var rows = this.$getSelectedRows();
  10809. var session = this.session;
  10810. var lines = [];
  10811. for (i = rows.first; i <= rows.last; i++)
  10812. lines.push(session.getLine(i));
  10813. lines.sort(function(a, b) {
  10814. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10815. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10816. return 0;
  10817. });
  10818. var deleteRange = new Range(0, 0, 0, 0);
  10819. for (var i = rows.first; i <= rows.last; i++) {
  10820. var line = session.getLine(i);
  10821. deleteRange.start.row = i;
  10822. deleteRange.end.row = i;
  10823. deleteRange.end.column = line.length;
  10824. session.replace(deleteRange, lines[i-rows.first]);
  10825. }
  10826. };
  10827. this.toggleCommentLines = function() {
  10828. var state = this.session.getState(this.getCursorPosition().row);
  10829. var rows = this.$getSelectedRows();
  10830. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10831. };
  10832. this.toggleBlockComment = function() {
  10833. var cursor = this.getCursorPosition();
  10834. var state = this.session.getState(cursor.row);
  10835. var range = this.getSelectionRange();
  10836. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10837. };
  10838. this.getNumberAt = function(row, column) {
  10839. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10840. _numberRx.lastIndex = 0;
  10841. var s = this.session.getLine(row);
  10842. while (_numberRx.lastIndex < column) {
  10843. var m = _numberRx.exec(s);
  10844. if(m.index <= column && m.index+m[0].length >= column){
  10845. var number = {
  10846. value: m[0],
  10847. start: m.index,
  10848. end: m.index+m[0].length
  10849. };
  10850. return number;
  10851. }
  10852. }
  10853. return null;
  10854. };
  10855. this.modifyNumber = function(amount) {
  10856. var row = this.selection.getCursor().row;
  10857. var column = this.selection.getCursor().column;
  10858. var charRange = new Range(row, column-1, row, column);
  10859. var c = this.session.getTextRange(charRange);
  10860. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10861. var nr = this.getNumberAt(row, column);
  10862. if (nr) {
  10863. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10864. var decimals = nr.start + nr.value.length - fp;
  10865. var t = parseFloat(nr.value);
  10866. t *= Math.pow(10, decimals);
  10867. if(fp !== nr.end && column < fp){
  10868. amount *= Math.pow(10, nr.end - column - 1);
  10869. } else {
  10870. amount *= Math.pow(10, nr.end - column);
  10871. }
  10872. t += amount;
  10873. t /= Math.pow(10, decimals);
  10874. var nnr = t.toFixed(decimals);
  10875. var replaceRange = new Range(row, nr.start, row, nr.end);
  10876. this.session.replace(replaceRange, nnr);
  10877. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10878. }
  10879. }
  10880. };
  10881. this.removeLines = function() {
  10882. var rows = this.$getSelectedRows();
  10883. this.session.removeFullLines(rows.first, rows.last);
  10884. this.clearSelection();
  10885. };
  10886. this.duplicateSelection = function() {
  10887. var sel = this.selection;
  10888. var doc = this.session;
  10889. var range = sel.getRange();
  10890. var reverse = sel.isBackwards();
  10891. if (range.isEmpty()) {
  10892. var row = range.start.row;
  10893. doc.duplicateLines(row, row);
  10894. } else {
  10895. var point = reverse ? range.start : range.end;
  10896. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10897. range.start = point;
  10898. range.end = endPoint;
  10899. sel.setSelectionRange(range, reverse);
  10900. }
  10901. };
  10902. this.moveLinesDown = function() {
  10903. this.$moveLines(1, false);
  10904. };
  10905. this.moveLinesUp = function() {
  10906. this.$moveLines(-1, false);
  10907. };
  10908. this.moveText = function(range, toPosition, copy) {
  10909. return this.session.moveText(range, toPosition, copy);
  10910. };
  10911. this.copyLinesUp = function() {
  10912. this.$moveLines(-1, true);
  10913. };
  10914. this.copyLinesDown = function() {
  10915. this.$moveLines(1, true);
  10916. };
  10917. this.$moveLines = function(dir, copy) {
  10918. var rows, moved;
  10919. var selection = this.selection;
  10920. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10921. var range = selection.toOrientedRange();
  10922. rows = this.$getSelectedRows(range);
  10923. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10924. if (copy && dir == -1) moved = 0;
  10925. range.moveBy(moved, 0);
  10926. selection.fromOrientedRange(range);
  10927. } else {
  10928. var ranges = selection.rangeList.ranges;
  10929. selection.rangeList.detach(this.session);
  10930. this.inVirtualSelectionMode = true;
  10931. var diff = 0;
  10932. var totalDiff = 0;
  10933. var l = ranges.length;
  10934. for (var i = 0; i < l; i++) {
  10935. var rangeIndex = i;
  10936. ranges[i].moveBy(diff, 0);
  10937. rows = this.$getSelectedRows(ranges[i]);
  10938. var first = rows.first;
  10939. var last = rows.last;
  10940. while (++i < l) {
  10941. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10942. var subRows = this.$getSelectedRows(ranges[i]);
  10943. if (copy && subRows.first != last)
  10944. break;
  10945. else if (!copy && subRows.first > last + 1)
  10946. break;
  10947. last = subRows.last;
  10948. }
  10949. i--;
  10950. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10951. if (copy && dir == -1) rangeIndex = i + 1;
  10952. while (rangeIndex <= i) {
  10953. ranges[rangeIndex].moveBy(diff, 0);
  10954. rangeIndex++;
  10955. }
  10956. if (!copy) diff = 0;
  10957. totalDiff += diff;
  10958. }
  10959. selection.fromOrientedRange(selection.ranges[0]);
  10960. selection.rangeList.attach(this.session);
  10961. this.inVirtualSelectionMode = false;
  10962. }
  10963. };
  10964. this.$getSelectedRows = function(range) {
  10965. range = (range || this.getSelectionRange()).collapseRows();
  10966. return {
  10967. first: this.session.getRowFoldStart(range.start.row),
  10968. last: this.session.getRowFoldEnd(range.end.row)
  10969. };
  10970. };
  10971. this.onCompositionStart = function(text) {
  10972. this.renderer.showComposition(this.getCursorPosition());
  10973. };
  10974. this.onCompositionUpdate = function(text) {
  10975. this.renderer.setCompositionText(text);
  10976. };
  10977. this.onCompositionEnd = function() {
  10978. this.renderer.hideComposition();
  10979. };
  10980. this.getFirstVisibleRow = function() {
  10981. return this.renderer.getFirstVisibleRow();
  10982. };
  10983. this.getLastVisibleRow = function() {
  10984. return this.renderer.getLastVisibleRow();
  10985. };
  10986. this.isRowVisible = function(row) {
  10987. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  10988. };
  10989. this.isRowFullyVisible = function(row) {
  10990. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  10991. };
  10992. this.$getVisibleRowCount = function() {
  10993. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  10994. };
  10995. this.$moveByPage = function(dir, select) {
  10996. var renderer = this.renderer;
  10997. var config = this.renderer.layerConfig;
  10998. var rows = dir * Math.floor(config.height / config.lineHeight);
  10999. this.$blockScrolling++;
  11000. if (select === true) {
  11001. this.selection.$moveSelection(function(){
  11002. this.moveCursorBy(rows, 0);
  11003. });
  11004. } else if (select === false) {
  11005. this.selection.moveCursorBy(rows, 0);
  11006. this.selection.clearSelection();
  11007. }
  11008. this.$blockScrolling--;
  11009. var scrollTop = renderer.scrollTop;
  11010. renderer.scrollBy(0, rows * config.lineHeight);
  11011. if (select != null)
  11012. renderer.scrollCursorIntoView(null, 0.5);
  11013. renderer.animateScrolling(scrollTop);
  11014. };
  11015. this.selectPageDown = function() {
  11016. this.$moveByPage(1, true);
  11017. };
  11018. this.selectPageUp = function() {
  11019. this.$moveByPage(-1, true);
  11020. };
  11021. this.gotoPageDown = function() {
  11022. this.$moveByPage(1, false);
  11023. };
  11024. this.gotoPageUp = function() {
  11025. this.$moveByPage(-1, false);
  11026. };
  11027. this.scrollPageDown = function() {
  11028. this.$moveByPage(1);
  11029. };
  11030. this.scrollPageUp = function() {
  11031. this.$moveByPage(-1);
  11032. };
  11033. this.scrollToRow = function(row) {
  11034. this.renderer.scrollToRow(row);
  11035. };
  11036. this.scrollToLine = function(line, center, animate, callback) {
  11037. this.renderer.scrollToLine(line, center, animate, callback);
  11038. };
  11039. this.centerSelection = function() {
  11040. var range = this.getSelectionRange();
  11041. var pos = {
  11042. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  11043. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  11044. };
  11045. this.renderer.alignCursor(pos, 0.5);
  11046. };
  11047. this.getCursorPosition = function() {
  11048. return this.selection.getCursor();
  11049. };
  11050. this.getCursorPositionScreen = function() {
  11051. return this.session.documentToScreenPosition(this.getCursorPosition());
  11052. };
  11053. this.getSelectionRange = function() {
  11054. return this.selection.getRange();
  11055. };
  11056. this.selectAll = function() {
  11057. this.$blockScrolling += 1;
  11058. this.selection.selectAll();
  11059. this.$blockScrolling -= 1;
  11060. };
  11061. this.clearSelection = function() {
  11062. this.selection.clearSelection();
  11063. };
  11064. this.moveCursorTo = function(row, column) {
  11065. this.selection.moveCursorTo(row, column);
  11066. };
  11067. this.moveCursorToPosition = function(pos) {
  11068. this.selection.moveCursorToPosition(pos);
  11069. };
  11070. this.jumpToMatching = function(select, expand) {
  11071. var cursor = this.getCursorPosition();
  11072. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  11073. var prevToken = iterator.getCurrentToken();
  11074. var token = prevToken || iterator.stepForward();
  11075. if (!token) return;
  11076. var matchType;
  11077. var found = false;
  11078. var depth = {};
  11079. var i = cursor.column - token.start;
  11080. var bracketType;
  11081. var brackets = {
  11082. ")": "(",
  11083. "(": "(",
  11084. "]": "[",
  11085. "[": "[",
  11086. "{": "{",
  11087. "}": "{"
  11088. };
  11089. do {
  11090. if (token.value.match(/[{}()\[\]]/g)) {
  11091. for (; i < token.value.length && !found; i++) {
  11092. if (!brackets[token.value[i]]) {
  11093. continue;
  11094. }
  11095. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  11096. if (isNaN(depth[bracketType])) {
  11097. depth[bracketType] = 0;
  11098. }
  11099. switch (token.value[i]) {
  11100. case '(':
  11101. case '[':
  11102. case '{':
  11103. depth[bracketType]++;
  11104. break;
  11105. case ')':
  11106. case ']':
  11107. case '}':
  11108. depth[bracketType]--;
  11109. if (depth[bracketType] === -1) {
  11110. matchType = 'bracket';
  11111. found = true;
  11112. }
  11113. break;
  11114. }
  11115. }
  11116. }
  11117. else if (token && token.type.indexOf('tag-name') !== -1) {
  11118. if (isNaN(depth[token.value])) {
  11119. depth[token.value] = 0;
  11120. }
  11121. if (prevToken.value === '<') {
  11122. depth[token.value]++;
  11123. }
  11124. else if (prevToken.value === '</') {
  11125. depth[token.value]--;
  11126. }
  11127. if (depth[token.value] === -1) {
  11128. matchType = 'tag';
  11129. found = true;
  11130. }
  11131. }
  11132. if (!found) {
  11133. prevToken = token;
  11134. token = iterator.stepForward();
  11135. i = 0;
  11136. }
  11137. } while (token && !found);
  11138. if (!matchType)
  11139. return;
  11140. var range, pos;
  11141. if (matchType === 'bracket') {
  11142. range = this.session.getBracketRange(cursor);
  11143. if (!range) {
  11144. range = new Range(
  11145. iterator.getCurrentTokenRow(),
  11146. iterator.getCurrentTokenColumn() + i - 1,
  11147. iterator.getCurrentTokenRow(),
  11148. iterator.getCurrentTokenColumn() + i - 1
  11149. );
  11150. pos = range.start;
  11151. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11152. range = this.session.getBracketRange(pos);
  11153. }
  11154. }
  11155. else if (matchType === 'tag') {
  11156. if (token && token.type.indexOf('tag-name') !== -1)
  11157. var tag = token.value;
  11158. else
  11159. return;
  11160. range = new Range(
  11161. iterator.getCurrentTokenRow(),
  11162. iterator.getCurrentTokenColumn() - 2,
  11163. iterator.getCurrentTokenRow(),
  11164. iterator.getCurrentTokenColumn() - 2
  11165. );
  11166. if (range.compare(cursor.row, cursor.column) === 0) {
  11167. found = false;
  11168. do {
  11169. token = prevToken;
  11170. prevToken = iterator.stepBackward();
  11171. if (prevToken) {
  11172. if (prevToken.type.indexOf('tag-close') !== -1) {
  11173. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11174. }
  11175. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11176. if (prevToken.value === '<') {
  11177. depth[tag]++;
  11178. }
  11179. else if (prevToken.value === '</') {
  11180. depth[tag]--;
  11181. }
  11182. if (depth[tag] === 0)
  11183. found = true;
  11184. }
  11185. }
  11186. } while (prevToken && !found);
  11187. }
  11188. if (token && token.type.indexOf('tag-name')) {
  11189. pos = range.start;
  11190. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11191. pos = range.end;
  11192. }
  11193. }
  11194. pos = range && range.cursor || pos;
  11195. if (pos) {
  11196. if (select) {
  11197. if (range && expand) {
  11198. this.selection.setRange(range);
  11199. } else if (range && range.isEqual(this.getSelectionRange())) {
  11200. this.clearSelection();
  11201. } else {
  11202. this.selection.selectTo(pos.row, pos.column);
  11203. }
  11204. } else {
  11205. this.selection.moveTo(pos.row, pos.column);
  11206. }
  11207. }
  11208. };
  11209. this.gotoLine = function(lineNumber, column, animate) {
  11210. this.selection.clearSelection();
  11211. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11212. this.$blockScrolling += 1;
  11213. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11214. this.moveCursorTo(lineNumber - 1, column || 0);
  11215. this.$blockScrolling -= 1;
  11216. if (!this.isRowFullyVisible(lineNumber - 1))
  11217. this.scrollToLine(lineNumber - 1, true, animate);
  11218. };
  11219. this.navigateTo = function(row, column) {
  11220. this.selection.moveTo(row, column);
  11221. };
  11222. this.navigateUp = function(times) {
  11223. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11224. var selectionStart = this.selection.anchor.getPosition();
  11225. return this.moveCursorToPosition(selectionStart);
  11226. }
  11227. this.selection.clearSelection();
  11228. this.selection.moveCursorBy(-times || -1, 0);
  11229. };
  11230. this.navigateDown = function(times) {
  11231. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11232. var selectionEnd = this.selection.anchor.getPosition();
  11233. return this.moveCursorToPosition(selectionEnd);
  11234. }
  11235. this.selection.clearSelection();
  11236. this.selection.moveCursorBy(times || 1, 0);
  11237. };
  11238. this.navigateLeft = function(times) {
  11239. if (!this.selection.isEmpty()) {
  11240. var selectionStart = this.getSelectionRange().start;
  11241. this.moveCursorToPosition(selectionStart);
  11242. }
  11243. else {
  11244. times = times || 1;
  11245. while (times--) {
  11246. this.selection.moveCursorLeft();
  11247. }
  11248. }
  11249. this.clearSelection();
  11250. };
  11251. this.navigateRight = function(times) {
  11252. if (!this.selection.isEmpty()) {
  11253. var selectionEnd = this.getSelectionRange().end;
  11254. this.moveCursorToPosition(selectionEnd);
  11255. }
  11256. else {
  11257. times = times || 1;
  11258. while (times--) {
  11259. this.selection.moveCursorRight();
  11260. }
  11261. }
  11262. this.clearSelection();
  11263. };
  11264. this.navigateLineStart = function() {
  11265. this.selection.moveCursorLineStart();
  11266. this.clearSelection();
  11267. };
  11268. this.navigateLineEnd = function() {
  11269. this.selection.moveCursorLineEnd();
  11270. this.clearSelection();
  11271. };
  11272. this.navigateFileEnd = function() {
  11273. this.selection.moveCursorFileEnd();
  11274. this.clearSelection();
  11275. };
  11276. this.navigateFileStart = function() {
  11277. this.selection.moveCursorFileStart();
  11278. this.clearSelection();
  11279. };
  11280. this.navigateWordRight = function() {
  11281. this.selection.moveCursorWordRight();
  11282. this.clearSelection();
  11283. };
  11284. this.navigateWordLeft = function() {
  11285. this.selection.moveCursorWordLeft();
  11286. this.clearSelection();
  11287. };
  11288. this.replace = function(replacement, options) {
  11289. if (options)
  11290. this.$search.set(options);
  11291. var range = this.$search.find(this.session);
  11292. var replaced = 0;
  11293. if (!range)
  11294. return replaced;
  11295. if (this.$tryReplace(range, replacement)) {
  11296. replaced = 1;
  11297. }
  11298. if (range !== null) {
  11299. this.selection.setSelectionRange(range);
  11300. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11301. }
  11302. return replaced;
  11303. };
  11304. this.replaceAll = function(replacement, options) {
  11305. if (options) {
  11306. this.$search.set(options);
  11307. }
  11308. var ranges = this.$search.findAll(this.session);
  11309. var replaced = 0;
  11310. if (!ranges.length)
  11311. return replaced;
  11312. this.$blockScrolling += 1;
  11313. var selection = this.getSelectionRange();
  11314. this.selection.moveTo(0, 0);
  11315. for (var i = ranges.length - 1; i >= 0; --i) {
  11316. if(this.$tryReplace(ranges[i], replacement)) {
  11317. replaced++;
  11318. }
  11319. }
  11320. this.selection.setSelectionRange(selection);
  11321. this.$blockScrolling -= 1;
  11322. return replaced;
  11323. };
  11324. this.$tryReplace = function(range, replacement) {
  11325. var input = this.session.getTextRange(range);
  11326. replacement = this.$search.replace(input, replacement);
  11327. if (replacement !== null) {
  11328. range.end = this.session.replace(range, replacement);
  11329. return range;
  11330. } else {
  11331. return null;
  11332. }
  11333. };
  11334. this.getLastSearchOptions = function() {
  11335. return this.$search.getOptions();
  11336. };
  11337. this.find = function(needle, options, animate) {
  11338. if (!options)
  11339. options = {};
  11340. if (typeof needle == "string" || needle instanceof RegExp)
  11341. options.needle = needle;
  11342. else if (typeof needle == "object")
  11343. oop.mixin(options, needle);
  11344. var range = this.selection.getRange();
  11345. if (options.needle == null) {
  11346. needle = this.session.getTextRange(range)
  11347. || this.$search.$options.needle;
  11348. if (!needle) {
  11349. range = this.session.getWordRange(range.start.row, range.start.column);
  11350. needle = this.session.getTextRange(range);
  11351. }
  11352. this.$search.set({needle: needle});
  11353. }
  11354. this.$search.set(options);
  11355. if (!options.start)
  11356. this.$search.set({start: range});
  11357. var newRange = this.$search.find(this.session);
  11358. if (options.preventScroll)
  11359. return newRange;
  11360. if (newRange) {
  11361. this.revealRange(newRange, animate);
  11362. return newRange;
  11363. }
  11364. if (options.backwards)
  11365. range.start = range.end;
  11366. else
  11367. range.end = range.start;
  11368. this.selection.setRange(range);
  11369. };
  11370. this.findNext = function(options, animate) {
  11371. this.find({skipCurrent: true, backwards: false}, options, animate);
  11372. };
  11373. this.findPrevious = function(options, animate) {
  11374. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11375. };
  11376. this.revealRange = function(range, animate) {
  11377. this.$blockScrolling += 1;
  11378. this.session.unfold(range);
  11379. this.selection.setSelectionRange(range);
  11380. this.$blockScrolling -= 1;
  11381. var scrollTop = this.renderer.scrollTop;
  11382. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11383. if (animate !== false)
  11384. this.renderer.animateScrolling(scrollTop);
  11385. };
  11386. this.undo = function() {
  11387. this.$blockScrolling++;
  11388. this.session.getUndoManager().undo();
  11389. this.$blockScrolling--;
  11390. this.renderer.scrollCursorIntoView(null, 0.5);
  11391. };
  11392. this.redo = function() {
  11393. this.$blockScrolling++;
  11394. this.session.getUndoManager().redo();
  11395. this.$blockScrolling--;
  11396. this.renderer.scrollCursorIntoView(null, 0.5);
  11397. };
  11398. this.destroy = function() {
  11399. this.renderer.destroy();
  11400. this._signal("destroy", this);
  11401. if (this.session) {
  11402. this.session.destroy();
  11403. }
  11404. };
  11405. this.setAutoScrollEditorIntoView = function(enable) {
  11406. if (!enable)
  11407. return;
  11408. var rect;
  11409. var self = this;
  11410. var shouldScroll = false;
  11411. if (!this.$scrollAnchor)
  11412. this.$scrollAnchor = document.createElement("div");
  11413. var scrollAnchor = this.$scrollAnchor;
  11414. scrollAnchor.style.cssText = "position:absolute";
  11415. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11416. var onChangeSelection = this.on("changeSelection", function() {
  11417. shouldScroll = true;
  11418. });
  11419. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11420. if (shouldScroll)
  11421. rect = self.renderer.container.getBoundingClientRect();
  11422. });
  11423. var onAfterRender = this.renderer.on("afterRender", function() {
  11424. if (shouldScroll && rect && (self.isFocused()
  11425. || self.searchBox && self.searchBox.isFocused())
  11426. ) {
  11427. var renderer = self.renderer;
  11428. var pos = renderer.$cursorLayer.$pixelPos;
  11429. var config = renderer.layerConfig;
  11430. var top = pos.top - config.offset;
  11431. if (pos.top >= 0 && top + rect.top < 0) {
  11432. shouldScroll = true;
  11433. } else if (pos.top < config.height &&
  11434. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11435. shouldScroll = false;
  11436. } else {
  11437. shouldScroll = null;
  11438. }
  11439. if (shouldScroll != null) {
  11440. scrollAnchor.style.top = top + "px";
  11441. scrollAnchor.style.left = pos.left + "px";
  11442. scrollAnchor.style.height = config.lineHeight + "px";
  11443. scrollAnchor.scrollIntoView(shouldScroll);
  11444. }
  11445. shouldScroll = rect = null;
  11446. }
  11447. });
  11448. this.setAutoScrollEditorIntoView = function(enable) {
  11449. if (enable)
  11450. return;
  11451. delete this.setAutoScrollEditorIntoView;
  11452. this.removeEventListener("changeSelection", onChangeSelection);
  11453. this.renderer.removeEventListener("afterRender", onAfterRender);
  11454. this.renderer.removeEventListener("beforeRender", onBeforeRender);
  11455. };
  11456. };
  11457. this.$resetCursorStyle = function() {
  11458. var style = this.$cursorStyle || "ace";
  11459. var cursorLayer = this.renderer.$cursorLayer;
  11460. if (!cursorLayer)
  11461. return;
  11462. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11463. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11464. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11465. };
  11466. }).call(Editor.prototype);
  11467. config.defineOptions(Editor.prototype, "editor", {
  11468. selectionStyle: {
  11469. set: function(style) {
  11470. this.onSelectionChange();
  11471. this._signal("changeSelectionStyle", {data: style});
  11472. },
  11473. initialValue: "line"
  11474. },
  11475. highlightActiveLine: {
  11476. set: function() {this.$updateHighlightActiveLine();},
  11477. initialValue: true
  11478. },
  11479. highlightSelectedWord: {
  11480. set: function(shouldHighlight) {this.$onSelectionChange();},
  11481. initialValue: true
  11482. },
  11483. readOnly: {
  11484. set: function(readOnly) {
  11485. this.$resetCursorStyle();
  11486. },
  11487. initialValue: false
  11488. },
  11489. cursorStyle: {
  11490. set: function(val) { this.$resetCursorStyle(); },
  11491. values: ["ace", "slim", "smooth", "wide"],
  11492. initialValue: "ace"
  11493. },
  11494. mergeUndoDeltas: {
  11495. values: [false, true, "always"],
  11496. initialValue: true
  11497. },
  11498. behavioursEnabled: {initialValue: true},
  11499. wrapBehavioursEnabled: {initialValue: true},
  11500. autoScrollEditorIntoView: {
  11501. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11502. },
  11503. hScrollBarAlwaysVisible: "renderer",
  11504. vScrollBarAlwaysVisible: "renderer",
  11505. highlightGutterLine: "renderer",
  11506. animatedScroll: "renderer",
  11507. showInvisibles: "renderer",
  11508. showPrintMargin: "renderer",
  11509. printMarginColumn: "renderer",
  11510. printMargin: "renderer",
  11511. fadeFoldWidgets: "renderer",
  11512. showFoldWidgets: "renderer",
  11513. showLineNumbers: "renderer",
  11514. showGutter: "renderer",
  11515. displayIndentGuides: "renderer",
  11516. fontSize: "renderer",
  11517. fontFamily: "renderer",
  11518. maxLines: "renderer",
  11519. minLines: "renderer",
  11520. scrollPastEnd: "renderer",
  11521. fixedWidthGutter: "renderer",
  11522. theme: "renderer",
  11523. scrollSpeed: "$mouseHandler",
  11524. dragDelay: "$mouseHandler",
  11525. dragEnabled: "$mouseHandler",
  11526. focusTimout: "$mouseHandler",
  11527. tooltipFollowsMouse: "$mouseHandler",
  11528. firstLineNumber: "session",
  11529. overwrite: "session",
  11530. newLineMode: "session",
  11531. useWorker: "session",
  11532. useSoftTabs: "session",
  11533. tabSize: "session",
  11534. wrap: "session",
  11535. indentedSoftWrap: "session",
  11536. foldStyle: "session",
  11537. mode: "session"
  11538. });
  11539. exports.Editor = Editor;
  11540. });
  11541. define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11542. "use strict";
  11543. var UndoManager = function() {
  11544. this.reset();
  11545. };
  11546. (function() {
  11547. this.execute = function(options) {
  11548. var deltaSets = options.args[0];
  11549. this.$doc = options.args[1];
  11550. if (options.merge && this.hasUndo()){
  11551. this.dirtyCounter--;
  11552. deltaSets = this.$undoStack.pop().concat(deltaSets);
  11553. }
  11554. this.$undoStack.push(deltaSets);
  11555. this.$redoStack = [];
  11556. if (this.dirtyCounter < 0) {
  11557. this.dirtyCounter = NaN;
  11558. }
  11559. this.dirtyCounter++;
  11560. };
  11561. this.undo = function(dontSelect) {
  11562. var deltaSets = this.$undoStack.pop();
  11563. var undoSelectionRange = null;
  11564. if (deltaSets) {
  11565. undoSelectionRange = this.$doc.undoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11566. this.$redoStack.push(deltaSets);
  11567. this.dirtyCounter--;
  11568. }
  11569. return undoSelectionRange;
  11570. };
  11571. this.redo = function(dontSelect) {
  11572. var deltaSets = this.$redoStack.pop();
  11573. var redoSelectionRange = null;
  11574. if (deltaSets) {
  11575. redoSelectionRange =
  11576. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11577. this.$undoStack.push(deltaSets);
  11578. this.dirtyCounter++;
  11579. }
  11580. return redoSelectionRange;
  11581. };
  11582. this.reset = function() {
  11583. this.$undoStack = [];
  11584. this.$redoStack = [];
  11585. this.dirtyCounter = 0;
  11586. };
  11587. this.hasUndo = function() {
  11588. return this.$undoStack.length > 0;
  11589. };
  11590. this.hasRedo = function() {
  11591. return this.$redoStack.length > 0;
  11592. };
  11593. this.markClean = function() {
  11594. this.dirtyCounter = 0;
  11595. };
  11596. this.isClean = function() {
  11597. return this.dirtyCounter === 0;
  11598. };
  11599. this.$serializeDeltas = function(deltaSets) {
  11600. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  11601. };
  11602. this.$deserializeDeltas = function(deltaSets) {
  11603. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  11604. };
  11605. function $serializeDelta(delta){
  11606. return {
  11607. action: delta.action,
  11608. start: delta.start,
  11609. end: delta.end,
  11610. lines: delta.lines.length == 1 ? null : delta.lines,
  11611. text: delta.lines.length == 1 ? delta.lines[0] : null,
  11612. };
  11613. }
  11614. function $deserializeDelta(delta) {
  11615. return {
  11616. action: delta.action,
  11617. start: delta.start,
  11618. end: delta.end,
  11619. lines: delta.lines || [delta.text]
  11620. };
  11621. }
  11622. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  11623. var deltaSets_new = new Array(deltaSets_old.length);
  11624. for (var i = 0; i < deltaSets_old.length; i++) {
  11625. var deltaSet_old = deltaSets_old[i];
  11626. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  11627. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  11628. var delta_old = deltaSet_old.deltas[j];
  11629. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  11630. }
  11631. deltaSets_new[i] = deltaSet_new;
  11632. }
  11633. return deltaSets_new;
  11634. }
  11635. }).call(UndoManager.prototype);
  11636. exports.UndoManager = UndoManager;
  11637. });
  11638. define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
  11639. "use strict";
  11640. var dom = require("../lib/dom");
  11641. var oop = require("../lib/oop");
  11642. var lang = require("../lib/lang");
  11643. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11644. var Gutter = function(parentEl) {
  11645. this.element = dom.createElement("div");
  11646. this.element.className = "ace_layer ace_gutter-layer";
  11647. parentEl.appendChild(this.element);
  11648. this.setShowFoldWidgets(this.$showFoldWidgets);
  11649. this.gutterWidth = 0;
  11650. this.$annotations = [];
  11651. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11652. this.$cells = [];
  11653. };
  11654. (function() {
  11655. oop.implement(this, EventEmitter);
  11656. this.setSession = function(session) {
  11657. if (this.session)
  11658. this.session.removeEventListener("change", this.$updateAnnotations);
  11659. this.session = session;
  11660. if (session)
  11661. session.on("change", this.$updateAnnotations);
  11662. };
  11663. this.addGutterDecoration = function(row, className){
  11664. if (window.console)
  11665. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11666. this.session.addGutterDecoration(row, className);
  11667. };
  11668. this.removeGutterDecoration = function(row, className){
  11669. if (window.console)
  11670. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11671. this.session.removeGutterDecoration(row, className);
  11672. };
  11673. this.setAnnotations = function(annotations) {
  11674. this.$annotations = [];
  11675. for (var i = 0; i < annotations.length; i++) {
  11676. var annotation = annotations[i];
  11677. var row = annotation.row;
  11678. var rowInfo = this.$annotations[row];
  11679. if (!rowInfo)
  11680. rowInfo = this.$annotations[row] = {text: []};
  11681. var annoText = annotation.text;
  11682. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11683. if (rowInfo.text.indexOf(annoText) === -1)
  11684. rowInfo.text.push(annoText);
  11685. var type = annotation.type;
  11686. if (type == "error")
  11687. rowInfo.className = " ace_error";
  11688. else if (type == "warning" && rowInfo.className != " ace_error")
  11689. rowInfo.className = " ace_warning";
  11690. else if (type == "info" && (!rowInfo.className))
  11691. rowInfo.className = " ace_info";
  11692. }
  11693. };
  11694. this.$updateAnnotations = function (delta) {
  11695. if (!this.$annotations.length)
  11696. return;
  11697. var firstRow = delta.start.row;
  11698. var len = delta.end.row - firstRow;
  11699. if (len === 0) {
  11700. } else if (delta.action == 'remove') {
  11701. this.$annotations.splice(firstRow, len + 1, null);
  11702. } else {
  11703. var args = new Array(len + 1);
  11704. args.unshift(firstRow, 1);
  11705. this.$annotations.splice.apply(this.$annotations, args);
  11706. }
  11707. };
  11708. this.update = function(config) {
  11709. var session = this.session;
  11710. var firstRow = config.firstRow;
  11711. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11712. session.getLength() - 1);
  11713. var fold = session.getNextFoldLine(firstRow);
  11714. var foldStart = fold ? fold.start.row : Infinity;
  11715. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11716. var breakpoints = session.$breakpoints;
  11717. var decorations = session.$decorations;
  11718. var firstLineNumber = session.$firstLineNumber;
  11719. var lastLineNumber = 0;
  11720. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11721. var cell = null;
  11722. var index = -1;
  11723. var row = firstRow;
  11724. while (true) {
  11725. if (row > foldStart) {
  11726. row = fold.end.row + 1;
  11727. fold = session.getNextFoldLine(row, fold);
  11728. foldStart = fold ? fold.start.row : Infinity;
  11729. }
  11730. if (row > lastRow) {
  11731. while (this.$cells.length > index + 1) {
  11732. cell = this.$cells.pop();
  11733. this.element.removeChild(cell.element);
  11734. }
  11735. break;
  11736. }
  11737. cell = this.$cells[++index];
  11738. if (!cell) {
  11739. cell = {element: null, textNode: null, foldWidget: null};
  11740. cell.element = dom.createElement("div");
  11741. cell.textNode = document.createTextNode('');
  11742. cell.element.appendChild(cell.textNode);
  11743. this.element.appendChild(cell.element);
  11744. this.$cells[index] = cell;
  11745. }
  11746. var className = "ace_gutter-cell ";
  11747. if (breakpoints[row])
  11748. className += breakpoints[row];
  11749. if (decorations[row])
  11750. className += decorations[row];
  11751. if (this.$annotations[row])
  11752. className += this.$annotations[row].className;
  11753. if (cell.element.className != className)
  11754. cell.element.className = className;
  11755. var height = session.getRowLength(row) * config.lineHeight + "px";
  11756. if (height != cell.element.style.height)
  11757. cell.element.style.height = height;
  11758. if (foldWidgets) {
  11759. var c = foldWidgets[row];
  11760. if (c == null)
  11761. c = foldWidgets[row] = session.getFoldWidget(row);
  11762. }
  11763. if (c) {
  11764. if (!cell.foldWidget) {
  11765. cell.foldWidget = dom.createElement("span");
  11766. cell.element.appendChild(cell.foldWidget);
  11767. }
  11768. var className = "ace_fold-widget ace_" + c;
  11769. if (c == "start" && row == foldStart && row < fold.end.row)
  11770. className += " ace_closed";
  11771. else
  11772. className += " ace_open";
  11773. if (cell.foldWidget.className != className)
  11774. cell.foldWidget.className = className;
  11775. var height = config.lineHeight + "px";
  11776. if (cell.foldWidget.style.height != height)
  11777. cell.foldWidget.style.height = height;
  11778. } else {
  11779. if (cell.foldWidget) {
  11780. cell.element.removeChild(cell.foldWidget);
  11781. cell.foldWidget = null;
  11782. }
  11783. }
  11784. var text = lastLineNumber = gutterRenderer
  11785. ? gutterRenderer.getText(session, row)
  11786. : row + firstLineNumber;
  11787. if (text != cell.textNode.data)
  11788. cell.textNode.data = text;
  11789. row++;
  11790. }
  11791. this.element.style.height = config.minHeight + "px";
  11792. if (this.$fixedWidth || session.$useWrapMode)
  11793. lastLineNumber = session.getLength() + firstLineNumber;
  11794. var gutterWidth = gutterRenderer
  11795. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11796. : lastLineNumber.toString().length * config.characterWidth;
  11797. var padding = this.$padding || this.$computePadding();
  11798. gutterWidth += padding.left + padding.right;
  11799. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11800. this.gutterWidth = gutterWidth;
  11801. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11802. this._emit("changeGutterWidth", gutterWidth);
  11803. }
  11804. };
  11805. this.$fixedWidth = false;
  11806. this.$showLineNumbers = true;
  11807. this.$renderer = "";
  11808. this.setShowLineNumbers = function(show) {
  11809. this.$renderer = !show && {
  11810. getWidth: function() {return ""},
  11811. getText: function() {return ""}
  11812. };
  11813. };
  11814. this.getShowLineNumbers = function() {
  11815. return this.$showLineNumbers;
  11816. };
  11817. this.$showFoldWidgets = true;
  11818. this.setShowFoldWidgets = function(show) {
  11819. if (show)
  11820. dom.addCssClass(this.element, "ace_folding-enabled");
  11821. else
  11822. dom.removeCssClass(this.element, "ace_folding-enabled");
  11823. this.$showFoldWidgets = show;
  11824. this.$padding = null;
  11825. };
  11826. this.getShowFoldWidgets = function() {
  11827. return this.$showFoldWidgets;
  11828. };
  11829. this.$computePadding = function() {
  11830. if (!this.element.firstChild)
  11831. return {left: 0, right: 0};
  11832. var style = dom.computedStyle(this.element.firstChild);
  11833. this.$padding = {};
  11834. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11835. this.$padding.right = parseInt(style.paddingRight) || 0;
  11836. return this.$padding;
  11837. };
  11838. this.getRegion = function(point) {
  11839. var padding = this.$padding || this.$computePadding();
  11840. var rect = this.element.getBoundingClientRect();
  11841. if (point.x < padding.left + rect.left)
  11842. return "markers";
  11843. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11844. return "foldWidgets";
  11845. };
  11846. }).call(Gutter.prototype);
  11847. exports.Gutter = Gutter;
  11848. });
  11849. define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11850. "use strict";
  11851. var Range = require("../range").Range;
  11852. var dom = require("../lib/dom");
  11853. var Marker = function(parentEl) {
  11854. this.element = dom.createElement("div");
  11855. this.element.className = "ace_layer ace_marker-layer";
  11856. parentEl.appendChild(this.element);
  11857. };
  11858. (function() {
  11859. this.$padding = 0;
  11860. this.setPadding = function(padding) {
  11861. this.$padding = padding;
  11862. };
  11863. this.setSession = function(session) {
  11864. this.session = session;
  11865. };
  11866. this.setMarkers = function(markers) {
  11867. this.markers = markers;
  11868. };
  11869. this.update = function(config) {
  11870. var config = config || this.config;
  11871. if (!config)
  11872. return;
  11873. this.config = config;
  11874. var html = [];
  11875. for (var key in this.markers) {
  11876. var marker = this.markers[key];
  11877. if (!marker.range) {
  11878. marker.update(html, this, this.session, config);
  11879. continue;
  11880. }
  11881. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11882. if (range.isEmpty()) continue;
  11883. range = range.toScreenRange(this.session);
  11884. if (marker.renderer) {
  11885. var top = this.$getTop(range.start.row, config);
  11886. var left = this.$padding + range.start.column * config.characterWidth;
  11887. marker.renderer(html, range, left, top, config);
  11888. } else if (marker.type == "fullLine") {
  11889. this.drawFullLineMarker(html, range, marker.clazz, config);
  11890. } else if (marker.type == "screenLine") {
  11891. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11892. } else if (range.isMultiLine()) {
  11893. if (marker.type == "text")
  11894. this.drawTextMarker(html, range, marker.clazz, config);
  11895. else
  11896. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11897. } else {
  11898. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  11899. }
  11900. }
  11901. this.element.innerHTML = html.join("");
  11902. };
  11903. this.$getTop = function(row, layerConfig) {
  11904. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11905. };
  11906. function getBorderClass(tl, tr, br, bl) {
  11907. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  11908. }
  11909. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11910. var session = this.session;
  11911. var start = range.start.row;
  11912. var end = range.end.row;
  11913. var row = start;
  11914. var prev = 0;
  11915. var curr = 0;
  11916. var next = session.getScreenLastRowColumn(row);
  11917. var lineRange = new Range(row, range.start.column, row, curr);
  11918. for (; row <= end; row++) {
  11919. lineRange.start.row = lineRange.end.row = row;
  11920. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  11921. lineRange.end.column = next;
  11922. prev = curr;
  11923. curr = next;
  11924. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  11925. this.drawSingleLineMarker(stringBuilder, lineRange,
  11926. clazz + (row == start ? " ace_start" : "") + " ace_br"
  11927. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
  11928. layerConfig, row == end ? 0 : 1, extraStyle);
  11929. }
  11930. };
  11931. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11932. var padding = this.$padding;
  11933. var height = config.lineHeight;
  11934. var top = this.$getTop(range.start.row, config);
  11935. var left = padding + range.start.column * config.characterWidth;
  11936. extraStyle = extraStyle || "";
  11937. stringBuilder.push(
  11938. "<div class='", clazz, " ace_br1 ace_start' style='",
  11939. "height:", height, "px;",
  11940. "right:0;",
  11941. "top:", top, "px;",
  11942. "left:", left, "px;", extraStyle, "'></div>"
  11943. );
  11944. top = this.$getTop(range.end.row, config);
  11945. var width = range.end.column * config.characterWidth;
  11946. stringBuilder.push(
  11947. "<div class='", clazz, " ace_br12' style='",
  11948. "height:", height, "px;",
  11949. "width:", width, "px;",
  11950. "top:", top, "px;",
  11951. "left:", padding, "px;", extraStyle, "'></div>"
  11952. );
  11953. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  11954. if (height <= 0)
  11955. return;
  11956. top = this.$getTop(range.start.row + 1, config);
  11957. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  11958. stringBuilder.push(
  11959. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  11960. "height:", height, "px;",
  11961. "right:0;",
  11962. "top:", top, "px;",
  11963. "left:", padding, "px;", extraStyle, "'></div>"
  11964. );
  11965. };
  11966. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  11967. var height = config.lineHeight;
  11968. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  11969. var top = this.$getTop(range.start.row, config);
  11970. var left = this.$padding + range.start.column * config.characterWidth;
  11971. stringBuilder.push(
  11972. "<div class='", clazz, "' style='",
  11973. "height:", height, "px;",
  11974. "width:", width, "px;",
  11975. "top:", top, "px;",
  11976. "left:", left, "px;", extraStyle || "", "'></div>"
  11977. );
  11978. };
  11979. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11980. var top = this.$getTop(range.start.row, config);
  11981. var height = config.lineHeight;
  11982. if (range.start.row != range.end.row)
  11983. height += this.$getTop(range.end.row, config) - top;
  11984. stringBuilder.push(
  11985. "<div class='", clazz, "' style='",
  11986. "height:", height, "px;",
  11987. "top:", top, "px;",
  11988. "left:0;right:0;", extraStyle || "", "'></div>"
  11989. );
  11990. };
  11991. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11992. var top = this.$getTop(range.start.row, config);
  11993. var height = config.lineHeight;
  11994. stringBuilder.push(
  11995. "<div class='", clazz, "' style='",
  11996. "height:", height, "px;",
  11997. "top:", top, "px;",
  11998. "left:0;right:0;", extraStyle || "", "'></div>"
  11999. );
  12000. };
  12001. }).call(Marker.prototype);
  12002. exports.Marker = Marker;
  12003. });
  12004. 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) {
  12005. "use strict";
  12006. var oop = require("../lib/oop");
  12007. var dom = require("../lib/dom");
  12008. var lang = require("../lib/lang");
  12009. var useragent = require("../lib/useragent");
  12010. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12011. var Text = function(parentEl) {
  12012. this.element = dom.createElement("div");
  12013. this.element.className = "ace_layer ace_text-layer";
  12014. parentEl.appendChild(this.element);
  12015. this.$updateEolChar = this.$updateEolChar.bind(this);
  12016. };
  12017. (function() {
  12018. oop.implement(this, EventEmitter);
  12019. this.EOF_CHAR = "\xB6";
  12020. this.EOL_CHAR_LF = "\xAC";
  12021. this.EOL_CHAR_CRLF = "\xa4";
  12022. this.EOL_CHAR = this.EOL_CHAR_LF;
  12023. this.TAB_CHAR = "\u2014"; //"\u21E5";
  12024. this.SPACE_CHAR = "\xB7";
  12025. this.$padding = 0;
  12026. this.$updateEolChar = function() {
  12027. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  12028. ? this.EOL_CHAR_LF
  12029. : this.EOL_CHAR_CRLF;
  12030. if (this.EOL_CHAR != EOL_CHAR) {
  12031. this.EOL_CHAR = EOL_CHAR;
  12032. return true;
  12033. }
  12034. }
  12035. this.setPadding = function(padding) {
  12036. this.$padding = padding;
  12037. this.element.style.padding = "0 " + padding + "px";
  12038. };
  12039. this.getLineHeight = function() {
  12040. return this.$fontMetrics.$characterSize.height || 0;
  12041. };
  12042. this.getCharacterWidth = function() {
  12043. return this.$fontMetrics.$characterSize.width || 0;
  12044. };
  12045. this.$setFontMetrics = function(measure) {
  12046. this.$fontMetrics = measure;
  12047. this.$fontMetrics.on("changeCharacterSize", function(e) {
  12048. this._signal("changeCharacterSize", e);
  12049. }.bind(this));
  12050. this.$pollSizeChanges();
  12051. }
  12052. this.checkForSizeChanges = function() {
  12053. this.$fontMetrics.checkForSizeChanges();
  12054. };
  12055. this.$pollSizeChanges = function() {
  12056. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  12057. };
  12058. this.setSession = function(session) {
  12059. this.session = session;
  12060. if (session)
  12061. this.$computeTabString();
  12062. };
  12063. this.showInvisibles = false;
  12064. this.setShowInvisibles = function(showInvisibles) {
  12065. if (this.showInvisibles == showInvisibles)
  12066. return false;
  12067. this.showInvisibles = showInvisibles;
  12068. this.$computeTabString();
  12069. return true;
  12070. };
  12071. this.displayIndentGuides = true;
  12072. this.setDisplayIndentGuides = function(display) {
  12073. if (this.displayIndentGuides == display)
  12074. return false;
  12075. this.displayIndentGuides = display;
  12076. this.$computeTabString();
  12077. return true;
  12078. };
  12079. this.$tabStrings = [];
  12080. this.onChangeTabSize =
  12081. this.$computeTabString = function() {
  12082. var tabSize = this.session.getTabSize();
  12083. this.tabSize = tabSize;
  12084. var tabStr = this.$tabStrings = [0];
  12085. for (var i = 1; i < tabSize + 1; i++) {
  12086. if (this.showInvisibles) {
  12087. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  12088. + lang.stringRepeat(this.TAB_CHAR, i)
  12089. + "</span>");
  12090. } else {
  12091. tabStr.push(lang.stringRepeat(" ", i));
  12092. }
  12093. }
  12094. if (this.displayIndentGuides) {
  12095. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  12096. var className = "ace_indent-guide";
  12097. var spaceClass = "";
  12098. var tabClass = "";
  12099. if (this.showInvisibles) {
  12100. className += " ace_invisible";
  12101. spaceClass = " ace_invisible_space";
  12102. tabClass = " ace_invisible_tab";
  12103. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  12104. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  12105. } else{
  12106. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  12107. var tabContent = spaceContent;
  12108. }
  12109. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  12110. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  12111. }
  12112. };
  12113. this.updateLines = function(config, firstRow, lastRow) {
  12114. if (this.config.lastRow != config.lastRow ||
  12115. this.config.firstRow != config.firstRow) {
  12116. this.scrollLines(config);
  12117. }
  12118. this.config = config;
  12119. var first = Math.max(firstRow, config.firstRow);
  12120. var last = Math.min(lastRow, config.lastRow);
  12121. var lineElements = this.element.childNodes;
  12122. var lineElementsIdx = 0;
  12123. for (var row = config.firstRow; row < first; row++) {
  12124. var foldLine = this.session.getFoldLine(row);
  12125. if (foldLine) {
  12126. if (foldLine.containsRow(first)) {
  12127. first = foldLine.start.row;
  12128. break;
  12129. } else {
  12130. row = foldLine.end.row;
  12131. }
  12132. }
  12133. lineElementsIdx ++;
  12134. }
  12135. var row = first;
  12136. var foldLine = this.session.getNextFoldLine(row);
  12137. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12138. while (true) {
  12139. if (row > foldStart) {
  12140. row = foldLine.end.row+1;
  12141. foldLine = this.session.getNextFoldLine(row, foldLine);
  12142. foldStart = foldLine ? foldLine.start.row :Infinity;
  12143. }
  12144. if (row > last)
  12145. break;
  12146. var lineElement = lineElements[lineElementsIdx++];
  12147. if (lineElement) {
  12148. var html = [];
  12149. this.$renderLine(
  12150. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  12151. );
  12152. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12153. lineElement.innerHTML = html.join("");
  12154. }
  12155. row++;
  12156. }
  12157. };
  12158. this.scrollLines = function(config) {
  12159. var oldConfig = this.config;
  12160. this.config = config;
  12161. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  12162. return this.update(config);
  12163. if (config.lastRow < oldConfig.firstRow)
  12164. return this.update(config);
  12165. var el = this.element;
  12166. if (oldConfig.firstRow < config.firstRow)
  12167. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  12168. el.removeChild(el.firstChild);
  12169. if (oldConfig.lastRow > config.lastRow)
  12170. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  12171. el.removeChild(el.lastChild);
  12172. if (config.firstRow < oldConfig.firstRow) {
  12173. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  12174. if (el.firstChild)
  12175. el.insertBefore(fragment, el.firstChild);
  12176. else
  12177. el.appendChild(fragment);
  12178. }
  12179. if (config.lastRow > oldConfig.lastRow) {
  12180. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  12181. el.appendChild(fragment);
  12182. }
  12183. };
  12184. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  12185. var fragment = this.element.ownerDocument.createDocumentFragment();
  12186. var row = firstRow;
  12187. var foldLine = this.session.getNextFoldLine(row);
  12188. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12189. while (true) {
  12190. if (row > foldStart) {
  12191. row = foldLine.end.row+1;
  12192. foldLine = this.session.getNextFoldLine(row, foldLine);
  12193. foldStart = foldLine ? foldLine.start.row : Infinity;
  12194. }
  12195. if (row > lastRow)
  12196. break;
  12197. var container = dom.createElement("div");
  12198. var html = [];
  12199. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12200. container.innerHTML = html.join("");
  12201. if (this.$useLineGroups()) {
  12202. container.className = 'ace_line_group';
  12203. fragment.appendChild(container);
  12204. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12205. } else {
  12206. while(container.firstChild)
  12207. fragment.appendChild(container.firstChild);
  12208. }
  12209. row++;
  12210. }
  12211. return fragment;
  12212. };
  12213. this.update = function(config) {
  12214. this.config = config;
  12215. var html = [];
  12216. var firstRow = config.firstRow, lastRow = config.lastRow;
  12217. var row = firstRow;
  12218. var foldLine = this.session.getNextFoldLine(row);
  12219. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12220. while (true) {
  12221. if (row > foldStart) {
  12222. row = foldLine.end.row+1;
  12223. foldLine = this.session.getNextFoldLine(row, foldLine);
  12224. foldStart = foldLine ? foldLine.start.row :Infinity;
  12225. }
  12226. if (row > lastRow)
  12227. break;
  12228. if (this.$useLineGroups())
  12229. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12230. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12231. if (this.$useLineGroups())
  12232. html.push("</div>"); // end the line group
  12233. row++;
  12234. }
  12235. this.element.innerHTML = html.join("");
  12236. };
  12237. this.$textToken = {
  12238. "text": true,
  12239. "rparen": true,
  12240. "lparen": true
  12241. };
  12242. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12243. var self = this;
  12244. 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;
  12245. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12246. if (a) {
  12247. return self.showInvisibles
  12248. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12249. : c;
  12250. } else if (c == "&") {
  12251. return "&#38;";
  12252. } else if (c == "<") {
  12253. return "&#60;";
  12254. } else if (c == ">") {
  12255. return "&#62;";
  12256. } else if (c == "\t") {
  12257. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12258. screenColumn += tabSize - 1;
  12259. return self.$tabStrings[tabSize];
  12260. } else if (c == "\u3000") {
  12261. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12262. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12263. screenColumn += 1;
  12264. return "<span class='" + classToUse + "' style='width:" +
  12265. (self.config.characterWidth * 2) +
  12266. "px'>" + space + "</span>";
  12267. } else if (b) {
  12268. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12269. } else {
  12270. screenColumn += 1;
  12271. return "<span class='ace_cjk' style='width:" +
  12272. (self.config.characterWidth * 2) +
  12273. "px'>" + c + "</span>";
  12274. }
  12275. };
  12276. var output = value.replace(replaceReg, replaceFunc);
  12277. if (!this.$textToken[token.type]) {
  12278. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12279. var style = "";
  12280. if (token.type == "fold")
  12281. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12282. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12283. }
  12284. else {
  12285. stringBuilder.push(output);
  12286. }
  12287. return screenColumn + value.length;
  12288. };
  12289. this.renderIndentGuide = function(stringBuilder, value, max) {
  12290. var cols = value.search(this.$indentGuideRe);
  12291. if (cols <= 0 || cols >= max)
  12292. return value;
  12293. if (value[0] == " ") {
  12294. cols -= cols % this.tabSize;
  12295. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12296. return value.substr(cols);
  12297. } else if (value[0] == "\t") {
  12298. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12299. return value.substr(cols);
  12300. }
  12301. return value;
  12302. };
  12303. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12304. var chars = 0;
  12305. var split = 0;
  12306. var splitChars = splits[0];
  12307. var screenColumn = 0;
  12308. for (var i = 0; i < tokens.length; i++) {
  12309. var token = tokens[i];
  12310. var value = token.value;
  12311. if (i == 0 && this.displayIndentGuides) {
  12312. chars = value.length;
  12313. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12314. if (!value)
  12315. continue;
  12316. chars -= value.length;
  12317. }
  12318. if (chars + value.length < splitChars) {
  12319. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12320. chars += value.length;
  12321. } else {
  12322. while (chars + value.length >= splitChars) {
  12323. screenColumn = this.$renderToken(
  12324. stringBuilder, screenColumn,
  12325. token, value.substring(0, splitChars - chars)
  12326. );
  12327. value = value.substring(splitChars - chars);
  12328. chars = splitChars;
  12329. if (!onlyContents) {
  12330. stringBuilder.push("</div>",
  12331. "<div class='ace_line' style='height:",
  12332. this.config.lineHeight, "px'>"
  12333. );
  12334. }
  12335. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  12336. split ++;
  12337. screenColumn = 0;
  12338. splitChars = splits[split] || Number.MAX_VALUE;
  12339. }
  12340. if (value.length != 0) {
  12341. chars += value.length;
  12342. screenColumn = this.$renderToken(
  12343. stringBuilder, screenColumn, token, value
  12344. );
  12345. }
  12346. }
  12347. }
  12348. };
  12349. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12350. var screenColumn = 0;
  12351. var token = tokens[0];
  12352. var value = token.value;
  12353. if (this.displayIndentGuides)
  12354. value = this.renderIndentGuide(stringBuilder, value);
  12355. if (value)
  12356. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12357. for (var i = 1; i < tokens.length; i++) {
  12358. token = tokens[i];
  12359. value = token.value;
  12360. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12361. }
  12362. };
  12363. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12364. if (!foldLine && foldLine != false)
  12365. foldLine = this.session.getFoldLine(row);
  12366. if (foldLine)
  12367. var tokens = this.$getFoldLineTokens(row, foldLine);
  12368. else
  12369. var tokens = this.session.getTokens(row);
  12370. if (!onlyContents) {
  12371. stringBuilder.push(
  12372. "<div class='ace_line' style='height:",
  12373. this.config.lineHeight * (
  12374. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12375. ), "px'>"
  12376. );
  12377. }
  12378. if (tokens.length) {
  12379. var splits = this.session.getRowSplitData(row);
  12380. if (splits && splits.length)
  12381. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12382. else
  12383. this.$renderSimpleLine(stringBuilder, tokens);
  12384. }
  12385. if (this.showInvisibles) {
  12386. if (foldLine)
  12387. row = foldLine.end.row
  12388. stringBuilder.push(
  12389. "<span class='ace_invisible ace_invisible_eol'>",
  12390. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12391. "</span>"
  12392. );
  12393. }
  12394. if (!onlyContents)
  12395. stringBuilder.push("</div>");
  12396. };
  12397. this.$getFoldLineTokens = function(row, foldLine) {
  12398. var session = this.session;
  12399. var renderTokens = [];
  12400. function addTokens(tokens, from, to) {
  12401. var idx = 0, col = 0;
  12402. while ((col + tokens[idx].value.length) < from) {
  12403. col += tokens[idx].value.length;
  12404. idx++;
  12405. if (idx == tokens.length)
  12406. return;
  12407. }
  12408. if (col != from) {
  12409. var value = tokens[idx].value.substring(from - col);
  12410. if (value.length > (to - from))
  12411. value = value.substring(0, to - from);
  12412. renderTokens.push({
  12413. type: tokens[idx].type,
  12414. value: value
  12415. });
  12416. col = from + value.length;
  12417. idx += 1;
  12418. }
  12419. while (col < to && idx < tokens.length) {
  12420. var value = tokens[idx].value;
  12421. if (value.length + col > to) {
  12422. renderTokens.push({
  12423. type: tokens[idx].type,
  12424. value: value.substring(0, to - col)
  12425. });
  12426. } else
  12427. renderTokens.push(tokens[idx]);
  12428. col += value.length;
  12429. idx += 1;
  12430. }
  12431. }
  12432. var tokens = session.getTokens(row);
  12433. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12434. if (placeholder != null) {
  12435. renderTokens.push({
  12436. type: "fold",
  12437. value: placeholder
  12438. });
  12439. } else {
  12440. if (isNewRow)
  12441. tokens = session.getTokens(row);
  12442. if (tokens.length)
  12443. addTokens(tokens, lastColumn, column);
  12444. }
  12445. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12446. return renderTokens;
  12447. };
  12448. this.$useLineGroups = function() {
  12449. return this.session.getUseWrapMode();
  12450. };
  12451. this.destroy = function() {
  12452. clearInterval(this.$pollSizeChangesTimer);
  12453. if (this.$measureNode)
  12454. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12455. delete this.$measureNode;
  12456. };
  12457. }).call(Text.prototype);
  12458. exports.Text = Text;
  12459. });
  12460. define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12461. "use strict";
  12462. var dom = require("../lib/dom");
  12463. var isIE8;
  12464. var Cursor = function(parentEl) {
  12465. this.element = dom.createElement("div");
  12466. this.element.className = "ace_layer ace_cursor-layer";
  12467. parentEl.appendChild(this.element);
  12468. if (isIE8 === undefined)
  12469. isIE8 = !("opacity" in this.element.style);
  12470. this.isVisible = false;
  12471. this.isBlinking = true;
  12472. this.blinkInterval = 1000;
  12473. this.smoothBlinking = false;
  12474. this.cursors = [];
  12475. this.cursor = this.addCursor();
  12476. dom.addCssClass(this.element, "ace_hidden-cursors");
  12477. this.$updateCursors = (isIE8
  12478. ? this.$updateVisibility
  12479. : this.$updateOpacity).bind(this);
  12480. };
  12481. (function() {
  12482. this.$updateVisibility = function(val) {
  12483. var cursors = this.cursors;
  12484. for (var i = cursors.length; i--; )
  12485. cursors[i].style.visibility = val ? "" : "hidden";
  12486. };
  12487. this.$updateOpacity = function(val) {
  12488. var cursors = this.cursors;
  12489. for (var i = cursors.length; i--; )
  12490. cursors[i].style.opacity = val ? "" : "0";
  12491. };
  12492. this.$padding = 0;
  12493. this.setPadding = function(padding) {
  12494. this.$padding = padding;
  12495. };
  12496. this.setSession = function(session) {
  12497. this.session = session;
  12498. };
  12499. this.setBlinking = function(blinking) {
  12500. if (blinking != this.isBlinking){
  12501. this.isBlinking = blinking;
  12502. this.restartTimer();
  12503. }
  12504. };
  12505. this.setBlinkInterval = function(blinkInterval) {
  12506. if (blinkInterval != this.blinkInterval){
  12507. this.blinkInterval = blinkInterval;
  12508. this.restartTimer();
  12509. }
  12510. };
  12511. this.setSmoothBlinking = function(smoothBlinking) {
  12512. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  12513. this.smoothBlinking = smoothBlinking;
  12514. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12515. this.$updateCursors(true);
  12516. this.$updateCursors = (this.$updateOpacity).bind(this);
  12517. this.restartTimer();
  12518. }
  12519. };
  12520. this.addCursor = function() {
  12521. var el = dom.createElement("div");
  12522. el.className = "ace_cursor";
  12523. this.element.appendChild(el);
  12524. this.cursors.push(el);
  12525. return el;
  12526. };
  12527. this.removeCursor = function() {
  12528. if (this.cursors.length > 1) {
  12529. var el = this.cursors.pop();
  12530. el.parentNode.removeChild(el);
  12531. return el;
  12532. }
  12533. };
  12534. this.hideCursor = function() {
  12535. this.isVisible = false;
  12536. dom.addCssClass(this.element, "ace_hidden-cursors");
  12537. this.restartTimer();
  12538. };
  12539. this.showCursor = function() {
  12540. this.isVisible = true;
  12541. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12542. this.restartTimer();
  12543. };
  12544. this.restartTimer = function() {
  12545. var update = this.$updateCursors;
  12546. clearInterval(this.intervalId);
  12547. clearTimeout(this.timeoutId);
  12548. if (this.smoothBlinking) {
  12549. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12550. }
  12551. update(true);
  12552. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12553. return;
  12554. if (this.smoothBlinking) {
  12555. setTimeout(function(){
  12556. dom.addCssClass(this.element, "ace_smooth-blinking");
  12557. }.bind(this));
  12558. }
  12559. var blink = function(){
  12560. this.timeoutId = setTimeout(function() {
  12561. update(false);
  12562. }, 0.6 * this.blinkInterval);
  12563. }.bind(this);
  12564. this.intervalId = setInterval(function() {
  12565. update(true);
  12566. blink();
  12567. }, this.blinkInterval);
  12568. blink();
  12569. };
  12570. this.getPixelPosition = function(position, onScreen) {
  12571. if (!this.config || !this.session)
  12572. return {left : 0, top : 0};
  12573. if (!position)
  12574. position = this.session.selection.getCursor();
  12575. var pos = this.session.documentToScreenPosition(position);
  12576. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12577. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12578. this.config.lineHeight;
  12579. return {left : cursorLeft, top : cursorTop};
  12580. };
  12581. this.update = function(config) {
  12582. this.config = config;
  12583. var selections = this.session.$selectionMarkers;
  12584. var i = 0, cursorIndex = 0;
  12585. if (selections === undefined || selections.length === 0){
  12586. selections = [{cursor: null}];
  12587. }
  12588. for (var i = 0, n = selections.length; i < n; i++) {
  12589. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12590. if ((pixelPos.top > config.height + config.offset ||
  12591. pixelPos.top < 0) && i > 1) {
  12592. continue;
  12593. }
  12594. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12595. if (!this.drawCursor) {
  12596. style.left = pixelPos.left + "px";
  12597. style.top = pixelPos.top + "px";
  12598. style.width = config.characterWidth + "px";
  12599. style.height = config.lineHeight + "px";
  12600. } else {
  12601. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12602. }
  12603. }
  12604. while (this.cursors.length > cursorIndex)
  12605. this.removeCursor();
  12606. var overwrite = this.session.getOverwrite();
  12607. this.$setOverwrite(overwrite);
  12608. this.$pixelPos = pixelPos;
  12609. this.restartTimer();
  12610. };
  12611. this.drawCursor = null;
  12612. this.$setOverwrite = function(overwrite) {
  12613. if (overwrite != this.overwrite) {
  12614. this.overwrite = overwrite;
  12615. if (overwrite)
  12616. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12617. else
  12618. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12619. }
  12620. };
  12621. this.destroy = function() {
  12622. clearInterval(this.intervalId);
  12623. clearTimeout(this.timeoutId);
  12624. };
  12625. }).call(Cursor.prototype);
  12626. exports.Cursor = Cursor;
  12627. });
  12628. define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12629. "use strict";
  12630. var oop = require("./lib/oop");
  12631. var dom = require("./lib/dom");
  12632. var event = require("./lib/event");
  12633. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12634. var ScrollBar = function(parent) {
  12635. this.element = dom.createElement("div");
  12636. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12637. this.inner = dom.createElement("div");
  12638. this.inner.className = "ace_scrollbar-inner";
  12639. this.element.appendChild(this.inner);
  12640. parent.appendChild(this.element);
  12641. this.setVisible(false);
  12642. this.skipEvent = false;
  12643. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12644. event.addListener(this.element, "mousedown", event.preventDefault);
  12645. };
  12646. (function() {
  12647. oop.implement(this, EventEmitter);
  12648. this.setVisible = function(isVisible) {
  12649. this.element.style.display = isVisible ? "" : "none";
  12650. this.isVisible = isVisible;
  12651. };
  12652. }).call(ScrollBar.prototype);
  12653. var VScrollBar = function(parent, renderer) {
  12654. ScrollBar.call(this, parent);
  12655. this.scrollTop = 0;
  12656. renderer.$scrollbarWidth =
  12657. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12658. this.inner.style.width =
  12659. this.element.style.width = (this.width || 15) + 5 + "px";
  12660. };
  12661. oop.inherits(VScrollBar, ScrollBar);
  12662. (function() {
  12663. this.classSuffix = '-v';
  12664. this.onScroll = function() {
  12665. if (!this.skipEvent) {
  12666. this.scrollTop = this.element.scrollTop;
  12667. this._emit("scroll", {data: this.scrollTop});
  12668. }
  12669. this.skipEvent = false;
  12670. };
  12671. this.getWidth = function() {
  12672. return this.isVisible ? this.width : 0;
  12673. };
  12674. this.setHeight = function(height) {
  12675. this.element.style.height = height + "px";
  12676. };
  12677. this.setInnerHeight = function(height) {
  12678. this.inner.style.height = height + "px";
  12679. };
  12680. this.setScrollHeight = function(height) {
  12681. this.inner.style.height = height + "px";
  12682. };
  12683. this.setScrollTop = function(scrollTop) {
  12684. if (this.scrollTop != scrollTop) {
  12685. this.skipEvent = true;
  12686. this.scrollTop = this.element.scrollTop = scrollTop;
  12687. }
  12688. };
  12689. }).call(VScrollBar.prototype);
  12690. var HScrollBar = function(parent, renderer) {
  12691. ScrollBar.call(this, parent);
  12692. this.scrollLeft = 0;
  12693. this.height = renderer.$scrollbarWidth;
  12694. this.inner.style.height =
  12695. this.element.style.height = (this.height || 15) + 5 + "px";
  12696. };
  12697. oop.inherits(HScrollBar, ScrollBar);
  12698. (function() {
  12699. this.classSuffix = '-h';
  12700. this.onScroll = function() {
  12701. if (!this.skipEvent) {
  12702. this.scrollLeft = this.element.scrollLeft;
  12703. this._emit("scroll", {data: this.scrollLeft});
  12704. }
  12705. this.skipEvent = false;
  12706. };
  12707. this.getHeight = function() {
  12708. return this.isVisible ? this.height : 0;
  12709. };
  12710. this.setWidth = function(width) {
  12711. this.element.style.width = width + "px";
  12712. };
  12713. this.setInnerWidth = function(width) {
  12714. this.inner.style.width = width + "px";
  12715. };
  12716. this.setScrollWidth = function(width) {
  12717. this.inner.style.width = width + "px";
  12718. };
  12719. this.setScrollLeft = function(scrollLeft) {
  12720. if (this.scrollLeft != scrollLeft) {
  12721. this.skipEvent = true;
  12722. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12723. }
  12724. };
  12725. }).call(HScrollBar.prototype);
  12726. exports.ScrollBar = VScrollBar; // backward compatibility
  12727. exports.ScrollBarV = VScrollBar; // backward compatibility
  12728. exports.ScrollBarH = HScrollBar; // backward compatibility
  12729. exports.VScrollBar = VScrollBar;
  12730. exports.HScrollBar = HScrollBar;
  12731. });
  12732. define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12733. "use strict";
  12734. var event = require("./lib/event");
  12735. var RenderLoop = function(onRender, win) {
  12736. this.onRender = onRender;
  12737. this.pending = false;
  12738. this.changes = 0;
  12739. this.window = win || window;
  12740. };
  12741. (function() {
  12742. this.schedule = function(change) {
  12743. this.changes = this.changes | change;
  12744. if (!this.pending && this.changes) {
  12745. this.pending = true;
  12746. var _self = this;
  12747. event.nextFrame(function() {
  12748. _self.pending = false;
  12749. var changes;
  12750. while (changes = _self.changes) {
  12751. _self.changes = 0;
  12752. _self.onRender(changes);
  12753. }
  12754. }, this.window);
  12755. }
  12756. };
  12757. }).call(RenderLoop.prototype);
  12758. exports.RenderLoop = RenderLoop;
  12759. });
  12760. 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) {
  12761. var oop = require("../lib/oop");
  12762. var dom = require("../lib/dom");
  12763. var lang = require("../lib/lang");
  12764. var useragent = require("../lib/useragent");
  12765. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12766. var CHAR_COUNT = 0;
  12767. var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
  12768. this.el = dom.createElement("div");
  12769. this.$setMeasureNodeStyles(this.el.style, true);
  12770. this.$main = dom.createElement("div");
  12771. this.$setMeasureNodeStyles(this.$main.style);
  12772. this.$measureNode = dom.createElement("div");
  12773. this.$setMeasureNodeStyles(this.$measureNode.style);
  12774. this.el.appendChild(this.$main);
  12775. this.el.appendChild(this.$measureNode);
  12776. parentEl.appendChild(this.el);
  12777. if (!CHAR_COUNT)
  12778. this.$testFractionalRect();
  12779. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12780. this.$characterSize = {width: 0, height: 0};
  12781. this.checkForSizeChanges();
  12782. };
  12783. (function() {
  12784. oop.implement(this, EventEmitter);
  12785. this.$characterSize = {width: 0, height: 0};
  12786. this.$testFractionalRect = function() {
  12787. var el = dom.createElement("div");
  12788. this.$setMeasureNodeStyles(el.style);
  12789. el.style.width = "0.2px";
  12790. document.documentElement.appendChild(el);
  12791. var w = el.getBoundingClientRect().width;
  12792. if (w > 0 && w < 1)
  12793. CHAR_COUNT = 50;
  12794. else
  12795. CHAR_COUNT = 100;
  12796. el.parentNode.removeChild(el);
  12797. };
  12798. this.$setMeasureNodeStyles = function(style, isRoot) {
  12799. style.width = style.height = "auto";
  12800. style.left = style.top = "0px";
  12801. style.visibility = "hidden";
  12802. style.position = "absolute";
  12803. style.whiteSpace = "pre";
  12804. if (useragent.isIE < 8) {
  12805. style["font-family"] = "inherit";
  12806. } else {
  12807. style.font = "inherit";
  12808. }
  12809. style.overflow = isRoot ? "hidden" : "visible";
  12810. };
  12811. this.checkForSizeChanges = function() {
  12812. var size = this.$measureSizes();
  12813. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12814. this.$measureNode.style.fontWeight = "bold";
  12815. var boldSize = this.$measureSizes();
  12816. this.$measureNode.style.fontWeight = "";
  12817. this.$characterSize = size;
  12818. this.charSizes = Object.create(null);
  12819. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12820. this._emit("changeCharacterSize", {data: size});
  12821. }
  12822. };
  12823. this.$pollSizeChanges = function() {
  12824. if (this.$pollSizeChangesTimer)
  12825. return this.$pollSizeChangesTimer;
  12826. var self = this;
  12827. return this.$pollSizeChangesTimer = setInterval(function() {
  12828. self.checkForSizeChanges();
  12829. }, 500);
  12830. };
  12831. this.setPolling = function(val) {
  12832. if (val) {
  12833. this.$pollSizeChanges();
  12834. } else if (this.$pollSizeChangesTimer) {
  12835. clearInterval(this.$pollSizeChangesTimer);
  12836. this.$pollSizeChangesTimer = 0;
  12837. }
  12838. };
  12839. this.$measureSizes = function() {
  12840. if (CHAR_COUNT === 50) {
  12841. var rect = null;
  12842. try {
  12843. rect = this.$measureNode.getBoundingClientRect();
  12844. } catch(e) {
  12845. rect = {width: 0, height:0 };
  12846. };
  12847. var size = {
  12848. height: rect.height,
  12849. width: rect.width / CHAR_COUNT
  12850. };
  12851. } else {
  12852. var size = {
  12853. height: this.$measureNode.clientHeight,
  12854. width: this.$measureNode.clientWidth / CHAR_COUNT
  12855. };
  12856. }
  12857. if (size.width === 0 || size.height === 0)
  12858. return null;
  12859. return size;
  12860. };
  12861. this.$measureCharWidth = function(ch) {
  12862. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12863. var rect = this.$main.getBoundingClientRect();
  12864. return rect.width / CHAR_COUNT;
  12865. };
  12866. this.getCharacterWidth = function(ch) {
  12867. var w = this.charSizes[ch];
  12868. if (w === undefined) {
  12869. this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12870. }
  12871. return w;
  12872. };
  12873. this.destroy = function() {
  12874. clearInterval(this.$pollSizeChangesTimer);
  12875. if (this.el && this.el.parentNode)
  12876. this.el.parentNode.removeChild(this.el);
  12877. };
  12878. }).call(FontMetrics.prototype);
  12879. });
  12880. 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) {
  12881. "use strict";
  12882. var oop = require("./lib/oop");
  12883. var dom = require("./lib/dom");
  12884. var config = require("./config");
  12885. var useragent = require("./lib/useragent");
  12886. var GutterLayer = require("./layer/gutter").Gutter;
  12887. var MarkerLayer = require("./layer/marker").Marker;
  12888. var TextLayer = require("./layer/text").Text;
  12889. var CursorLayer = require("./layer/cursor").Cursor;
  12890. var HScrollBar = require("./scrollbar").HScrollBar;
  12891. var VScrollBar = require("./scrollbar").VScrollBar;
  12892. var RenderLoop = require("./renderloop").RenderLoop;
  12893. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12894. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12895. var editorCss = ".ace_editor {\
  12896. position: relative;\
  12897. overflow: hidden;\
  12898. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12899. direction: ltr;\
  12900. }\
  12901. .ace_scroller {\
  12902. position: absolute;\
  12903. overflow: hidden;\
  12904. top: 0;\
  12905. bottom: 0;\
  12906. background-color: inherit;\
  12907. -ms-user-select: none;\
  12908. -moz-user-select: none;\
  12909. -webkit-user-select: none;\
  12910. user-select: none;\
  12911. cursor: text;\
  12912. }\
  12913. .ace_content {\
  12914. position: absolute;\
  12915. -moz-box-sizing: border-box;\
  12916. -webkit-box-sizing: border-box;\
  12917. box-sizing: border-box;\
  12918. min-width: 100%;\
  12919. }\
  12920. .ace_dragging .ace_scroller:before{\
  12921. position: absolute;\
  12922. top: 0;\
  12923. left: 0;\
  12924. right: 0;\
  12925. bottom: 0;\
  12926. content: '';\
  12927. background: rgba(250, 250, 250, 0.01);\
  12928. z-index: 1000;\
  12929. }\
  12930. .ace_dragging.ace_dark .ace_scroller:before{\
  12931. background: rgba(0, 0, 0, 0.01);\
  12932. }\
  12933. .ace_selecting, .ace_selecting * {\
  12934. cursor: text !important;\
  12935. }\
  12936. .ace_gutter {\
  12937. position: absolute;\
  12938. overflow : hidden;\
  12939. width: auto;\
  12940. top: 0;\
  12941. bottom: 0;\
  12942. left: 0;\
  12943. cursor: default;\
  12944. z-index: 4;\
  12945. -ms-user-select: none;\
  12946. -moz-user-select: none;\
  12947. -webkit-user-select: none;\
  12948. user-select: none;\
  12949. }\
  12950. .ace_gutter-active-line {\
  12951. position: absolute;\
  12952. left: 0;\
  12953. right: 0;\
  12954. }\
  12955. .ace_scroller.ace_scroll-left {\
  12956. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  12957. }\
  12958. .ace_gutter-cell {\
  12959. padding-left: 19px;\
  12960. padding-right: 6px;\
  12961. background-repeat: no-repeat;\
  12962. }\
  12963. .ace_gutter-cell.ace_error {\
  12964. 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==\");\
  12965. background-repeat: no-repeat;\
  12966. background-position: 2px center;\
  12967. }\
  12968. .ace_gutter-cell.ace_warning {\
  12969. 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==\");\
  12970. background-position: 2px center;\
  12971. }\
  12972. .ace_gutter-cell.ace_info {\
  12973. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  12974. background-position: 2px center;\
  12975. }\
  12976. .ace_dark .ace_gutter-cell.ace_info {\
  12977. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  12978. }\
  12979. .ace_scrollbar {\
  12980. position: absolute;\
  12981. right: 0;\
  12982. bottom: 0;\
  12983. z-index: 6;\
  12984. }\
  12985. .ace_scrollbar-inner {\
  12986. position: absolute;\
  12987. cursor: text;\
  12988. left: 0;\
  12989. top: 0;\
  12990. }\
  12991. .ace_scrollbar-v{\
  12992. overflow-x: hidden;\
  12993. overflow-y: scroll;\
  12994. top: 0;\
  12995. }\
  12996. .ace_scrollbar-h {\
  12997. overflow-x: scroll;\
  12998. overflow-y: hidden;\
  12999. left: 0;\
  13000. }\
  13001. .ace_print-margin {\
  13002. position: absolute;\
  13003. height: 100%;\
  13004. }\
  13005. .ace_text-input {\
  13006. position: absolute;\
  13007. z-index: 0;\
  13008. width: 0.5em;\
  13009. height: 1em;\
  13010. opacity: 0;\
  13011. background: transparent;\
  13012. -moz-appearance: none;\
  13013. appearance: none;\
  13014. border: none;\
  13015. resize: none;\
  13016. outline: none;\
  13017. overflow: hidden;\
  13018. font: inherit;\
  13019. padding: 0 1px;\
  13020. margin: 0 -1px;\
  13021. text-indent: -1em;\
  13022. -ms-user-select: text;\
  13023. -moz-user-select: text;\
  13024. -webkit-user-select: text;\
  13025. user-select: text;\
  13026. white-space: pre!important;\
  13027. }\
  13028. .ace_text-input.ace_composition {\
  13029. background: inherit;\
  13030. color: inherit;\
  13031. z-index: 1000;\
  13032. opacity: 1;\
  13033. text-indent: 0;\
  13034. }\
  13035. .ace_layer {\
  13036. z-index: 1;\
  13037. position: absolute;\
  13038. overflow: hidden;\
  13039. word-wrap: normal;\
  13040. white-space: pre;\
  13041. height: 100%;\
  13042. width: 100%;\
  13043. -moz-box-sizing: border-box;\
  13044. -webkit-box-sizing: border-box;\
  13045. box-sizing: border-box;\
  13046. pointer-events: none;\
  13047. }\
  13048. .ace_gutter-layer {\
  13049. position: relative;\
  13050. width: auto;\
  13051. text-align: right;\
  13052. pointer-events: auto;\
  13053. }\
  13054. .ace_text-layer {\
  13055. font: inherit !important;\
  13056. }\
  13057. .ace_cjk {\
  13058. display: inline-block;\
  13059. text-align: center;\
  13060. }\
  13061. .ace_cursor-layer {\
  13062. z-index: 4;\
  13063. }\
  13064. .ace_cursor {\
  13065. z-index: 4;\
  13066. position: absolute;\
  13067. -moz-box-sizing: border-box;\
  13068. -webkit-box-sizing: border-box;\
  13069. box-sizing: border-box;\
  13070. border-left: 2px solid;\
  13071. transform: translatez(0);\
  13072. }\
  13073. .ace_slim-cursors .ace_cursor {\
  13074. border-left-width: 1px;\
  13075. }\
  13076. .ace_overwrite-cursors .ace_cursor {\
  13077. border-left-width: 0;\
  13078. border-bottom: 1px solid;\
  13079. }\
  13080. .ace_hidden-cursors .ace_cursor {\
  13081. opacity: 0.2;\
  13082. }\
  13083. .ace_smooth-blinking .ace_cursor {\
  13084. -webkit-transition: opacity 0.18s;\
  13085. transition: opacity 0.18s;\
  13086. }\
  13087. .ace_editor.ace_multiselect .ace_cursor {\
  13088. border-left-width: 1px;\
  13089. }\
  13090. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  13091. position: absolute;\
  13092. z-index: 3;\
  13093. }\
  13094. .ace_marker-layer .ace_selection {\
  13095. position: absolute;\
  13096. z-index: 5;\
  13097. }\
  13098. .ace_marker-layer .ace_bracket {\
  13099. position: absolute;\
  13100. z-index: 6;\
  13101. }\
  13102. .ace_marker-layer .ace_active-line {\
  13103. position: absolute;\
  13104. z-index: 2;\
  13105. }\
  13106. .ace_marker-layer .ace_selected-word {\
  13107. position: absolute;\
  13108. z-index: 4;\
  13109. -moz-box-sizing: border-box;\
  13110. -webkit-box-sizing: border-box;\
  13111. box-sizing: border-box;\
  13112. }\
  13113. .ace_line .ace_fold {\
  13114. -moz-box-sizing: border-box;\
  13115. -webkit-box-sizing: border-box;\
  13116. box-sizing: border-box;\
  13117. display: inline-block;\
  13118. height: 11px;\
  13119. margin-top: -2px;\
  13120. vertical-align: middle;\
  13121. background-image:\
  13122. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13123. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  13124. background-repeat: no-repeat, repeat-x;\
  13125. background-position: center center, top left;\
  13126. color: transparent;\
  13127. border: 1px solid black;\
  13128. border-radius: 2px;\
  13129. cursor: pointer;\
  13130. pointer-events: auto;\
  13131. }\
  13132. .ace_dark .ace_fold {\
  13133. }\
  13134. .ace_fold:hover{\
  13135. background-image:\
  13136. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13137. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  13138. }\
  13139. .ace_tooltip {\
  13140. background-color: #FFF;\
  13141. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  13142. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  13143. border: 1px solid gray;\
  13144. border-radius: 1px;\
  13145. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  13146. color: black;\
  13147. max-width: 100%;\
  13148. padding: 3px 4px;\
  13149. position: fixed;\
  13150. z-index: 999999;\
  13151. -moz-box-sizing: border-box;\
  13152. -webkit-box-sizing: border-box;\
  13153. box-sizing: border-box;\
  13154. cursor: default;\
  13155. white-space: pre;\
  13156. word-wrap: break-word;\
  13157. line-height: normal;\
  13158. font-style: normal;\
  13159. font-weight: normal;\
  13160. letter-spacing: normal;\
  13161. pointer-events: none;\
  13162. }\
  13163. .ace_folding-enabled > .ace_gutter-cell {\
  13164. padding-right: 13px;\
  13165. }\
  13166. .ace_fold-widget {\
  13167. -moz-box-sizing: border-box;\
  13168. -webkit-box-sizing: border-box;\
  13169. box-sizing: border-box;\
  13170. margin: 0 -12px 0 1px;\
  13171. display: none;\
  13172. width: 11px;\
  13173. vertical-align: top;\
  13174. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  13175. background-repeat: no-repeat;\
  13176. background-position: center;\
  13177. border-radius: 3px;\
  13178. border: 1px solid transparent;\
  13179. cursor: pointer;\
  13180. }\
  13181. .ace_folding-enabled .ace_fold-widget {\
  13182. display: inline-block; \
  13183. }\
  13184. .ace_fold-widget.ace_end {\
  13185. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  13186. }\
  13187. .ace_fold-widget.ace_closed {\
  13188. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  13189. }\
  13190. .ace_fold-widget:hover {\
  13191. border: 1px solid rgba(0, 0, 0, 0.3);\
  13192. background-color: rgba(255, 255, 255, 0.2);\
  13193. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  13194. }\
  13195. .ace_fold-widget:active {\
  13196. border: 1px solid rgba(0, 0, 0, 0.4);\
  13197. background-color: rgba(0, 0, 0, 0.05);\
  13198. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  13199. }\
  13200. .ace_dark .ace_fold-widget {\
  13201. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  13202. }\
  13203. .ace_dark .ace_fold-widget.ace_end {\
  13204. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  13205. }\
  13206. .ace_dark .ace_fold-widget.ace_closed {\
  13207. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  13208. }\
  13209. .ace_dark .ace_fold-widget:hover {\
  13210. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13211. background-color: rgba(255, 255, 255, 0.1);\
  13212. }\
  13213. .ace_dark .ace_fold-widget:active {\
  13214. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13215. }\
  13216. .ace_fold-widget.ace_invalid {\
  13217. background-color: #FFB4B4;\
  13218. border-color: #DE5555;\
  13219. }\
  13220. .ace_fade-fold-widgets .ace_fold-widget {\
  13221. -webkit-transition: opacity 0.4s ease 0.05s;\
  13222. transition: opacity 0.4s ease 0.05s;\
  13223. opacity: 0;\
  13224. }\
  13225. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13226. -webkit-transition: opacity 0.05s ease 0.05s;\
  13227. transition: opacity 0.05s ease 0.05s;\
  13228. opacity:1;\
  13229. }\
  13230. .ace_underline {\
  13231. text-decoration: underline;\
  13232. }\
  13233. .ace_bold {\
  13234. font-weight: bold;\
  13235. }\
  13236. .ace_nobold .ace_bold {\
  13237. font-weight: normal;\
  13238. }\
  13239. .ace_italic {\
  13240. font-style: italic;\
  13241. }\
  13242. .ace_error-marker {\
  13243. background-color: rgba(255, 0, 0,0.2);\
  13244. position: absolute;\
  13245. z-index: 9;\
  13246. }\
  13247. .ace_highlight-marker {\
  13248. background-color: rgba(255, 255, 0,0.2);\
  13249. position: absolute;\
  13250. z-index: 8;\
  13251. }\
  13252. .ace_br1 {border-top-left-radius : 3px;}\
  13253. .ace_br2 {border-top-right-radius : 3px;}\
  13254. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  13255. .ace_br4 {border-bottom-right-radius: 3px;}\
  13256. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  13257. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  13258. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  13259. .ace_br8 {border-bottom-left-radius : 3px;}\
  13260. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  13261. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  13262. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13263. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13264. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13265. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13266. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13267. ";
  13268. dom.importCssString(editorCss, "ace_editor.css");
  13269. var VirtualRenderer = function(container, theme) {
  13270. var _self = this;
  13271. this.container = container || dom.createElement("div");
  13272. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13273. dom.addCssClass(this.container, "ace_editor");
  13274. this.setTheme(theme);
  13275. this.$gutter = dom.createElement("div");
  13276. this.$gutter.className = "ace_gutter";
  13277. this.container.appendChild(this.$gutter);
  13278. this.scroller = dom.createElement("div");
  13279. this.scroller.className = "ace_scroller";
  13280. this.container.appendChild(this.scroller);
  13281. this.content = dom.createElement("div");
  13282. this.content.className = "ace_content";
  13283. this.scroller.appendChild(this.content);
  13284. this.$gutterLayer = new GutterLayer(this.$gutter);
  13285. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13286. this.$markerBack = new MarkerLayer(this.content);
  13287. var textLayer = this.$textLayer = new TextLayer(this.content);
  13288. this.canvas = textLayer.element;
  13289. this.$markerFront = new MarkerLayer(this.content);
  13290. this.$cursorLayer = new CursorLayer(this.content);
  13291. this.$horizScroll = false;
  13292. this.$vScroll = false;
  13293. this.scrollBar =
  13294. this.scrollBarV = new VScrollBar(this.container, this);
  13295. this.scrollBarH = new HScrollBar(this.container, this);
  13296. this.scrollBarV.addEventListener("scroll", function(e) {
  13297. if (!_self.$scrollAnimation)
  13298. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13299. });
  13300. this.scrollBarH.addEventListener("scroll", function(e) {
  13301. if (!_self.$scrollAnimation)
  13302. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13303. });
  13304. this.scrollTop = 0;
  13305. this.scrollLeft = 0;
  13306. this.cursorPos = {
  13307. row : 0,
  13308. column : 0
  13309. };
  13310. this.$fontMetrics = new FontMetrics(this.container, 500);
  13311. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13312. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13313. _self.updateCharacterSize();
  13314. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13315. _self._signal("changeCharacterSize", e);
  13316. });
  13317. this.$size = {
  13318. width: 0,
  13319. height: 0,
  13320. scrollerHeight: 0,
  13321. scrollerWidth: 0,
  13322. $dirty: true
  13323. };
  13324. this.layerConfig = {
  13325. width : 1,
  13326. padding : 0,
  13327. firstRow : 0,
  13328. firstRowScreen: 0,
  13329. lastRow : 0,
  13330. lineHeight : 0,
  13331. characterWidth : 0,
  13332. minHeight : 1,
  13333. maxHeight : 1,
  13334. offset : 0,
  13335. height : 1,
  13336. gutterOffset: 1
  13337. };
  13338. this.scrollMargin = {
  13339. left: 0,
  13340. right: 0,
  13341. top: 0,
  13342. bottom: 0,
  13343. v: 0,
  13344. h: 0
  13345. };
  13346. this.$loop = new RenderLoop(
  13347. this.$renderChanges.bind(this),
  13348. this.container.ownerDocument.defaultView
  13349. );
  13350. this.$loop.schedule(this.CHANGE_FULL);
  13351. this.updateCharacterSize();
  13352. this.setPadding(4);
  13353. config.resetOptions(this);
  13354. config._emit("renderer", this);
  13355. };
  13356. (function() {
  13357. this.CHANGE_CURSOR = 1;
  13358. this.CHANGE_MARKER = 2;
  13359. this.CHANGE_GUTTER = 4;
  13360. this.CHANGE_SCROLL = 8;
  13361. this.CHANGE_LINES = 16;
  13362. this.CHANGE_TEXT = 32;
  13363. this.CHANGE_SIZE = 64;
  13364. this.CHANGE_MARKER_BACK = 128;
  13365. this.CHANGE_MARKER_FRONT = 256;
  13366. this.CHANGE_FULL = 512;
  13367. this.CHANGE_H_SCROLL = 1024;
  13368. oop.implement(this, EventEmitter);
  13369. this.updateCharacterSize = function() {
  13370. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13371. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13372. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13373. }
  13374. this.layerConfig.characterWidth =
  13375. this.characterWidth = this.$textLayer.getCharacterWidth();
  13376. this.layerConfig.lineHeight =
  13377. this.lineHeight = this.$textLayer.getLineHeight();
  13378. this.$updatePrintMargin();
  13379. };
  13380. this.setSession = function(session) {
  13381. if (this.session)
  13382. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13383. this.session = session;
  13384. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13385. session.setScrollTop(-this.scrollMargin.top);
  13386. this.$cursorLayer.setSession(session);
  13387. this.$markerBack.setSession(session);
  13388. this.$markerFront.setSession(session);
  13389. this.$gutterLayer.setSession(session);
  13390. this.$textLayer.setSession(session);
  13391. if (!session)
  13392. return;
  13393. this.$loop.schedule(this.CHANGE_FULL);
  13394. this.session.$setFontMetrics(this.$fontMetrics);
  13395. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13396. this.onChangeNewLineMode()
  13397. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13398. };
  13399. this.updateLines = function(firstRow, lastRow, force) {
  13400. if (lastRow === undefined)
  13401. lastRow = Infinity;
  13402. if (!this.$changedLines) {
  13403. this.$changedLines = {
  13404. firstRow: firstRow,
  13405. lastRow: lastRow
  13406. };
  13407. }
  13408. else {
  13409. if (this.$changedLines.firstRow > firstRow)
  13410. this.$changedLines.firstRow = firstRow;
  13411. if (this.$changedLines.lastRow < lastRow)
  13412. this.$changedLines.lastRow = lastRow;
  13413. }
  13414. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13415. if (force)
  13416. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13417. else
  13418. return;
  13419. }
  13420. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13421. return;
  13422. this.$loop.schedule(this.CHANGE_LINES);
  13423. };
  13424. this.onChangeNewLineMode = function() {
  13425. this.$loop.schedule(this.CHANGE_TEXT);
  13426. this.$textLayer.$updateEolChar();
  13427. };
  13428. this.onChangeTabSize = function() {
  13429. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13430. this.$textLayer.onChangeTabSize();
  13431. };
  13432. this.updateText = function() {
  13433. this.$loop.schedule(this.CHANGE_TEXT);
  13434. };
  13435. this.updateFull = function(force) {
  13436. if (force)
  13437. this.$renderChanges(this.CHANGE_FULL, true);
  13438. else
  13439. this.$loop.schedule(this.CHANGE_FULL);
  13440. };
  13441. this.updateFontSize = function() {
  13442. this.$textLayer.checkForSizeChanges();
  13443. };
  13444. this.$changes = 0;
  13445. this.$updateSizeAsync = function() {
  13446. if (this.$loop.pending)
  13447. this.$size.$dirty = true;
  13448. else
  13449. this.onResize();
  13450. };
  13451. this.onResize = function(force, gutterWidth, width, height) {
  13452. if (this.resizing > 2)
  13453. return;
  13454. else if (this.resizing > 0)
  13455. this.resizing++;
  13456. else
  13457. this.resizing = force ? 1 : 0;
  13458. var el = this.container;
  13459. if (!height)
  13460. height = el.clientHeight || el.scrollHeight;
  13461. if (!width)
  13462. width = el.clientWidth || el.scrollWidth;
  13463. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13464. if (!this.$size.scrollerHeight || (!width && !height))
  13465. return this.resizing = 0;
  13466. if (force)
  13467. this.$gutterLayer.$padding = null;
  13468. if (force)
  13469. this.$renderChanges(changes | this.$changes, true);
  13470. else
  13471. this.$loop.schedule(changes | this.$changes);
  13472. if (this.resizing)
  13473. this.resizing = 0;
  13474. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13475. };
  13476. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13477. height -= (this.$extraHeight || 0);
  13478. var changes = 0;
  13479. var size = this.$size;
  13480. var oldSize = {
  13481. width: size.width,
  13482. height: size.height,
  13483. scrollerHeight: size.scrollerHeight,
  13484. scrollerWidth: size.scrollerWidth
  13485. };
  13486. if (height && (force || size.height != height)) {
  13487. size.height = height;
  13488. changes |= this.CHANGE_SIZE;
  13489. size.scrollerHeight = size.height;
  13490. if (this.$horizScroll)
  13491. size.scrollerHeight -= this.scrollBarH.getHeight();
  13492. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13493. changes = changes | this.CHANGE_SCROLL;
  13494. }
  13495. if (width && (force || size.width != width)) {
  13496. changes |= this.CHANGE_SIZE;
  13497. size.width = width;
  13498. if (gutterWidth == null)
  13499. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13500. this.gutterWidth = gutterWidth;
  13501. this.scrollBarH.element.style.left =
  13502. this.scroller.style.left = gutterWidth + "px";
  13503. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13504. this.scrollBarH.element.style.right =
  13505. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13506. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13507. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13508. changes |= this.CHANGE_FULL;
  13509. }
  13510. size.$dirty = !width || !height;
  13511. if (changes)
  13512. this._signal("resize", oldSize);
  13513. return changes;
  13514. };
  13515. this.onGutterResize = function() {
  13516. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13517. if (gutterWidth != this.gutterWidth)
  13518. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13519. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13520. this.$loop.schedule(this.CHANGE_FULL);
  13521. } else if (this.$size.$dirty) {
  13522. this.$loop.schedule(this.CHANGE_FULL);
  13523. } else {
  13524. this.$computeLayerConfig();
  13525. this.$loop.schedule(this.CHANGE_MARKER);
  13526. }
  13527. };
  13528. this.adjustWrapLimit = function() {
  13529. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13530. var limit = Math.floor(availableWidth / this.characterWidth);
  13531. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13532. };
  13533. this.setAnimatedScroll = function(shouldAnimate){
  13534. this.setOption("animatedScroll", shouldAnimate);
  13535. };
  13536. this.getAnimatedScroll = function() {
  13537. return this.$animatedScroll;
  13538. };
  13539. this.setShowInvisibles = function(showInvisibles) {
  13540. this.setOption("showInvisibles", showInvisibles);
  13541. };
  13542. this.getShowInvisibles = function() {
  13543. return this.getOption("showInvisibles");
  13544. };
  13545. this.getDisplayIndentGuides = function() {
  13546. return this.getOption("displayIndentGuides");
  13547. };
  13548. this.setDisplayIndentGuides = function(display) {
  13549. this.setOption("displayIndentGuides", display);
  13550. };
  13551. this.setShowPrintMargin = function(showPrintMargin) {
  13552. this.setOption("showPrintMargin", showPrintMargin);
  13553. };
  13554. this.getShowPrintMargin = function() {
  13555. return this.getOption("showPrintMargin");
  13556. };
  13557. this.setPrintMarginColumn = function(showPrintMargin) {
  13558. this.setOption("printMarginColumn", showPrintMargin);
  13559. };
  13560. this.getPrintMarginColumn = function() {
  13561. return this.getOption("printMarginColumn");
  13562. };
  13563. this.getShowGutter = function(){
  13564. return this.getOption("showGutter");
  13565. };
  13566. this.setShowGutter = function(show){
  13567. return this.setOption("showGutter", show);
  13568. };
  13569. this.getFadeFoldWidgets = function(){
  13570. return this.getOption("fadeFoldWidgets")
  13571. };
  13572. this.setFadeFoldWidgets = function(show) {
  13573. this.setOption("fadeFoldWidgets", show);
  13574. };
  13575. this.setHighlightGutterLine = function(shouldHighlight) {
  13576. this.setOption("highlightGutterLine", shouldHighlight);
  13577. };
  13578. this.getHighlightGutterLine = function() {
  13579. return this.getOption("highlightGutterLine");
  13580. };
  13581. this.$updateGutterLineHighlight = function() {
  13582. var pos = this.$cursorLayer.$pixelPos;
  13583. var height = this.layerConfig.lineHeight;
  13584. if (this.session.getUseWrapMode()) {
  13585. var cursor = this.session.selection.getCursor();
  13586. cursor.column = 0;
  13587. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13588. height *= this.session.getRowLength(cursor.row);
  13589. }
  13590. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13591. this.$gutterLineHighlight.style.height = height + "px";
  13592. };
  13593. this.$updatePrintMargin = function() {
  13594. if (!this.$showPrintMargin && !this.$printMarginEl)
  13595. return;
  13596. if (!this.$printMarginEl) {
  13597. var containerEl = dom.createElement("div");
  13598. containerEl.className = "ace_layer ace_print-margin-layer";
  13599. this.$printMarginEl = dom.createElement("div");
  13600. this.$printMarginEl.className = "ace_print-margin";
  13601. containerEl.appendChild(this.$printMarginEl);
  13602. this.content.insertBefore(containerEl, this.content.firstChild);
  13603. }
  13604. var style = this.$printMarginEl.style;
  13605. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13606. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13607. if (this.session && this.session.$wrap == -1)
  13608. this.adjustWrapLimit();
  13609. };
  13610. this.getContainerElement = function() {
  13611. return this.container;
  13612. };
  13613. this.getMouseEventTarget = function() {
  13614. return this.scroller;
  13615. };
  13616. this.getTextAreaContainer = function() {
  13617. return this.container;
  13618. };
  13619. this.$moveTextAreaToCursor = function() {
  13620. if (!this.$keepTextAreaAtCursor)
  13621. return;
  13622. var config = this.layerConfig;
  13623. var posTop = this.$cursorLayer.$pixelPos.top;
  13624. var posLeft = this.$cursorLayer.$pixelPos.left;
  13625. posTop -= config.offset;
  13626. var style = this.textarea.style;
  13627. var h = this.lineHeight;
  13628. if (posTop < 0 || posTop > config.height - h) {
  13629. style.top = style.left = "0";
  13630. return;
  13631. }
  13632. var w = this.characterWidth;
  13633. if (this.$composition) {
  13634. var val = this.textarea.value.replace(/^\x01+/, "");
  13635. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13636. h += 2;
  13637. }
  13638. posLeft -= this.scrollLeft;
  13639. if (posLeft > this.$size.scrollerWidth - w)
  13640. posLeft = this.$size.scrollerWidth - w;
  13641. posLeft += this.gutterWidth;
  13642. style.height = h + "px";
  13643. style.width = w + "px";
  13644. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13645. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13646. };
  13647. this.getFirstVisibleRow = function() {
  13648. return this.layerConfig.firstRow;
  13649. };
  13650. this.getFirstFullyVisibleRow = function() {
  13651. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13652. };
  13653. this.getLastFullyVisibleRow = function() {
  13654. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  13655. return this.layerConfig.firstRow - 1 + flint;
  13656. };
  13657. this.getLastVisibleRow = function() {
  13658. return this.layerConfig.lastRow;
  13659. };
  13660. this.$padding = null;
  13661. this.setPadding = function(padding) {
  13662. this.$padding = padding;
  13663. this.$textLayer.setPadding(padding);
  13664. this.$cursorLayer.setPadding(padding);
  13665. this.$markerFront.setPadding(padding);
  13666. this.$markerBack.setPadding(padding);
  13667. this.$loop.schedule(this.CHANGE_FULL);
  13668. this.$updatePrintMargin();
  13669. };
  13670. this.setScrollMargin = function(top, bottom, left, right) {
  13671. var sm = this.scrollMargin;
  13672. sm.top = top|0;
  13673. sm.bottom = bottom|0;
  13674. sm.right = right|0;
  13675. sm.left = left|0;
  13676. sm.v = sm.top + sm.bottom;
  13677. sm.h = sm.left + sm.right;
  13678. if (sm.top && this.scrollTop <= 0 && this.session)
  13679. this.session.setScrollTop(-sm.top);
  13680. this.updateFull();
  13681. };
  13682. this.getHScrollBarAlwaysVisible = function() {
  13683. return this.$hScrollBarAlwaysVisible;
  13684. };
  13685. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13686. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13687. };
  13688. this.getVScrollBarAlwaysVisible = function() {
  13689. return this.$vScrollBarAlwaysVisible;
  13690. };
  13691. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13692. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13693. };
  13694. this.$updateScrollBarV = function() {
  13695. var scrollHeight = this.layerConfig.maxHeight;
  13696. var scrollerHeight = this.$size.scrollerHeight;
  13697. if (!this.$maxLines && this.$scrollPastEnd) {
  13698. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13699. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13700. scrollHeight = this.scrollTop + scrollerHeight;
  13701. this.scrollBarV.scrollTop = null;
  13702. }
  13703. }
  13704. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13705. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13706. };
  13707. this.$updateScrollBarH = function() {
  13708. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13709. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13710. };
  13711. this.$frozen = false;
  13712. this.freeze = function() {
  13713. this.$frozen = true;
  13714. };
  13715. this.unfreeze = function() {
  13716. this.$frozen = false;
  13717. };
  13718. this.$renderChanges = function(changes, force) {
  13719. if (this.$changes) {
  13720. changes |= this.$changes;
  13721. this.$changes = 0;
  13722. }
  13723. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13724. this.$changes |= changes;
  13725. return;
  13726. }
  13727. if (this.$size.$dirty) {
  13728. this.$changes |= changes;
  13729. return this.onResize(true);
  13730. }
  13731. if (!this.lineHeight) {
  13732. this.$textLayer.checkForSizeChanges();
  13733. }
  13734. this._signal("beforeRender");
  13735. var config = this.layerConfig;
  13736. if (changes & this.CHANGE_FULL ||
  13737. changes & this.CHANGE_SIZE ||
  13738. changes & this.CHANGE_TEXT ||
  13739. changes & this.CHANGE_LINES ||
  13740. changes & this.CHANGE_SCROLL ||
  13741. changes & this.CHANGE_H_SCROLL
  13742. ) {
  13743. changes |= this.$computeLayerConfig();
  13744. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13745. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13746. if (st > 0) {
  13747. this.scrollTop = st;
  13748. changes = changes | this.CHANGE_SCROLL;
  13749. changes |= this.$computeLayerConfig();
  13750. }
  13751. }
  13752. config = this.layerConfig;
  13753. this.$updateScrollBarV();
  13754. if (changes & this.CHANGE_H_SCROLL)
  13755. this.$updateScrollBarH();
  13756. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13757. this.content.style.marginTop = (-config.offset) + "px";
  13758. this.content.style.width = config.width + 2 * this.$padding + "px";
  13759. this.content.style.height = config.minHeight + "px";
  13760. }
  13761. if (changes & this.CHANGE_H_SCROLL) {
  13762. this.content.style.marginLeft = -this.scrollLeft + "px";
  13763. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13764. }
  13765. if (changes & this.CHANGE_FULL) {
  13766. this.$textLayer.update(config);
  13767. if (this.$showGutter)
  13768. this.$gutterLayer.update(config);
  13769. this.$markerBack.update(config);
  13770. this.$markerFront.update(config);
  13771. this.$cursorLayer.update(config);
  13772. this.$moveTextAreaToCursor();
  13773. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13774. this._signal("afterRender");
  13775. return;
  13776. }
  13777. if (changes & this.CHANGE_SCROLL) {
  13778. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13779. this.$textLayer.update(config);
  13780. else
  13781. this.$textLayer.scrollLines(config);
  13782. if (this.$showGutter)
  13783. this.$gutterLayer.update(config);
  13784. this.$markerBack.update(config);
  13785. this.$markerFront.update(config);
  13786. this.$cursorLayer.update(config);
  13787. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13788. this.$moveTextAreaToCursor();
  13789. this._signal("afterRender");
  13790. return;
  13791. }
  13792. if (changes & this.CHANGE_TEXT) {
  13793. this.$textLayer.update(config);
  13794. if (this.$showGutter)
  13795. this.$gutterLayer.update(config);
  13796. }
  13797. else if (changes & this.CHANGE_LINES) {
  13798. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13799. this.$gutterLayer.update(config);
  13800. }
  13801. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13802. if (this.$showGutter)
  13803. this.$gutterLayer.update(config);
  13804. }
  13805. if (changes & this.CHANGE_CURSOR) {
  13806. this.$cursorLayer.update(config);
  13807. this.$moveTextAreaToCursor();
  13808. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13809. }
  13810. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13811. this.$markerFront.update(config);
  13812. }
  13813. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13814. this.$markerBack.update(config);
  13815. }
  13816. this._signal("afterRender");
  13817. };
  13818. this.$autosize = function() {
  13819. var height = this.session.getScreenLength() * this.lineHeight;
  13820. var maxHeight = this.$maxLines * this.lineHeight;
  13821. var desiredHeight = Math.max(
  13822. (this.$minLines||1) * this.lineHeight,
  13823. Math.min(maxHeight, height)
  13824. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13825. if (this.$horizScroll)
  13826. desiredHeight += this.scrollBarH.getHeight();
  13827. var vScroll = height > maxHeight;
  13828. if (desiredHeight != this.desiredHeight ||
  13829. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13830. if (vScroll != this.$vScroll) {
  13831. this.$vScroll = vScroll;
  13832. this.scrollBarV.setVisible(vScroll);
  13833. }
  13834. var w = this.container.clientWidth;
  13835. this.container.style.height = desiredHeight + "px";
  13836. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13837. this.desiredHeight = desiredHeight;
  13838. this._signal("autosize");
  13839. }
  13840. };
  13841. this.$computeLayerConfig = function() {
  13842. var session = this.session;
  13843. var size = this.$size;
  13844. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13845. var screenLines = this.session.getScreenLength();
  13846. var maxHeight = screenLines * this.lineHeight;
  13847. var longestLine = this.$getLongestLine();
  13848. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13849. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13850. var hScrollChanged = this.$horizScroll !== horizScroll;
  13851. if (hScrollChanged) {
  13852. this.$horizScroll = horizScroll;
  13853. this.scrollBarH.setVisible(horizScroll);
  13854. }
  13855. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  13856. if (this.$maxLines && this.lineHeight > 1)
  13857. this.$autosize();
  13858. var offset = this.scrollTop % this.lineHeight;
  13859. var minHeight = size.scrollerHeight + this.lineHeight;
  13860. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13861. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13862. : 0;
  13863. maxHeight += scrollPastEnd;
  13864. var sm = this.scrollMargin;
  13865. this.session.setScrollTop(Math.max(-sm.top,
  13866. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  13867. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  13868. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  13869. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13870. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  13871. var vScrollChanged = vScrollBefore !== vScroll;
  13872. if (vScrollChanged) {
  13873. this.$vScroll = vScroll;
  13874. this.scrollBarV.setVisible(vScroll);
  13875. }
  13876. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13877. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13878. var lastRow = firstRow + lineCount;
  13879. var firstRowScreen, firstRowHeight;
  13880. var lineHeight = this.lineHeight;
  13881. firstRow = session.screenToDocumentRow(firstRow, 0);
  13882. var foldLine = session.getFoldLine(firstRow);
  13883. if (foldLine) {
  13884. firstRow = foldLine.start.row;
  13885. }
  13886. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13887. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13888. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13889. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13890. firstRowHeight;
  13891. offset = this.scrollTop - firstRowScreen * lineHeight;
  13892. var changes = 0;
  13893. if (this.layerConfig.width != longestLine)
  13894. changes = this.CHANGE_H_SCROLL;
  13895. if (hScrollChanged || vScrollChanged) {
  13896. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13897. this._signal("scrollbarVisibilityChanged");
  13898. if (vScrollChanged)
  13899. longestLine = this.$getLongestLine();
  13900. }
  13901. this.layerConfig = {
  13902. width : longestLine,
  13903. padding : this.$padding,
  13904. firstRow : firstRow,
  13905. firstRowScreen: firstRowScreen,
  13906. lastRow : lastRow,
  13907. lineHeight : lineHeight,
  13908. characterWidth : this.characterWidth,
  13909. minHeight : minHeight,
  13910. maxHeight : maxHeight,
  13911. offset : offset,
  13912. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13913. height : this.$size.scrollerHeight
  13914. };
  13915. return changes;
  13916. };
  13917. this.$updateLines = function() {
  13918. var firstRow = this.$changedLines.firstRow;
  13919. var lastRow = this.$changedLines.lastRow;
  13920. this.$changedLines = null;
  13921. var layerConfig = this.layerConfig;
  13922. if (firstRow > layerConfig.lastRow + 1) { return; }
  13923. if (lastRow < layerConfig.firstRow) { return; }
  13924. if (lastRow === Infinity) {
  13925. if (this.$showGutter)
  13926. this.$gutterLayer.update(layerConfig);
  13927. this.$textLayer.update(layerConfig);
  13928. return;
  13929. }
  13930. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13931. return true;
  13932. };
  13933. this.$getLongestLine = function() {
  13934. var charCount = this.session.getScreenWidth();
  13935. if (this.showInvisibles && !this.session.$useWrapMode)
  13936. charCount += 1;
  13937. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13938. };
  13939. this.updateFrontMarkers = function() {
  13940. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13941. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13942. };
  13943. this.updateBackMarkers = function() {
  13944. this.$markerBack.setMarkers(this.session.getMarkers());
  13945. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  13946. };
  13947. this.addGutterDecoration = function(row, className){
  13948. this.$gutterLayer.addGutterDecoration(row, className);
  13949. };
  13950. this.removeGutterDecoration = function(row, className){
  13951. this.$gutterLayer.removeGutterDecoration(row, className);
  13952. };
  13953. this.updateBreakpoints = function(rows) {
  13954. this.$loop.schedule(this.CHANGE_GUTTER);
  13955. };
  13956. this.setAnnotations = function(annotations) {
  13957. this.$gutterLayer.setAnnotations(annotations);
  13958. this.$loop.schedule(this.CHANGE_GUTTER);
  13959. };
  13960. this.updateCursor = function() {
  13961. this.$loop.schedule(this.CHANGE_CURSOR);
  13962. };
  13963. this.hideCursor = function() {
  13964. this.$cursorLayer.hideCursor();
  13965. };
  13966. this.showCursor = function() {
  13967. this.$cursorLayer.showCursor();
  13968. };
  13969. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  13970. this.scrollCursorIntoView(anchor, offset);
  13971. this.scrollCursorIntoView(lead, offset);
  13972. };
  13973. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  13974. if (this.$size.scrollerHeight === 0)
  13975. return;
  13976. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13977. var left = pos.left;
  13978. var top = pos.top;
  13979. var topMargin = $viewMargin && $viewMargin.top || 0;
  13980. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  13981. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  13982. if (scrollTop + topMargin > top) {
  13983. if (offset)
  13984. top -= offset * this.$size.scrollerHeight;
  13985. if (top === 0)
  13986. top = -this.scrollMargin.top;
  13987. this.session.setScrollTop(top);
  13988. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  13989. if (offset)
  13990. top += offset * this.$size.scrollerHeight;
  13991. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  13992. }
  13993. var scrollLeft = this.scrollLeft;
  13994. if (scrollLeft > left) {
  13995. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  13996. left = -this.scrollMargin.left;
  13997. this.session.setScrollLeft(left);
  13998. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  13999. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  14000. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  14001. this.session.setScrollLeft(0);
  14002. }
  14003. };
  14004. this.getScrollTop = function() {
  14005. return this.session.getScrollTop();
  14006. };
  14007. this.getScrollLeft = function() {
  14008. return this.session.getScrollLeft();
  14009. };
  14010. this.getScrollTopRow = function() {
  14011. return this.scrollTop / this.lineHeight;
  14012. };
  14013. this.getScrollBottomRow = function() {
  14014. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  14015. };
  14016. this.scrollToRow = function(row) {
  14017. this.session.setScrollTop(row * this.lineHeight);
  14018. };
  14019. this.alignCursor = function(cursor, alignment) {
  14020. if (typeof cursor == "number")
  14021. cursor = {row: cursor, column: 0};
  14022. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14023. var h = this.$size.scrollerHeight - this.lineHeight;
  14024. var offset = pos.top - h * (alignment || 0);
  14025. this.session.setScrollTop(offset);
  14026. return offset;
  14027. };
  14028. this.STEPS = 8;
  14029. this.$calcSteps = function(fromValue, toValue){
  14030. var i = 0;
  14031. var l = this.STEPS;
  14032. var steps = [];
  14033. var func = function(t, x_min, dx) {
  14034. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  14035. };
  14036. for (i = 0; i < l; ++i)
  14037. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  14038. return steps;
  14039. };
  14040. this.scrollToLine = function(line, center, animate, callback) {
  14041. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  14042. var offset = pos.top;
  14043. if (center)
  14044. offset -= this.$size.scrollerHeight / 2;
  14045. var initialScroll = this.scrollTop;
  14046. this.session.setScrollTop(offset);
  14047. if (animate !== false)
  14048. this.animateScrolling(initialScroll, callback);
  14049. };
  14050. this.animateScrolling = function(fromValue, callback) {
  14051. var toValue = this.scrollTop;
  14052. if (!this.$animatedScroll)
  14053. return;
  14054. var _self = this;
  14055. if (fromValue == toValue)
  14056. return;
  14057. if (this.$scrollAnimation) {
  14058. var oldSteps = this.$scrollAnimation.steps;
  14059. if (oldSteps.length) {
  14060. fromValue = oldSteps[0];
  14061. if (fromValue == toValue)
  14062. return;
  14063. }
  14064. }
  14065. var steps = _self.$calcSteps(fromValue, toValue);
  14066. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  14067. clearInterval(this.$timer);
  14068. _self.session.setScrollTop(steps.shift());
  14069. _self.session.$scrollTop = toValue;
  14070. this.$timer = setInterval(function() {
  14071. if (steps.length) {
  14072. _self.session.setScrollTop(steps.shift());
  14073. _self.session.$scrollTop = toValue;
  14074. } else if (toValue != null) {
  14075. _self.session.$scrollTop = -1;
  14076. _self.session.setScrollTop(toValue);
  14077. toValue = null;
  14078. } else {
  14079. _self.$timer = clearInterval(_self.$timer);
  14080. _self.$scrollAnimation = null;
  14081. callback && callback();
  14082. }
  14083. }, 10);
  14084. };
  14085. this.scrollToY = function(scrollTop) {
  14086. if (this.scrollTop !== scrollTop) {
  14087. this.$loop.schedule(this.CHANGE_SCROLL);
  14088. this.scrollTop = scrollTop;
  14089. }
  14090. };
  14091. this.scrollToX = function(scrollLeft) {
  14092. if (this.scrollLeft !== scrollLeft)
  14093. this.scrollLeft = scrollLeft;
  14094. this.$loop.schedule(this.CHANGE_H_SCROLL);
  14095. };
  14096. this.scrollTo = function(x, y) {
  14097. this.session.setScrollTop(y);
  14098. this.session.setScrollLeft(y);
  14099. };
  14100. this.scrollBy = function(deltaX, deltaY) {
  14101. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  14102. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  14103. };
  14104. this.isScrollableBy = function(deltaX, deltaY) {
  14105. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  14106. return true;
  14107. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  14108. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  14109. return true;
  14110. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  14111. return true;
  14112. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  14113. - this.layerConfig.width < -1 + this.scrollMargin.right)
  14114. return true;
  14115. };
  14116. this.pixelToScreenCoordinates = function(x, y) {
  14117. var canvasPos = this.scroller.getBoundingClientRect();
  14118. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  14119. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  14120. var col = Math.round(offset);
  14121. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  14122. };
  14123. this.screenToTextCoordinates = function(x, y) {
  14124. var canvasPos = this.scroller.getBoundingClientRect();
  14125. var col = Math.round(
  14126. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  14127. );
  14128. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  14129. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  14130. };
  14131. this.textToScreenCoordinates = function(row, column) {
  14132. var canvasPos = this.scroller.getBoundingClientRect();
  14133. var pos = this.session.documentToScreenPosition(row, column);
  14134. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  14135. var y = pos.row * this.lineHeight;
  14136. return {
  14137. pageX: canvasPos.left + x - this.scrollLeft,
  14138. pageY: canvasPos.top + y - this.scrollTop
  14139. };
  14140. };
  14141. this.visualizeFocus = function() {
  14142. dom.addCssClass(this.container, "ace_focus");
  14143. };
  14144. this.visualizeBlur = function() {
  14145. dom.removeCssClass(this.container, "ace_focus");
  14146. };
  14147. this.showComposition = function(position) {
  14148. if (!this.$composition)
  14149. this.$composition = {
  14150. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  14151. cssText: this.textarea.style.cssText
  14152. };
  14153. this.$keepTextAreaAtCursor = true;
  14154. dom.addCssClass(this.textarea, "ace_composition");
  14155. this.textarea.style.cssText = "";
  14156. this.$moveTextAreaToCursor();
  14157. };
  14158. this.setCompositionText = function(text) {
  14159. this.$moveTextAreaToCursor();
  14160. };
  14161. this.hideComposition = function() {
  14162. if (!this.$composition)
  14163. return;
  14164. dom.removeCssClass(this.textarea, "ace_composition");
  14165. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  14166. this.textarea.style.cssText = this.$composition.cssText;
  14167. this.$composition = null;
  14168. };
  14169. this.setTheme = function(theme, cb) {
  14170. var _self = this;
  14171. this.$themeId = theme;
  14172. _self._dispatchEvent('themeChange',{theme:theme});
  14173. if (!theme || typeof theme == "string") {
  14174. var moduleName = theme || this.$options.theme.initialValue;
  14175. config.loadModule(["theme", moduleName], afterLoad);
  14176. } else {
  14177. afterLoad(theme);
  14178. }
  14179. function afterLoad(module) {
  14180. if (_self.$themeId != theme)
  14181. return cb && cb();
  14182. if (!module.cssClass)
  14183. return;
  14184. dom.importCssString(
  14185. module.cssText,
  14186. module.cssClass,
  14187. _self.container.ownerDocument
  14188. );
  14189. if (_self.theme)
  14190. dom.removeCssClass(_self.container, _self.theme.cssClass);
  14191. var padding = "padding" in module ? module.padding
  14192. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  14193. if (_self.$padding && padding != _self.$padding)
  14194. _self.setPadding(padding);
  14195. _self.$theme = module.cssClass;
  14196. _self.theme = module;
  14197. dom.addCssClass(_self.container, module.cssClass);
  14198. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  14199. if (_self.$size) {
  14200. _self.$size.width = 0;
  14201. _self.$updateSizeAsync();
  14202. }
  14203. _self._dispatchEvent('themeLoaded', {theme:module});
  14204. cb && cb();
  14205. }
  14206. };
  14207. this.getTheme = function() {
  14208. return this.$themeId;
  14209. };
  14210. this.setStyle = function(style, include) {
  14211. dom.setCssClass(this.container, style, include !== false);
  14212. };
  14213. this.unsetStyle = function(style) {
  14214. dom.removeCssClass(this.container, style);
  14215. };
  14216. this.setCursorStyle = function(style) {
  14217. if (this.scroller.style.cursor != style)
  14218. this.scroller.style.cursor = style;
  14219. };
  14220. this.setMouseCursor = function(cursorStyle) {
  14221. this.scroller.style.cursor = cursorStyle;
  14222. };
  14223. this.destroy = function() {
  14224. this.$textLayer.destroy();
  14225. this.$cursorLayer.destroy();
  14226. };
  14227. }).call(VirtualRenderer.prototype);
  14228. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  14229. animatedScroll: {initialValue: false},
  14230. showInvisibles: {
  14231. set: function(value) {
  14232. if (this.$textLayer.setShowInvisibles(value))
  14233. this.$loop.schedule(this.CHANGE_TEXT);
  14234. },
  14235. initialValue: false
  14236. },
  14237. showPrintMargin: {
  14238. set: function() { this.$updatePrintMargin(); },
  14239. initialValue: true
  14240. },
  14241. printMarginColumn: {
  14242. set: function() { this.$updatePrintMargin(); },
  14243. initialValue: 80
  14244. },
  14245. printMargin: {
  14246. set: function(val) {
  14247. if (typeof val == "number")
  14248. this.$printMarginColumn = val;
  14249. this.$showPrintMargin = !!val;
  14250. this.$updatePrintMargin();
  14251. },
  14252. get: function() {
  14253. return this.$showPrintMargin && this.$printMarginColumn;
  14254. }
  14255. },
  14256. showGutter: {
  14257. set: function(show){
  14258. this.$gutter.style.display = show ? "block" : "none";
  14259. this.$loop.schedule(this.CHANGE_FULL);
  14260. this.onGutterResize();
  14261. },
  14262. initialValue: true
  14263. },
  14264. fadeFoldWidgets: {
  14265. set: function(show) {
  14266. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14267. },
  14268. initialValue: false
  14269. },
  14270. showFoldWidgets: {
  14271. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14272. initialValue: true
  14273. },
  14274. showLineNumbers: {
  14275. set: function(show) {
  14276. this.$gutterLayer.setShowLineNumbers(show);
  14277. this.$loop.schedule(this.CHANGE_GUTTER);
  14278. },
  14279. initialValue: true
  14280. },
  14281. displayIndentGuides: {
  14282. set: function(show) {
  14283. if (this.$textLayer.setDisplayIndentGuides(show))
  14284. this.$loop.schedule(this.CHANGE_TEXT);
  14285. },
  14286. initialValue: true
  14287. },
  14288. highlightGutterLine: {
  14289. set: function(shouldHighlight) {
  14290. if (!this.$gutterLineHighlight) {
  14291. this.$gutterLineHighlight = dom.createElement("div");
  14292. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14293. this.$gutter.appendChild(this.$gutterLineHighlight);
  14294. return;
  14295. }
  14296. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14297. if (this.$cursorLayer.$pixelPos)
  14298. this.$updateGutterLineHighlight();
  14299. },
  14300. initialValue: false,
  14301. value: true
  14302. },
  14303. hScrollBarAlwaysVisible: {
  14304. set: function(val) {
  14305. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14306. this.$loop.schedule(this.CHANGE_SCROLL);
  14307. },
  14308. initialValue: false
  14309. },
  14310. vScrollBarAlwaysVisible: {
  14311. set: function(val) {
  14312. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14313. this.$loop.schedule(this.CHANGE_SCROLL);
  14314. },
  14315. initialValue: false
  14316. },
  14317. fontSize: {
  14318. set: function(size) {
  14319. if (typeof size == "number")
  14320. size = size + "px";
  14321. this.container.style.fontSize = size;
  14322. this.updateFontSize();
  14323. },
  14324. initialValue: 12
  14325. },
  14326. fontFamily: {
  14327. set: function(name) {
  14328. this.container.style.fontFamily = name;
  14329. this.updateFontSize();
  14330. }
  14331. },
  14332. maxLines: {
  14333. set: function(val) {
  14334. this.updateFull();
  14335. }
  14336. },
  14337. minLines: {
  14338. set: function(val) {
  14339. this.updateFull();
  14340. }
  14341. },
  14342. scrollPastEnd: {
  14343. set: function(val) {
  14344. val = +val || 0;
  14345. if (this.$scrollPastEnd == val)
  14346. return;
  14347. this.$scrollPastEnd = val;
  14348. this.$loop.schedule(this.CHANGE_SCROLL);
  14349. },
  14350. initialValue: 0,
  14351. handlesSet: true
  14352. },
  14353. fixedWidthGutter: {
  14354. set: function(val) {
  14355. this.$gutterLayer.$fixedWidth = !!val;
  14356. this.$loop.schedule(this.CHANGE_GUTTER);
  14357. }
  14358. },
  14359. theme: {
  14360. set: function(val) { this.setTheme(val) },
  14361. get: function() { return this.$themeId || this.theme; },
  14362. initialValue: "./theme/textmate",
  14363. handlesSet: true
  14364. }
  14365. });
  14366. exports.VirtualRenderer = VirtualRenderer;
  14367. });
  14368. define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
  14369. "use strict";
  14370. var oop = require("../lib/oop");
  14371. var net = require("../lib/net");
  14372. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14373. var config = require("../config");
  14374. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14375. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14376. this.changeListener = this.changeListener.bind(this);
  14377. this.onMessage = this.onMessage.bind(this);
  14378. if (require.nameToUrl && !require.toUrl)
  14379. require.toUrl = require.nameToUrl;
  14380. if (config.get("packaged") || !require.toUrl) {
  14381. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14382. } else {
  14383. var normalizePath = this.$normalizePath;
  14384. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14385. var tlns = {};
  14386. topLevelNamespaces.forEach(function(ns) {
  14387. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14388. });
  14389. }
  14390. try {
  14391. this.$worker = new Worker(workerUrl);
  14392. } catch(e) {
  14393. if (e instanceof window.DOMException) {
  14394. var blob = this.$workerBlob(workerUrl);
  14395. var URL = window.URL || window.webkitURL;
  14396. var blobURL = URL.createObjectURL(blob);
  14397. this.$worker = new Worker(blobURL);
  14398. URL.revokeObjectURL(blobURL);
  14399. } else {
  14400. throw e;
  14401. }
  14402. }
  14403. this.$worker.postMessage({
  14404. init : true,
  14405. tlns : tlns,
  14406. module : mod,
  14407. classname : classname
  14408. });
  14409. this.callbackId = 1;
  14410. this.callbacks = {};
  14411. this.$worker.onmessage = this.onMessage;
  14412. };
  14413. (function(){
  14414. oop.implement(this, EventEmitter);
  14415. this.onMessage = function(e) {
  14416. var msg = e.data;
  14417. switch(msg.type) {
  14418. case "event":
  14419. this._signal(msg.name, {data: msg.data});
  14420. break;
  14421. case "call":
  14422. var callback = this.callbacks[msg.id];
  14423. if (callback) {
  14424. callback(msg.data);
  14425. delete this.callbacks[msg.id];
  14426. }
  14427. break;
  14428. case "error":
  14429. this.reportError(msg.data);
  14430. break;
  14431. case "log":
  14432. window.console && console.log && console.log.apply(console, msg.data);
  14433. break;
  14434. }
  14435. };
  14436. this.reportError = function(err) {
  14437. window.console && console.error && console.error(err);
  14438. };
  14439. this.$normalizePath = function(path) {
  14440. return net.qualifyURL(path);
  14441. };
  14442. this.terminate = function() {
  14443. this._signal("terminate", {});
  14444. this.deltaQueue = null;
  14445. this.$worker.terminate();
  14446. this.$worker = null;
  14447. if (this.$doc)
  14448. this.$doc.off("change", this.changeListener);
  14449. this.$doc = null;
  14450. };
  14451. this.send = function(cmd, args) {
  14452. this.$worker.postMessage({command: cmd, args: args});
  14453. };
  14454. this.call = function(cmd, args, callback) {
  14455. if (callback) {
  14456. var id = this.callbackId++;
  14457. this.callbacks[id] = callback;
  14458. args.push(id);
  14459. }
  14460. this.send(cmd, args);
  14461. };
  14462. this.emit = function(event, data) {
  14463. try {
  14464. this.$worker.postMessage({event: event, data: {data: data.data}});
  14465. }
  14466. catch(ex) {
  14467. console.error(ex.stack);
  14468. }
  14469. };
  14470. this.attachToDocument = function(doc) {
  14471. if(this.$doc)
  14472. this.terminate();
  14473. this.$doc = doc;
  14474. this.call("setValue", [doc.getValue()]);
  14475. doc.on("change", this.changeListener);
  14476. };
  14477. this.changeListener = function(delta) {
  14478. if (!this.deltaQueue) {
  14479. this.deltaQueue = [];
  14480. setTimeout(this.$sendDeltaQueue, 0);
  14481. }
  14482. if (delta.action == "insert")
  14483. this.deltaQueue.push(delta.start, delta.lines);
  14484. else
  14485. this.deltaQueue.push(delta.start, delta.end);
  14486. };
  14487. this.$sendDeltaQueue = function() {
  14488. var q = this.deltaQueue;
  14489. if (!q) return;
  14490. this.deltaQueue = null;
  14491. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  14492. this.call("setValue", [this.$doc.getValue()]);
  14493. } else
  14494. this.emit("change", {data: q});
  14495. };
  14496. this.$workerBlob = function(workerUrl) {
  14497. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14498. try {
  14499. return new Blob([script], {"type": "application/javascript"});
  14500. } catch (e) { // Backwards-compatibility
  14501. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14502. var blobBuilder = new BlobBuilder();
  14503. blobBuilder.append(script);
  14504. return blobBuilder.getBlob("application/javascript");
  14505. }
  14506. };
  14507. }).call(WorkerClient.prototype);
  14508. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14509. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14510. this.changeListener = this.changeListener.bind(this);
  14511. this.callbackId = 1;
  14512. this.callbacks = {};
  14513. this.messageBuffer = [];
  14514. var main = null;
  14515. var emitSync = false;
  14516. var sender = Object.create(EventEmitter);
  14517. var _self = this;
  14518. this.$worker = {};
  14519. this.$worker.terminate = function() {};
  14520. this.$worker.postMessage = function(e) {
  14521. _self.messageBuffer.push(e);
  14522. if (main) {
  14523. if (emitSync)
  14524. setTimeout(processNext);
  14525. else
  14526. processNext();
  14527. }
  14528. };
  14529. this.setEmitSync = function(val) { emitSync = val };
  14530. var processNext = function() {
  14531. var msg = _self.messageBuffer.shift();
  14532. if (msg.command)
  14533. main[msg.command].apply(main, msg.args);
  14534. else if (msg.event)
  14535. sender._signal(msg.event, msg.data);
  14536. };
  14537. sender.postMessage = function(msg) {
  14538. _self.onMessage({data: msg});
  14539. };
  14540. sender.callback = function(data, callbackId) {
  14541. this.postMessage({type: "call", id: callbackId, data: data});
  14542. };
  14543. sender.emit = function(name, data) {
  14544. this.postMessage({type: "event", name: name, data: data});
  14545. };
  14546. config.loadModule(["worker", mod], function(Main) {
  14547. main = new Main[classname](sender);
  14548. while (_self.messageBuffer.length)
  14549. processNext();
  14550. });
  14551. };
  14552. UIWorkerClient.prototype = WorkerClient.prototype;
  14553. exports.UIWorkerClient = UIWorkerClient;
  14554. exports.WorkerClient = WorkerClient;
  14555. });
  14556. define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14557. "use strict";
  14558. var Range = require("./range").Range;
  14559. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14560. var oop = require("./lib/oop");
  14561. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14562. var _self = this;
  14563. this.length = length;
  14564. this.session = session;
  14565. this.doc = session.getDocument();
  14566. this.mainClass = mainClass;
  14567. this.othersClass = othersClass;
  14568. this.$onUpdate = this.onUpdate.bind(this);
  14569. this.doc.on("change", this.$onUpdate);
  14570. this.$others = others;
  14571. this.$onCursorChange = function() {
  14572. setTimeout(function() {
  14573. _self.onCursorChange();
  14574. });
  14575. };
  14576. this.$pos = pos;
  14577. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14578. this.$undoStackDepth = undoStack.length;
  14579. this.setup();
  14580. session.selection.on("changeCursor", this.$onCursorChange);
  14581. };
  14582. (function() {
  14583. oop.implement(this, EventEmitter);
  14584. this.setup = function() {
  14585. var _self = this;
  14586. var doc = this.doc;
  14587. var session = this.session;
  14588. var pos = this.$pos;
  14589. this.selectionBefore = session.selection.toJSON();
  14590. if (session.selection.inMultiSelectMode)
  14591. session.selection.toSingleRange();
  14592. this.pos = doc.createAnchor(pos.row, pos.column);
  14593. this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14594. this.pos.on("change", function(event) {
  14595. session.removeMarker(_self.markerId);
  14596. _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
  14597. });
  14598. this.others = [];
  14599. this.$others.forEach(function(other) {
  14600. var anchor = doc.createAnchor(other.row, other.column);
  14601. _self.others.push(anchor);
  14602. });
  14603. session.setUndoSelect(false);
  14604. };
  14605. this.showOtherMarkers = function() {
  14606. if(this.othersActive) return;
  14607. var session = this.session;
  14608. var _self = this;
  14609. this.othersActive = true;
  14610. this.others.forEach(function(anchor) {
  14611. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14612. anchor.on("change", function(event) {
  14613. session.removeMarker(anchor.markerId);
  14614. anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
  14615. });
  14616. });
  14617. };
  14618. this.hideOtherMarkers = function() {
  14619. if(!this.othersActive) return;
  14620. this.othersActive = false;
  14621. for (var i = 0; i < this.others.length; i++) {
  14622. this.session.removeMarker(this.others[i].markerId);
  14623. }
  14624. };
  14625. this.onUpdate = function(delta) {
  14626. var range = delta;
  14627. if(range.start.row !== range.end.row) return;
  14628. if(range.start.row !== this.pos.row) return;
  14629. if (this.$updating) return;
  14630. this.$updating = true;
  14631. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14632. if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
  14633. var distanceFromStart = range.start.column - this.pos.column;
  14634. this.length += lengthDiff;
  14635. if(!this.session.$fromUndo) {
  14636. if(delta.action === 'insert') {
  14637. for (var i = this.others.length - 1; i >= 0; i--) {
  14638. var otherPos = this.others[i];
  14639. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14640. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14641. newPos.column += lengthDiff;
  14642. this.doc.insertMergedLines(newPos, delta.lines);
  14643. }
  14644. } else if(delta.action === 'remove') {
  14645. for (var i = this.others.length - 1; i >= 0; i--) {
  14646. var otherPos = this.others[i];
  14647. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14648. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14649. newPos.column += lengthDiff;
  14650. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14651. }
  14652. }
  14653. if(range.start.column === this.pos.column && delta.action === 'insert') {
  14654. setTimeout(function() {
  14655. this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
  14656. for (var i = 0; i < this.others.length; i++) {
  14657. var other = this.others[i];
  14658. var newPos = {row: other.row, column: other.column - lengthDiff};
  14659. if(other.row === range.start.row && range.start.column < other.column)
  14660. newPos.column += lengthDiff;
  14661. other.setPosition(newPos.row, newPos.column);
  14662. }
  14663. }.bind(this), 0);
  14664. }
  14665. else if(range.start.column === this.pos.column && delta.action === 'remove') {
  14666. setTimeout(function() {
  14667. for (var i = 0; i < this.others.length; i++) {
  14668. var other = this.others[i];
  14669. if(other.row === range.start.row && range.start.column < other.column) {
  14670. other.setPosition(other.row, other.column - lengthDiff);
  14671. }
  14672. }
  14673. }.bind(this), 0);
  14674. }
  14675. }
  14676. this.pos._emit("change", {value: this.pos});
  14677. for (var i = 0; i < this.others.length; i++) {
  14678. this.others[i]._emit("change", {value: this.others[i]});
  14679. }
  14680. }
  14681. this.$updating = false;
  14682. };
  14683. this.onCursorChange = function(event) {
  14684. if (this.$updating || !this.session) return;
  14685. var pos = this.session.selection.getCursor();
  14686. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14687. this.showOtherMarkers();
  14688. this._emit("cursorEnter", event);
  14689. } else {
  14690. this.hideOtherMarkers();
  14691. this._emit("cursorLeave", event);
  14692. }
  14693. };
  14694. this.detach = function() {
  14695. this.session.removeMarker(this.markerId);
  14696. this.hideOtherMarkers();
  14697. this.doc.removeEventListener("change", this.$onUpdate);
  14698. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14699. this.pos.detach();
  14700. for (var i = 0; i < this.others.length; i++) {
  14701. this.others[i].detach();
  14702. }
  14703. this.session.setUndoSelect(true);
  14704. this.session = null;
  14705. };
  14706. this.cancel = function() {
  14707. if(this.$undoStackDepth === -1)
  14708. throw Error("Canceling placeholders only supported with undo manager attached to session.");
  14709. var undoManager = this.session.getUndoManager();
  14710. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14711. for (var i = 0; i < undosRequired; i++) {
  14712. undoManager.undo(true);
  14713. }
  14714. if (this.selectionBefore)
  14715. this.session.selection.fromJSON(this.selectionBefore);
  14716. };
  14717. }).call(PlaceHolder.prototype);
  14718. exports.PlaceHolder = PlaceHolder;
  14719. });
  14720. define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14721. var event = require("../lib/event");
  14722. var useragent = require("../lib/useragent");
  14723. function isSamePoint(p1, p2) {
  14724. return p1.row == p2.row && p1.column == p2.column;
  14725. }
  14726. function onMouseDown(e) {
  14727. var ev = e.domEvent;
  14728. var alt = ev.altKey;
  14729. var shift = ev.shiftKey;
  14730. var ctrl = ev.ctrlKey;
  14731. var accel = e.getAccelKey();
  14732. var button = e.getButton();
  14733. if (ctrl && useragent.isMac)
  14734. button = ev.button;
  14735. if (e.editor.inMultiSelectMode && button == 2) {
  14736. e.editor.textInput.onContextMenu(e.domEvent);
  14737. return;
  14738. }
  14739. if (!ctrl && !alt && !accel) {
  14740. if (button === 0 && e.editor.inMultiSelectMode)
  14741. e.editor.exitMultiSelectMode();
  14742. return;
  14743. }
  14744. if (button !== 0)
  14745. return;
  14746. var editor = e.editor;
  14747. var selection = editor.selection;
  14748. var isMultiSelect = editor.inMultiSelectMode;
  14749. var pos = e.getDocumentPosition();
  14750. var cursor = selection.getCursor();
  14751. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14752. var mouseX = e.x, mouseY = e.y;
  14753. var onMouseSelection = function(e) {
  14754. mouseX = e.clientX;
  14755. mouseY = e.clientY;
  14756. };
  14757. var session = editor.session;
  14758. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14759. var screenCursor = screenAnchor;
  14760. var selectionMode;
  14761. if (editor.$mouseHandler.$enableJumpToDef) {
  14762. if (ctrl && alt || accel && alt)
  14763. selectionMode = shift ? "block" : "add";
  14764. else if (alt && editor.$blockSelectEnabled)
  14765. selectionMode = "block";
  14766. } else {
  14767. if (accel && !alt) {
  14768. selectionMode = "add";
  14769. if (!isMultiSelect && shift)
  14770. return;
  14771. } else if (alt && editor.$blockSelectEnabled) {
  14772. selectionMode = "block";
  14773. }
  14774. }
  14775. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14776. editor.$mouseHandler.cancelContextMenu();
  14777. }
  14778. if (selectionMode == "add") {
  14779. if (!isMultiSelect && inSelection)
  14780. return; // dragging
  14781. if (!isMultiSelect) {
  14782. var range = selection.toOrientedRange();
  14783. editor.addSelectionMarker(range);
  14784. }
  14785. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14786. editor.$blockScrolling++;
  14787. editor.inVirtualSelectionMode = true;
  14788. if (shift) {
  14789. oldRange = null;
  14790. range = selection.ranges[0] || range;
  14791. editor.removeSelectionMarker(range);
  14792. }
  14793. editor.once("mouseup", function() {
  14794. var tmpSel = selection.toOrientedRange();
  14795. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14796. selection.substractPoint(tmpSel.cursor);
  14797. else {
  14798. if (shift) {
  14799. selection.substractPoint(range.cursor);
  14800. } else if (range) {
  14801. editor.removeSelectionMarker(range);
  14802. selection.addRange(range);
  14803. }
  14804. selection.addRange(tmpSel);
  14805. }
  14806. editor.$blockScrolling--;
  14807. editor.inVirtualSelectionMode = false;
  14808. });
  14809. } else if (selectionMode == "block") {
  14810. e.stop();
  14811. editor.inVirtualSelectionMode = true;
  14812. var initialRange;
  14813. var rectSel = [];
  14814. var blockSelect = function() {
  14815. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14816. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14817. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14818. return;
  14819. screenCursor = newCursor;
  14820. editor.$blockScrolling++;
  14821. editor.selection.moveToPosition(cursor);
  14822. editor.renderer.scrollCursorIntoView();
  14823. editor.removeSelectionMarkers(rectSel);
  14824. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14825. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14826. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14827. rectSel.forEach(editor.addSelectionMarker, editor);
  14828. editor.updateSelectionMarkers();
  14829. editor.$blockScrolling--;
  14830. };
  14831. editor.$blockScrolling++;
  14832. if (isMultiSelect && !accel) {
  14833. selection.toSingleRange();
  14834. } else if (!isMultiSelect && accel) {
  14835. initialRange = selection.toOrientedRange();
  14836. editor.addSelectionMarker(initialRange);
  14837. }
  14838. if (shift)
  14839. screenAnchor = session.documentToScreenPosition(selection.lead);
  14840. else
  14841. selection.moveToPosition(pos);
  14842. editor.$blockScrolling--;
  14843. screenCursor = {row: -1, column: -1};
  14844. var onMouseSelectionEnd = function(e) {
  14845. clearInterval(timerId);
  14846. editor.removeSelectionMarkers(rectSel);
  14847. if (!rectSel.length)
  14848. rectSel = [selection.toOrientedRange()];
  14849. editor.$blockScrolling++;
  14850. if (initialRange) {
  14851. editor.removeSelectionMarker(initialRange);
  14852. selection.toSingleRange(initialRange);
  14853. }
  14854. for (var i = 0; i < rectSel.length; i++)
  14855. selection.addRange(rectSel[i]);
  14856. editor.inVirtualSelectionMode = false;
  14857. editor.$mouseHandler.$clickSelection = null;
  14858. editor.$blockScrolling--;
  14859. };
  14860. var onSelectionInterval = blockSelect;
  14861. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14862. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14863. return e.preventDefault();
  14864. }
  14865. }
  14866. exports.onMouseDown = onMouseDown;
  14867. });
  14868. define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14869. exports.defaultCommands = [{
  14870. name: "addCursorAbove",
  14871. exec: function(editor) { editor.selectMoreLines(-1); },
  14872. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14873. scrollIntoView: "cursor",
  14874. readOnly: true
  14875. }, {
  14876. name: "addCursorBelow",
  14877. exec: function(editor) { editor.selectMoreLines(1); },
  14878. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14879. scrollIntoView: "cursor",
  14880. readOnly: true
  14881. }, {
  14882. name: "addCursorAboveSkipCurrent",
  14883. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14884. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14885. scrollIntoView: "cursor",
  14886. readOnly: true
  14887. }, {
  14888. name: "addCursorBelowSkipCurrent",
  14889. exec: function(editor) { editor.selectMoreLines(1, true); },
  14890. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14891. scrollIntoView: "cursor",
  14892. readOnly: true
  14893. }, {
  14894. name: "selectMoreBefore",
  14895. exec: function(editor) { editor.selectMore(-1); },
  14896. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14897. scrollIntoView: "cursor",
  14898. readOnly: true
  14899. }, {
  14900. name: "selectMoreAfter",
  14901. exec: function(editor) { editor.selectMore(1); },
  14902. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14903. scrollIntoView: "cursor",
  14904. readOnly: true
  14905. }, {
  14906. name: "selectNextBefore",
  14907. exec: function(editor) { editor.selectMore(-1, true); },
  14908. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14909. scrollIntoView: "cursor",
  14910. readOnly: true
  14911. }, {
  14912. name: "selectNextAfter",
  14913. exec: function(editor) { editor.selectMore(1, true); },
  14914. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14915. scrollIntoView: "cursor",
  14916. readOnly: true
  14917. }, {
  14918. name: "splitIntoLines",
  14919. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14920. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14921. readOnly: true
  14922. }, {
  14923. name: "alignCursors",
  14924. exec: function(editor) { editor.alignCursors(); },
  14925. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14926. scrollIntoView: "cursor"
  14927. }, {
  14928. name: "findAll",
  14929. exec: function(editor) { editor.findAll(); },
  14930. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14931. scrollIntoView: "cursor",
  14932. readOnly: true
  14933. }];
  14934. exports.multiSelectCommands = [{
  14935. name: "singleSelection",
  14936. bindKey: "esc",
  14937. exec: function(editor) { editor.exitMultiSelectMode(); },
  14938. scrollIntoView: "cursor",
  14939. readOnly: true,
  14940. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14941. }];
  14942. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14943. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14944. });
  14945. 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) {
  14946. var RangeList = require("./range_list").RangeList;
  14947. var Range = require("./range").Range;
  14948. var Selection = require("./selection").Selection;
  14949. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14950. var event = require("./lib/event");
  14951. var lang = require("./lib/lang");
  14952. var commands = require("./commands/multi_select_commands");
  14953. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14954. var Search = require("./search").Search;
  14955. var search = new Search();
  14956. function find(session, needle, dir) {
  14957. search.$options.wrap = true;
  14958. search.$options.needle = needle;
  14959. search.$options.backwards = dir == -1;
  14960. return search.find(session);
  14961. }
  14962. var EditSession = require("./edit_session").EditSession;
  14963. (function() {
  14964. this.getSelectionMarkers = function() {
  14965. return this.$selectionMarkers;
  14966. };
  14967. }).call(EditSession.prototype);
  14968. (function() {
  14969. this.ranges = null;
  14970. this.rangeList = null;
  14971. this.addRange = function(range, $blockChangeEvents) {
  14972. if (!range)
  14973. return;
  14974. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  14975. var oldRange = this.toOrientedRange();
  14976. this.rangeList.add(oldRange);
  14977. this.rangeList.add(range);
  14978. if (this.rangeList.ranges.length != 2) {
  14979. this.rangeList.removeAll();
  14980. return $blockChangeEvents || this.fromOrientedRange(range);
  14981. }
  14982. this.rangeList.removeAll();
  14983. this.rangeList.add(oldRange);
  14984. this.$onAddRange(oldRange);
  14985. }
  14986. if (!range.cursor)
  14987. range.cursor = range.end;
  14988. var removed = this.rangeList.add(range);
  14989. this.$onAddRange(range);
  14990. if (removed.length)
  14991. this.$onRemoveRange(removed);
  14992. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  14993. this._signal("multiSelect");
  14994. this.inMultiSelectMode = true;
  14995. this.session.$undoSelect = false;
  14996. this.rangeList.attach(this.session);
  14997. }
  14998. return $blockChangeEvents || this.fromOrientedRange(range);
  14999. };
  15000. this.toSingleRange = function(range) {
  15001. range = range || this.ranges[0];
  15002. var removed = this.rangeList.removeAll();
  15003. if (removed.length)
  15004. this.$onRemoveRange(removed);
  15005. range && this.fromOrientedRange(range);
  15006. };
  15007. this.substractPoint = function(pos) {
  15008. var removed = this.rangeList.substractPoint(pos);
  15009. if (removed) {
  15010. this.$onRemoveRange(removed);
  15011. return removed[0];
  15012. }
  15013. };
  15014. this.mergeOverlappingRanges = function() {
  15015. var removed = this.rangeList.merge();
  15016. if (removed.length)
  15017. this.$onRemoveRange(removed);
  15018. else if(this.ranges[0])
  15019. this.fromOrientedRange(this.ranges[0]);
  15020. };
  15021. this.$onAddRange = function(range) {
  15022. this.rangeCount = this.rangeList.ranges.length;
  15023. this.ranges.unshift(range);
  15024. this._signal("addRange", {range: range});
  15025. };
  15026. this.$onRemoveRange = function(removed) {
  15027. this.rangeCount = this.rangeList.ranges.length;
  15028. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  15029. var lastRange = this.rangeList.ranges.pop();
  15030. removed.push(lastRange);
  15031. this.rangeCount = 0;
  15032. }
  15033. for (var i = removed.length; i--; ) {
  15034. var index = this.ranges.indexOf(removed[i]);
  15035. this.ranges.splice(index, 1);
  15036. }
  15037. this._signal("removeRange", {ranges: removed});
  15038. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  15039. this.inMultiSelectMode = false;
  15040. this._signal("singleSelect");
  15041. this.session.$undoSelect = true;
  15042. this.rangeList.detach(this.session);
  15043. }
  15044. lastRange = lastRange || this.ranges[0];
  15045. if (lastRange && !lastRange.isEqual(this.getRange()))
  15046. this.fromOrientedRange(lastRange);
  15047. };
  15048. this.$initRangeList = function() {
  15049. if (this.rangeList)
  15050. return;
  15051. this.rangeList = new RangeList();
  15052. this.ranges = [];
  15053. this.rangeCount = 0;
  15054. };
  15055. this.getAllRanges = function() {
  15056. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  15057. };
  15058. this.splitIntoLines = function () {
  15059. if (this.rangeCount > 1) {
  15060. var ranges = this.rangeList.ranges;
  15061. var lastRange = ranges[ranges.length - 1];
  15062. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15063. this.toSingleRange();
  15064. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15065. } else {
  15066. var range = this.getRange();
  15067. var isBackwards = this.isBackwards();
  15068. var startRow = range.start.row;
  15069. var endRow = range.end.row;
  15070. if (startRow == endRow) {
  15071. if (isBackwards)
  15072. var start = range.end, end = range.start;
  15073. else
  15074. var start = range.start, end = range.end;
  15075. this.addRange(Range.fromPoints(end, end));
  15076. this.addRange(Range.fromPoints(start, start));
  15077. return;
  15078. }
  15079. var rectSel = [];
  15080. var r = this.getLineRange(startRow, true);
  15081. r.start.column = range.start.column;
  15082. rectSel.push(r);
  15083. for (var i = startRow + 1; i < endRow; i++)
  15084. rectSel.push(this.getLineRange(i, true));
  15085. r = this.getLineRange(endRow, true);
  15086. r.end.column = range.end.column;
  15087. rectSel.push(r);
  15088. rectSel.forEach(this.addRange, this);
  15089. }
  15090. };
  15091. this.toggleBlockSelection = function () {
  15092. if (this.rangeCount > 1) {
  15093. var ranges = this.rangeList.ranges;
  15094. var lastRange = ranges[ranges.length - 1];
  15095. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15096. this.toSingleRange();
  15097. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15098. } else {
  15099. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  15100. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  15101. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  15102. rectSel.forEach(this.addRange, this);
  15103. }
  15104. };
  15105. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  15106. var rectSel = [];
  15107. var xBackwards = screenCursor.column < screenAnchor.column;
  15108. if (xBackwards) {
  15109. var startColumn = screenCursor.column;
  15110. var endColumn = screenAnchor.column;
  15111. } else {
  15112. var startColumn = screenAnchor.column;
  15113. var endColumn = screenCursor.column;
  15114. }
  15115. var yBackwards = screenCursor.row < screenAnchor.row;
  15116. if (yBackwards) {
  15117. var startRow = screenCursor.row;
  15118. var endRow = screenAnchor.row;
  15119. } else {
  15120. var startRow = screenAnchor.row;
  15121. var endRow = screenCursor.row;
  15122. }
  15123. if (startColumn < 0)
  15124. startColumn = 0;
  15125. if (startRow < 0)
  15126. startRow = 0;
  15127. if (startRow == endRow)
  15128. includeEmptyLines = true;
  15129. for (var row = startRow; row <= endRow; row++) {
  15130. var range = Range.fromPoints(
  15131. this.session.screenToDocumentPosition(row, startColumn),
  15132. this.session.screenToDocumentPosition(row, endColumn)
  15133. );
  15134. if (range.isEmpty()) {
  15135. if (docEnd && isSamePoint(range.end, docEnd))
  15136. break;
  15137. var docEnd = range.end;
  15138. }
  15139. range.cursor = xBackwards ? range.start : range.end;
  15140. rectSel.push(range);
  15141. }
  15142. if (yBackwards)
  15143. rectSel.reverse();
  15144. if (!includeEmptyLines) {
  15145. var end = rectSel.length - 1;
  15146. while (rectSel[end].isEmpty() && end > 0)
  15147. end--;
  15148. if (end > 0) {
  15149. var start = 0;
  15150. while (rectSel[start].isEmpty())
  15151. start++;
  15152. }
  15153. for (var i = end; i >= start; i--) {
  15154. if (rectSel[i].isEmpty())
  15155. rectSel.splice(i, 1);
  15156. }
  15157. }
  15158. return rectSel;
  15159. };
  15160. }).call(Selection.prototype);
  15161. var Editor = require("./editor").Editor;
  15162. (function() {
  15163. this.updateSelectionMarkers = function() {
  15164. this.renderer.updateCursor();
  15165. this.renderer.updateBackMarkers();
  15166. };
  15167. this.addSelectionMarker = function(orientedRange) {
  15168. if (!orientedRange.cursor)
  15169. orientedRange.cursor = orientedRange.end;
  15170. var style = this.getSelectionStyle();
  15171. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  15172. this.session.$selectionMarkers.push(orientedRange);
  15173. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15174. return orientedRange;
  15175. };
  15176. this.removeSelectionMarker = function(range) {
  15177. if (!range.marker)
  15178. return;
  15179. this.session.removeMarker(range.marker);
  15180. var index = this.session.$selectionMarkers.indexOf(range);
  15181. if (index != -1)
  15182. this.session.$selectionMarkers.splice(index, 1);
  15183. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15184. };
  15185. this.removeSelectionMarkers = function(ranges) {
  15186. var markerList = this.session.$selectionMarkers;
  15187. for (var i = ranges.length; i--; ) {
  15188. var range = ranges[i];
  15189. if (!range.marker)
  15190. continue;
  15191. this.session.removeMarker(range.marker);
  15192. var index = markerList.indexOf(range);
  15193. if (index != -1)
  15194. markerList.splice(index, 1);
  15195. }
  15196. this.session.selectionMarkerCount = markerList.length;
  15197. };
  15198. this.$onAddRange = function(e) {
  15199. this.addSelectionMarker(e.range);
  15200. this.renderer.updateCursor();
  15201. this.renderer.updateBackMarkers();
  15202. };
  15203. this.$onRemoveRange = function(e) {
  15204. this.removeSelectionMarkers(e.ranges);
  15205. this.renderer.updateCursor();
  15206. this.renderer.updateBackMarkers();
  15207. };
  15208. this.$onMultiSelect = function(e) {
  15209. if (this.inMultiSelectMode)
  15210. return;
  15211. this.inMultiSelectMode = true;
  15212. this.setStyle("ace_multiselect");
  15213. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  15214. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  15215. this.renderer.updateCursor();
  15216. this.renderer.updateBackMarkers();
  15217. };
  15218. this.$onSingleSelect = function(e) {
  15219. if (this.session.multiSelect.inVirtualMode)
  15220. return;
  15221. this.inMultiSelectMode = false;
  15222. this.unsetStyle("ace_multiselect");
  15223. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  15224. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  15225. this.renderer.updateCursor();
  15226. this.renderer.updateBackMarkers();
  15227. this._emit("changeSelection");
  15228. };
  15229. this.$onMultiSelectExec = function(e) {
  15230. var command = e.command;
  15231. var editor = e.editor;
  15232. if (!editor.multiSelect)
  15233. return;
  15234. if (!command.multiSelectAction) {
  15235. var result = command.exec(editor, e.args || {});
  15236. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15237. editor.multiSelect.mergeOverlappingRanges();
  15238. } else if (command.multiSelectAction == "forEach") {
  15239. result = editor.forEachSelection(command, e.args);
  15240. } else if (command.multiSelectAction == "forEachLine") {
  15241. result = editor.forEachSelection(command, e.args, true);
  15242. } else if (command.multiSelectAction == "single") {
  15243. editor.exitMultiSelectMode();
  15244. result = command.exec(editor, e.args || {});
  15245. } else {
  15246. result = command.multiSelectAction(editor, e.args || {});
  15247. }
  15248. return result;
  15249. };
  15250. this.forEachSelection = function(cmd, args, options) {
  15251. if (this.inVirtualSelectionMode)
  15252. return;
  15253. var keepOrder = options && options.keepOrder;
  15254. var $byLines = options == true || options && options.$byLines
  15255. var session = this.session;
  15256. var selection = this.selection;
  15257. var rangeList = selection.rangeList;
  15258. var ranges = (keepOrder ? selection : rangeList).ranges;
  15259. var result;
  15260. if (!ranges.length)
  15261. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15262. var reg = selection._eventRegistry;
  15263. selection._eventRegistry = {};
  15264. var tmpSel = new Selection(session);
  15265. this.inVirtualSelectionMode = true;
  15266. for (var i = ranges.length; i--;) {
  15267. if ($byLines) {
  15268. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15269. i--;
  15270. }
  15271. tmpSel.fromOrientedRange(ranges[i]);
  15272. tmpSel.index = i;
  15273. this.selection = session.selection = tmpSel;
  15274. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15275. if (!result && cmdResult !== undefined)
  15276. result = cmdResult;
  15277. tmpSel.toOrientedRange(ranges[i]);
  15278. }
  15279. tmpSel.detach();
  15280. this.selection = session.selection = selection;
  15281. this.inVirtualSelectionMode = false;
  15282. selection._eventRegistry = reg;
  15283. selection.mergeOverlappingRanges();
  15284. var anim = this.renderer.$scrollAnimation;
  15285. this.onCursorChange();
  15286. this.onSelectionChange();
  15287. if (anim && anim.from == anim.to)
  15288. this.renderer.animateScrolling(anim.from);
  15289. return result;
  15290. };
  15291. this.exitMultiSelectMode = function() {
  15292. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15293. return;
  15294. this.multiSelect.toSingleRange();
  15295. };
  15296. this.getSelectedText = function() {
  15297. var text = "";
  15298. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15299. var ranges = this.multiSelect.rangeList.ranges;
  15300. var buf = [];
  15301. for (var i = 0; i < ranges.length; i++) {
  15302. buf.push(this.session.getTextRange(ranges[i]));
  15303. }
  15304. var nl = this.session.getDocument().getNewLineCharacter();
  15305. text = buf.join(nl);
  15306. if (text.length == (buf.length - 1) * nl.length)
  15307. text = "";
  15308. } else if (!this.selection.isEmpty()) {
  15309. text = this.session.getTextRange(this.getSelectionRange());
  15310. }
  15311. return text;
  15312. };
  15313. this.$checkMultiselectChange = function(e, anchor) {
  15314. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15315. var range = this.multiSelect.ranges[0];
  15316. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15317. return;
  15318. var pos = anchor == this.multiSelect.anchor
  15319. ? range.cursor == range.start ? range.end : range.start
  15320. : range.cursor;
  15321. if (pos.row != anchor.row
  15322. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15323. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15324. }
  15325. };
  15326. this.findAll = function(needle, options, additive) {
  15327. options = options || {};
  15328. options.needle = needle || options.needle;
  15329. if (options.needle == undefined) {
  15330. var range = this.selection.isEmpty()
  15331. ? this.selection.getWordRange()
  15332. : this.selection.getRange();
  15333. options.needle = this.session.getTextRange(range);
  15334. }
  15335. this.$search.set(options);
  15336. var ranges = this.$search.findAll(this.session);
  15337. if (!ranges.length)
  15338. return 0;
  15339. this.$blockScrolling += 1;
  15340. var selection = this.multiSelect;
  15341. if (!additive)
  15342. selection.toSingleRange(ranges[0]);
  15343. for (var i = ranges.length; i--; )
  15344. selection.addRange(ranges[i], true);
  15345. if (range && selection.rangeList.rangeAtPoint(range.start))
  15346. selection.addRange(range, true);
  15347. this.$blockScrolling -= 1;
  15348. return ranges.length;
  15349. };
  15350. this.selectMoreLines = function(dir, skip) {
  15351. var range = this.selection.toOrientedRange();
  15352. var isBackwards = range.cursor == range.end;
  15353. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15354. if (this.selection.$desiredColumn)
  15355. screenLead.column = this.selection.$desiredColumn;
  15356. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15357. if (!range.isEmpty()) {
  15358. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15359. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15360. } else {
  15361. var anchor = lead;
  15362. }
  15363. if (isBackwards) {
  15364. var newRange = Range.fromPoints(lead, anchor);
  15365. newRange.cursor = newRange.start;
  15366. } else {
  15367. var newRange = Range.fromPoints(anchor, lead);
  15368. newRange.cursor = newRange.end;
  15369. }
  15370. newRange.desiredColumn = screenLead.column;
  15371. if (!this.selection.inMultiSelectMode) {
  15372. this.selection.addRange(range);
  15373. } else {
  15374. if (skip)
  15375. var toRemove = range.cursor;
  15376. }
  15377. this.selection.addRange(newRange);
  15378. if (toRemove)
  15379. this.selection.substractPoint(toRemove);
  15380. };
  15381. this.transposeSelections = function(dir) {
  15382. var session = this.session;
  15383. var sel = session.multiSelect;
  15384. var all = sel.ranges;
  15385. for (var i = all.length; i--; ) {
  15386. var range = all[i];
  15387. if (range.isEmpty()) {
  15388. var tmp = session.getWordRange(range.start.row, range.start.column);
  15389. range.start.row = tmp.start.row;
  15390. range.start.column = tmp.start.column;
  15391. range.end.row = tmp.end.row;
  15392. range.end.column = tmp.end.column;
  15393. }
  15394. }
  15395. sel.mergeOverlappingRanges();
  15396. var words = [];
  15397. for (var i = all.length; i--; ) {
  15398. var range = all[i];
  15399. words.unshift(session.getTextRange(range));
  15400. }
  15401. if (dir < 0)
  15402. words.unshift(words.pop());
  15403. else
  15404. words.push(words.shift());
  15405. for (var i = all.length; i--; ) {
  15406. var range = all[i];
  15407. var tmp = range.clone();
  15408. session.replace(range, words[i]);
  15409. range.start.row = tmp.start.row;
  15410. range.start.column = tmp.start.column;
  15411. }
  15412. };
  15413. this.selectMore = function(dir, skip, stopAtFirst) {
  15414. var session = this.session;
  15415. var sel = session.multiSelect;
  15416. var range = sel.toOrientedRange();
  15417. if (range.isEmpty()) {
  15418. range = session.getWordRange(range.start.row, range.start.column);
  15419. range.cursor = dir == -1 ? range.start : range.end;
  15420. this.multiSelect.addRange(range);
  15421. if (stopAtFirst)
  15422. return;
  15423. }
  15424. var needle = session.getTextRange(range);
  15425. var newRange = find(session, needle, dir);
  15426. if (newRange) {
  15427. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15428. this.$blockScrolling += 1;
  15429. this.session.unfold(newRange);
  15430. this.multiSelect.addRange(newRange);
  15431. this.$blockScrolling -= 1;
  15432. this.renderer.scrollCursorIntoView(null, 0.5);
  15433. }
  15434. if (skip)
  15435. this.multiSelect.substractPoint(range.cursor);
  15436. };
  15437. this.alignCursors = function() {
  15438. var session = this.session;
  15439. var sel = session.multiSelect;
  15440. var ranges = sel.ranges;
  15441. var row = -1;
  15442. var sameRowRanges = ranges.filter(function(r) {
  15443. if (r.cursor.row == row)
  15444. return true;
  15445. row = r.cursor.row;
  15446. });
  15447. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15448. var range = this.selection.getRange();
  15449. var fr = range.start.row, lr = range.end.row;
  15450. var guessRange = fr == lr;
  15451. if (guessRange) {
  15452. var max = this.session.getLength();
  15453. var line;
  15454. do {
  15455. line = this.session.getLine(lr);
  15456. } while (/[=:]/.test(line) && ++lr < max);
  15457. do {
  15458. line = this.session.getLine(fr);
  15459. } while (/[=:]/.test(line) && --fr > 0);
  15460. if (fr < 0) fr = 0;
  15461. if (lr >= max) lr = max - 1;
  15462. }
  15463. var lines = this.session.removeFullLines(fr, lr);
  15464. lines = this.$reAlignText(lines, guessRange);
  15465. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15466. if (!guessRange) {
  15467. range.start.column = 0;
  15468. range.end.column = lines[lines.length - 1].length;
  15469. }
  15470. this.selection.setRange(range);
  15471. } else {
  15472. sameRowRanges.forEach(function(r) {
  15473. sel.substractPoint(r.cursor);
  15474. });
  15475. var maxCol = 0;
  15476. var minSpace = Infinity;
  15477. var spaceOffsets = ranges.map(function(r) {
  15478. var p = r.cursor;
  15479. var line = session.getLine(p.row);
  15480. var spaceOffset = line.substr(p.column).search(/\S/g);
  15481. if (spaceOffset == -1)
  15482. spaceOffset = 0;
  15483. if (p.column > maxCol)
  15484. maxCol = p.column;
  15485. if (spaceOffset < minSpace)
  15486. minSpace = spaceOffset;
  15487. return spaceOffset;
  15488. });
  15489. ranges.forEach(function(r, i) {
  15490. var p = r.cursor;
  15491. var l = maxCol - p.column;
  15492. var d = spaceOffsets[i] - minSpace;
  15493. if (l > d)
  15494. session.insert(p, lang.stringRepeat(" ", l - d));
  15495. else
  15496. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15497. r.start.column = r.end.column = maxCol;
  15498. r.start.row = r.end.row = p.row;
  15499. r.cursor = r.end;
  15500. });
  15501. sel.fromOrientedRange(ranges[0]);
  15502. this.renderer.updateCursor();
  15503. this.renderer.updateBackMarkers();
  15504. }
  15505. };
  15506. this.$reAlignText = function(lines, forceLeft) {
  15507. var isLeftAligned = true, isRightAligned = true;
  15508. var startW, textW, endW;
  15509. return lines.map(function(line) {
  15510. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15511. if (!m)
  15512. return [line];
  15513. if (startW == null) {
  15514. startW = m[1].length;
  15515. textW = m[2].length;
  15516. endW = m[3].length;
  15517. return m;
  15518. }
  15519. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15520. isRightAligned = false;
  15521. if (startW != m[1].length)
  15522. isLeftAligned = false;
  15523. if (startW > m[1].length)
  15524. startW = m[1].length;
  15525. if (textW < m[2].length)
  15526. textW = m[2].length;
  15527. if (endW > m[3].length)
  15528. endW = m[3].length;
  15529. return m;
  15530. }).map(forceLeft ? alignLeft :
  15531. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15532. function spaces(n) {
  15533. return lang.stringRepeat(" ", n);
  15534. }
  15535. function alignLeft(m) {
  15536. return !m[2] ? m[0] : spaces(startW) + m[2]
  15537. + spaces(textW - m[2].length + endW)
  15538. + m[4].replace(/^([=:])\s+/, "$1 ");
  15539. }
  15540. function alignRight(m) {
  15541. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15542. + spaces(endW, " ")
  15543. + m[4].replace(/^([=:])\s+/, "$1 ");
  15544. }
  15545. function unAlign(m) {
  15546. return !m[2] ? m[0] : spaces(startW) + m[2]
  15547. + spaces(endW)
  15548. + m[4].replace(/^([=:])\s+/, "$1 ");
  15549. }
  15550. };
  15551. }).call(Editor.prototype);
  15552. function isSamePoint(p1, p2) {
  15553. return p1.row == p2.row && p1.column == p2.column;
  15554. }
  15555. exports.onSessionChange = function(e) {
  15556. var session = e.session;
  15557. if (session && !session.multiSelect) {
  15558. session.$selectionMarkers = [];
  15559. session.selection.$initRangeList();
  15560. session.multiSelect = session.selection;
  15561. }
  15562. this.multiSelect = session && session.multiSelect;
  15563. var oldSession = e.oldSession;
  15564. if (oldSession) {
  15565. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15566. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15567. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15568. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15569. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15570. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15571. }
  15572. if (session) {
  15573. session.multiSelect.on("addRange", this.$onAddRange);
  15574. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15575. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15576. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15577. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15578. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15579. }
  15580. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15581. if (session.selection.inMultiSelectMode)
  15582. this.$onMultiSelect();
  15583. else
  15584. this.$onSingleSelect();
  15585. }
  15586. };
  15587. function MultiSelect(editor) {
  15588. if (editor.$multiselectOnSessionChange)
  15589. return;
  15590. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15591. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15592. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15593. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15594. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15595. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15596. editor.$multiselectOnSessionChange(editor);
  15597. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15598. editor.on("mousedown", onMouseDown);
  15599. editor.commands.addCommands(commands.defaultCommands);
  15600. addAltCursorListeners(editor);
  15601. }
  15602. function addAltCursorListeners(editor){
  15603. var el = editor.textInput.getElement();
  15604. var altCursor = false;
  15605. event.addListener(el, "keydown", function(e) {
  15606. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  15607. if (editor.$blockSelectEnabled && altDown) {
  15608. if (!altCursor) {
  15609. editor.renderer.setMouseCursor("crosshair");
  15610. altCursor = true;
  15611. }
  15612. } else if (altCursor) {
  15613. reset();
  15614. }
  15615. });
  15616. event.addListener(el, "keyup", reset);
  15617. event.addListener(el, "blur", reset);
  15618. function reset(e) {
  15619. if (altCursor) {
  15620. editor.renderer.setMouseCursor("");
  15621. altCursor = false;
  15622. }
  15623. }
  15624. }
  15625. exports.MultiSelect = MultiSelect;
  15626. require("./config").defineOptions(Editor.prototype, "editor", {
  15627. enableMultiselect: {
  15628. set: function(val) {
  15629. MultiSelect(this);
  15630. if (val) {
  15631. this.on("changeSession", this.$multiselectOnSessionChange);
  15632. this.on("mousedown", onMouseDown);
  15633. } else {
  15634. this.off("changeSession", this.$multiselectOnSessionChange);
  15635. this.off("mousedown", onMouseDown);
  15636. }
  15637. },
  15638. value: true
  15639. },
  15640. enableBlockSelect: {
  15641. set: function(val) {
  15642. this.$blockSelectEnabled = val;
  15643. },
  15644. value: true
  15645. }
  15646. });
  15647. });
  15648. define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15649. "use strict";
  15650. var Range = require("../../range").Range;
  15651. var FoldMode = exports.FoldMode = function() {};
  15652. (function() {
  15653. this.foldingStartMarker = null;
  15654. this.foldingStopMarker = null;
  15655. this.getFoldWidget = function(session, foldStyle, row) {
  15656. var line = session.getLine(row);
  15657. if (this.foldingStartMarker.test(line))
  15658. return "start";
  15659. if (foldStyle == "markbeginend"
  15660. && this.foldingStopMarker
  15661. && this.foldingStopMarker.test(line))
  15662. return "end";
  15663. return "";
  15664. };
  15665. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15666. return null;
  15667. };
  15668. this.indentationBlock = function(session, row, column) {
  15669. var re = /\S/;
  15670. var line = session.getLine(row);
  15671. var startLevel = line.search(re);
  15672. if (startLevel == -1)
  15673. return;
  15674. var startColumn = column || line.length;
  15675. var maxRow = session.getLength();
  15676. var startRow = row;
  15677. var endRow = row;
  15678. while (++row < maxRow) {
  15679. var level = session.getLine(row).search(re);
  15680. if (level == -1)
  15681. continue;
  15682. if (level <= startLevel)
  15683. break;
  15684. endRow = row;
  15685. }
  15686. if (endRow > startRow) {
  15687. var endColumn = session.getLine(endRow).length;
  15688. return new Range(startRow, startColumn, endRow, endColumn);
  15689. }
  15690. };
  15691. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15692. var start = {row: row, column: column + 1};
  15693. var end = session.$findClosingBracket(bracket, start, typeRe);
  15694. if (!end)
  15695. return;
  15696. var fw = session.foldWidgets[end.row];
  15697. if (fw == null)
  15698. fw = session.getFoldWidget(end.row);
  15699. if (fw == "start" && end.row > start.row) {
  15700. end.row --;
  15701. end.column = session.getLine(end.row).length;
  15702. }
  15703. return Range.fromPoints(start, end);
  15704. };
  15705. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15706. var end = {row: row, column: column};
  15707. var start = session.$findOpeningBracket(bracket, end);
  15708. if (!start)
  15709. return;
  15710. start.column++;
  15711. end.column--;
  15712. return Range.fromPoints(start, end);
  15713. };
  15714. }).call(FoldMode.prototype);
  15715. });
  15716. define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15717. "use strict";
  15718. exports.isDark = false;
  15719. exports.cssClass = "ace-tm";
  15720. exports.cssText = ".ace-tm .ace_gutter {\
  15721. background: #f0f0f0;\
  15722. color: #333;\
  15723. }\
  15724. .ace-tm .ace_print-margin {\
  15725. width: 1px;\
  15726. background: #e8e8e8;\
  15727. }\
  15728. .ace-tm .ace_fold {\
  15729. background-color: #6B72E6;\
  15730. }\
  15731. .ace-tm {\
  15732. background-color: #FFFFFF;\
  15733. color: black;\
  15734. }\
  15735. .ace-tm .ace_cursor {\
  15736. color: black;\
  15737. }\
  15738. .ace-tm .ace_invisible {\
  15739. color: rgb(191, 191, 191);\
  15740. }\
  15741. .ace-tm .ace_storage,\
  15742. .ace-tm .ace_keyword {\
  15743. color: blue;\
  15744. }\
  15745. .ace-tm .ace_constant {\
  15746. color: rgb(197, 6, 11);\
  15747. }\
  15748. .ace-tm .ace_constant.ace_buildin {\
  15749. color: rgb(88, 72, 246);\
  15750. }\
  15751. .ace-tm .ace_constant.ace_language {\
  15752. color: rgb(88, 92, 246);\
  15753. }\
  15754. .ace-tm .ace_constant.ace_library {\
  15755. color: rgb(6, 150, 14);\
  15756. }\
  15757. .ace-tm .ace_invalid {\
  15758. background-color: rgba(255, 0, 0, 0.1);\
  15759. color: red;\
  15760. }\
  15761. .ace-tm .ace_support.ace_function {\
  15762. color: rgb(60, 76, 114);\
  15763. }\
  15764. .ace-tm .ace_support.ace_constant {\
  15765. color: rgb(6, 150, 14);\
  15766. }\
  15767. .ace-tm .ace_support.ace_type,\
  15768. .ace-tm .ace_support.ace_class {\
  15769. color: rgb(109, 121, 222);\
  15770. }\
  15771. .ace-tm .ace_keyword.ace_operator {\
  15772. color: rgb(104, 118, 135);\
  15773. }\
  15774. .ace-tm .ace_string {\
  15775. color: rgb(3, 106, 7);\
  15776. }\
  15777. .ace-tm .ace_comment {\
  15778. color: rgb(76, 136, 107);\
  15779. }\
  15780. .ace-tm .ace_comment.ace_doc {\
  15781. color: rgb(0, 102, 255);\
  15782. }\
  15783. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15784. color: rgb(128, 159, 191);\
  15785. }\
  15786. .ace-tm .ace_constant.ace_numeric {\
  15787. color: rgb(0, 0, 205);\
  15788. }\
  15789. .ace-tm .ace_variable {\
  15790. color: rgb(49, 132, 149);\
  15791. }\
  15792. .ace-tm .ace_xml-pe {\
  15793. color: rgb(104, 104, 91);\
  15794. }\
  15795. .ace-tm .ace_entity.ace_name.ace_function {\
  15796. color: #0000A2;\
  15797. }\
  15798. .ace-tm .ace_heading {\
  15799. color: rgb(12, 7, 255);\
  15800. }\
  15801. .ace-tm .ace_list {\
  15802. color:rgb(185, 6, 144);\
  15803. }\
  15804. .ace-tm .ace_meta.ace_tag {\
  15805. color:rgb(0, 22, 142);\
  15806. }\
  15807. .ace-tm .ace_string.ace_regex {\
  15808. color: rgb(255, 0, 0)\
  15809. }\
  15810. .ace-tm .ace_marker-layer .ace_selection {\
  15811. background: rgb(181, 213, 255);\
  15812. }\
  15813. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15814. box-shadow: 0 0 3px 0px white;\
  15815. }\
  15816. .ace-tm .ace_marker-layer .ace_step {\
  15817. background: rgb(252, 255, 0);\
  15818. }\
  15819. .ace-tm .ace_marker-layer .ace_stack {\
  15820. background: rgb(164, 229, 101);\
  15821. }\
  15822. .ace-tm .ace_marker-layer .ace_bracket {\
  15823. margin: -1px 0 0 -1px;\
  15824. border: 1px solid rgb(192, 192, 192);\
  15825. }\
  15826. .ace-tm .ace_marker-layer .ace_active-line {\
  15827. background: rgba(0, 0, 0, 0.07);\
  15828. }\
  15829. .ace-tm .ace_gutter-active-line {\
  15830. background-color : #dcdcdc;\
  15831. }\
  15832. .ace-tm .ace_marker-layer .ace_selected-word {\
  15833. background: rgb(250, 250, 255);\
  15834. border: 1px solid rgb(200, 200, 250);\
  15835. }\
  15836. .ace-tm .ace_indent-guide {\
  15837. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15838. }\
  15839. ";
  15840. var dom = require("../lib/dom");
  15841. dom.importCssString(exports.cssText, exports.cssClass);
  15842. });
  15843. define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15844. "use strict";
  15845. var oop = require("./lib/oop");
  15846. var dom = require("./lib/dom");
  15847. var Range = require("./range").Range;
  15848. function LineWidgets(session) {
  15849. this.session = session;
  15850. this.session.widgetManager = this;
  15851. this.session.getRowLength = this.getRowLength;
  15852. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15853. this.updateOnChange = this.updateOnChange.bind(this);
  15854. this.renderWidgets = this.renderWidgets.bind(this);
  15855. this.measureWidgets = this.measureWidgets.bind(this);
  15856. this.session._changedWidgets = [];
  15857. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15858. this.session.on("change", this.updateOnChange);
  15859. this.session.on("changeEditor", this.$onChangeEditor);
  15860. }
  15861. (function() {
  15862. this.getRowLength = function(row) {
  15863. var h;
  15864. if (this.lineWidgets)
  15865. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15866. else
  15867. h = 0;
  15868. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15869. return 1 + h;
  15870. } else {
  15871. return this.$wrapData[row].length + 1 + h;
  15872. }
  15873. };
  15874. this.$getWidgetScreenLength = function() {
  15875. var screenRows = 0;
  15876. this.lineWidgets.forEach(function(w){
  15877. if (w && w.rowCount)
  15878. screenRows +=w.rowCount;
  15879. });
  15880. return screenRows;
  15881. };
  15882. this.$onChangeEditor = function(e) {
  15883. this.attach(e.editor);
  15884. };
  15885. this.attach = function(editor) {
  15886. if (editor && editor.widgetManager && editor.widgetManager != this)
  15887. editor.widgetManager.detach();
  15888. if (this.editor == editor)
  15889. return;
  15890. this.detach();
  15891. this.editor = editor;
  15892. if (editor) {
  15893. editor.widgetManager = this;
  15894. editor.renderer.on("beforeRender", this.measureWidgets);
  15895. editor.renderer.on("afterRender", this.renderWidgets);
  15896. }
  15897. };
  15898. this.detach = function(e) {
  15899. var editor = this.editor;
  15900. if (!editor)
  15901. return;
  15902. this.editor = null;
  15903. editor.widgetManager = null;
  15904. editor.renderer.off("beforeRender", this.measureWidgets);
  15905. editor.renderer.off("afterRender", this.renderWidgets);
  15906. var lineWidgets = this.session.lineWidgets;
  15907. lineWidgets && lineWidgets.forEach(function(w) {
  15908. if (w && w.el && w.el.parentNode) {
  15909. w._inDocument = false;
  15910. w.el.parentNode.removeChild(w.el);
  15911. }
  15912. });
  15913. };
  15914. this.updateOnChange = function(delta) {
  15915. var lineWidgets = this.session.lineWidgets;
  15916. if (!lineWidgets) return;
  15917. var startRow = delta.start.row;
  15918. var len = delta.end.row - startRow;
  15919. if (len === 0) {
  15920. } else if (delta.action == 'remove') {
  15921. var removed = lineWidgets.splice(startRow + 1, len);
  15922. removed.forEach(function(w) {
  15923. w && this.removeLineWidget(w);
  15924. }, this);
  15925. this.$updateRows();
  15926. } else {
  15927. var args = new Array(len);
  15928. args.unshift(startRow, 0);
  15929. lineWidgets.splice.apply(lineWidgets, args);
  15930. this.$updateRows();
  15931. }
  15932. };
  15933. this.$updateRows = function() {
  15934. var lineWidgets = this.session.lineWidgets;
  15935. if (!lineWidgets) return;
  15936. var noWidgets = true;
  15937. lineWidgets.forEach(function(w, i) {
  15938. if (w) {
  15939. noWidgets = false;
  15940. w.row = i;
  15941. }
  15942. });
  15943. if (noWidgets)
  15944. this.session.lineWidgets = null;
  15945. };
  15946. this.addLineWidget = function(w) {
  15947. if (!this.session.lineWidgets)
  15948. this.session.lineWidgets = new Array(this.session.getLength());
  15949. this.session.lineWidgets[w.row] = w;
  15950. var renderer = this.editor.renderer;
  15951. if (w.html && !w.el) {
  15952. w.el = dom.createElement("div");
  15953. w.el.innerHTML = w.html;
  15954. }
  15955. if (w.el) {
  15956. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  15957. w.el.style.position = "absolute";
  15958. w.el.style.zIndex = 5;
  15959. renderer.container.appendChild(w.el);
  15960. w._inDocument = true;
  15961. }
  15962. if (!w.coverGutter) {
  15963. w.el.style.zIndex = 3;
  15964. }
  15965. if (!w.pixelHeight) {
  15966. w.pixelHeight = w.el.offsetHeight;
  15967. }
  15968. if (w.rowCount == null)
  15969. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  15970. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15971. this.$updateRows();
  15972. this.renderWidgets(null, renderer);
  15973. return w;
  15974. };
  15975. this.removeLineWidget = function(w) {
  15976. w._inDocument = false;
  15977. if (w.el && w.el.parentNode)
  15978. w.el.parentNode.removeChild(w.el);
  15979. if (w.editor && w.editor.destroy) try {
  15980. w.editor.destroy();
  15981. } catch(e){}
  15982. if (this.session.lineWidgets)
  15983. this.session.lineWidgets[w.row] = undefined;
  15984. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15985. this.$updateRows();
  15986. };
  15987. this.onWidgetChanged = function(w) {
  15988. this.session._changedWidgets.push(w);
  15989. this.editor && this.editor.renderer.updateFull();
  15990. };
  15991. this.measureWidgets = function(e, renderer) {
  15992. var changedWidgets = this.session._changedWidgets;
  15993. var config = renderer.layerConfig;
  15994. if (!changedWidgets || !changedWidgets.length) return;
  15995. var min = Infinity;
  15996. for (var i = 0; i < changedWidgets.length; i++) {
  15997. var w = changedWidgets[i];
  15998. if (!w._inDocument) {
  15999. w._inDocument = true;
  16000. renderer.container.appendChild(w.el);
  16001. }
  16002. w.h = w.el.offsetHeight;
  16003. if (!w.fixedWidth) {
  16004. w.w = w.el.offsetWidth;
  16005. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  16006. }
  16007. var rowCount = w.h / config.lineHeight;
  16008. if (w.coverLine) {
  16009. rowCount -= this.session.getRowLineCount(w.row);
  16010. if (rowCount < 0)
  16011. rowCount = 0;
  16012. }
  16013. if (w.rowCount != rowCount) {
  16014. w.rowCount = rowCount;
  16015. if (w.row < min)
  16016. min = w.row;
  16017. }
  16018. }
  16019. if (min != Infinity) {
  16020. this.session._emit("changeFold", {data:{start:{row: min}}});
  16021. this.session.lineWidgetWidth = null;
  16022. }
  16023. this.session._changedWidgets = [];
  16024. };
  16025. this.renderWidgets = function(e, renderer) {
  16026. var config = renderer.layerConfig;
  16027. var lineWidgets = this.session.lineWidgets;
  16028. if (!lineWidgets)
  16029. return;
  16030. var first = Math.min(this.firstRow, config.firstRow);
  16031. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  16032. while (first > 0 && !lineWidgets[first])
  16033. first--;
  16034. this.firstRow = config.firstRow;
  16035. this.lastRow = config.lastRow;
  16036. renderer.$cursorLayer.config = config;
  16037. for (var i = first; i <= last; i++) {
  16038. var w = lineWidgets[i];
  16039. if (!w || !w.el) continue;
  16040. if (!w._inDocument) {
  16041. w._inDocument = true;
  16042. renderer.container.appendChild(w.el);
  16043. }
  16044. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  16045. if (!w.coverLine)
  16046. top += config.lineHeight * this.session.getRowLineCount(w.row);
  16047. w.el.style.top = top - config.offset + "px";
  16048. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  16049. if (!w.fixedWidth)
  16050. left -= renderer.scrollLeft;
  16051. w.el.style.left = left + "px";
  16052. if (w.fixedWidth) {
  16053. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  16054. } else {
  16055. w.el.style.right = "";
  16056. }
  16057. }
  16058. };
  16059. }).call(LineWidgets.prototype);
  16060. exports.LineWidgets = LineWidgets;
  16061. });
  16062. define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  16063. "use strict";
  16064. var LineWidgets = require("../line_widgets").LineWidgets;
  16065. var dom = require("../lib/dom");
  16066. var Range = require("../range").Range;
  16067. function binarySearch(array, needle, comparator) {
  16068. var first = 0;
  16069. var last = array.length - 1;
  16070. while (first <= last) {
  16071. var mid = (first + last) >> 1;
  16072. var c = comparator(needle, array[mid]);
  16073. if (c > 0)
  16074. first = mid + 1;
  16075. else if (c < 0)
  16076. last = mid - 1;
  16077. else
  16078. return mid;
  16079. }
  16080. return -(first + 1);
  16081. }
  16082. function findAnnotations(session, row, dir) {
  16083. var annotations = session.getAnnotations().sort(Range.comparePoints);
  16084. if (!annotations.length)
  16085. return;
  16086. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  16087. if (i < 0)
  16088. i = -i - 1;
  16089. if (i >= annotations.length)
  16090. i = dir > 0 ? 0 : annotations.length - 1;
  16091. else if (i === 0 && dir < 0)
  16092. i = annotations.length - 1;
  16093. var annotation = annotations[i];
  16094. if (!annotation || !dir)
  16095. return;
  16096. if (annotation.row === row) {
  16097. do {
  16098. annotation = annotations[i += dir];
  16099. } while (annotation && annotation.row === row);
  16100. if (!annotation)
  16101. return annotations.slice();
  16102. }
  16103. var matched = [];
  16104. row = annotation.row;
  16105. do {
  16106. matched[dir < 0 ? "unshift" : "push"](annotation);
  16107. annotation = annotations[i += dir];
  16108. } while (annotation && annotation.row == row);
  16109. return matched.length && matched;
  16110. }
  16111. exports.showErrorMarker = function(editor, dir) {
  16112. var session = editor.session;
  16113. if (!session.widgetManager) {
  16114. session.widgetManager = new LineWidgets(session);
  16115. session.widgetManager.attach(editor);
  16116. }
  16117. var pos = editor.getCursorPosition();
  16118. var row = pos.row;
  16119. var oldWidget = session.lineWidgets && session.lineWidgets[row];
  16120. if (oldWidget) {
  16121. oldWidget.destroy();
  16122. } else {
  16123. row -= dir;
  16124. }
  16125. var annotations = findAnnotations(session, row, dir);
  16126. var gutterAnno;
  16127. if (annotations) {
  16128. var annotation = annotations[0];
  16129. pos.column = (annotation.pos && typeof annotation.column != "number"
  16130. ? annotation.pos.sc
  16131. : annotation.column) || 0;
  16132. pos.row = annotation.row;
  16133. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  16134. } else if (oldWidget) {
  16135. return;
  16136. } else {
  16137. gutterAnno = {
  16138. text: ["Looks good!"],
  16139. className: "ace_ok"
  16140. };
  16141. }
  16142. editor.session.unfold(pos.row);
  16143. editor.selection.moveToPosition(pos);
  16144. var w = {
  16145. row: pos.row,
  16146. fixedWidth: true,
  16147. coverGutter: true,
  16148. el: dom.createElement("div")
  16149. };
  16150. var el = w.el.appendChild(dom.createElement("div"));
  16151. var arrow = w.el.appendChild(dom.createElement("div"));
  16152. arrow.className = "error_widget_arrow " + gutterAnno.className;
  16153. var left = editor.renderer.$cursorLayer
  16154. .getPixelPosition(pos).left;
  16155. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  16156. w.el.className = "error_widget_wrapper";
  16157. el.className = "error_widget " + gutterAnno.className;
  16158. el.innerHTML = gutterAnno.text.join("<br>");
  16159. el.appendChild(dom.createElement("div"));
  16160. var kb = function(_, hashId, keyString) {
  16161. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  16162. w.destroy();
  16163. return {command: "null"};
  16164. }
  16165. };
  16166. w.destroy = function() {
  16167. if (editor.$mouseHandler.isMousePressed)
  16168. return;
  16169. editor.keyBinding.removeKeyboardHandler(kb);
  16170. session.widgetManager.removeLineWidget(w);
  16171. editor.off("changeSelection", w.destroy);
  16172. editor.off("changeSession", w.destroy);
  16173. editor.off("mouseup", w.destroy);
  16174. editor.off("change", w.destroy);
  16175. };
  16176. editor.keyBinding.addKeyboardHandler(kb);
  16177. editor.on("changeSelection", w.destroy);
  16178. editor.on("changeSession", w.destroy);
  16179. editor.on("mouseup", w.destroy);
  16180. editor.on("change", w.destroy);
  16181. editor.session.widgetManager.addLineWidget(w);
  16182. w.el.onmousedown = editor.focus.bind(editor);
  16183. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  16184. };
  16185. dom.importCssString("\
  16186. .error_widget_wrapper {\
  16187. background: inherit;\
  16188. color: inherit;\
  16189. border:none\
  16190. }\
  16191. .error_widget {\
  16192. border-top: solid 2px;\
  16193. border-bottom: solid 2px;\
  16194. margin: 5px 0;\
  16195. padding: 10px 40px;\
  16196. white-space: pre-wrap;\
  16197. }\
  16198. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  16199. border-color: #ff5a5a\
  16200. }\
  16201. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  16202. border-color: #F1D817\
  16203. }\
  16204. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  16205. border-color: #5a5a5a\
  16206. }\
  16207. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  16208. border-color: #5aaa5a\
  16209. }\
  16210. .error_widget_arrow {\
  16211. position: absolute;\
  16212. border: solid 5px;\
  16213. border-top-color: transparent!important;\
  16214. border-right-color: transparent!important;\
  16215. border-left-color: transparent!important;\
  16216. top: -5px;\
  16217. }\
  16218. ", "");
  16219. });
  16220. 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) {
  16221. "use strict";
  16222. require("./lib/fixoldbrowsers");
  16223. var dom = require("./lib/dom");
  16224. var event = require("./lib/event");
  16225. var Editor = require("./editor").Editor;
  16226. var EditSession = require("./edit_session").EditSession;
  16227. var UndoManager = require("./undomanager").UndoManager;
  16228. var Renderer = require("./virtual_renderer").VirtualRenderer;
  16229. require("./worker/worker_client");
  16230. require("./keyboard/hash_handler");
  16231. require("./placeholder");
  16232. require("./multi_select");
  16233. require("./mode/folding/fold_mode");
  16234. require("./theme/textmate");
  16235. require("./ext/error_marker");
  16236. exports.config = require("./config");
  16237. exports.require = require;
  16238. exports.edit = function(el) {
  16239. if (typeof(el) == "string") {
  16240. var _id = el;
  16241. el = document.getElementById(_id);
  16242. if (!el)
  16243. throw new Error("ace.edit can't find div #" + _id);
  16244. }
  16245. if (el && el.env && el.env.editor instanceof Editor)
  16246. return el.env.editor;
  16247. var value = "";
  16248. if (el && /input|textarea/i.test(el.tagName)) {
  16249. var oldNode = el;
  16250. value = oldNode.value;
  16251. el = dom.createElement("pre");
  16252. oldNode.parentNode.replaceChild(el, oldNode);
  16253. } else if (el) {
  16254. value = dom.getInnerText(el);
  16255. el.innerHTML = '';
  16256. }
  16257. var doc = exports.createEditSession(value);
  16258. var editor = new Editor(new Renderer(el));
  16259. editor.setSession(doc);
  16260. var env = {
  16261. document: doc,
  16262. editor: editor,
  16263. onResize: editor.resize.bind(editor, null)
  16264. };
  16265. if (oldNode) env.textarea = oldNode;
  16266. event.addListener(window, "resize", env.onResize);
  16267. editor.on("destroy", function() {
  16268. event.removeListener(window, "resize", env.onResize);
  16269. env.editor.container.env = null; // prevent memory leak on old ie
  16270. });
  16271. editor.container.env = editor.env = env;
  16272. return editor;
  16273. };
  16274. exports.createEditSession = function(text, mode) {
  16275. var doc = new EditSession(text, mode);
  16276. doc.setUndoManager(new UndoManager());
  16277. return doc;
  16278. }
  16279. exports.EditSession = EditSession;
  16280. exports.UndoManager = UndoManager;
  16281. });
  16282. (function() {
  16283. window.require(["ace/ace"], function(a) {
  16284. a && a.config.init(true);
  16285. if (!window.ace)
  16286. window.ace = a;
  16287. for (var key in a) if (a.hasOwnProperty(key))
  16288. window.ace[key] = a[key];
  16289. });
  16290. })();