ace.js 685 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /**
  31. * Define a module along with a payload
  32. * @param module a name for the payload
  33. * @param payload a function to call with (require, exports, module) params
  34. */
  35. (function() {
  36. var ACE_NAMESPACE = "";
  37. var global = (function() { return this; })();
  38. if (!global && typeof window != "undefined") global = window; // strict mode
  39. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  40. return;
  41. var define = function(module, deps, payload) {
  42. if (typeof module !== "string") {
  43. if (define.original)
  44. define.original.apply(this, arguments);
  45. else {
  46. console.error("dropping module because define wasn\'t a string.");
  47. console.trace();
  48. }
  49. return;
  50. }
  51. if (arguments.length == 2)
  52. payload = deps;
  53. if (!define.modules[module]) {
  54. define.payloads[module] = payload;
  55. define.modules[module] = null;
  56. }
  57. };
  58. define.modules = {};
  59. define.payloads = {};
  60. /**
  61. * Get at functionality define()ed using the function above
  62. */
  63. var _require = function(parentId, module, callback) {
  64. if (typeof module === "string") {
  65. var payload = lookup(parentId, module);
  66. if (payload != undefined) {
  67. callback && callback();
  68. return payload;
  69. }
  70. } else if (Object.prototype.toString.call(module) === "[object Array]") {
  71. var params = [];
  72. for (var i = 0, l = module.length; i < l; ++i) {
  73. var dep = lookup(parentId, module[i]);
  74. if (dep == undefined && require.original)
  75. return;
  76. params.push(dep);
  77. }
  78. return callback && callback.apply(null, params) || true;
  79. }
  80. };
  81. var require = function(module, callback) {
  82. var packagedModule = _require("", module, callback);
  83. if (packagedModule == undefined && require.original)
  84. return require.original.apply(this, arguments);
  85. return packagedModule;
  86. };
  87. var normalizeModule = function(parentId, moduleName) {
  88. // normalize plugin requires
  89. if (moduleName.indexOf("!") !== -1) {
  90. var chunks = moduleName.split("!");
  91. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  92. }
  93. // normalize relative requires
  94. if (moduleName.charAt(0) == ".") {
  95. var base = parentId.split("/").slice(0, -1).join("/");
  96. moduleName = base + "/" + moduleName;
  97. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  98. var previous = moduleName;
  99. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  100. }
  101. }
  102. return moduleName;
  103. };
  104. /**
  105. * Internal function to lookup moduleNames and resolve them by calling the
  106. * definition function if needed.
  107. */
  108. var lookup = function(parentId, moduleName) {
  109. moduleName = normalizeModule(parentId, moduleName);
  110. var module = define.modules[moduleName];
  111. if (!module) {
  112. module = define.payloads[moduleName];
  113. if (typeof module === 'function') {
  114. var exports = {};
  115. var mod = {
  116. id: moduleName,
  117. uri: '',
  118. exports: exports,
  119. packaged: true
  120. };
  121. var req = function(module, callback) {
  122. return _require(moduleName, module, callback);
  123. };
  124. var returnValue = module(req, exports, mod);
  125. exports = returnValue || mod.exports;
  126. define.modules[moduleName] = exports;
  127. delete define.payloads[moduleName];
  128. }
  129. module = define.modules[moduleName] = exports || module;
  130. }
  131. return module;
  132. };
  133. function exportAce(ns) {
  134. var root = global;
  135. if (ns) {
  136. if (!global[ns])
  137. global[ns] = {};
  138. root = global[ns];
  139. }
  140. if (!root.define || !root.define.packaged) {
  141. define.original = root.define;
  142. root.define = define;
  143. root.define.packaged = true;
  144. }
  145. if (!root.require || !root.require.packaged) {
  146. require.original = root.require;
  147. root.require = require;
  148. root.require.packaged = true;
  149. }
  150. }
  151. exportAce(ACE_NAMESPACE);
  152. })();
  153. define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  154. "use strict";
  155. var real = {
  156. exec: RegExp.prototype.exec,
  157. test: RegExp.prototype.test,
  158. match: String.prototype.match,
  159. replace: String.prototype.replace,
  160. split: String.prototype.split
  161. },
  162. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  163. compliantLastIndexIncrement = function () {
  164. var x = /^/g;
  165. real.test.call(x, "");
  166. return !x.lastIndex;
  167. }();
  168. if (compliantLastIndexIncrement && compliantExecNpcg)
  169. return;
  170. RegExp.prototype.exec = function (str) {
  171. var match = real.exec.apply(this, arguments),
  172. name, r2;
  173. if ( typeof(str) == 'string' && match) {
  174. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  175. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  176. real.replace.call(str.slice(match.index), r2, function () {
  177. for (var i = 1; i < arguments.length - 2; i++) {
  178. if (arguments[i] === undefined)
  179. match[i] = undefined;
  180. }
  181. });
  182. }
  183. if (this._xregexp && this._xregexp.captureNames) {
  184. for (var i = 1; i < match.length; i++) {
  185. name = this._xregexp.captureNames[i - 1];
  186. if (name)
  187. match[name] = match[i];
  188. }
  189. }
  190. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  191. this.lastIndex--;
  192. }
  193. return match;
  194. };
  195. if (!compliantLastIndexIncrement) {
  196. RegExp.prototype.test = function (str) {
  197. var match = real.exec.call(this, str);
  198. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  199. this.lastIndex--;
  200. return !!match;
  201. };
  202. }
  203. function getNativeFlags (regex) {
  204. return (regex.global ? "g" : "") +
  205. (regex.ignoreCase ? "i" : "") +
  206. (regex.multiline ? "m" : "") +
  207. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  208. (regex.sticky ? "y" : "");
  209. }
  210. function indexOf (array, item, from) {
  211. if (Array.prototype.indexOf) // Use the native array method if available
  212. return array.indexOf(item, from);
  213. for (var i = from || 0; i < array.length; i++) {
  214. if (array[i] === item)
  215. return i;
  216. }
  217. return -1;
  218. }
  219. });
  220. define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  221. function Empty() {}
  222. if (!Function.prototype.bind) {
  223. Function.prototype.bind = function bind(that) { // .length is 1
  224. var target = this;
  225. if (typeof target != "function") {
  226. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  227. }
  228. var args = slice.call(arguments, 1); // for normal call
  229. var bound = function () {
  230. if (this instanceof bound) {
  231. var result = target.apply(
  232. this,
  233. args.concat(slice.call(arguments))
  234. );
  235. if (Object(result) === result) {
  236. return result;
  237. }
  238. return this;
  239. } else {
  240. return target.apply(
  241. that,
  242. args.concat(slice.call(arguments))
  243. );
  244. }
  245. };
  246. if(target.prototype) {
  247. Empty.prototype = target.prototype;
  248. bound.prototype = new Empty();
  249. Empty.prototype = null;
  250. }
  251. return bound;
  252. };
  253. }
  254. var call = Function.prototype.call;
  255. var prototypeOfArray = Array.prototype;
  256. var prototypeOfObject = Object.prototype;
  257. var slice = prototypeOfArray.slice;
  258. var _toString = call.bind(prototypeOfObject.toString);
  259. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  260. var defineGetter;
  261. var defineSetter;
  262. var lookupGetter;
  263. var lookupSetter;
  264. var supportsAccessors;
  265. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  266. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  267. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  268. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  269. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  270. }
  271. if ([1,2].splice(0).length != 2) {
  272. if(function() { // test IE < 9 to splice bug - see issue #138
  273. function makeArray(l) {
  274. var a = new Array(l+2);
  275. a[0] = a[1] = 0;
  276. return a;
  277. }
  278. var array = [], lengthBefore;
  279. array.splice.apply(array, makeArray(20));
  280. array.splice.apply(array, makeArray(26));
  281. lengthBefore = array.length; //46
  282. array.splice(5, 0, "XXX"); // add one element
  283. lengthBefore + 1 == array.length
  284. if (lengthBefore + 1 == array.length) {
  285. return true;// has right splice implementation without bugs
  286. }
  287. }()) {//IE 6/7
  288. var array_splice = Array.prototype.splice;
  289. Array.prototype.splice = function(start, deleteCount) {
  290. if (!arguments.length) {
  291. return [];
  292. } else {
  293. return array_splice.apply(this, [
  294. start === void 0 ? 0 : start,
  295. deleteCount === void 0 ? (this.length - start) : deleteCount
  296. ].concat(slice.call(arguments, 2)))
  297. }
  298. };
  299. } else {//IE8
  300. Array.prototype.splice = function(pos, removeCount){
  301. var length = this.length;
  302. if (pos > 0) {
  303. if (pos > length)
  304. pos = length;
  305. } else if (pos == void 0) {
  306. pos = 0;
  307. } else if (pos < 0) {
  308. pos = Math.max(length + pos, 0);
  309. }
  310. if (!(pos+removeCount < length))
  311. removeCount = length - pos;
  312. var removed = this.slice(pos, pos+removeCount);
  313. var insert = slice.call(arguments, 2);
  314. var add = insert.length;
  315. if (pos === length) {
  316. if (add) {
  317. this.push.apply(this, insert);
  318. }
  319. } else {
  320. var remove = Math.min(removeCount, length - pos);
  321. var tailOldPos = pos + remove;
  322. var tailNewPos = tailOldPos + add - remove;
  323. var tailCount = length - tailOldPos;
  324. var lengthAfterRemove = length - remove;
  325. if (tailNewPos < tailOldPos) { // case A
  326. for (var i = 0; i < tailCount; ++i) {
  327. this[tailNewPos+i] = this[tailOldPos+i];
  328. }
  329. } else if (tailNewPos > tailOldPos) { // case B
  330. for (i = tailCount; i--; ) {
  331. this[tailNewPos+i] = this[tailOldPos+i];
  332. }
  333. } // else, add == remove (nothing to do)
  334. if (add && pos === lengthAfterRemove) {
  335. this.length = lengthAfterRemove; // truncate array
  336. this.push.apply(this, insert);
  337. } else {
  338. this.length = lengthAfterRemove + add; // reserves space
  339. for (i = 0; i < add; ++i) {
  340. this[pos+i] = insert[i];
  341. }
  342. }
  343. }
  344. return removed;
  345. };
  346. }
  347. }
  348. if (!Array.isArray) {
  349. Array.isArray = function isArray(obj) {
  350. return _toString(obj) == "[object Array]";
  351. };
  352. }
  353. var boxedString = Object("a"),
  354. splitString = boxedString[0] != "a" || !(0 in boxedString);
  355. if (!Array.prototype.forEach) {
  356. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. thisp = arguments[1],
  362. i = -1,
  363. length = self.length >>> 0;
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(); // TODO message
  366. }
  367. while (++i < length) {
  368. if (i in self) {
  369. fun.call(thisp, self[i], i, object);
  370. }
  371. }
  372. };
  373. }
  374. if (!Array.prototype.map) {
  375. Array.prototype.map = function map(fun /*, thisp*/) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = Array(length),
  382. thisp = arguments[1];
  383. if (_toString(fun) != "[object Function]") {
  384. throw new TypeError(fun + " is not a function");
  385. }
  386. for (var i = 0; i < length; i++) {
  387. if (i in self)
  388. result[i] = fun.call(thisp, self[i], i, object);
  389. }
  390. return result;
  391. };
  392. }
  393. if (!Array.prototype.filter) {
  394. Array.prototype.filter = function filter(fun /*, thisp */) {
  395. var object = toObject(this),
  396. self = splitString && _toString(this) == "[object String]" ?
  397. this.split("") :
  398. object,
  399. length = self.length >>> 0,
  400. result = [],
  401. value,
  402. thisp = arguments[1];
  403. if (_toString(fun) != "[object Function]") {
  404. throw new TypeError(fun + " is not a function");
  405. }
  406. for (var i = 0; i < length; i++) {
  407. if (i in self) {
  408. value = self[i];
  409. if (fun.call(thisp, value, i, object)) {
  410. result.push(value);
  411. }
  412. }
  413. }
  414. return result;
  415. };
  416. }
  417. if (!Array.prototype.every) {
  418. Array.prototype.every = function every(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && !fun.call(thisp, self[i], i, object)) {
  430. return false;
  431. }
  432. }
  433. return true;
  434. };
  435. }
  436. if (!Array.prototype.some) {
  437. Array.prototype.some = function some(fun /*, thisp */) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0,
  443. thisp = arguments[1];
  444. if (_toString(fun) != "[object Function]") {
  445. throw new TypeError(fun + " is not a function");
  446. }
  447. for (var i = 0; i < length; i++) {
  448. if (i in self && fun.call(thisp, self[i], i, object)) {
  449. return true;
  450. }
  451. }
  452. return false;
  453. };
  454. }
  455. if (!Array.prototype.reduce) {
  456. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  457. var object = toObject(this),
  458. self = splitString && _toString(this) == "[object String]" ?
  459. this.split("") :
  460. object,
  461. length = self.length >>> 0;
  462. if (_toString(fun) != "[object Function]") {
  463. throw new TypeError(fun + " is not a function");
  464. }
  465. if (!length && arguments.length == 1) {
  466. throw new TypeError("reduce of empty array with no initial value");
  467. }
  468. var i = 0;
  469. var result;
  470. if (arguments.length >= 2) {
  471. result = arguments[1];
  472. } else {
  473. do {
  474. if (i in self) {
  475. result = self[i++];
  476. break;
  477. }
  478. if (++i >= length) {
  479. throw new TypeError("reduce of empty array with no initial value");
  480. }
  481. } while (true);
  482. }
  483. for (; i < length; i++) {
  484. if (i in self) {
  485. result = fun.call(void 0, result, self[i], i, object);
  486. }
  487. }
  488. return result;
  489. };
  490. }
  491. if (!Array.prototype.reduceRight) {
  492. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  493. var object = toObject(this),
  494. self = splitString && _toString(this) == "[object String]" ?
  495. this.split("") :
  496. object,
  497. length = self.length >>> 0;
  498. if (_toString(fun) != "[object Function]") {
  499. throw new TypeError(fun + " is not a function");
  500. }
  501. if (!length && arguments.length == 1) {
  502. throw new TypeError("reduceRight of empty array with no initial value");
  503. }
  504. var result, i = length - 1;
  505. if (arguments.length >= 2) {
  506. result = arguments[1];
  507. } else {
  508. do {
  509. if (i in self) {
  510. result = self[i--];
  511. break;
  512. }
  513. if (--i < 0) {
  514. throw new TypeError("reduceRight of empty array with no initial value");
  515. }
  516. } while (true);
  517. }
  518. do {
  519. if (i in this) {
  520. result = fun.call(void 0, result, self[i], i, object);
  521. }
  522. } while (i--);
  523. return result;
  524. };
  525. }
  526. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  527. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  528. var self = splitString && _toString(this) == "[object String]" ?
  529. this.split("") :
  530. toObject(this),
  531. length = self.length >>> 0;
  532. if (!length) {
  533. return -1;
  534. }
  535. var i = 0;
  536. if (arguments.length > 1) {
  537. i = toInteger(arguments[1]);
  538. }
  539. i = i >= 0 ? i : Math.max(0, length + i);
  540. for (; i < length; i++) {
  541. if (i in self && self[i] === sought) {
  542. return i;
  543. }
  544. }
  545. return -1;
  546. };
  547. }
  548. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  549. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  550. var self = splitString && _toString(this) == "[object String]" ?
  551. this.split("") :
  552. toObject(this),
  553. length = self.length >>> 0;
  554. if (!length) {
  555. return -1;
  556. }
  557. var i = length - 1;
  558. if (arguments.length > 1) {
  559. i = Math.min(i, toInteger(arguments[1]));
  560. }
  561. i = i >= 0 ? i : length - Math.abs(i);
  562. for (; i >= 0; i--) {
  563. if (i in self && sought === self[i]) {
  564. return i;
  565. }
  566. }
  567. return -1;
  568. };
  569. }
  570. if (!Object.getPrototypeOf) {
  571. Object.getPrototypeOf = function getPrototypeOf(object) {
  572. return object.__proto__ || (
  573. object.constructor ?
  574. object.constructor.prototype :
  575. prototypeOfObject
  576. );
  577. };
  578. }
  579. if (!Object.getOwnPropertyDescriptor) {
  580. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  581. "non-object: ";
  582. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  583. if ((typeof object != "object" && typeof object != "function") || object === null)
  584. throw new TypeError(ERR_NON_OBJECT + object);
  585. if (!owns(object, property))
  586. return;
  587. var descriptor, getter, setter;
  588. descriptor = { enumerable: true, configurable: true };
  589. if (supportsAccessors) {
  590. var prototype = object.__proto__;
  591. object.__proto__ = prototypeOfObject;
  592. var getter = lookupGetter(object, property);
  593. var setter = lookupSetter(object, property);
  594. object.__proto__ = prototype;
  595. if (getter || setter) {
  596. if (getter) descriptor.get = getter;
  597. if (setter) descriptor.set = setter;
  598. return descriptor;
  599. }
  600. }
  601. descriptor.value = object[property];
  602. return descriptor;
  603. };
  604. }
  605. if (!Object.getOwnPropertyNames) {
  606. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  607. return Object.keys(object);
  608. };
  609. }
  610. if (!Object.create) {
  611. var createEmpty;
  612. if (Object.prototype.__proto__ === null) {
  613. createEmpty = function () {
  614. return { "__proto__": null };
  615. };
  616. } else {
  617. createEmpty = function () {
  618. var empty = {};
  619. for (var i in empty)
  620. empty[i] = null;
  621. empty.constructor =
  622. empty.hasOwnProperty =
  623. empty.propertyIsEnumerable =
  624. empty.isPrototypeOf =
  625. empty.toLocaleString =
  626. empty.toString =
  627. empty.valueOf =
  628. empty.__proto__ = null;
  629. return empty;
  630. }
  631. }
  632. Object.create = function create(prototype, properties) {
  633. var object;
  634. if (prototype === null) {
  635. object = createEmpty();
  636. } else {
  637. if (typeof prototype != "object")
  638. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  639. var Type = function () {};
  640. Type.prototype = prototype;
  641. object = new Type();
  642. object.__proto__ = prototype;
  643. }
  644. if (properties !== void 0)
  645. Object.defineProperties(object, properties);
  646. return object;
  647. };
  648. }
  649. function doesDefinePropertyWork(object) {
  650. try {
  651. Object.defineProperty(object, "sentinel", {});
  652. return "sentinel" in object;
  653. } catch (exception) {
  654. }
  655. }
  656. if (Object.defineProperty) {
  657. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  658. var definePropertyWorksOnDom = typeof document == "undefined" ||
  659. doesDefinePropertyWork(document.createElement("div"));
  660. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  661. var definePropertyFallback = Object.defineProperty;
  662. }
  663. }
  664. if (!Object.defineProperty || definePropertyFallback) {
  665. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  666. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  667. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  668. "on this javascript engine";
  669. Object.defineProperty = function defineProperty(object, property, descriptor) {
  670. if ((typeof object != "object" && typeof object != "function") || object === null)
  671. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  672. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  673. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  674. if (definePropertyFallback) {
  675. try {
  676. return definePropertyFallback.call(Object, object, property, descriptor);
  677. } catch (exception) {
  678. }
  679. }
  680. if (owns(descriptor, "value")) {
  681. if (supportsAccessors && (lookupGetter(object, property) ||
  682. lookupSetter(object, property)))
  683. {
  684. var prototype = object.__proto__;
  685. object.__proto__ = prototypeOfObject;
  686. delete object[property];
  687. object[property] = descriptor.value;
  688. object.__proto__ = prototype;
  689. } else {
  690. object[property] = descriptor.value;
  691. }
  692. } else {
  693. if (!supportsAccessors)
  694. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  695. if (owns(descriptor, "get"))
  696. defineGetter(object, property, descriptor.get);
  697. if (owns(descriptor, "set"))
  698. defineSetter(object, property, descriptor.set);
  699. }
  700. return object;
  701. };
  702. }
  703. if (!Object.defineProperties) {
  704. Object.defineProperties = function defineProperties(object, properties) {
  705. for (var property in properties) {
  706. if (owns(properties, property))
  707. Object.defineProperty(object, property, properties[property]);
  708. }
  709. return object;
  710. };
  711. }
  712. if (!Object.seal) {
  713. Object.seal = function seal(object) {
  714. return object;
  715. };
  716. }
  717. if (!Object.freeze) {
  718. Object.freeze = function freeze(object) {
  719. return object;
  720. };
  721. }
  722. try {
  723. Object.freeze(function () {});
  724. } catch (exception) {
  725. Object.freeze = (function freeze(freezeObject) {
  726. return function freeze(object) {
  727. if (typeof object == "function") {
  728. return object;
  729. } else {
  730. return freezeObject(object);
  731. }
  732. };
  733. })(Object.freeze);
  734. }
  735. if (!Object.preventExtensions) {
  736. Object.preventExtensions = function preventExtensions(object) {
  737. return object;
  738. };
  739. }
  740. if (!Object.isSealed) {
  741. Object.isSealed = function isSealed(object) {
  742. return false;
  743. };
  744. }
  745. if (!Object.isFrozen) {
  746. Object.isFrozen = function isFrozen(object) {
  747. return false;
  748. };
  749. }
  750. if (!Object.isExtensible) {
  751. Object.isExtensible = function isExtensible(object) {
  752. if (Object(object) === object) {
  753. throw new TypeError(); // TODO message
  754. }
  755. var name = '';
  756. while (owns(object, name)) {
  757. name += '?';
  758. }
  759. object[name] = true;
  760. var returnValue = owns(object, name);
  761. delete object[name];
  762. return returnValue;
  763. };
  764. }
  765. if (!Object.keys) {
  766. var hasDontEnumBug = true,
  767. dontEnums = [
  768. "toString",
  769. "toLocaleString",
  770. "valueOf",
  771. "hasOwnProperty",
  772. "isPrototypeOf",
  773. "propertyIsEnumerable",
  774. "constructor"
  775. ],
  776. dontEnumsLength = dontEnums.length;
  777. for (var key in {"toString": null}) {
  778. hasDontEnumBug = false;
  779. }
  780. Object.keys = function keys(object) {
  781. if (
  782. (typeof object != "object" && typeof object != "function") ||
  783. object === null
  784. ) {
  785. throw new TypeError("Object.keys called on a non-object");
  786. }
  787. var keys = [];
  788. for (var name in object) {
  789. if (owns(object, name)) {
  790. keys.push(name);
  791. }
  792. }
  793. if (hasDontEnumBug) {
  794. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  795. var dontEnum = dontEnums[i];
  796. if (owns(object, dontEnum)) {
  797. keys.push(dontEnum);
  798. }
  799. }
  800. }
  801. return keys;
  802. };
  803. }
  804. if (!Date.now) {
  805. Date.now = function now() {
  806. return new Date().getTime();
  807. };
  808. }
  809. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  810. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  811. "\u2029\uFEFF";
  812. if (!String.prototype.trim || ws.trim()) {
  813. ws = "[" + ws + "]";
  814. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  815. trimEndRegexp = new RegExp(ws + ws + "*$");
  816. String.prototype.trim = function trim() {
  817. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  818. };
  819. }
  820. function toInteger(n) {
  821. n = +n;
  822. if (n !== n) { // isNaN
  823. n = 0;
  824. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  825. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  826. }
  827. return n;
  828. }
  829. function isPrimitive(input) {
  830. var type = typeof input;
  831. return (
  832. input === null ||
  833. type === "undefined" ||
  834. type === "boolean" ||
  835. type === "number" ||
  836. type === "string"
  837. );
  838. }
  839. function toPrimitive(input) {
  840. var val, valueOf, toString;
  841. if (isPrimitive(input)) {
  842. return input;
  843. }
  844. valueOf = input.valueOf;
  845. if (typeof valueOf === "function") {
  846. val = valueOf.call(input);
  847. if (isPrimitive(val)) {
  848. return val;
  849. }
  850. }
  851. toString = input.toString;
  852. if (typeof toString === "function") {
  853. val = toString.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. throw new TypeError();
  859. }
  860. var toObject = function (o) {
  861. if (o == null) { // this matches both null and undefined
  862. throw new TypeError("can't convert "+o+" to object");
  863. }
  864. return Object(o);
  865. };
  866. });
  867. define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  868. "use strict";
  869. require("./regexp");
  870. require("./es5-shim");
  871. });
  872. define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  873. "use strict";
  874. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  875. exports.getDocumentHead = function(doc) {
  876. if (!doc)
  877. doc = document;
  878. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  879. };
  880. exports.createElement = function(tag, ns) {
  881. return document.createElementNS ?
  882. document.createElementNS(ns || XHTML_NS, tag) :
  883. document.createElement(tag);
  884. };
  885. exports.hasCssClass = function(el, name) {
  886. var classes = (el.className + "").split(/\s+/g);
  887. return classes.indexOf(name) !== -1;
  888. };
  889. exports.addCssClass = function(el, name) {
  890. if (!exports.hasCssClass(el, name)) {
  891. el.className += " " + name;
  892. }
  893. };
  894. exports.removeCssClass = function(el, name) {
  895. var classes = el.className.split(/\s+/g);
  896. while (true) {
  897. var index = classes.indexOf(name);
  898. if (index == -1) {
  899. break;
  900. }
  901. classes.splice(index, 1);
  902. }
  903. el.className = classes.join(" ");
  904. };
  905. exports.toggleCssClass = function(el, name) {
  906. var classes = el.className.split(/\s+/g), add = true;
  907. while (true) {
  908. var index = classes.indexOf(name);
  909. if (index == -1) {
  910. break;
  911. }
  912. add = false;
  913. classes.splice(index, 1);
  914. }
  915. if (add)
  916. classes.push(name);
  917. el.className = classes.join(" ");
  918. return add;
  919. };
  920. exports.setCssClass = function(node, className, include) {
  921. if (include) {
  922. exports.addCssClass(node, className);
  923. } else {
  924. exports.removeCssClass(node, className);
  925. }
  926. };
  927. exports.hasCssString = function(id, doc) {
  928. var index = 0, sheets;
  929. doc = doc || document;
  930. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  931. while (index < sheets.length)
  932. if (sheets[index++].owningElement.id === id) return true;
  933. } else if ((sheets = doc.getElementsByTagName("style"))) {
  934. while (index < sheets.length)
  935. if (sheets[index++].id === id) return true;
  936. }
  937. return false;
  938. };
  939. exports.importCssString = function importCssString(cssText, id, doc) {
  940. doc = doc || document;
  941. if (id && exports.hasCssString(id, doc))
  942. return null;
  943. var style;
  944. if (id)
  945. cssText += "\n/*# sourceURL=ace/css/" + id + " */";
  946. if (doc.createStyleSheet) {
  947. style = doc.createStyleSheet();
  948. style.cssText = cssText;
  949. if (id)
  950. style.owningElement.id = id;
  951. } else {
  952. style = exports.createElement("style");
  953. style.appendChild(doc.createTextNode(cssText));
  954. if (id)
  955. style.id = id;
  956. exports.getDocumentHead(doc).appendChild(style);
  957. }
  958. };
  959. exports.importCssStylsheet = function(uri, doc) {
  960. if (doc.createStyleSheet) {
  961. doc.createStyleSheet(uri);
  962. } else {
  963. var link = exports.createElement('link');
  964. link.rel = 'stylesheet';
  965. link.href = uri;
  966. exports.getDocumentHead(doc).appendChild(link);
  967. }
  968. };
  969. exports.getInnerWidth = function(element) {
  970. return (
  971. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  972. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  973. element.clientWidth
  974. );
  975. };
  976. exports.getInnerHeight = function(element) {
  977. return (
  978. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  979. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  980. element.clientHeight
  981. );
  982. };
  983. exports.scrollbarWidth = function(document) {
  984. var inner = exports.createElement("ace_inner");
  985. inner.style.width = "100%";
  986. inner.style.minWidth = "0px";
  987. inner.style.height = "200px";
  988. inner.style.display = "block";
  989. var outer = exports.createElement("ace_outer");
  990. var style = outer.style;
  991. style.position = "absolute";
  992. style.left = "-10000px";
  993. style.overflow = "hidden";
  994. style.width = "200px";
  995. style.minWidth = "0px";
  996. style.height = "150px";
  997. style.display = "block";
  998. outer.appendChild(inner);
  999. var body = document.documentElement;
  1000. body.appendChild(outer);
  1001. var noScrollbar = inner.offsetWidth;
  1002. style.overflow = "scroll";
  1003. var withScrollbar = inner.offsetWidth;
  1004. if (noScrollbar == withScrollbar) {
  1005. withScrollbar = outer.clientWidth;
  1006. }
  1007. body.removeChild(outer);
  1008. return noScrollbar-withScrollbar;
  1009. };
  1010. if (typeof document == "undefined") {
  1011. exports.importCssString = function() {};
  1012. return;
  1013. }
  1014. if (window.pageYOffset !== undefined) {
  1015. exports.getPageScrollTop = function() {
  1016. return window.pageYOffset;
  1017. };
  1018. exports.getPageScrollLeft = function() {
  1019. return window.pageXOffset;
  1020. };
  1021. }
  1022. else {
  1023. exports.getPageScrollTop = function() {
  1024. return document.body.scrollTop;
  1025. };
  1026. exports.getPageScrollLeft = function() {
  1027. return document.body.scrollLeft;
  1028. };
  1029. }
  1030. if (window.getComputedStyle)
  1031. exports.computedStyle = function(element, style) {
  1032. if (style)
  1033. return (window.getComputedStyle(element, "") || {})[style] || "";
  1034. return window.getComputedStyle(element, "") || {};
  1035. };
  1036. else
  1037. exports.computedStyle = function(element, style) {
  1038. if (style)
  1039. return element.currentStyle[style];
  1040. return element.currentStyle;
  1041. };
  1042. exports.setInnerHtml = function(el, innerHtml) {
  1043. var element = el.cloneNode(false);//document.createElement("div");
  1044. element.innerHTML = innerHtml;
  1045. el.parentNode.replaceChild(element, el);
  1046. return element;
  1047. };
  1048. if ("textContent" in document.documentElement) {
  1049. exports.setInnerText = function(el, innerText) {
  1050. el.textContent = innerText;
  1051. };
  1052. exports.getInnerText = function(el) {
  1053. return el.textContent;
  1054. };
  1055. }
  1056. else {
  1057. exports.setInnerText = function(el, innerText) {
  1058. el.innerText = innerText;
  1059. };
  1060. exports.getInnerText = function(el) {
  1061. return el.innerText;
  1062. };
  1063. }
  1064. exports.getParentWindow = function(document) {
  1065. return document.defaultView || document.parentWindow;
  1066. };
  1067. });
  1068. define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1069. "use strict";
  1070. exports.inherits = function(ctor, superCtor) {
  1071. ctor.super_ = superCtor;
  1072. ctor.prototype = Object.create(superCtor.prototype, {
  1073. constructor: {
  1074. value: ctor,
  1075. enumerable: false,
  1076. writable: true,
  1077. configurable: true
  1078. }
  1079. });
  1080. };
  1081. exports.mixin = function(obj, mixin) {
  1082. for (var key in mixin) {
  1083. obj[key] = mixin[key];
  1084. }
  1085. return obj;
  1086. };
  1087. exports.implement = function(proto, mixin) {
  1088. exports.mixin(proto, mixin);
  1089. };
  1090. });
  1091. define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1092. "use strict";
  1093. require("./fixoldbrowsers");
  1094. var oop = require("./oop");
  1095. var Keys = (function() {
  1096. var ret = {
  1097. MODIFIER_KEYS: {
  1098. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1099. },
  1100. KEY_MODS: {
  1101. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1102. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1103. },
  1104. FUNCTION_KEYS : {
  1105. 8 : "Backspace",
  1106. 9 : "Tab",
  1107. 13 : "Return",
  1108. 19 : "Pause",
  1109. 27 : "Esc",
  1110. 32 : "Space",
  1111. 33 : "PageUp",
  1112. 34 : "PageDown",
  1113. 35 : "End",
  1114. 36 : "Home",
  1115. 37 : "Left",
  1116. 38 : "Up",
  1117. 39 : "Right",
  1118. 40 : "Down",
  1119. 44 : "Print",
  1120. 45 : "Insert",
  1121. 46 : "Delete",
  1122. 96 : "Numpad0",
  1123. 97 : "Numpad1",
  1124. 98 : "Numpad2",
  1125. 99 : "Numpad3",
  1126. 100: "Numpad4",
  1127. 101: "Numpad5",
  1128. 102: "Numpad6",
  1129. 103: "Numpad7",
  1130. 104: "Numpad8",
  1131. 105: "Numpad9",
  1132. '-13': "NumpadEnter",
  1133. 112: "F1",
  1134. 113: "F2",
  1135. 114: "F3",
  1136. 115: "F4",
  1137. 116: "F5",
  1138. 117: "F6",
  1139. 118: "F7",
  1140. 119: "F8",
  1141. 120: "F9",
  1142. 121: "F10",
  1143. 122: "F11",
  1144. 123: "F12",
  1145. 144: "Numlock",
  1146. 145: "Scrolllock"
  1147. },
  1148. PRINTABLE_KEYS: {
  1149. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1150. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1151. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1152. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1153. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1154. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1155. 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
  1156. 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*'
  1157. }
  1158. };
  1159. var name, i;
  1160. for (i in ret.FUNCTION_KEYS) {
  1161. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1162. ret[name] = parseInt(i, 10);
  1163. }
  1164. for (i in ret.PRINTABLE_KEYS) {
  1165. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1166. ret[name] = parseInt(i, 10);
  1167. }
  1168. oop.mixin(ret, ret.MODIFIER_KEYS);
  1169. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1170. oop.mixin(ret, ret.FUNCTION_KEYS);
  1171. ret.enter = ret["return"];
  1172. ret.escape = ret.esc;
  1173. ret.del = ret["delete"];
  1174. ret[173] = '-';
  1175. (function() {
  1176. var mods = ["cmd", "ctrl", "alt", "shift"];
  1177. for (var i = Math.pow(2, mods.length); i--;) {
  1178. ret.KEY_MODS[i] = mods.filter(function(x) {
  1179. return i & ret.KEY_MODS[x];
  1180. }).join("-") + "-";
  1181. }
  1182. })();
  1183. ret.KEY_MODS[0] = "";
  1184. ret.KEY_MODS[-1] = "input-";
  1185. return ret;
  1186. })();
  1187. oop.mixin(exports, Keys);
  1188. exports.keyCodeToString = function(keyCode) {
  1189. var keyString = Keys[keyCode];
  1190. if (typeof keyString != "string")
  1191. keyString = String.fromCharCode(keyCode);
  1192. return keyString.toLowerCase();
  1193. };
  1194. });
  1195. define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1196. "use strict";
  1197. exports.OS = {
  1198. LINUX: "LINUX",
  1199. MAC: "MAC",
  1200. WINDOWS: "WINDOWS"
  1201. };
  1202. exports.getOS = function() {
  1203. if (exports.isMac) {
  1204. return exports.OS.MAC;
  1205. } else if (exports.isLinux) {
  1206. return exports.OS.LINUX;
  1207. } else {
  1208. return exports.OS.WINDOWS;
  1209. }
  1210. };
  1211. if (typeof navigator != "object")
  1212. return;
  1213. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1214. var ua = navigator.userAgent;
  1215. exports.isWin = (os == "win");
  1216. exports.isMac = (os == "mac");
  1217. exports.isLinux = (os == "linux");
  1218. exports.isIE =
  1219. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1220. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1221. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1222. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1223. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1224. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv:(\d+)/)||[])[1], 10) < 4;
  1225. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1226. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1227. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1228. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1229. exports.isIPad = ua.indexOf("iPad") >= 0;
  1230. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1231. exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream;
  1232. if (exports.isIOS) exports.isMac = true;
  1233. });
  1234. define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1235. "use strict";
  1236. var keys = require("./keys");
  1237. var useragent = require("./useragent");
  1238. var pressedKeys = null;
  1239. var ts = 0;
  1240. exports.addListener = function(elem, type, callback) {
  1241. if (elem.addEventListener) {
  1242. return elem.addEventListener(type, callback, false);
  1243. }
  1244. if (elem.attachEvent) {
  1245. var wrapper = function() {
  1246. callback.call(elem, window.event);
  1247. };
  1248. callback._wrapper = wrapper;
  1249. elem.attachEvent("on" + type, wrapper);
  1250. }
  1251. };
  1252. exports.removeListener = function(elem, type, callback) {
  1253. if (elem.removeEventListener) {
  1254. return elem.removeEventListener(type, callback, false);
  1255. }
  1256. if (elem.detachEvent) {
  1257. elem.detachEvent("on" + type, callback._wrapper || callback);
  1258. }
  1259. };
  1260. exports.stopEvent = function(e) {
  1261. exports.stopPropagation(e);
  1262. exports.preventDefault(e);
  1263. return false;
  1264. };
  1265. exports.stopPropagation = function(e) {
  1266. if (e.stopPropagation)
  1267. e.stopPropagation();
  1268. else
  1269. e.cancelBubble = true;
  1270. };
  1271. exports.preventDefault = function(e) {
  1272. if (e.preventDefault)
  1273. e.preventDefault();
  1274. else
  1275. e.returnValue = false;
  1276. };
  1277. exports.getButton = function(e) {
  1278. if (e.type == "dblclick")
  1279. return 0;
  1280. if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
  1281. return 2;
  1282. if (e.preventDefault) {
  1283. return e.button;
  1284. }
  1285. else {
  1286. return {1:0, 2:2, 4:1}[e.button];
  1287. }
  1288. };
  1289. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1290. function onMouseUp(e) {
  1291. eventHandler && eventHandler(e);
  1292. releaseCaptureHandler && releaseCaptureHandler(e);
  1293. exports.removeListener(document, "mousemove", eventHandler, true);
  1294. exports.removeListener(document, "mouseup", onMouseUp, true);
  1295. exports.removeListener(document, "dragstart", onMouseUp, true);
  1296. }
  1297. exports.addListener(document, "mousemove", eventHandler, true);
  1298. exports.addListener(document, "mouseup", onMouseUp, true);
  1299. exports.addListener(document, "dragstart", onMouseUp, true);
  1300. return onMouseUp;
  1301. };
  1302. exports.addTouchMoveListener = function (el, callback) {
  1303. var startx, starty;
  1304. exports.addListener(el, "touchstart", function (e) {
  1305. var touches = e.touches;
  1306. var touchObj = touches[0];
  1307. startx = touchObj.clientX;
  1308. starty = touchObj.clientY;
  1309. });
  1310. exports.addListener(el, "touchmove", function (e) {
  1311. var touches = e.touches;
  1312. if (touches.length > 1) return;
  1313. var touchObj = touches[0];
  1314. e.wheelX = startx - touchObj.clientX;
  1315. e.wheelY = starty - touchObj.clientY;
  1316. startx = touchObj.clientX;
  1317. starty = touchObj.clientY;
  1318. callback(e);
  1319. });
  1320. };
  1321. exports.addMouseWheelListener = function(el, callback) {
  1322. if ("onmousewheel" in el) {
  1323. exports.addListener(el, "mousewheel", function(e) {
  1324. var factor = 8;
  1325. if (e.wheelDeltaX !== undefined) {
  1326. e.wheelX = -e.wheelDeltaX / factor;
  1327. e.wheelY = -e.wheelDeltaY / factor;
  1328. } else {
  1329. e.wheelX = 0;
  1330. e.wheelY = -e.wheelDelta / factor;
  1331. }
  1332. callback(e);
  1333. });
  1334. } else if ("onwheel" in el) {
  1335. exports.addListener(el, "wheel", function(e) {
  1336. var factor = 0.35;
  1337. switch (e.deltaMode) {
  1338. case e.DOM_DELTA_PIXEL:
  1339. e.wheelX = e.deltaX * factor || 0;
  1340. e.wheelY = e.deltaY * factor || 0;
  1341. break;
  1342. case e.DOM_DELTA_LINE:
  1343. case e.DOM_DELTA_PAGE:
  1344. e.wheelX = (e.deltaX || 0) * 5;
  1345. e.wheelY = (e.deltaY || 0) * 5;
  1346. break;
  1347. }
  1348. callback(e);
  1349. });
  1350. } else {
  1351. exports.addListener(el, "DOMMouseScroll", function(e) {
  1352. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1353. e.wheelX = (e.detail || 0) * 5;
  1354. e.wheelY = 0;
  1355. } else {
  1356. e.wheelX = 0;
  1357. e.wheelY = (e.detail || 0) * 5;
  1358. }
  1359. callback(e);
  1360. });
  1361. }
  1362. };
  1363. exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) {
  1364. var clicks = 0;
  1365. var startX, startY, timer;
  1366. var eventNames = {
  1367. 2: "dblclick",
  1368. 3: "tripleclick",
  1369. 4: "quadclick"
  1370. };
  1371. function onMousedown(e) {
  1372. if (exports.getButton(e) !== 0) {
  1373. clicks = 0;
  1374. } else if (e.detail > 1) {
  1375. clicks++;
  1376. if (clicks > 4)
  1377. clicks = 1;
  1378. } else {
  1379. clicks = 1;
  1380. }
  1381. if (useragent.isIE) {
  1382. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1383. if (!timer || isNewClick)
  1384. clicks = 1;
  1385. if (timer)
  1386. clearTimeout(timer);
  1387. timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600);
  1388. if (clicks == 1) {
  1389. startX = e.clientX;
  1390. startY = e.clientY;
  1391. }
  1392. }
  1393. e._clicks = clicks;
  1394. eventHandler[callbackName]("mousedown", e);
  1395. if (clicks > 4)
  1396. clicks = 0;
  1397. else if (clicks > 1)
  1398. return eventHandler[callbackName](eventNames[clicks], e);
  1399. }
  1400. function onDblclick(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. if (!Array.isArray(elements))
  1409. elements = [elements];
  1410. elements.forEach(function(el) {
  1411. exports.addListener(el, "mousedown", onMousedown);
  1412. if (useragent.isOldIE)
  1413. exports.addListener(el, "dblclick", onDblclick);
  1414. });
  1415. };
  1416. var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
  1417. ? function(e) {
  1418. return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1419. }
  1420. : function(e) {
  1421. return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1422. };
  1423. exports.getModifierString = function(e) {
  1424. return keys.KEY_MODS[getModifierHash(e)];
  1425. };
  1426. function normalizeCommandKeys(callback, e, keyCode) {
  1427. var hashId = getModifierHash(e);
  1428. if (!useragent.isMac && pressedKeys) {
  1429. if (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win")))
  1430. hashId |= 8;
  1431. if (pressedKeys.altGr) {
  1432. if ((3 & hashId) != 3)
  1433. pressedKeys.altGr = 0;
  1434. else
  1435. return;
  1436. }
  1437. if (keyCode === 18 || keyCode === 17) {
  1438. var location = "location" in e ? e.location : e.keyLocation;
  1439. if (keyCode === 17 && location === 1) {
  1440. if (pressedKeys[keyCode] == 1)
  1441. ts = e.timeStamp;
  1442. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1443. var dt = e.timeStamp - ts;
  1444. if (dt < 50)
  1445. pressedKeys.altGr = true;
  1446. }
  1447. }
  1448. }
  1449. if (keyCode in keys.MODIFIER_KEYS) {
  1450. keyCode = -1;
  1451. }
  1452. if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) {
  1453. keyCode = -1;
  1454. }
  1455. if (!hashId && keyCode === 13) {
  1456. var location = "location" in e ? e.location : e.keyLocation;
  1457. if (location === 3) {
  1458. callback(e, hashId, -keyCode);
  1459. if (e.defaultPrevented)
  1460. return;
  1461. }
  1462. }
  1463. if (useragent.isChromeOS && hashId & 8) {
  1464. callback(e, hashId, keyCode);
  1465. if (e.defaultPrevented)
  1466. return;
  1467. else
  1468. hashId &= ~8;
  1469. }
  1470. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1471. return false;
  1472. }
  1473. return callback(e, hashId, keyCode);
  1474. }
  1475. exports.addCommandKeyListener = function(el, callback) {
  1476. var addListener = exports.addListener;
  1477. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1478. var lastKeyDownKeyCode = null;
  1479. addListener(el, "keydown", function(e) {
  1480. lastKeyDownKeyCode = e.keyCode;
  1481. });
  1482. addListener(el, "keypress", function(e) {
  1483. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1484. });
  1485. } else {
  1486. var lastDefaultPrevented = null;
  1487. addListener(el, "keydown", function(e) {
  1488. pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
  1489. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1490. lastDefaultPrevented = e.defaultPrevented;
  1491. return result;
  1492. });
  1493. addListener(el, "keypress", function(e) {
  1494. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1495. exports.stopEvent(e);
  1496. lastDefaultPrevented = null;
  1497. }
  1498. });
  1499. addListener(el, "keyup", function(e) {
  1500. pressedKeys[e.keyCode] = null;
  1501. });
  1502. if (!pressedKeys) {
  1503. resetPressedKeys();
  1504. addListener(window, "focus", resetPressedKeys);
  1505. }
  1506. }
  1507. };
  1508. function resetPressedKeys() {
  1509. pressedKeys = Object.create(null);
  1510. }
  1511. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1512. var postMessageId = 1;
  1513. exports.nextTick = function(callback, win) {
  1514. win = win || window;
  1515. var messageName = "zero-timeout-message-" + postMessageId;
  1516. exports.addListener(win, "message", function listener(e) {
  1517. if (e.data == messageName) {
  1518. exports.stopPropagation(e);
  1519. exports.removeListener(win, "message", listener);
  1520. callback();
  1521. }
  1522. });
  1523. win.postMessage(messageName, "*");
  1524. };
  1525. }
  1526. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1527. || window.mozRequestAnimationFrame
  1528. || window.webkitRequestAnimationFrame
  1529. || window.msRequestAnimationFrame
  1530. || window.oRequestAnimationFrame);
  1531. if (exports.nextFrame)
  1532. exports.nextFrame = exports.nextFrame.bind(window);
  1533. else
  1534. exports.nextFrame = function(callback) {
  1535. setTimeout(callback, 17);
  1536. };
  1537. });
  1538. define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1539. "use strict";
  1540. exports.last = function(a) {
  1541. return a[a.length - 1];
  1542. };
  1543. exports.stringReverse = function(string) {
  1544. return string.split("").reverse().join("");
  1545. };
  1546. exports.stringRepeat = function (string, count) {
  1547. var result = '';
  1548. while (count > 0) {
  1549. if (count & 1)
  1550. result += string;
  1551. if (count >>= 1)
  1552. string += string;
  1553. }
  1554. return result;
  1555. };
  1556. var trimBeginRegexp = /^\s\s*/;
  1557. var trimEndRegexp = /\s\s*$/;
  1558. exports.stringTrimLeft = function (string) {
  1559. return string.replace(trimBeginRegexp, '');
  1560. };
  1561. exports.stringTrimRight = function (string) {
  1562. return string.replace(trimEndRegexp, '');
  1563. };
  1564. exports.copyObject = function(obj) {
  1565. var copy = {};
  1566. for (var key in obj) {
  1567. copy[key] = obj[key];
  1568. }
  1569. return copy;
  1570. };
  1571. exports.copyArray = function(array){
  1572. var copy = [];
  1573. for (var i=0, l=array.length; i<l; i++) {
  1574. if (array[i] && typeof array[i] == "object")
  1575. copy[i] = this.copyObject(array[i]);
  1576. else
  1577. copy[i] = array[i];
  1578. }
  1579. return copy;
  1580. };
  1581. exports.deepCopy = function deepCopy(obj) {
  1582. if (typeof obj !== "object" || !obj)
  1583. return obj;
  1584. var copy;
  1585. if (Array.isArray(obj)) {
  1586. copy = [];
  1587. for (var key = 0; key < obj.length; key++) {
  1588. copy[key] = deepCopy(obj[key]);
  1589. }
  1590. return copy;
  1591. }
  1592. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1593. return obj;
  1594. copy = {};
  1595. for (var key in obj)
  1596. copy[key] = deepCopy(obj[key]);
  1597. return copy;
  1598. };
  1599. exports.arrayToMap = function(arr) {
  1600. var map = {};
  1601. for (var i=0; i<arr.length; i++) {
  1602. map[arr[i]] = 1;
  1603. }
  1604. return map;
  1605. };
  1606. exports.createMap = function(props) {
  1607. var map = Object.create(null);
  1608. for (var i in props) {
  1609. map[i] = props[i];
  1610. }
  1611. return map;
  1612. };
  1613. exports.arrayRemove = function(array, value) {
  1614. for (var i = 0; i <= array.length; i++) {
  1615. if (value === array[i]) {
  1616. array.splice(i, 1);
  1617. }
  1618. }
  1619. };
  1620. exports.escapeRegExp = function(str) {
  1621. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1622. };
  1623. exports.escapeHTML = function(str) {
  1624. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1625. };
  1626. exports.getMatchOffsets = function(string, regExp) {
  1627. var matches = [];
  1628. string.replace(regExp, function(str) {
  1629. matches.push({
  1630. offset: arguments[arguments.length-2],
  1631. length: str.length
  1632. });
  1633. });
  1634. return matches;
  1635. };
  1636. exports.deferredCall = function(fcn) {
  1637. var timer = null;
  1638. var callback = function() {
  1639. timer = null;
  1640. fcn();
  1641. };
  1642. var deferred = function(timeout) {
  1643. deferred.cancel();
  1644. timer = setTimeout(callback, timeout || 0);
  1645. return deferred;
  1646. };
  1647. deferred.schedule = deferred;
  1648. deferred.call = function() {
  1649. this.cancel();
  1650. fcn();
  1651. return deferred;
  1652. };
  1653. deferred.cancel = function() {
  1654. clearTimeout(timer);
  1655. timer = null;
  1656. return deferred;
  1657. };
  1658. deferred.isPending = function() {
  1659. return timer;
  1660. };
  1661. return deferred;
  1662. };
  1663. exports.delayedCall = function(fcn, defaultTimeout) {
  1664. var timer = null;
  1665. var callback = function() {
  1666. timer = null;
  1667. fcn();
  1668. };
  1669. var _self = function(timeout) {
  1670. if (timer == null)
  1671. timer = setTimeout(callback, timeout || defaultTimeout);
  1672. };
  1673. _self.delay = function(timeout) {
  1674. timer && clearTimeout(timer);
  1675. timer = setTimeout(callback, timeout || defaultTimeout);
  1676. };
  1677. _self.schedule = _self;
  1678. _self.call = function() {
  1679. this.cancel();
  1680. fcn();
  1681. };
  1682. _self.cancel = function() {
  1683. timer && clearTimeout(timer);
  1684. timer = null;
  1685. };
  1686. _self.isPending = function() {
  1687. return timer;
  1688. };
  1689. return _self;
  1690. };
  1691. });
  1692. define("ace/keyboard/textinput_ios",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/lib/keys"], function(require, exports, module) {
  1693. "use strict";
  1694. var event = require("../lib/event");
  1695. var useragent = require("../lib/useragent");
  1696. var dom = require("../lib/dom");
  1697. var lang = require("../lib/lang");
  1698. var KEYS = require("../lib/keys");
  1699. var MODS = KEYS.KEY_MODS;
  1700. var BROKEN_SETDATA = useragent.isChrome < 18;
  1701. var USE_IE_MIME_TYPE = useragent.isIE;
  1702. var TextInput = function(parentNode, host) {
  1703. var self = this;
  1704. var text = dom.createElement("textarea");
  1705. text.className = useragent.isIOS ? "ace_text-input ace_text-input-ios" : "ace_text-input";
  1706. if (useragent.isTouchPad)
  1707. text.setAttribute("x-palm-disable-auto-cap", true);
  1708. text.setAttribute("wrap", "off");
  1709. text.setAttribute("autocorrect", "off");
  1710. text.setAttribute("autocapitalize", "off");
  1711. text.setAttribute("spellcheck", false);
  1712. text.style.opacity = "0";
  1713. parentNode.insertBefore(text, parentNode.firstChild);
  1714. var PLACEHOLDER = "\n aaaa a\n";
  1715. var copied = false;
  1716. var cut = false;
  1717. var pasted = false;
  1718. var inComposition = false;
  1719. var tempStyle = '';
  1720. var isSelectionEmpty = true;
  1721. try { var isFocused = document.activeElement === text; } catch(e) {}
  1722. event.addListener(text, "blur", function(e) {
  1723. host.onBlur(e);
  1724. isFocused = false;
  1725. });
  1726. event.addListener(text, "focus", function(e) {
  1727. isFocused = true;
  1728. host.onFocus(e);
  1729. resetSelection();
  1730. });
  1731. this.focus = function() {
  1732. if (tempStyle) return text.focus();
  1733. text.style.position = "fixed";
  1734. text.focus();
  1735. };
  1736. this.blur = function() {
  1737. text.blur();
  1738. };
  1739. this.isFocused = function() {
  1740. return isFocused;
  1741. };
  1742. var syncSelection = lang.delayedCall(function() {
  1743. isFocused && resetSelection(isSelectionEmpty);
  1744. });
  1745. var syncValue = lang.delayedCall(function() {
  1746. if (!inComposition) {
  1747. text.value = PLACEHOLDER;
  1748. isFocused && resetSelection();
  1749. }
  1750. });
  1751. function resetSelection(isEmpty) {
  1752. if (inComposition)
  1753. return;
  1754. inComposition = true;
  1755. if (inputHandler) {
  1756. selectionStart = 0;
  1757. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1758. } else {
  1759. var selectionStart = 4;
  1760. var selectionEnd = 5;
  1761. }
  1762. try {
  1763. text.setSelectionRange(selectionStart, selectionEnd);
  1764. } catch(e) {}
  1765. inComposition = false;
  1766. }
  1767. function resetValue() {
  1768. if (inComposition)
  1769. return;
  1770. text.value = PLACEHOLDER;
  1771. if (useragent.isWebKit)
  1772. syncValue.schedule();
  1773. }
  1774. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1775. if (host.selection.isEmpty() != isSelectionEmpty) {
  1776. isSelectionEmpty = !isSelectionEmpty;
  1777. syncSelection.schedule();
  1778. }
  1779. });
  1780. resetValue();
  1781. if (isFocused)
  1782. host.onFocus();
  1783. var isAllSelected = function(text) {
  1784. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1785. };
  1786. var onSelect = function(e) {
  1787. if (isAllSelected(text)) {
  1788. host.selectAll();
  1789. resetSelection();
  1790. } else if (inputHandler) {
  1791. resetSelection(host.selection.isEmpty());
  1792. }
  1793. };
  1794. var inputHandler = null;
  1795. this.setInputHandler = function(cb) {inputHandler = cb;};
  1796. this.getInputHandler = function() {return inputHandler;};
  1797. var afterContextMenu = false;
  1798. var sendText = function(data) {
  1799. if (text.selectionStart === 4 && text.selectionEnd === 5) {
  1800. return;
  1801. }
  1802. if (inputHandler) {
  1803. data = inputHandler(data);
  1804. inputHandler = null;
  1805. }
  1806. if (pasted) {
  1807. resetSelection();
  1808. if (data)
  1809. host.onPaste(data);
  1810. pasted = false;
  1811. } else if (data == PLACEHOLDER.substr(0) && text.selectionStart === 4) {
  1812. if (afterContextMenu)
  1813. host.execCommand("del", {source: "ace"});
  1814. else // some versions of android do not fire keydown when pressing backspace
  1815. host.execCommand("backspace", {source: "ace"});
  1816. } else if (!copied) {
  1817. if (data.substring(0, 9) == PLACEHOLDER && data.length > PLACEHOLDER.length)
  1818. data = data.substr(9);
  1819. else if (data.substr(0, 4) == PLACEHOLDER.substr(0, 4))
  1820. data = data.substr(4, data.length - PLACEHOLDER.length + 1);
  1821. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1822. data = data.slice(0, -1);
  1823. if (data == PLACEHOLDER.charAt(0)) {
  1824. } else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1825. data = data.slice(0, -1);
  1826. if (data)
  1827. host.onTextInput(data);
  1828. }
  1829. if (copied) {
  1830. copied = false;
  1831. }
  1832. if (afterContextMenu)
  1833. afterContextMenu = false;
  1834. };
  1835. var onInput = function(e) {
  1836. if (inComposition)
  1837. return;
  1838. var data = text.value;
  1839. sendText(data);
  1840. resetValue();
  1841. };
  1842. var handleClipboardData = function(e, data, forceIEMime) {
  1843. var clipboardData = e.clipboardData || window.clipboardData;
  1844. if (!clipboardData || BROKEN_SETDATA)
  1845. return;
  1846. var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
  1847. try {
  1848. if (data) {
  1849. return clipboardData.setData(mime, data) !== false;
  1850. } else {
  1851. return clipboardData.getData(mime);
  1852. }
  1853. } catch(e) {
  1854. if (!forceIEMime)
  1855. return handleClipboardData(e, data, true);
  1856. }
  1857. };
  1858. var doCopy = function(e, isCut) {
  1859. var data = host.getCopyText();
  1860. if (!data)
  1861. return event.preventDefault(e);
  1862. if (handleClipboardData(e, data)) {
  1863. if (useragent.isIOS) {
  1864. cut = isCut;
  1865. text.value = "\n aa" + data + "a a\n";
  1866. text.setSelectionRange(4, 4 + data.length);
  1867. copied = {
  1868. value: data
  1869. };
  1870. }
  1871. isCut ? host.onCut() : host.onCopy();
  1872. if (!useragent.isIOS) event.preventDefault(e);
  1873. } else {
  1874. copied = true;
  1875. text.value = data;
  1876. text.select();
  1877. setTimeout(function(){
  1878. copied = false;
  1879. resetValue();
  1880. resetSelection();
  1881. isCut ? host.onCut() : host.onCopy();
  1882. });
  1883. }
  1884. };
  1885. var onCut = function(e) {
  1886. doCopy(e, true);
  1887. };
  1888. var onCopy = function(e) {
  1889. doCopy(e, false);
  1890. };
  1891. var onPaste = function(e) {
  1892. var data = handleClipboardData(e);
  1893. if (typeof data == "string") {
  1894. if (data)
  1895. host.onPaste(data, e);
  1896. if (useragent.isIE)
  1897. setTimeout(resetSelection);
  1898. event.preventDefault(e);
  1899. }
  1900. else {
  1901. text.value = "";
  1902. pasted = true;
  1903. }
  1904. };
  1905. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1906. event.addListener(text, "select", onSelect);
  1907. event.addListener(text, "input", onInput);
  1908. event.addListener(text, "cut", onCut);
  1909. event.addListener(text, "copy", onCopy);
  1910. event.addListener(text, "paste", onPaste);
  1911. var onCompositionStart = function(e) {
  1912. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1913. return;
  1914. inComposition = {};
  1915. inComposition.canUndo = host.session.$undoManager;
  1916. host.onCompositionStart();
  1917. setTimeout(onCompositionUpdate, 0);
  1918. host.on("mousedown", onCompositionEnd);
  1919. if (inComposition.canUndo && !host.selection.isEmpty()) {
  1920. host.insert("");
  1921. host.session.markUndoGroup();
  1922. host.selection.clearSelection();
  1923. }
  1924. host.session.markUndoGroup();
  1925. };
  1926. var onCompositionUpdate = function() {
  1927. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1928. return;
  1929. var val = text.value.replace(/\x01/g, "");
  1930. if (inComposition.lastValue === val) return;
  1931. host.onCompositionUpdate(val);
  1932. if (inComposition.lastValue)
  1933. host.undo();
  1934. if (inComposition.canUndo)
  1935. inComposition.lastValue = val;
  1936. if (inComposition.lastValue) {
  1937. var r = host.selection.getRange();
  1938. host.insert(inComposition.lastValue);
  1939. host.session.markUndoGroup();
  1940. inComposition.range = host.selection.getRange();
  1941. host.selection.setRange(r);
  1942. host.selection.clearSelection();
  1943. }
  1944. };
  1945. var onCompositionEnd = function(e) {
  1946. if (!host.onCompositionEnd || host.$readOnly) return;
  1947. var c = inComposition;
  1948. inComposition = false;
  1949. var timer = setTimeout(function() {
  1950. timer = null;
  1951. var str = text.value.replace(/\x01/g, "");
  1952. if (inComposition)
  1953. return;
  1954. else if (str == c.lastValue)
  1955. resetValue();
  1956. else if (!c.lastValue && str) {
  1957. resetValue();
  1958. sendText(str);
  1959. }
  1960. });
  1961. inputHandler = function compositionInputHandler(str) {
  1962. if (timer)
  1963. clearTimeout(timer);
  1964. str = str.replace(/\x01/g, "");
  1965. if (str == c.lastValue)
  1966. return "";
  1967. if (c.lastValue && timer)
  1968. host.undo();
  1969. return str;
  1970. };
  1971. host.onCompositionEnd();
  1972. host.removeListener("mousedown", onCompositionEnd);
  1973. if (e.type == "compositionend" && c.range) {
  1974. host.selection.setRange(c.range);
  1975. }
  1976. var needsOnInput =
  1977. (!!useragent.isChrome && useragent.isChrome >= 53) ||
  1978. (!!useragent.isWebKit && useragent.isWebKit >= 603);
  1979. if (needsOnInput) {
  1980. onInput();
  1981. }
  1982. };
  1983. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  1984. event.addListener(text, "compositionstart", onCompositionStart);
  1985. if (useragent.isGecko) {
  1986. event.addListener(text, "text", function(){syncComposition.schedule();});
  1987. } else {
  1988. event.addListener(text, "keyup", function(){syncComposition.schedule();});
  1989. event.addListener(text, "keydown", function(){syncComposition.schedule();});
  1990. }
  1991. event.addListener(text, "compositionend", onCompositionEnd);
  1992. this.getElement = function() {
  1993. return text;
  1994. };
  1995. this.setReadOnly = function(readOnly) {
  1996. text.readOnly = readOnly;
  1997. };
  1998. this.onContextMenu = function(e) {
  1999. afterContextMenu = true;
  2000. resetSelection(host.selection.isEmpty());
  2001. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2002. this.moveToMouse(e, true);
  2003. };
  2004. this.moveToMouse = function(e, bringToFront) {
  2005. if (!tempStyle)
  2006. tempStyle = text.style.cssText;
  2007. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2008. + "height:" + text.style.height + ";"
  2009. + (useragent.isIE ? "opacity:0.1;" : "");
  2010. var rect = host.container.getBoundingClientRect();
  2011. var style = dom.computedStyle(host.container);
  2012. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2013. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2014. var maxTop = rect.bottom - top - text.clientHeight -2;
  2015. var move = function(e) {
  2016. text.style.left = e.clientX - left - 2 + "px";
  2017. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2018. };
  2019. move(e);
  2020. if (e.type != "mousedown")
  2021. return;
  2022. if (host.renderer.$keepTextAreaAtCursor)
  2023. host.renderer.$keepTextAreaAtCursor = null;
  2024. clearTimeout(closeTimeout);
  2025. if (useragent.isWin)
  2026. event.capture(host.container, move, onContextMenuClose);
  2027. };
  2028. this.onContextMenuClose = onContextMenuClose;
  2029. var closeTimeout;
  2030. function onContextMenuClose() {
  2031. clearTimeout(closeTimeout);
  2032. closeTimeout = setTimeout(function () {
  2033. if (tempStyle) {
  2034. text.style.cssText = tempStyle;
  2035. tempStyle = '';
  2036. }
  2037. if (host.renderer.$keepTextAreaAtCursor == null) {
  2038. host.renderer.$keepTextAreaAtCursor = true;
  2039. host.renderer.$moveTextAreaToCursor();
  2040. }
  2041. }, 0);
  2042. }
  2043. var onContextMenu = function(e) {
  2044. host.textInput.onContextMenu(e);
  2045. onContextMenuClose();
  2046. };
  2047. event.addListener(text, "mouseup", onContextMenu);
  2048. event.addListener(text, "mousedown", function(e) {
  2049. e.preventDefault();
  2050. onContextMenuClose();
  2051. });
  2052. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2053. event.addListener(text, "contextmenu", onContextMenu);
  2054. if (useragent.isIOS) {
  2055. var typingResetTimeout = null;
  2056. var typing = false;
  2057. parentNode.addEventListener("keydown", function (e) {
  2058. if (typingResetTimeout) clearTimeout(typingResetTimeout);
  2059. typing = true;
  2060. });
  2061. parentNode.addEventListener("keyup", function (e) {
  2062. typingResetTimeout = setTimeout(function () {
  2063. typing = false;
  2064. }, 100);
  2065. });
  2066. var detectArrowKeys = function(e) {
  2067. if (document.activeElement !== text) return;
  2068. if (typing) return;
  2069. if (cut) {
  2070. return setTimeout(function () {
  2071. cut = false;
  2072. }, 100);
  2073. }
  2074. var selectionStart = text.selectionStart;
  2075. var selectionEnd = text.selectionEnd;
  2076. text.setSelectionRange(4, 5);
  2077. if (selectionStart == selectionEnd) {
  2078. switch (selectionStart) {
  2079. case 0: host.onCommandKey(null, 0, KEYS.up); break;
  2080. case 1: host.onCommandKey(null, 0, KEYS.home); break;
  2081. case 2: host.onCommandKey(null, MODS.option, KEYS.left); break;
  2082. case 4: host.onCommandKey(null, 0, KEYS.left); break;
  2083. case 5: host.onCommandKey(null, 0, KEYS.right); break;
  2084. case 7: host.onCommandKey(null, MODS.option, KEYS.right); break;
  2085. case 8: host.onCommandKey(null, 0, KEYS.end); break;
  2086. case 9: host.onCommandKey(null, 0, KEYS.down); break;
  2087. }
  2088. } else {
  2089. switch (selectionEnd) {
  2090. case 6: host.onCommandKey(null, MODS.shift, KEYS.right); break;
  2091. case 7: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.right); break;
  2092. case 8: host.onCommandKey(null, MODS.shift, KEYS.end); break;
  2093. case 9: host.onCommandKey(null, MODS.shift, KEYS.down); break;
  2094. }
  2095. switch (selectionStart) {
  2096. case 0: host.onCommandKey(null, MODS.shift, KEYS.up); break;
  2097. case 1: host.onCommandKey(null, MODS.shift, KEYS.home); break;
  2098. case 2: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.left); break;
  2099. case 3: host.onCommandKey(null, MODS.shift, KEYS.left); break;
  2100. }
  2101. }
  2102. };
  2103. document.addEventListener("selectionchange", detectArrowKeys);
  2104. host.on("destroy", function() {
  2105. document.removeEventListener("selectionchange", detectArrowKeys);
  2106. });
  2107. }
  2108. };
  2109. exports.TextInput = TextInput;
  2110. });
  2111. define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/keyboard/textinput_ios"], function(require, exports, module) {
  2112. "use strict";
  2113. var event = require("../lib/event");
  2114. var useragent = require("../lib/useragent");
  2115. var dom = require("../lib/dom");
  2116. var lang = require("../lib/lang");
  2117. var BROKEN_SETDATA = useragent.isChrome < 18;
  2118. var USE_IE_MIME_TYPE = useragent.isIE;
  2119. var TextInputIOS = require("./textinput_ios").TextInput;
  2120. var TextInput = function(parentNode, host) {
  2121. if (useragent.isIOS)
  2122. return TextInputIOS.call(this, parentNode, host);
  2123. var text = dom.createElement("textarea");
  2124. text.className = "ace_text-input";
  2125. text.setAttribute("wrap", "off");
  2126. text.setAttribute("autocorrect", "off");
  2127. text.setAttribute("autocapitalize", "off");
  2128. text.setAttribute("spellcheck", false);
  2129. text.style.opacity = "0";
  2130. parentNode.insertBefore(text, parentNode.firstChild);
  2131. var PLACEHOLDER = "\u2028\u2028";
  2132. var copied = false;
  2133. var pasted = false;
  2134. var inComposition = false;
  2135. var tempStyle = '';
  2136. var isSelectionEmpty = true;
  2137. try { var isFocused = document.activeElement === text; } catch(e) {}
  2138. event.addListener(text, "blur", function(e) {
  2139. host.onBlur(e);
  2140. isFocused = false;
  2141. });
  2142. event.addListener(text, "focus", function(e) {
  2143. isFocused = true;
  2144. host.onFocus(e);
  2145. resetSelection();
  2146. });
  2147. this.focus = function() {
  2148. if (tempStyle) return text.focus();
  2149. var top = text.style.top;
  2150. text.style.position = "fixed";
  2151. text.style.top = "0px";
  2152. text.focus();
  2153. setTimeout(function() {
  2154. text.style.position = "";
  2155. if (text.style.top == "0px")
  2156. text.style.top = top;
  2157. }, 0);
  2158. };
  2159. this.blur = function() {
  2160. text.blur();
  2161. };
  2162. this.isFocused = function() {
  2163. return isFocused;
  2164. };
  2165. var syncSelection = lang.delayedCall(function() {
  2166. isFocused && resetSelection(isSelectionEmpty);
  2167. });
  2168. var syncValue = lang.delayedCall(function() {
  2169. if (!inComposition) {
  2170. text.value = PLACEHOLDER;
  2171. isFocused && resetSelection();
  2172. }
  2173. });
  2174. function resetSelection(isEmpty) {
  2175. if (inComposition)
  2176. return;
  2177. inComposition = true;
  2178. if (inputHandler) {
  2179. var selectionStart = 0;
  2180. var selectionEnd = isEmpty ? 0 : text.value.length - 1;
  2181. } else {
  2182. var selectionStart = isEmpty ? 2 : 1;
  2183. var selectionEnd = 2;
  2184. }
  2185. try {
  2186. text.setSelectionRange(selectionStart, selectionEnd);
  2187. } catch(e){}
  2188. inComposition = false;
  2189. }
  2190. function resetValue() {
  2191. if (inComposition)
  2192. return;
  2193. text.value = PLACEHOLDER;
  2194. if (useragent.isWebKit)
  2195. syncValue.schedule();
  2196. }
  2197. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  2198. if (host.selection.isEmpty() != isSelectionEmpty) {
  2199. isSelectionEmpty = !isSelectionEmpty;
  2200. syncSelection.schedule();
  2201. }
  2202. });
  2203. resetValue();
  2204. if (isFocused)
  2205. host.onFocus();
  2206. var isAllSelected = function(text) {
  2207. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  2208. };
  2209. var onSelect = function(e) {
  2210. if (copied) {
  2211. copied = false;
  2212. } else if (isAllSelected(text)) {
  2213. host.selectAll();
  2214. resetSelection();
  2215. } else if (inputHandler) {
  2216. resetSelection(host.selection.isEmpty());
  2217. }
  2218. };
  2219. var inputHandler = null;
  2220. this.setInputHandler = function(cb) {inputHandler = cb;};
  2221. this.getInputHandler = function() {return inputHandler;};
  2222. var afterContextMenu = false;
  2223. var sendText = function(data) {
  2224. if (inputHandler) {
  2225. data = inputHandler(data);
  2226. inputHandler = null;
  2227. }
  2228. if (pasted) {
  2229. resetSelection();
  2230. if (data)
  2231. host.onPaste(data);
  2232. pasted = false;
  2233. } else if (data == PLACEHOLDER.charAt(0)) {
  2234. if (afterContextMenu)
  2235. host.execCommand("del", {source: "ace"});
  2236. else // some versions of android do not fire keydown when pressing backspace
  2237. host.execCommand("backspace", {source: "ace"});
  2238. } else {
  2239. if (data.substring(0, 2) == PLACEHOLDER)
  2240. data = data.substr(2);
  2241. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  2242. data = data.substr(1);
  2243. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  2244. data = data.slice(0, -1);
  2245. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  2246. data = data.slice(0, -1);
  2247. if (data)
  2248. host.onTextInput(data);
  2249. }
  2250. if (afterContextMenu)
  2251. afterContextMenu = false;
  2252. };
  2253. var onInput = function(e) {
  2254. if (inComposition)
  2255. return;
  2256. var data = text.value;
  2257. sendText(data);
  2258. resetValue();
  2259. };
  2260. var handleClipboardData = function(e, data, forceIEMime) {
  2261. var clipboardData = e.clipboardData || window.clipboardData;
  2262. if (!clipboardData || BROKEN_SETDATA)
  2263. return;
  2264. var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
  2265. try {
  2266. if (data) {
  2267. return clipboardData.setData(mime, data) !== false;
  2268. } else {
  2269. return clipboardData.getData(mime);
  2270. }
  2271. } catch(e) {
  2272. if (!forceIEMime)
  2273. return handleClipboardData(e, data, true);
  2274. }
  2275. };
  2276. var doCopy = function(e, isCut) {
  2277. var data = host.getCopyText();
  2278. if (!data)
  2279. return event.preventDefault(e);
  2280. if (handleClipboardData(e, data)) {
  2281. isCut ? host.onCut() : host.onCopy();
  2282. event.preventDefault(e);
  2283. } else {
  2284. copied = true;
  2285. text.value = data;
  2286. text.select();
  2287. setTimeout(function(){
  2288. copied = false;
  2289. resetValue();
  2290. resetSelection();
  2291. isCut ? host.onCut() : host.onCopy();
  2292. });
  2293. }
  2294. };
  2295. var onCut = function(e) {
  2296. doCopy(e, true);
  2297. };
  2298. var onCopy = function(e) {
  2299. doCopy(e, false);
  2300. };
  2301. var onPaste = function(e) {
  2302. var data = handleClipboardData(e);
  2303. if (typeof data == "string") {
  2304. if (data)
  2305. host.onPaste(data, e);
  2306. if (useragent.isIE)
  2307. setTimeout(resetSelection);
  2308. event.preventDefault(e);
  2309. }
  2310. else {
  2311. text.value = "";
  2312. pasted = true;
  2313. }
  2314. };
  2315. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  2316. event.addListener(text, "select", onSelect);
  2317. event.addListener(text, "input", onInput);
  2318. event.addListener(text, "cut", onCut);
  2319. event.addListener(text, "copy", onCopy);
  2320. event.addListener(text, "paste", onPaste);
  2321. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) {
  2322. event.addListener(parentNode, "keydown", function(e) {
  2323. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  2324. return;
  2325. switch (e.keyCode) {
  2326. case 67:
  2327. onCopy(e);
  2328. break;
  2329. case 86:
  2330. onPaste(e);
  2331. break;
  2332. case 88:
  2333. onCut(e);
  2334. break;
  2335. }
  2336. });
  2337. }
  2338. var onCompositionStart = function(e) {
  2339. if (inComposition || !host.onCompositionStart || host.$readOnly)
  2340. return;
  2341. inComposition = {};
  2342. inComposition.canUndo = host.session.$undoManager;
  2343. host.onCompositionStart();
  2344. setTimeout(onCompositionUpdate, 0);
  2345. host.on("mousedown", onCompositionEnd);
  2346. if (inComposition.canUndo && !host.selection.isEmpty()) {
  2347. host.insert("");
  2348. host.session.markUndoGroup();
  2349. host.selection.clearSelection();
  2350. }
  2351. host.session.markUndoGroup();
  2352. };
  2353. var onCompositionUpdate = function() {
  2354. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  2355. return;
  2356. var val = text.value.replace(/\u2028/g, "");
  2357. if (inComposition.lastValue === val) return;
  2358. host.onCompositionUpdate(val);
  2359. if (inComposition.lastValue)
  2360. host.undo();
  2361. if (inComposition.canUndo)
  2362. inComposition.lastValue = val;
  2363. if (inComposition.lastValue) {
  2364. var r = host.selection.getRange();
  2365. host.insert(inComposition.lastValue);
  2366. host.session.markUndoGroup();
  2367. inComposition.range = host.selection.getRange();
  2368. host.selection.setRange(r);
  2369. host.selection.clearSelection();
  2370. }
  2371. };
  2372. var onCompositionEnd = function(e) {
  2373. if (!host.onCompositionEnd || host.$readOnly) return;
  2374. var c = inComposition;
  2375. inComposition = false;
  2376. var timer = setTimeout(function() {
  2377. timer = null;
  2378. var str = text.value.replace(/\u2028/g, "");
  2379. if (inComposition)
  2380. return;
  2381. else if (str == c.lastValue)
  2382. resetValue();
  2383. else if (!c.lastValue && str) {
  2384. resetValue();
  2385. sendText(str);
  2386. }
  2387. });
  2388. inputHandler = function compositionInputHandler(str) {
  2389. if (timer)
  2390. clearTimeout(timer);
  2391. str = str.replace(/\u2028/g, "");
  2392. if (str == c.lastValue)
  2393. return "";
  2394. if (c.lastValue && timer)
  2395. host.undo();
  2396. return str;
  2397. };
  2398. host.onCompositionEnd();
  2399. host.removeListener("mousedown", onCompositionEnd);
  2400. if (e.type == "compositionend" && c.range) {
  2401. host.selection.setRange(c.range);
  2402. }
  2403. var needsOnInput =
  2404. (!!useragent.isChrome && useragent.isChrome >= 53) ||
  2405. (!!useragent.isWebKit && useragent.isWebKit >= 603);
  2406. if (needsOnInput) {
  2407. onInput();
  2408. }
  2409. };
  2410. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2411. event.addListener(text, "compositionstart", onCompositionStart);
  2412. if (useragent.isGecko) {
  2413. event.addListener(text, "text", function(){syncComposition.schedule();});
  2414. } else {
  2415. event.addListener(text, "keyup", function(){syncComposition.schedule();});
  2416. event.addListener(text, "keydown", function(){syncComposition.schedule();});
  2417. }
  2418. event.addListener(text, "compositionend", onCompositionEnd);
  2419. this.getElement = function() {
  2420. return text;
  2421. };
  2422. this.setReadOnly = function(readOnly) {
  2423. text.readOnly = readOnly;
  2424. };
  2425. this.onContextMenu = function(e) {
  2426. afterContextMenu = true;
  2427. resetSelection(host.selection.isEmpty());
  2428. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2429. this.moveToMouse(e, true);
  2430. };
  2431. this.moveToMouse = function(e, bringToFront) {
  2432. if (!tempStyle)
  2433. tempStyle = text.style.cssText;
  2434. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2435. + "height:" + text.style.height + ";"
  2436. + (useragent.isIE ? "opacity:0.1;" : "");
  2437. var rect = host.container.getBoundingClientRect();
  2438. var style = dom.computedStyle(host.container);
  2439. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2440. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2441. var maxTop = rect.bottom - top - text.clientHeight -2;
  2442. var move = function(e) {
  2443. text.style.left = e.clientX - left - 2 + "px";
  2444. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2445. };
  2446. move(e);
  2447. if (e.type != "mousedown")
  2448. return;
  2449. if (host.renderer.$keepTextAreaAtCursor)
  2450. host.renderer.$keepTextAreaAtCursor = null;
  2451. clearTimeout(closeTimeout);
  2452. if (useragent.isWin)
  2453. event.capture(host.container, move, onContextMenuClose);
  2454. };
  2455. this.onContextMenuClose = onContextMenuClose;
  2456. var closeTimeout;
  2457. function onContextMenuClose() {
  2458. clearTimeout(closeTimeout);
  2459. closeTimeout = setTimeout(function () {
  2460. if (tempStyle) {
  2461. text.style.cssText = tempStyle;
  2462. tempStyle = '';
  2463. }
  2464. if (host.renderer.$keepTextAreaAtCursor == null) {
  2465. host.renderer.$keepTextAreaAtCursor = true;
  2466. host.renderer.$moveTextAreaToCursor();
  2467. }
  2468. }, 0);
  2469. }
  2470. var onContextMenu = function(e) {
  2471. host.textInput.onContextMenu(e);
  2472. onContextMenuClose();
  2473. };
  2474. event.addListener(text, "mouseup", onContextMenu);
  2475. event.addListener(text, "mousedown", function(e) {
  2476. e.preventDefault();
  2477. onContextMenuClose();
  2478. });
  2479. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2480. event.addListener(text, "contextmenu", onContextMenu);
  2481. };
  2482. exports.TextInput = TextInput;
  2483. });
  2484. define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2485. "use strict";
  2486. var dom = require("../lib/dom");
  2487. var event = require("../lib/event");
  2488. var useragent = require("../lib/useragent");
  2489. var DRAG_OFFSET = 0; // pixels
  2490. var SCROLL_COOLDOWN_T = 250; // milliseconds
  2491. function DefaultHandlers(mouseHandler) {
  2492. mouseHandler.$clickSelection = null;
  2493. var editor = mouseHandler.editor;
  2494. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2495. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2496. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2497. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2498. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2499. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2500. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2501. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2502. exports.forEach(function(x) {
  2503. mouseHandler[x] = this[x];
  2504. }, this);
  2505. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2506. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2507. }
  2508. (function() {
  2509. this.onMouseDown = function(ev) {
  2510. var inSelection = ev.inSelection();
  2511. var pos = ev.getDocumentPosition();
  2512. this.mousedownEvent = ev;
  2513. var editor = this.editor;
  2514. var button = ev.getButton();
  2515. if (button !== 0) {
  2516. var selectionRange = editor.getSelectionRange();
  2517. var selectionEmpty = selectionRange.isEmpty();
  2518. editor.$blockScrolling++;
  2519. if (selectionEmpty || button == 1)
  2520. editor.selection.moveToPosition(pos);
  2521. editor.$blockScrolling--;
  2522. if (button == 2) {
  2523. editor.textInput.onContextMenu(ev.domEvent);
  2524. if (!useragent.isMozilla)
  2525. ev.preventDefault();
  2526. }
  2527. return;
  2528. }
  2529. this.mousedownEvent.time = Date.now();
  2530. if (inSelection && !editor.isFocused()) {
  2531. editor.focus();
  2532. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2533. this.setState("focusWait");
  2534. this.captureMouse(ev);
  2535. return;
  2536. }
  2537. }
  2538. this.captureMouse(ev);
  2539. this.startSelect(pos, ev.domEvent._clicks > 1);
  2540. return ev.preventDefault();
  2541. };
  2542. this.startSelect = function(pos, waitForClickSelection) {
  2543. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2544. var editor = this.editor;
  2545. editor.$blockScrolling++;
  2546. if (this.mousedownEvent.getShiftKey())
  2547. editor.selection.selectToPosition(pos);
  2548. else if (!waitForClickSelection)
  2549. editor.selection.moveToPosition(pos);
  2550. if (!waitForClickSelection)
  2551. this.select();
  2552. if (editor.renderer.scroller.setCapture) {
  2553. editor.renderer.scroller.setCapture();
  2554. }
  2555. editor.setStyle("ace_selecting");
  2556. this.setState("select");
  2557. editor.$blockScrolling--;
  2558. };
  2559. this.select = function() {
  2560. var anchor, editor = this.editor;
  2561. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2562. editor.$blockScrolling++;
  2563. if (this.$clickSelection) {
  2564. var cmp = this.$clickSelection.comparePoint(cursor);
  2565. if (cmp == -1) {
  2566. anchor = this.$clickSelection.end;
  2567. } else if (cmp == 1) {
  2568. anchor = this.$clickSelection.start;
  2569. } else {
  2570. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2571. cursor = orientedRange.cursor;
  2572. anchor = orientedRange.anchor;
  2573. }
  2574. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2575. }
  2576. editor.selection.selectToPosition(cursor);
  2577. editor.$blockScrolling--;
  2578. editor.renderer.scrollCursorIntoView();
  2579. };
  2580. this.extendSelectionBy = function(unitName) {
  2581. var anchor, editor = this.editor;
  2582. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2583. var range = editor.selection[unitName](cursor.row, cursor.column);
  2584. editor.$blockScrolling++;
  2585. if (this.$clickSelection) {
  2586. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2587. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2588. if (cmpStart == -1 && cmpEnd <= 0) {
  2589. anchor = this.$clickSelection.end;
  2590. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2591. cursor = range.start;
  2592. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2593. anchor = this.$clickSelection.start;
  2594. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2595. cursor = range.end;
  2596. } else if (cmpStart == -1 && cmpEnd == 1) {
  2597. cursor = range.end;
  2598. anchor = range.start;
  2599. } else {
  2600. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2601. cursor = orientedRange.cursor;
  2602. anchor = orientedRange.anchor;
  2603. }
  2604. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2605. }
  2606. editor.selection.selectToPosition(cursor);
  2607. editor.$blockScrolling--;
  2608. editor.renderer.scrollCursorIntoView();
  2609. };
  2610. this.selectEnd =
  2611. this.selectAllEnd =
  2612. this.selectByWordsEnd =
  2613. this.selectByLinesEnd = function() {
  2614. this.$clickSelection = null;
  2615. this.editor.unsetStyle("ace_selecting");
  2616. if (this.editor.renderer.scroller.releaseCapture) {
  2617. this.editor.renderer.scroller.releaseCapture();
  2618. }
  2619. };
  2620. this.focusWait = function() {
  2621. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2622. var time = Date.now();
  2623. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2624. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2625. };
  2626. this.onDoubleClick = function(ev) {
  2627. var pos = ev.getDocumentPosition();
  2628. var editor = this.editor;
  2629. var session = editor.session;
  2630. var range = session.getBracketRange(pos);
  2631. if (range) {
  2632. if (range.isEmpty()) {
  2633. range.start.column--;
  2634. range.end.column++;
  2635. }
  2636. this.setState("select");
  2637. } else {
  2638. range = editor.selection.getWordRange(pos.row, pos.column);
  2639. this.setState("selectByWords");
  2640. }
  2641. this.$clickSelection = range;
  2642. this.select();
  2643. };
  2644. this.onTripleClick = function(ev) {
  2645. var pos = ev.getDocumentPosition();
  2646. var editor = this.editor;
  2647. this.setState("selectByLines");
  2648. var range = editor.getSelectionRange();
  2649. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2650. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2651. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2652. } else {
  2653. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2654. }
  2655. this.select();
  2656. };
  2657. this.onQuadClick = function(ev) {
  2658. var editor = this.editor;
  2659. editor.selectAll();
  2660. this.$clickSelection = editor.getSelectionRange();
  2661. this.setState("selectAll");
  2662. };
  2663. this.onMouseWheel = function(ev) {
  2664. if (ev.getAccelKey())
  2665. return;
  2666. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2667. ev.wheelX = ev.wheelY;
  2668. ev.wheelY = 0;
  2669. }
  2670. var editor = this.editor;
  2671. if (!this.$lastScroll)
  2672. this.$lastScroll = { t: 0, vx: 0, vy: 0, allowed: 0 };
  2673. var prevScroll = this.$lastScroll;
  2674. var t = ev.domEvent.timeStamp;
  2675. var dt = t - prevScroll.t;
  2676. var vx = ev.wheelX / dt;
  2677. var vy = ev.wheelY / dt;
  2678. if (dt < SCROLL_COOLDOWN_T) {
  2679. vx = (vx + prevScroll.vx) / 2;
  2680. vy = (vy + prevScroll.vy) / 2;
  2681. }
  2682. var direction = Math.abs(vx / vy);
  2683. var canScroll = false;
  2684. if (direction >= 1 && editor.renderer.isScrollableBy(ev.wheelX * ev.speed, 0))
  2685. canScroll = true;
  2686. if (direction <= 1 && editor.renderer.isScrollableBy(0, ev.wheelY * ev.speed))
  2687. canScroll = true;
  2688. if (canScroll) {
  2689. prevScroll.allowed = t;
  2690. } else if (t - prevScroll.allowed < SCROLL_COOLDOWN_T) {
  2691. var isSlower = Math.abs(vx) <= 1.1 * Math.abs(prevScroll.vx)
  2692. && Math.abs(vy) <= 1.1 * Math.abs(prevScroll.vy);
  2693. if (isSlower) {
  2694. canScroll = true;
  2695. prevScroll.allowed = t;
  2696. }
  2697. else {
  2698. prevScroll.allowed = 0;
  2699. }
  2700. }
  2701. prevScroll.t = t;
  2702. prevScroll.vx = vx;
  2703. prevScroll.vy = vy;
  2704. if (canScroll) {
  2705. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2706. return ev.stop();
  2707. }
  2708. };
  2709. this.onTouchMove = function(ev) {
  2710. this.editor._emit("mousewheel", ev);
  2711. };
  2712. }).call(DefaultHandlers.prototype);
  2713. exports.DefaultHandlers = DefaultHandlers;
  2714. function calcDistance(ax, ay, bx, by) {
  2715. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2716. }
  2717. function calcRangeOrientation(range, cursor) {
  2718. if (range.start.row == range.end.row)
  2719. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2720. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2721. var cmp = cursor.column - 4;
  2722. else
  2723. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2724. if (cmp < 0)
  2725. return {cursor: range.start, anchor: range.end};
  2726. else
  2727. return {cursor: range.end, anchor: range.start};
  2728. }
  2729. });
  2730. define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2731. "use strict";
  2732. var oop = require("./lib/oop");
  2733. var dom = require("./lib/dom");
  2734. function Tooltip (parentNode) {
  2735. this.isOpen = false;
  2736. this.$element = null;
  2737. this.$parentNode = parentNode;
  2738. }
  2739. (function() {
  2740. this.$init = function() {
  2741. this.$element = dom.createElement("div");
  2742. this.$element.className = "ace_tooltip";
  2743. this.$element.style.display = "none";
  2744. this.$parentNode.appendChild(this.$element);
  2745. return this.$element;
  2746. };
  2747. this.getElement = function() {
  2748. return this.$element || this.$init();
  2749. };
  2750. this.setText = function(text) {
  2751. dom.setInnerText(this.getElement(), text);
  2752. };
  2753. this.setHtml = function(html) {
  2754. this.getElement().innerHTML = html;
  2755. };
  2756. this.setPosition = function(x, y) {
  2757. this.getElement().style.left = x + "px";
  2758. this.getElement().style.top = y + "px";
  2759. };
  2760. this.setClassName = function(className) {
  2761. dom.addCssClass(this.getElement(), className);
  2762. };
  2763. this.show = function(text, x, y) {
  2764. if (text != null)
  2765. this.setText(text);
  2766. if (x != null && y != null)
  2767. this.setPosition(x, y);
  2768. if (!this.isOpen) {
  2769. this.getElement().style.display = "block";
  2770. this.isOpen = true;
  2771. }
  2772. };
  2773. this.hide = function() {
  2774. if (this.isOpen) {
  2775. this.getElement().style.display = "none";
  2776. this.isOpen = false;
  2777. }
  2778. };
  2779. this.getHeight = function() {
  2780. return this.getElement().offsetHeight;
  2781. };
  2782. this.getWidth = function() {
  2783. return this.getElement().offsetWidth;
  2784. };
  2785. this.destroy = function() {
  2786. this.isOpen = false;
  2787. if (this.$element && this.$element.parentNode) {
  2788. this.$element.parentNode.removeChild(this.$element);
  2789. }
  2790. };
  2791. }).call(Tooltip.prototype);
  2792. exports.Tooltip = Tooltip;
  2793. });
  2794. define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
  2795. "use strict";
  2796. var dom = require("../lib/dom");
  2797. var oop = require("../lib/oop");
  2798. var event = require("../lib/event");
  2799. var Tooltip = require("../tooltip").Tooltip;
  2800. function GutterHandler(mouseHandler) {
  2801. var editor = mouseHandler.editor;
  2802. var gutter = editor.renderer.$gutterLayer;
  2803. var tooltip = new GutterTooltip(editor.container);
  2804. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2805. if (!editor.isFocused() || e.getButton() != 0)
  2806. return;
  2807. var gutterRegion = gutter.getRegion(e);
  2808. if (gutterRegion == "foldWidgets")
  2809. return;
  2810. var row = e.getDocumentPosition().row;
  2811. var selection = editor.session.selection;
  2812. if (e.getShiftKey())
  2813. selection.selectTo(row, 0);
  2814. else {
  2815. if (e.domEvent.detail == 2) {
  2816. editor.selectAll();
  2817. return e.preventDefault();
  2818. }
  2819. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2820. }
  2821. mouseHandler.setState("selectByLines");
  2822. mouseHandler.captureMouse(e);
  2823. return e.preventDefault();
  2824. });
  2825. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2826. function showTooltip() {
  2827. var row = mouseEvent.getDocumentPosition().row;
  2828. var annotation = gutter.$annotations[row];
  2829. if (!annotation)
  2830. return hideTooltip();
  2831. var maxRow = editor.session.getLength();
  2832. if (row == maxRow) {
  2833. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2834. var pos = mouseEvent.$pos;
  2835. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2836. return hideTooltip();
  2837. }
  2838. if (tooltipAnnotation == annotation)
  2839. return;
  2840. tooltipAnnotation = annotation.text.join("<br/>");
  2841. tooltip.setHtml(tooltipAnnotation);
  2842. tooltip.show();
  2843. editor._signal("showGutterTooltip", tooltip);
  2844. editor.on("mousewheel", hideTooltip);
  2845. if (mouseHandler.$tooltipFollowsMouse) {
  2846. moveTooltip(mouseEvent);
  2847. } else {
  2848. var gutterElement = mouseEvent.domEvent.target;
  2849. var rect = gutterElement.getBoundingClientRect();
  2850. var style = tooltip.getElement().style;
  2851. style.left = rect.right + "px";
  2852. style.top = rect.bottom + "px";
  2853. }
  2854. }
  2855. function hideTooltip() {
  2856. if (tooltipTimeout)
  2857. tooltipTimeout = clearTimeout(tooltipTimeout);
  2858. if (tooltipAnnotation) {
  2859. tooltip.hide();
  2860. tooltipAnnotation = null;
  2861. editor._signal("hideGutterTooltip", tooltip);
  2862. editor.removeEventListener("mousewheel", hideTooltip);
  2863. }
  2864. }
  2865. function moveTooltip(e) {
  2866. tooltip.setPosition(e.x, e.y);
  2867. }
  2868. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2869. var target = e.domEvent.target || e.domEvent.srcElement;
  2870. if (dom.hasCssClass(target, "ace_fold-widget"))
  2871. return hideTooltip();
  2872. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2873. moveTooltip(e);
  2874. mouseEvent = e;
  2875. if (tooltipTimeout)
  2876. return;
  2877. tooltipTimeout = setTimeout(function() {
  2878. tooltipTimeout = null;
  2879. if (mouseEvent && !mouseHandler.isMousePressed)
  2880. showTooltip();
  2881. else
  2882. hideTooltip();
  2883. }, 50);
  2884. });
  2885. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2886. mouseEvent = null;
  2887. if (!tooltipAnnotation || tooltipTimeout)
  2888. return;
  2889. tooltipTimeout = setTimeout(function() {
  2890. tooltipTimeout = null;
  2891. hideTooltip();
  2892. }, 50);
  2893. });
  2894. editor.on("changeSession", hideTooltip);
  2895. }
  2896. function GutterTooltip(parentNode) {
  2897. Tooltip.call(this, parentNode);
  2898. }
  2899. oop.inherits(GutterTooltip, Tooltip);
  2900. (function(){
  2901. this.setPosition = function(x, y) {
  2902. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2903. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2904. var width = this.getWidth();
  2905. var height = this.getHeight();
  2906. x += 15;
  2907. y += 15;
  2908. if (x + width > windowWidth) {
  2909. x -= (x + width) - windowWidth;
  2910. }
  2911. if (y + height > windowHeight) {
  2912. y -= 20 + height;
  2913. }
  2914. Tooltip.prototype.setPosition.call(this, x, y);
  2915. };
  2916. }).call(GutterTooltip.prototype);
  2917. exports.GutterHandler = GutterHandler;
  2918. });
  2919. define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2920. "use strict";
  2921. var event = require("../lib/event");
  2922. var useragent = require("../lib/useragent");
  2923. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2924. this.domEvent = domEvent;
  2925. this.editor = editor;
  2926. this.x = this.clientX = domEvent.clientX;
  2927. this.y = this.clientY = domEvent.clientY;
  2928. this.$pos = null;
  2929. this.$inSelection = null;
  2930. this.propagationStopped = false;
  2931. this.defaultPrevented = false;
  2932. };
  2933. (function() {
  2934. this.stopPropagation = function() {
  2935. event.stopPropagation(this.domEvent);
  2936. this.propagationStopped = true;
  2937. };
  2938. this.preventDefault = function() {
  2939. event.preventDefault(this.domEvent);
  2940. this.defaultPrevented = true;
  2941. };
  2942. this.stop = function() {
  2943. this.stopPropagation();
  2944. this.preventDefault();
  2945. };
  2946. this.getDocumentPosition = function() {
  2947. if (this.$pos)
  2948. return this.$pos;
  2949. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2950. return this.$pos;
  2951. };
  2952. this.inSelection = function() {
  2953. if (this.$inSelection !== null)
  2954. return this.$inSelection;
  2955. var editor = this.editor;
  2956. var selectionRange = editor.getSelectionRange();
  2957. if (selectionRange.isEmpty())
  2958. this.$inSelection = false;
  2959. else {
  2960. var pos = this.getDocumentPosition();
  2961. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2962. }
  2963. return this.$inSelection;
  2964. };
  2965. this.getButton = function() {
  2966. return event.getButton(this.domEvent);
  2967. };
  2968. this.getShiftKey = function() {
  2969. return this.domEvent.shiftKey;
  2970. };
  2971. this.getAccelKey = useragent.isMac
  2972. ? function() { return this.domEvent.metaKey; }
  2973. : function() { return this.domEvent.ctrlKey; };
  2974. }).call(MouseEvent.prototype);
  2975. });
  2976. define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2977. "use strict";
  2978. var dom = require("../lib/dom");
  2979. var event = require("../lib/event");
  2980. var useragent = require("../lib/useragent");
  2981. var AUTOSCROLL_DELAY = 200;
  2982. var SCROLL_CURSOR_DELAY = 200;
  2983. var SCROLL_CURSOR_HYSTERESIS = 5;
  2984. function DragdropHandler(mouseHandler) {
  2985. var editor = mouseHandler.editor;
  2986. var blankImage = dom.createElement("img");
  2987. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2988. if (useragent.isOpera)
  2989. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2990. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2991. exports.forEach(function(x) {
  2992. mouseHandler[x] = this[x];
  2993. }, this);
  2994. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2995. var mouseTarget = editor.container;
  2996. var dragSelectionMarker, x, y;
  2997. var timerId, range;
  2998. var dragCursor, counter = 0;
  2999. var dragOperation;
  3000. var isInternal;
  3001. var autoScrollStartTime;
  3002. var cursorMovedTime;
  3003. var cursorPointOnCaretMoved;
  3004. this.onDragStart = function(e) {
  3005. if (this.cancelDrag || !mouseTarget.draggable) {
  3006. var self = this;
  3007. setTimeout(function(){
  3008. self.startSelect();
  3009. self.captureMouse(e);
  3010. }, 0);
  3011. return e.preventDefault();
  3012. }
  3013. range = editor.getSelectionRange();
  3014. var dataTransfer = e.dataTransfer;
  3015. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  3016. if (useragent.isOpera) {
  3017. editor.container.appendChild(blankImage);
  3018. blankImage.scrollTop = 0;
  3019. }
  3020. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  3021. if (useragent.isOpera) {
  3022. editor.container.removeChild(blankImage);
  3023. }
  3024. dataTransfer.clearData();
  3025. dataTransfer.setData("Text", editor.session.getTextRange());
  3026. isInternal = true;
  3027. this.setState("drag");
  3028. };
  3029. this.onDragEnd = function(e) {
  3030. mouseTarget.draggable = false;
  3031. isInternal = false;
  3032. this.setState(null);
  3033. if (!editor.getReadOnly()) {
  3034. var dropEffect = e.dataTransfer.dropEffect;
  3035. if (!dragOperation && dropEffect == "move")
  3036. editor.session.remove(editor.getSelectionRange());
  3037. editor.renderer.$cursorLayer.setBlinking(true);
  3038. }
  3039. this.editor.unsetStyle("ace_dragging");
  3040. this.editor.renderer.setCursorStyle("");
  3041. };
  3042. this.onDragEnter = function(e) {
  3043. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  3044. return;
  3045. x = e.clientX;
  3046. y = e.clientY;
  3047. if (!dragSelectionMarker)
  3048. addDragMarker();
  3049. counter++;
  3050. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  3051. return event.preventDefault(e);
  3052. };
  3053. this.onDragOver = function(e) {
  3054. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  3055. return;
  3056. x = e.clientX;
  3057. y = e.clientY;
  3058. if (!dragSelectionMarker) {
  3059. addDragMarker();
  3060. counter++;
  3061. }
  3062. if (onMouseMoveTimer !== null)
  3063. onMouseMoveTimer = null;
  3064. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  3065. return event.preventDefault(e);
  3066. };
  3067. this.onDragLeave = function(e) {
  3068. counter--;
  3069. if (counter <= 0 && dragSelectionMarker) {
  3070. clearDragMarker();
  3071. dragOperation = null;
  3072. return event.preventDefault(e);
  3073. }
  3074. };
  3075. this.onDrop = function(e) {
  3076. if (!dragCursor)
  3077. return;
  3078. var dataTransfer = e.dataTransfer;
  3079. if (isInternal) {
  3080. switch (dragOperation) {
  3081. case "move":
  3082. if (range.contains(dragCursor.row, dragCursor.column)) {
  3083. range = {
  3084. start: dragCursor,
  3085. end: dragCursor
  3086. };
  3087. } else {
  3088. range = editor.moveText(range, dragCursor);
  3089. }
  3090. break;
  3091. case "copy":
  3092. range = editor.moveText(range, dragCursor, true);
  3093. break;
  3094. }
  3095. } else {
  3096. var dropData = dataTransfer.getData('Text');
  3097. range = {
  3098. start: dragCursor,
  3099. end: editor.session.insert(dragCursor, dropData)
  3100. };
  3101. editor.focus();
  3102. dragOperation = null;
  3103. }
  3104. clearDragMarker();
  3105. return event.preventDefault(e);
  3106. };
  3107. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  3108. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  3109. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  3110. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  3111. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  3112. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  3113. function scrollCursorIntoView(cursor, prevCursor) {
  3114. var now = Date.now();
  3115. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  3116. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  3117. if (!cursorMovedTime || vMovement || hMovement) {
  3118. editor.$blockScrolling += 1;
  3119. editor.moveCursorToPosition(cursor);
  3120. editor.$blockScrolling -= 1;
  3121. cursorMovedTime = now;
  3122. cursorPointOnCaretMoved = {x: x, y: y};
  3123. } else {
  3124. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  3125. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  3126. cursorMovedTime = null;
  3127. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  3128. editor.renderer.scrollCursorIntoView();
  3129. cursorMovedTime = null;
  3130. }
  3131. }
  3132. }
  3133. function autoScroll(cursor, prevCursor) {
  3134. var now = Date.now();
  3135. var lineHeight = editor.renderer.layerConfig.lineHeight;
  3136. var characterWidth = editor.renderer.layerConfig.characterWidth;
  3137. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  3138. var offsets = {
  3139. x: {
  3140. left: x - editorRect.left,
  3141. right: editorRect.right - x
  3142. },
  3143. y: {
  3144. top: y - editorRect.top,
  3145. bottom: editorRect.bottom - y
  3146. }
  3147. };
  3148. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  3149. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  3150. var scrollCursor = {row: cursor.row, column: cursor.column};
  3151. if (nearestXOffset / characterWidth <= 2) {
  3152. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  3153. }
  3154. if (nearestYOffset / lineHeight <= 1) {
  3155. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  3156. }
  3157. var vScroll = cursor.row != scrollCursor.row;
  3158. var hScroll = cursor.column != scrollCursor.column;
  3159. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  3160. if (vScroll || (hScroll && !vMovement)) {
  3161. if (!autoScrollStartTime)
  3162. autoScrollStartTime = now;
  3163. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  3164. editor.renderer.scrollCursorIntoView(scrollCursor);
  3165. } else {
  3166. autoScrollStartTime = null;
  3167. }
  3168. }
  3169. function onDragInterval() {
  3170. var prevCursor = dragCursor;
  3171. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  3172. scrollCursorIntoView(dragCursor, prevCursor);
  3173. autoScroll(dragCursor, prevCursor);
  3174. }
  3175. function addDragMarker() {
  3176. range = editor.selection.toOrientedRange();
  3177. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  3178. editor.clearSelection();
  3179. if (editor.isFocused())
  3180. editor.renderer.$cursorLayer.setBlinking(false);
  3181. clearInterval(timerId);
  3182. onDragInterval();
  3183. timerId = setInterval(onDragInterval, 20);
  3184. counter = 0;
  3185. event.addListener(document, "mousemove", onMouseMove);
  3186. }
  3187. function clearDragMarker() {
  3188. clearInterval(timerId);
  3189. editor.session.removeMarker(dragSelectionMarker);
  3190. dragSelectionMarker = null;
  3191. editor.$blockScrolling += 1;
  3192. editor.selection.fromOrientedRange(range);
  3193. editor.$blockScrolling -= 1;
  3194. if (editor.isFocused() && !isInternal)
  3195. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  3196. range = null;
  3197. dragCursor = null;
  3198. counter = 0;
  3199. autoScrollStartTime = null;
  3200. cursorMovedTime = null;
  3201. event.removeListener(document, "mousemove", onMouseMove);
  3202. }
  3203. var onMouseMoveTimer = null;
  3204. function onMouseMove() {
  3205. if (onMouseMoveTimer == null) {
  3206. onMouseMoveTimer = setTimeout(function() {
  3207. if (onMouseMoveTimer != null && dragSelectionMarker)
  3208. clearDragMarker();
  3209. }, 20);
  3210. }
  3211. }
  3212. function canAccept(dataTransfer) {
  3213. var types = dataTransfer.types;
  3214. return !types || Array.prototype.some.call(types, function(type) {
  3215. return type == 'text/plain' || type == 'Text';
  3216. });
  3217. }
  3218. function getDropEffect(e) {
  3219. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  3220. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  3221. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  3222. var effectAllowed = "uninitialized";
  3223. try {
  3224. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  3225. } catch (e) {}
  3226. var dropEffect = "none";
  3227. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  3228. dropEffect = "copy";
  3229. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  3230. dropEffect = "move";
  3231. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  3232. dropEffect = "copy";
  3233. return dropEffect;
  3234. }
  3235. }
  3236. (function() {
  3237. this.dragWait = function() {
  3238. var interval = Date.now() - this.mousedownEvent.time;
  3239. if (interval > this.editor.getDragDelay())
  3240. this.startDrag();
  3241. };
  3242. this.dragWaitEnd = function() {
  3243. var target = this.editor.container;
  3244. target.draggable = false;
  3245. this.startSelect(this.mousedownEvent.getDocumentPosition());
  3246. this.selectEnd();
  3247. };
  3248. this.dragReadyEnd = function(e) {
  3249. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  3250. this.editor.unsetStyle("ace_dragging");
  3251. this.editor.renderer.setCursorStyle("");
  3252. this.dragWaitEnd();
  3253. };
  3254. this.startDrag = function(){
  3255. this.cancelDrag = false;
  3256. var editor = this.editor;
  3257. var target = editor.container;
  3258. target.draggable = true;
  3259. editor.renderer.$cursorLayer.setBlinking(false);
  3260. editor.setStyle("ace_dragging");
  3261. var cursorStyle = useragent.isWin ? "default" : "move";
  3262. editor.renderer.setCursorStyle(cursorStyle);
  3263. this.setState("dragReady");
  3264. };
  3265. this.onMouseDrag = function(e) {
  3266. var target = this.editor.container;
  3267. if (useragent.isIE && this.state == "dragReady") {
  3268. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  3269. if (distance > 3)
  3270. target.dragDrop();
  3271. }
  3272. if (this.state === "dragWait") {
  3273. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  3274. if (distance > 0) {
  3275. target.draggable = false;
  3276. this.startSelect(this.mousedownEvent.getDocumentPosition());
  3277. }
  3278. }
  3279. };
  3280. this.onMouseDown = function(e) {
  3281. if (!this.$dragEnabled)
  3282. return;
  3283. this.mousedownEvent = e;
  3284. var editor = this.editor;
  3285. var inSelection = e.inSelection();
  3286. var button = e.getButton();
  3287. var clickCount = e.domEvent.detail || 1;
  3288. if (clickCount === 1 && button === 0 && inSelection) {
  3289. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  3290. return;
  3291. this.mousedownEvent.time = Date.now();
  3292. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  3293. if ("unselectable" in eventTarget)
  3294. eventTarget.unselectable = "on";
  3295. if (editor.getDragDelay()) {
  3296. if (useragent.isWebKit) {
  3297. this.cancelDrag = true;
  3298. var mouseTarget = editor.container;
  3299. mouseTarget.draggable = true;
  3300. }
  3301. this.setState("dragWait");
  3302. } else {
  3303. this.startDrag();
  3304. }
  3305. this.captureMouse(e, this.onMouseDrag.bind(this));
  3306. e.defaultPrevented = true;
  3307. }
  3308. };
  3309. }).call(DragdropHandler.prototype);
  3310. function calcDistance(ax, ay, bx, by) {
  3311. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  3312. }
  3313. exports.DragdropHandler = DragdropHandler;
  3314. });
  3315. define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  3316. "use strict";
  3317. var dom = require("./dom");
  3318. exports.get = function (url, callback) {
  3319. var xhr = new XMLHttpRequest();
  3320. xhr.open('GET', url, true);
  3321. xhr.onreadystatechange = function () {
  3322. if (xhr.readyState === 4) {
  3323. callback(xhr.responseText);
  3324. }
  3325. };
  3326. xhr.send(null);
  3327. };
  3328. exports.loadScript = function(path, callback) {
  3329. var head = dom.getDocumentHead();
  3330. var s = document.createElement('script');
  3331. s.src = path;
  3332. head.appendChild(s);
  3333. s.onload = s.onreadystatechange = function(_, isAbort) {
  3334. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  3335. s = s.onload = s.onreadystatechange = null;
  3336. if (!isAbort)
  3337. callback();
  3338. }
  3339. };
  3340. };
  3341. exports.qualifyURL = function(url) {
  3342. var a = document.createElement('a');
  3343. a.href = url;
  3344. return a.href;
  3345. };
  3346. });
  3347. define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  3348. "use strict";
  3349. var EventEmitter = {};
  3350. var stopPropagation = function() { this.propagationStopped = true; };
  3351. var preventDefault = function() { this.defaultPrevented = true; };
  3352. EventEmitter._emit =
  3353. EventEmitter._dispatchEvent = function(eventName, e) {
  3354. this._eventRegistry || (this._eventRegistry = {});
  3355. this._defaultHandlers || (this._defaultHandlers = {});
  3356. var listeners = this._eventRegistry[eventName] || [];
  3357. var defaultHandler = this._defaultHandlers[eventName];
  3358. if (!listeners.length && !defaultHandler)
  3359. return;
  3360. if (typeof e != "object" || !e)
  3361. e = {};
  3362. if (!e.type)
  3363. e.type = eventName;
  3364. if (!e.stopPropagation)
  3365. e.stopPropagation = stopPropagation;
  3366. if (!e.preventDefault)
  3367. e.preventDefault = preventDefault;
  3368. listeners = listeners.slice();
  3369. for (var i=0; i<listeners.length; i++) {
  3370. listeners[i](e, this);
  3371. if (e.propagationStopped)
  3372. break;
  3373. }
  3374. if (defaultHandler && !e.defaultPrevented)
  3375. return defaultHandler(e, this);
  3376. };
  3377. EventEmitter._signal = function(eventName, e) {
  3378. var listeners = (this._eventRegistry || {})[eventName];
  3379. if (!listeners)
  3380. return;
  3381. listeners = listeners.slice();
  3382. for (var i=0; i<listeners.length; i++)
  3383. listeners[i](e, this);
  3384. };
  3385. EventEmitter.once = function(eventName, callback) {
  3386. var _self = this;
  3387. callback && this.addEventListener(eventName, function newCallback() {
  3388. _self.removeEventListener(eventName, newCallback);
  3389. callback.apply(null, arguments);
  3390. });
  3391. };
  3392. EventEmitter.setDefaultHandler = function(eventName, callback) {
  3393. var handlers = this._defaultHandlers;
  3394. if (!handlers)
  3395. handlers = this._defaultHandlers = {_disabled_: {}};
  3396. if (handlers[eventName]) {
  3397. var old = handlers[eventName];
  3398. var disabled = handlers._disabled_[eventName];
  3399. if (!disabled)
  3400. handlers._disabled_[eventName] = disabled = [];
  3401. disabled.push(old);
  3402. var i = disabled.indexOf(callback);
  3403. if (i != -1)
  3404. disabled.splice(i, 1);
  3405. }
  3406. handlers[eventName] = callback;
  3407. };
  3408. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  3409. var handlers = this._defaultHandlers;
  3410. if (!handlers)
  3411. return;
  3412. var disabled = handlers._disabled_[eventName];
  3413. if (handlers[eventName] == callback) {
  3414. var old = handlers[eventName];
  3415. if (disabled)
  3416. this.setDefaultHandler(eventName, disabled.pop());
  3417. } else if (disabled) {
  3418. var i = disabled.indexOf(callback);
  3419. if (i != -1)
  3420. disabled.splice(i, 1);
  3421. }
  3422. };
  3423. EventEmitter.on =
  3424. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  3425. this._eventRegistry = this._eventRegistry || {};
  3426. var listeners = this._eventRegistry[eventName];
  3427. if (!listeners)
  3428. listeners = this._eventRegistry[eventName] = [];
  3429. if (listeners.indexOf(callback) == -1)
  3430. listeners[capturing ? "unshift" : "push"](callback);
  3431. return callback;
  3432. };
  3433. EventEmitter.off =
  3434. EventEmitter.removeListener =
  3435. EventEmitter.removeEventListener = function(eventName, callback) {
  3436. this._eventRegistry = this._eventRegistry || {};
  3437. var listeners = this._eventRegistry[eventName];
  3438. if (!listeners)
  3439. return;
  3440. var index = listeners.indexOf(callback);
  3441. if (index !== -1)
  3442. listeners.splice(index, 1);
  3443. };
  3444. EventEmitter.removeAllListeners = function(eventName) {
  3445. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3446. };
  3447. exports.EventEmitter = EventEmitter;
  3448. });
  3449. define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3450. "no use strict";
  3451. var oop = require("./oop");
  3452. var EventEmitter = require("./event_emitter").EventEmitter;
  3453. var optionsProvider = {
  3454. setOptions: function(optList) {
  3455. Object.keys(optList).forEach(function(key) {
  3456. this.setOption(key, optList[key]);
  3457. }, this);
  3458. },
  3459. getOptions: function(optionNames) {
  3460. var result = {};
  3461. if (!optionNames) {
  3462. optionNames = Object.keys(this.$options);
  3463. } else if (!Array.isArray(optionNames)) {
  3464. result = optionNames;
  3465. optionNames = Object.keys(result);
  3466. }
  3467. optionNames.forEach(function(key) {
  3468. result[key] = this.getOption(key);
  3469. }, this);
  3470. return result;
  3471. },
  3472. setOption: function(name, value) {
  3473. if (this["$" + name] === value)
  3474. return;
  3475. var opt = this.$options[name];
  3476. if (!opt) {
  3477. return warn('misspelled option "' + name + '"');
  3478. }
  3479. if (opt.forwardTo)
  3480. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3481. if (!opt.handlesSet)
  3482. this["$" + name] = value;
  3483. if (opt && opt.set)
  3484. opt.set.call(this, value);
  3485. },
  3486. getOption: function(name) {
  3487. var opt = this.$options[name];
  3488. if (!opt) {
  3489. return warn('misspelled option "' + name + '"');
  3490. }
  3491. if (opt.forwardTo)
  3492. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3493. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3494. }
  3495. };
  3496. function warn(message) {
  3497. if (typeof console != "undefined" && console.warn)
  3498. console.warn.apply(console, arguments);
  3499. }
  3500. function reportError(msg, data) {
  3501. var e = new Error(msg);
  3502. e.data = data;
  3503. if (typeof console == "object" && console.error)
  3504. console.error(e);
  3505. setTimeout(function() { throw e; });
  3506. }
  3507. var AppConfig = function() {
  3508. this.$defaultOptions = {};
  3509. };
  3510. (function() {
  3511. oop.implement(this, EventEmitter);
  3512. this.defineOptions = function(obj, path, options) {
  3513. if (!obj.$options)
  3514. this.$defaultOptions[path] = obj.$options = {};
  3515. Object.keys(options).forEach(function(key) {
  3516. var opt = options[key];
  3517. if (typeof opt == "string")
  3518. opt = {forwardTo: opt};
  3519. opt.name || (opt.name = key);
  3520. obj.$options[opt.name] = opt;
  3521. if ("initialValue" in opt)
  3522. obj["$" + opt.name] = opt.initialValue;
  3523. });
  3524. oop.implement(obj, optionsProvider);
  3525. return this;
  3526. };
  3527. this.resetOptions = function(obj) {
  3528. Object.keys(obj.$options).forEach(function(key) {
  3529. var opt = obj.$options[key];
  3530. if ("value" in opt)
  3531. obj.setOption(key, opt.value);
  3532. });
  3533. };
  3534. this.setDefaultValue = function(path, name, value) {
  3535. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3536. if (opts[name]) {
  3537. if (opts.forwardTo)
  3538. this.setDefaultValue(opts.forwardTo, name, value);
  3539. else
  3540. opts[name].value = value;
  3541. }
  3542. };
  3543. this.setDefaultValues = function(path, optionHash) {
  3544. Object.keys(optionHash).forEach(function(key) {
  3545. this.setDefaultValue(path, key, optionHash[key]);
  3546. }, this);
  3547. };
  3548. this.warn = warn;
  3549. this.reportError = reportError;
  3550. }).call(AppConfig.prototype);
  3551. exports.AppConfig = AppConfig;
  3552. });
  3553. define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3554. "no use strict";
  3555. var lang = require("./lib/lang");
  3556. var oop = require("./lib/oop");
  3557. var net = require("./lib/net");
  3558. var AppConfig = require("./lib/app_config").AppConfig;
  3559. module.exports = exports = new AppConfig();
  3560. var global = (function() {
  3561. return this || typeof window != "undefined" && window;
  3562. })();
  3563. var options = {
  3564. packaged: false,
  3565. workerPath: null,
  3566. modePath: null,
  3567. themePath: null,
  3568. basePath: "",
  3569. suffix: ".js",
  3570. $moduleUrls: {}
  3571. };
  3572. exports.get = function(key) {
  3573. if (!options.hasOwnProperty(key))
  3574. throw new Error("Unknown config key: " + key);
  3575. return options[key];
  3576. };
  3577. exports.set = function(key, value) {
  3578. if (!options.hasOwnProperty(key))
  3579. throw new Error("Unknown config key: " + key);
  3580. options[key] = value;
  3581. };
  3582. exports.all = function() {
  3583. return lang.copyObject(options);
  3584. };
  3585. exports.moduleUrl = function(name, component) {
  3586. if (options.$moduleUrls[name])
  3587. return options.$moduleUrls[name];
  3588. var parts = name.split("/");
  3589. component = component || parts[parts.length - 2] || "";
  3590. var sep = component == "snippets" ? "/" : "-";
  3591. var base = parts[parts.length - 1];
  3592. if (component == "worker" && sep == "-") {
  3593. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3594. base = base.replace(re, "");
  3595. }
  3596. if ((!base || base == component) && parts.length > 1)
  3597. base = parts[parts.length - 2];
  3598. var path = options[component + "Path"];
  3599. if (path == null) {
  3600. path = options.basePath;
  3601. } else if (sep == "/") {
  3602. component = sep = "";
  3603. }
  3604. if (path && path.slice(-1) != "/")
  3605. path += "/";
  3606. return path + component + sep + base + this.get("suffix");
  3607. };
  3608. exports.setModuleUrl = function(name, subst) {
  3609. return options.$moduleUrls[name] = subst;
  3610. };
  3611. exports.$loading = {};
  3612. exports.loadModule = function(moduleName, onLoad) {
  3613. var module, moduleType;
  3614. if (Array.isArray(moduleName)) {
  3615. moduleType = moduleName[0];
  3616. moduleName = moduleName[1];
  3617. }
  3618. try {
  3619. module = require(moduleName);
  3620. } catch (e) {}
  3621. if (module && !exports.$loading[moduleName])
  3622. return onLoad && onLoad(module);
  3623. if (!exports.$loading[moduleName])
  3624. exports.$loading[moduleName] = [];
  3625. exports.$loading[moduleName].push(onLoad);
  3626. if (exports.$loading[moduleName].length > 1)
  3627. return;
  3628. var afterLoad = function() {
  3629. require([moduleName], function(module) {
  3630. exports._emit("load.module", {name: moduleName, module: module});
  3631. var listeners = exports.$loading[moduleName];
  3632. exports.$loading[moduleName] = null;
  3633. listeners.forEach(function(onLoad) {
  3634. onLoad && onLoad(module);
  3635. });
  3636. });
  3637. };
  3638. if (!exports.get("packaged"))
  3639. return afterLoad();
  3640. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3641. };
  3642. init(true);function init(packaged) {
  3643. if (!global || !global.document)
  3644. return;
  3645. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3646. var scriptOptions = {};
  3647. var scriptUrl = "";
  3648. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3649. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3650. var scripts = currentDocument.getElementsByTagName("script");
  3651. for (var i=0; i<scripts.length; i++) {
  3652. var script = scripts[i];
  3653. var src = script.src || script.getAttribute("src");
  3654. if (!src)
  3655. continue;
  3656. var attributes = script.attributes;
  3657. for (var j=0, l=attributes.length; j < l; j++) {
  3658. var attr = attributes[j];
  3659. if (attr.name.indexOf("data-ace-") === 0) {
  3660. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3661. }
  3662. }
  3663. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3664. if (m)
  3665. scriptUrl = m[1];
  3666. }
  3667. if (scriptUrl) {
  3668. scriptOptions.base = scriptOptions.base || scriptUrl;
  3669. scriptOptions.packaged = true;
  3670. }
  3671. scriptOptions.basePath = scriptOptions.base;
  3672. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3673. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3674. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3675. delete scriptOptions.base;
  3676. for (var key in scriptOptions)
  3677. if (typeof scriptOptions[key] !== "undefined")
  3678. exports.set(key, scriptOptions[key]);
  3679. }
  3680. exports.init = init;
  3681. function deHyphenate(str) {
  3682. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3683. }
  3684. });
  3685. 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) {
  3686. "use strict";
  3687. var event = require("../lib/event");
  3688. var useragent = require("../lib/useragent");
  3689. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3690. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3691. var MouseEvent = require("./mouse_event").MouseEvent;
  3692. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3693. var config = require("../config");
  3694. var MouseHandler = function(editor) {
  3695. var _self = this;
  3696. this.editor = editor;
  3697. new DefaultHandlers(this);
  3698. new DefaultGutterHandler(this);
  3699. new DragdropHandler(this);
  3700. var focusEditor = function(e) {
  3701. var windowBlurred = !document.hasFocus || !document.hasFocus()
  3702. || !editor.isFocused() && document.activeElement == (editor.textInput && editor.textInput.getElement());
  3703. if (windowBlurred)
  3704. window.focus();
  3705. editor.focus();
  3706. };
  3707. var mouseTarget = editor.renderer.getMouseEventTarget();
  3708. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3709. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3710. event.addMultiMouseDownListener([
  3711. mouseTarget,
  3712. editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner,
  3713. editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner,
  3714. editor.textInput && editor.textInput.getElement()
  3715. ].filter(Boolean), [400, 300, 250], this, "onMouseEvent");
  3716. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3717. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3718. var gutterEl = editor.renderer.$gutter;
  3719. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3720. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3721. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3722. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3723. event.addListener(mouseTarget, "mousedown", focusEditor);
  3724. event.addListener(gutterEl, "mousedown", focusEditor);
  3725. if (useragent.isIE && editor.renderer.scrollBarV) {
  3726. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3727. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3728. }
  3729. editor.on("mousemove", function(e){
  3730. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3731. return;
  3732. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3733. var range = editor.session.selection.getRange();
  3734. var renderer = editor.renderer;
  3735. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3736. renderer.setCursorStyle("default");
  3737. } else {
  3738. renderer.setCursorStyle("");
  3739. }
  3740. });
  3741. };
  3742. (function() {
  3743. this.onMouseEvent = function(name, e) {
  3744. this.editor._emit(name, new MouseEvent(e, this.editor));
  3745. };
  3746. this.onMouseMove = function(name, e) {
  3747. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3748. if (!listeners || !listeners.length)
  3749. return;
  3750. this.editor._emit(name, new MouseEvent(e, this.editor));
  3751. };
  3752. this.onMouseWheel = function(name, e) {
  3753. var mouseEvent = new MouseEvent(e, this.editor);
  3754. mouseEvent.speed = this.$scrollSpeed * 2;
  3755. mouseEvent.wheelX = e.wheelX;
  3756. mouseEvent.wheelY = e.wheelY;
  3757. this.editor._emit(name, mouseEvent);
  3758. };
  3759. this.onTouchMove = function (name, e) {
  3760. var mouseEvent = new MouseEvent(e, this.editor);
  3761. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3762. mouseEvent.wheelX = e.wheelX;
  3763. mouseEvent.wheelY = e.wheelY;
  3764. this.editor._emit(name, mouseEvent);
  3765. };
  3766. this.setState = function(state) {
  3767. this.state = state;
  3768. };
  3769. this.captureMouse = function(ev, mouseMoveHandler) {
  3770. this.x = ev.x;
  3771. this.y = ev.y;
  3772. this.isMousePressed = true;
  3773. var renderer = this.editor.renderer;
  3774. if (renderer.$keepTextAreaAtCursor)
  3775. renderer.$keepTextAreaAtCursor = null;
  3776. var self = this;
  3777. var onMouseMove = function(e) {
  3778. if (!e) return;
  3779. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3780. return self.releaseMouse();
  3781. self.x = e.clientX;
  3782. self.y = e.clientY;
  3783. mouseMoveHandler && mouseMoveHandler(e);
  3784. self.mouseEvent = new MouseEvent(e, self.editor);
  3785. self.$mouseMoved = true;
  3786. };
  3787. var onCaptureEnd = function(e) {
  3788. clearInterval(timerId);
  3789. onCaptureInterval();
  3790. self[self.state + "End"] && self[self.state + "End"](e);
  3791. self.state = "";
  3792. if (renderer.$keepTextAreaAtCursor == null) {
  3793. renderer.$keepTextAreaAtCursor = true;
  3794. renderer.$moveTextAreaToCursor();
  3795. }
  3796. self.isMousePressed = false;
  3797. self.$onCaptureMouseMove = self.releaseMouse = null;
  3798. e && self.onMouseEvent("mouseup", e);
  3799. };
  3800. var onCaptureInterval = function() {
  3801. self[self.state] && self[self.state]();
  3802. self.$mouseMoved = false;
  3803. };
  3804. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3805. return setTimeout(function() {onCaptureEnd(ev);});
  3806. }
  3807. self.$onCaptureMouseMove = onMouseMove;
  3808. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3809. var timerId = setInterval(onCaptureInterval, 20);
  3810. };
  3811. this.releaseMouse = null;
  3812. this.cancelContextMenu = function() {
  3813. var stop = function(e) {
  3814. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3815. return;
  3816. this.editor.off("nativecontextmenu", stop);
  3817. if (e && e.domEvent)
  3818. event.stopEvent(e.domEvent);
  3819. }.bind(this);
  3820. setTimeout(stop, 10);
  3821. this.editor.on("nativecontextmenu", stop);
  3822. };
  3823. }).call(MouseHandler.prototype);
  3824. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3825. scrollSpeed: {initialValue: 2},
  3826. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3827. dragEnabled: {initialValue: true},
  3828. focusTimout: {initialValue: 0},
  3829. tooltipFollowsMouse: {initialValue: true}
  3830. });
  3831. exports.MouseHandler = MouseHandler;
  3832. });
  3833. define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3834. "use strict";
  3835. function FoldHandler(editor) {
  3836. editor.on("click", function(e) {
  3837. var position = e.getDocumentPosition();
  3838. var session = editor.session;
  3839. var fold = session.getFoldAt(position.row, position.column, 1);
  3840. if (fold) {
  3841. if (e.getAccelKey())
  3842. session.removeFold(fold);
  3843. else
  3844. session.expandFold(fold);
  3845. e.stop();
  3846. }
  3847. });
  3848. editor.on("gutterclick", function(e) {
  3849. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3850. if (gutterRegion == "foldWidgets") {
  3851. var row = e.getDocumentPosition().row;
  3852. var session = editor.session;
  3853. if (session.foldWidgets && session.foldWidgets[row])
  3854. editor.session.onFoldWidgetClick(row, e);
  3855. if (!editor.isFocused())
  3856. editor.focus();
  3857. e.stop();
  3858. }
  3859. });
  3860. editor.on("gutterdblclick", function(e) {
  3861. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3862. if (gutterRegion == "foldWidgets") {
  3863. var row = e.getDocumentPosition().row;
  3864. var session = editor.session;
  3865. var data = session.getParentFoldRangeData(row, true);
  3866. var range = data.range || data.firstRange;
  3867. if (range) {
  3868. row = range.start.row;
  3869. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3870. if (fold) {
  3871. session.removeFold(fold);
  3872. } else {
  3873. session.addFold("...", range);
  3874. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3875. }
  3876. }
  3877. e.stop();
  3878. }
  3879. });
  3880. }
  3881. exports.FoldHandler = FoldHandler;
  3882. });
  3883. define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3884. "use strict";
  3885. var keyUtil = require("../lib/keys");
  3886. var event = require("../lib/event");
  3887. var KeyBinding = function(editor) {
  3888. this.$editor = editor;
  3889. this.$data = {editor: editor};
  3890. this.$handlers = [];
  3891. this.setDefaultHandler(editor.commands);
  3892. };
  3893. (function() {
  3894. this.setDefaultHandler = function(kb) {
  3895. this.removeKeyboardHandler(this.$defaultHandler);
  3896. this.$defaultHandler = kb;
  3897. this.addKeyboardHandler(kb, 0);
  3898. };
  3899. this.setKeyboardHandler = function(kb) {
  3900. var h = this.$handlers;
  3901. if (h[h.length - 1] == kb)
  3902. return;
  3903. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3904. this.removeKeyboardHandler(h[h.length - 1]);
  3905. this.addKeyboardHandler(kb, 1);
  3906. };
  3907. this.addKeyboardHandler = function(kb, pos) {
  3908. if (!kb)
  3909. return;
  3910. if (typeof kb == "function" && !kb.handleKeyboard)
  3911. kb.handleKeyboard = kb;
  3912. var i = this.$handlers.indexOf(kb);
  3913. if (i != -1)
  3914. this.$handlers.splice(i, 1);
  3915. if (pos == undefined)
  3916. this.$handlers.push(kb);
  3917. else
  3918. this.$handlers.splice(pos, 0, kb);
  3919. if (i == -1 && kb.attach)
  3920. kb.attach(this.$editor);
  3921. };
  3922. this.removeKeyboardHandler = function(kb) {
  3923. var i = this.$handlers.indexOf(kb);
  3924. if (i == -1)
  3925. return false;
  3926. this.$handlers.splice(i, 1);
  3927. kb.detach && kb.detach(this.$editor);
  3928. return true;
  3929. };
  3930. this.getKeyboardHandler = function() {
  3931. return this.$handlers[this.$handlers.length - 1];
  3932. };
  3933. this.getStatusText = function() {
  3934. var data = this.$data;
  3935. var editor = data.editor;
  3936. return this.$handlers.map(function(h) {
  3937. return h.getStatusText && h.getStatusText(editor, data) || "";
  3938. }).filter(Boolean).join(" ");
  3939. };
  3940. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3941. var toExecute;
  3942. var success = false;
  3943. var commands = this.$editor.commands;
  3944. for (var i = this.$handlers.length; i--;) {
  3945. toExecute = this.$handlers[i].handleKeyboard(
  3946. this.$data, hashId, keyString, keyCode, e
  3947. );
  3948. if (!toExecute || !toExecute.command)
  3949. continue;
  3950. if (toExecute.command == "null") {
  3951. success = true;
  3952. } else {
  3953. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3954. }
  3955. if (success && e && hashId != -1 &&
  3956. toExecute.passEvent != true && toExecute.command.passEvent != true
  3957. ) {
  3958. event.stopEvent(e);
  3959. }
  3960. if (success)
  3961. break;
  3962. }
  3963. if (!success && hashId == -1) {
  3964. toExecute = {command: "insertstring"};
  3965. success = commands.exec("insertstring", this.$editor, keyString);
  3966. }
  3967. if (success && this.$editor._signal)
  3968. this.$editor._signal("keyboardActivity", toExecute);
  3969. return success;
  3970. };
  3971. this.onCommandKey = function(e, hashId, keyCode) {
  3972. var keyString = keyUtil.keyCodeToString(keyCode);
  3973. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3974. };
  3975. this.onTextInput = function(text) {
  3976. this.$callKeyboardHandlers(-1, text);
  3977. };
  3978. }).call(KeyBinding.prototype);
  3979. exports.KeyBinding = KeyBinding;
  3980. });
  3981. define("ace/lib/bidiutil",["require","exports","module"], function(require, exports, module) {
  3982. "use strict";
  3983. var ArabicAlefBetIntervalsBegine = ['\u0621', '\u0641'];
  3984. var ArabicAlefBetIntervalsEnd = ['\u063A', '\u064a'];
  3985. var dir = 0, hiLevel = 0;
  3986. var lastArabic = false, hasUBAT_AL = false, hasUBAT_B = false, hasUBAT_S = false, hasBlockSep = false, hasSegSep = false;
  3987. var impTab_LTR = [ [ 0, 3, 0, 1, 0, 0, 0 ], [ 0, 3, 0, 1, 2, 2, 0 ], [ 0, 3, 0, 0x11, 2, 0, 1 ], [ 0, 3, 5, 5, 4, 1, 0 ], [ 0, 3, 0x15, 0x15, 4, 0, 1 ], [ 0, 3, 5, 5, 4, 2, 0 ]
  3988. ];
  3989. var impTab_RTL = [ [ 2, 0, 1, 1, 0, 1, 0 ], [ 2, 0, 1, 1, 0, 2, 0 ], [ 2, 0, 2, 1, 3, 2, 0 ], [ 2, 0, 2, 0x21, 3, 1, 1 ]
  3990. ];
  3991. var LTR = 0, RTL = 1;
  3992. var L = 0;
  3993. var R = 1;
  3994. var EN = 2;
  3995. var AN = 3;
  3996. var ON = 4;
  3997. var B = 5;
  3998. var S = 6;
  3999. var AL = 7;
  4000. var WS = 8;
  4001. var CS = 9;
  4002. var ES = 10;
  4003. var ET = 11;
  4004. var NSM = 12;
  4005. var LRE = 13;
  4006. var RLE = 14;
  4007. var PDF = 15;
  4008. var LRO = 16;
  4009. var RLO = 17;
  4010. var BN = 18;
  4011. var UnicodeTBL00 = [
  4012. BN,BN,BN,BN,BN,BN,BN,BN,BN,S,B,S,WS,B,BN,BN,
  4013. BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,B,B,B,S,
  4014. WS,ON,ON,ET,ET,ET,ON,ON,ON,ON,ON,ES,CS,ES,CS,CS,
  4015. EN,EN,EN,EN,EN,EN,EN,EN,EN,EN,CS,ON,ON,ON,ON,ON,
  4016. ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,
  4017. L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,ON,
  4018. ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,
  4019. L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,BN,
  4020. BN,BN,BN,BN,BN,B,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,
  4021. BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,
  4022. CS,ON,ET,ET,ET,ET,ON,ON,ON,ON,L,ON,ON,BN,ON,ON,
  4023. ET,ET,EN,EN,ON,L,ON,ON,ON,EN,L,ON,ON,ON,ON,ON
  4024. ];
  4025. var UnicodeTBL20 = [
  4026. WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,BN,BN,BN,L,R ,
  4027. ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
  4028. ON,ON,ON,ON,ON,ON,ON,ON,WS,B,LRE,RLE,PDF,LRO,RLO,CS,
  4029. ET,ET,ET,ET,ET,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
  4030. ON,ON,ON,ON,CS,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
  4031. ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,WS
  4032. ];
  4033. function _computeLevels(chars, levels, len, charTypes) {
  4034. var impTab = dir ? impTab_RTL : impTab_LTR
  4035. , prevState = null, newClass = null, newLevel = null, newState = 0
  4036. , action = null, cond = null, condPos = -1, i = null, ix = null, classes = [];
  4037. if (!charTypes) {
  4038. for (i = 0, charTypes = []; i < len; i++) {
  4039. charTypes[i] = _getCharacterType(chars[i]);
  4040. }
  4041. }
  4042. hiLevel = dir;
  4043. lastArabic = false;
  4044. hasUBAT_AL = false;
  4045. hasUBAT_B = false;
  4046. hasUBAT_S = false;
  4047. for (ix = 0; ix < len; ix++){
  4048. prevState = newState;
  4049. classes[ix] = newClass = _getCharClass(chars, charTypes, classes, ix);
  4050. newState = impTab[prevState][newClass];
  4051. action = newState & 0xF0;
  4052. newState &= 0x0F;
  4053. levels[ix] = newLevel = impTab[newState][5];
  4054. if (action > 0){
  4055. if (action == 0x10){
  4056. for(i = condPos; i < ix; i++){
  4057. levels[i] = 1;
  4058. }
  4059. condPos = -1;
  4060. } else {
  4061. condPos = -1;
  4062. }
  4063. }
  4064. cond = impTab[newState][6];
  4065. if (cond){
  4066. if(condPos == -1){
  4067. condPos = ix;
  4068. }
  4069. }else{
  4070. if (condPos > -1){
  4071. for(i = condPos; i < ix; i++){
  4072. levels[i] = newLevel;
  4073. }
  4074. condPos = -1;
  4075. }
  4076. }
  4077. if (charTypes[ix] == B){
  4078. levels[ix] = 0;
  4079. }
  4080. hiLevel |= newLevel;
  4081. }
  4082. if (hasUBAT_S){
  4083. for(i = 0; i < len; i++){
  4084. if(charTypes[i] == S){
  4085. levels[i] = dir;
  4086. for(var j = i - 1; j >= 0; j--){
  4087. if(charTypes[j] == WS){
  4088. levels[j] = dir;
  4089. }else{
  4090. break;
  4091. }
  4092. }
  4093. }
  4094. }
  4095. }
  4096. }
  4097. function _invertLevel(lev, levels, _array) {
  4098. if (hiLevel < lev){
  4099. return;
  4100. }
  4101. if (lev == 1 && dir == RTL && !hasUBAT_B){
  4102. _array.reverse();
  4103. return;
  4104. }
  4105. var len = _array.length, start = 0, end, lo, hi, tmp;
  4106. while(start < len){
  4107. if (levels[start] >= lev){
  4108. end = start + 1;
  4109. while(end < len && levels[end] >= lev){
  4110. end++;
  4111. }
  4112. for(lo = start, hi = end - 1 ; lo < hi; lo++, hi--){
  4113. tmp = _array[lo];
  4114. _array[lo] = _array[hi];
  4115. _array[hi] = tmp;
  4116. }
  4117. start = end;
  4118. }
  4119. start++;
  4120. }
  4121. }
  4122. function _getCharClass(chars, types, classes, ix) {
  4123. var cType = types[ix], wType, nType, len, i;
  4124. switch(cType){
  4125. case L:
  4126. case R:
  4127. lastArabic = false;
  4128. case ON:
  4129. case AN:
  4130. return cType;
  4131. case EN:
  4132. return lastArabic ? AN : EN;
  4133. case AL:
  4134. lastArabic = true;
  4135. hasUBAT_AL = true;
  4136. return R;
  4137. case WS:
  4138. return ON;
  4139. case CS:
  4140. if (ix < 1 || (ix + 1) >= types.length ||
  4141. ((wType = classes[ix - 1]) != EN && wType != AN) ||
  4142. ((nType = types[ix + 1]) != EN && nType != AN)){
  4143. return ON;
  4144. }
  4145. if (lastArabic){nType = AN;}
  4146. return nType == wType ? nType : ON;
  4147. case ES:
  4148. wType = ix > 0 ? classes[ix - 1] : B;
  4149. if (wType == EN && (ix + 1) < types.length && types[ix + 1] == EN){
  4150. return EN;
  4151. }
  4152. return ON;
  4153. case ET:
  4154. if (ix > 0 && classes[ix - 1] == EN){
  4155. return EN;
  4156. }
  4157. if (lastArabic){
  4158. return ON;
  4159. }
  4160. i = ix + 1;
  4161. len = types.length;
  4162. while (i < len && types[i] == ET){
  4163. i++;
  4164. }
  4165. if (i < len && types[i] == EN){
  4166. return EN;
  4167. }
  4168. return ON;
  4169. case NSM:
  4170. len = types.length;
  4171. i = ix + 1;
  4172. while (i < len && types[i] == NSM){
  4173. i++;
  4174. }
  4175. if (i < len){
  4176. var c = chars[ix], rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E;
  4177. wType = types[i];
  4178. if (rtlCandidate && (wType == R || wType == AL)){
  4179. return R;
  4180. }
  4181. }
  4182. if (ix < 1 || (wType = types[ix - 1]) == B){
  4183. return ON;
  4184. }
  4185. return classes[ix - 1];
  4186. case B:
  4187. lastArabic = false;
  4188. hasUBAT_B = true;
  4189. return dir;
  4190. case S:
  4191. hasUBAT_S = true;
  4192. return ON;
  4193. case LRE:
  4194. case RLE:
  4195. case LRO:
  4196. case RLO:
  4197. case PDF:
  4198. lastArabic = false;
  4199. case BN:
  4200. return ON;
  4201. }
  4202. }
  4203. function _getCharacterType( ch ) {
  4204. var uc = ch.charCodeAt(0), hi = uc >> 8;
  4205. if (hi == 0) {
  4206. return ((uc > 0x00BF) ? L : UnicodeTBL00[uc]);
  4207. } else if (hi == 5) {
  4208. return (/[\u0591-\u05f4]/.test(ch) ? R : L);
  4209. } else if (hi == 6) {
  4210. if (/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(ch))
  4211. return NSM;
  4212. else if (/[\u0660-\u0669\u066b-\u066c]/.test(ch))
  4213. return AN;
  4214. else if (uc == 0x066A)
  4215. return ET;
  4216. else if (/[\u06f0-\u06f9]/.test(ch))
  4217. return EN;
  4218. else
  4219. return AL;
  4220. } else if (hi == 0x20 && uc <= 0x205F) {
  4221. return UnicodeTBL20[uc & 0xFF];
  4222. } else if (hi == 0xFE) {
  4223. return (uc >= 0xFE70 ? AL : ON);
  4224. }
  4225. return ON;
  4226. }
  4227. function _isArabicDiacritics( ch ) {
  4228. return (ch >= '\u064b' && ch <= '\u0655');
  4229. }
  4230. exports.L = L;
  4231. exports.R = R;
  4232. exports.EN = EN;
  4233. exports.ON_R = 3;
  4234. exports.AN = 4;
  4235. exports.R_H = 5;
  4236. exports.B = 6;
  4237. exports.DOT = "\xB7";
  4238. exports.doBidiReorder = function(text, textCharTypes, isRtl) {
  4239. if (text.length < 2)
  4240. return {};
  4241. var chars = text.split(""), logicalFromVisual = new Array(chars.length),
  4242. bidiLevels = new Array(chars.length), levels = [];
  4243. dir = isRtl ? RTL : LTR;
  4244. _computeLevels(chars, levels, chars.length, textCharTypes);
  4245. for (var i = 0; i < logicalFromVisual.length; logicalFromVisual[i] = i, i++);
  4246. _invertLevel(2, levels, logicalFromVisual);
  4247. _invertLevel(1, levels, logicalFromVisual);
  4248. for (var i = 0; i < logicalFromVisual.length - 1; i++) { //fix levels to reflect character width
  4249. if (textCharTypes[i] === AN) {
  4250. levels[i] = exports.AN;
  4251. } else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE)
  4252. || textCharTypes[i] === ON || textCharTypes[i] === BN)) {
  4253. levels[i] = exports.ON_R;
  4254. } else if ((i > 0 && chars[i - 1] === '\u0644') && /\u0622|\u0623|\u0625|\u0627/.test(chars[i])) {
  4255. levels[i - 1] = levels[i] = exports.R_H;
  4256. i++;
  4257. }
  4258. }
  4259. if (chars[chars.length - 1] === exports.DOT)
  4260. levels[chars.length - 1] = exports.B;
  4261. for (var i = 0; i < logicalFromVisual.length; i++) {
  4262. bidiLevels[i] = levels[logicalFromVisual[i]];
  4263. }
  4264. return {'logicalFromVisual': logicalFromVisual, 'bidiLevels': bidiLevels};
  4265. };
  4266. exports.hasBidiCharacters = function(text, textCharTypes){
  4267. var ret = false;
  4268. for (var i = 0; i < text.length; i++){
  4269. textCharTypes[i] = _getCharacterType(text.charAt(i));
  4270. if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL))
  4271. ret = true;
  4272. }
  4273. return ret;
  4274. };
  4275. exports.getVisualFromLogicalIdx = function(logIdx, rowMap) {
  4276. for (var i = 0; i < rowMap.logicalFromVisual.length; i++) {
  4277. if (rowMap.logicalFromVisual[i] == logIdx)
  4278. return i;
  4279. }
  4280. return 0;
  4281. };
  4282. });
  4283. define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang","ace/lib/useragent"], function(require, exports, module) {
  4284. "use strict";
  4285. var bidiUtil = require("./lib/bidiutil");
  4286. var lang = require("./lib/lang");
  4287. var useragent = require("./lib/useragent");
  4288. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  4289. var BidiHandler = function(session) {
  4290. this.session = session;
  4291. this.bidiMap = {};
  4292. this.currentRow = null;
  4293. this.bidiUtil = bidiUtil;
  4294. this.charWidths = [];
  4295. this.EOL = "\xAC";
  4296. this.showInvisibles = true;
  4297. this.isRtlDir = false;
  4298. this.line = "";
  4299. this.wrapIndent = 0;
  4300. this.isLastRow = false;
  4301. this.EOF = "\xB6";
  4302. this.seenBidi = false;
  4303. };
  4304. (function() {
  4305. this.isBidiRow = function(screenRow, docRow, splitIndex) {
  4306. if (!this.seenBidi)
  4307. return false;
  4308. if (screenRow !== this.currentRow) {
  4309. this.currentRow = screenRow;
  4310. this.updateRowLine(docRow, splitIndex);
  4311. this.updateBidiMap();
  4312. }
  4313. return this.bidiMap.bidiLevels;
  4314. };
  4315. this.onChange = function(delta) {
  4316. if (!this.seenBidi) {
  4317. if (delta.action == "insert" && bidiRE.test(delta.lines.join("\n"))) {
  4318. this.seenBidi = true;
  4319. this.currentRow = null;
  4320. }
  4321. }
  4322. else {
  4323. this.currentRow = null;
  4324. }
  4325. };
  4326. this.getDocumentRow = function() {
  4327. var docRow = 0;
  4328. var rowCache = this.session.$screenRowCache;
  4329. if (rowCache.length) {
  4330. var index = this.session.$getRowCacheIndex(rowCache, this.currentRow);
  4331. if (index >= 0)
  4332. docRow = this.session.$docRowCache[index];
  4333. }
  4334. return docRow;
  4335. };
  4336. this.getSplitIndex = function() {
  4337. var splitIndex = 0;
  4338. var rowCache = this.session.$screenRowCache;
  4339. if (rowCache.length) {
  4340. var currentIndex, prevIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow);
  4341. while (this.currentRow - splitIndex > 0) {
  4342. currentIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow - splitIndex - 1);
  4343. if (currentIndex !== prevIndex)
  4344. break;
  4345. prevIndex = currentIndex;
  4346. splitIndex++;
  4347. }
  4348. }
  4349. return splitIndex;
  4350. };
  4351. this.updateRowLine = function(docRow, splitIndex) {
  4352. if (docRow === undefined)
  4353. docRow = this.getDocumentRow();
  4354. this.wrapIndent = 0;
  4355. this.isLastRow = (docRow === this.session.getLength() - 1);
  4356. this.line = this.session.getLine(docRow);
  4357. if (this.session.$useWrapMode) {
  4358. var splits = this.session.$wrapData[docRow];
  4359. if (splits) {
  4360. if (splitIndex === undefined)
  4361. splitIndex = this.getSplitIndex();
  4362. if(splitIndex > 0 && splits.length) {
  4363. this.wrapIndent = splits.indent;
  4364. this.line = (splitIndex < splits.length) ?
  4365. this.line.substring(splits[splitIndex - 1], splits[splits.length - 1]) :
  4366. this.line.substring(splits[splits.length - 1]);
  4367. } else {
  4368. this.line = this.line.substring(0, splits[splitIndex]);
  4369. }
  4370. }
  4371. }
  4372. var session = this.session, shift = 0, size;
  4373. this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function(ch, i){
  4374. if (ch === '\t' || session.isFullWidth(ch.charCodeAt(0))) {
  4375. size = (ch === '\t') ? session.getScreenTabSize(i + shift) : 2;
  4376. shift += size - 1;
  4377. return lang.stringRepeat(bidiUtil.DOT, size);
  4378. }
  4379. return ch;
  4380. });
  4381. };
  4382. this.updateBidiMap = function() {
  4383. var textCharTypes = [], endOfLine = this.isLastRow ? this.EOF : this.EOL;
  4384. var line = this.line + (this.showInvisibles ? endOfLine : bidiUtil.DOT);
  4385. if (bidiUtil.hasBidiCharacters(line, textCharTypes)) {
  4386. this.bidiMap = bidiUtil.doBidiReorder(line, textCharTypes, this.isRtlDir);
  4387. } else {
  4388. this.bidiMap = {};
  4389. }
  4390. };
  4391. this.markAsDirty = function() {
  4392. this.currentRow = null;
  4393. };
  4394. this.updateCharacterWidths = function(fontMetrics) {
  4395. if (!this.seenBidi)
  4396. return;
  4397. if (this.characterWidth === fontMetrics.$characterSize.width)
  4398. return;
  4399. var characterWidth = this.characterWidth = fontMetrics.$characterSize.width;
  4400. var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4");
  4401. this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth;
  4402. this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth;
  4403. this.charWidths[bidiUtil.R_H] = useragent.isChrome ? bidiCharWidth : bidiCharWidth * 0.45;
  4404. this.charWidths[bidiUtil.B] = 0;
  4405. this.currentRow = null;
  4406. };
  4407. this.getShowInvisibles = function() {
  4408. return this.showInvisibles;
  4409. };
  4410. this.setShowInvisibles = function(showInvisibles) {
  4411. this.showInvisibles = showInvisibles;
  4412. this.currentRow = null;
  4413. };
  4414. this.setEolChar = function(eolChar) {
  4415. this.EOL = eolChar;
  4416. };
  4417. this.setTextDir = function(isRtlDir) {
  4418. this.isRtlDir = isRtlDir;
  4419. };
  4420. this.getPosLeft = function(col) {
  4421. col -= this.wrapIndent;
  4422. var visualIdx = bidiUtil.getVisualFromLogicalIdx(col > 0 ? col - 1 : 0, this.bidiMap),
  4423. levels = this.bidiMap.bidiLevels, left = 0;
  4424. if (col === 0 && levels[visualIdx] % 2 !== 0)
  4425. visualIdx++;
  4426. for (var i = 0; i < visualIdx; i++) {
  4427. left += this.charWidths[levels[i]];
  4428. }
  4429. if (col !== 0 && levels[visualIdx] % 2 === 0)
  4430. left += this.charWidths[levels[visualIdx]];
  4431. if (this.wrapIndent)
  4432. left += this.wrapIndent * this.charWidths[bidiUtil.L];
  4433. return left;
  4434. };
  4435. this.getSelections = function(startCol, endCol) {
  4436. var map = this.bidiMap, levels = map.bidiLevels, level, offset = this.wrapIndent * this.charWidths[bidiUtil.L], selections = [],
  4437. selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent,
  4438. isSelected = false, isSelectedPrev = false, selectionStart = 0;
  4439. for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) {
  4440. logIdx = map.logicalFromVisual[visIdx];
  4441. level = levels[visIdx];
  4442. isSelected = (logIdx >= selColMin) && (logIdx < selColMax);
  4443. if (isSelected && !isSelectedPrev) {
  4444. selectionStart = offset;
  4445. } else if (!isSelected && isSelectedPrev) {
  4446. selections.push({left: selectionStart, width: offset - selectionStart});
  4447. }
  4448. offset += this.charWidths[level];
  4449. isSelectedPrev = isSelected;
  4450. }
  4451. if (isSelected && (visIdx === levels.length)) {
  4452. selections.push({left: selectionStart, width: offset - selectionStart});
  4453. }
  4454. return selections;
  4455. };
  4456. this.offsetToCol = function(posX) {
  4457. var logicalIdx = 0, posX = Math.max(posX, 0),
  4458. offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels,
  4459. charWidth = this.charWidths[levels[visualIdx]];
  4460. if (this.wrapIndent) {
  4461. posX -= this.wrapIndent * this.charWidths[bidiUtil.L];
  4462. }
  4463. while(posX > offset + charWidth/2) {
  4464. offset += charWidth;
  4465. if(visualIdx === levels.length - 1) {
  4466. charWidth = 0;
  4467. break;
  4468. }
  4469. charWidth = this.charWidths[levels[++visualIdx]];
  4470. }
  4471. if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)){
  4472. if(posX < offset)
  4473. visualIdx--;
  4474. logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
  4475. } else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)){
  4476. logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx]
  4477. : this.bidiMap.logicalFromVisual[visualIdx - 1]);
  4478. } else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0))
  4479. || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))){
  4480. logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx];
  4481. } else {
  4482. if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0)
  4483. visualIdx--;
  4484. logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
  4485. }
  4486. return (logicalIdx + this.wrapIndent);
  4487. };
  4488. }).call(BidiHandler.prototype);
  4489. exports.BidiHandler = BidiHandler;
  4490. });
  4491. define("ace/range",["require","exports","module"], function(require, exports, module) {
  4492. "use strict";
  4493. var comparePoints = function(p1, p2) {
  4494. return p1.row - p2.row || p1.column - p2.column;
  4495. };
  4496. var Range = function(startRow, startColumn, endRow, endColumn) {
  4497. this.start = {
  4498. row: startRow,
  4499. column: startColumn
  4500. };
  4501. this.end = {
  4502. row: endRow,
  4503. column: endColumn
  4504. };
  4505. };
  4506. (function() {
  4507. this.isEqual = function(range) {
  4508. return this.start.row === range.start.row &&
  4509. this.end.row === range.end.row &&
  4510. this.start.column === range.start.column &&
  4511. this.end.column === range.end.column;
  4512. };
  4513. this.toString = function() {
  4514. return ("Range: [" + this.start.row + "/" + this.start.column +
  4515. "] -> [" + this.end.row + "/" + this.end.column + "]");
  4516. };
  4517. this.contains = function(row, column) {
  4518. return this.compare(row, column) == 0;
  4519. };
  4520. this.compareRange = function(range) {
  4521. var cmp,
  4522. end = range.end,
  4523. start = range.start;
  4524. cmp = this.compare(end.row, end.column);
  4525. if (cmp == 1) {
  4526. cmp = this.compare(start.row, start.column);
  4527. if (cmp == 1) {
  4528. return 2;
  4529. } else if (cmp == 0) {
  4530. return 1;
  4531. } else {
  4532. return 0;
  4533. }
  4534. } else if (cmp == -1) {
  4535. return -2;
  4536. } else {
  4537. cmp = this.compare(start.row, start.column);
  4538. if (cmp == -1) {
  4539. return -1;
  4540. } else if (cmp == 1) {
  4541. return 42;
  4542. } else {
  4543. return 0;
  4544. }
  4545. }
  4546. };
  4547. this.comparePoint = function(p) {
  4548. return this.compare(p.row, p.column);
  4549. };
  4550. this.containsRange = function(range) {
  4551. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  4552. };
  4553. this.intersects = function(range) {
  4554. var cmp = this.compareRange(range);
  4555. return (cmp == -1 || cmp == 0 || cmp == 1);
  4556. };
  4557. this.isEnd = function(row, column) {
  4558. return this.end.row == row && this.end.column == column;
  4559. };
  4560. this.isStart = function(row, column) {
  4561. return this.start.row == row && this.start.column == column;
  4562. };
  4563. this.setStart = function(row, column) {
  4564. if (typeof row == "object") {
  4565. this.start.column = row.column;
  4566. this.start.row = row.row;
  4567. } else {
  4568. this.start.row = row;
  4569. this.start.column = column;
  4570. }
  4571. };
  4572. this.setEnd = function(row, column) {
  4573. if (typeof row == "object") {
  4574. this.end.column = row.column;
  4575. this.end.row = row.row;
  4576. } else {
  4577. this.end.row = row;
  4578. this.end.column = column;
  4579. }
  4580. };
  4581. this.inside = function(row, column) {
  4582. if (this.compare(row, column) == 0) {
  4583. if (this.isEnd(row, column) || this.isStart(row, column)) {
  4584. return false;
  4585. } else {
  4586. return true;
  4587. }
  4588. }
  4589. return false;
  4590. };
  4591. this.insideStart = function(row, column) {
  4592. if (this.compare(row, column) == 0) {
  4593. if (this.isEnd(row, column)) {
  4594. return false;
  4595. } else {
  4596. return true;
  4597. }
  4598. }
  4599. return false;
  4600. };
  4601. this.insideEnd = function(row, column) {
  4602. if (this.compare(row, column) == 0) {
  4603. if (this.isStart(row, column)) {
  4604. return false;
  4605. } else {
  4606. return true;
  4607. }
  4608. }
  4609. return false;
  4610. };
  4611. this.compare = function(row, column) {
  4612. if (!this.isMultiLine()) {
  4613. if (row === this.start.row) {
  4614. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  4615. }
  4616. }
  4617. if (row < this.start.row)
  4618. return -1;
  4619. if (row > this.end.row)
  4620. return 1;
  4621. if (this.start.row === row)
  4622. return column >= this.start.column ? 0 : -1;
  4623. if (this.end.row === row)
  4624. return column <= this.end.column ? 0 : 1;
  4625. return 0;
  4626. };
  4627. this.compareStart = function(row, column) {
  4628. if (this.start.row == row && this.start.column == column) {
  4629. return -1;
  4630. } else {
  4631. return this.compare(row, column);
  4632. }
  4633. };
  4634. this.compareEnd = function(row, column) {
  4635. if (this.end.row == row && this.end.column == column) {
  4636. return 1;
  4637. } else {
  4638. return this.compare(row, column);
  4639. }
  4640. };
  4641. this.compareInside = function(row, column) {
  4642. if (this.end.row == row && this.end.column == column) {
  4643. return 1;
  4644. } else if (this.start.row == row && this.start.column == column) {
  4645. return -1;
  4646. } else {
  4647. return this.compare(row, column);
  4648. }
  4649. };
  4650. this.clipRows = function(firstRow, lastRow) {
  4651. if (this.end.row > lastRow)
  4652. var end = {row: lastRow + 1, column: 0};
  4653. else if (this.end.row < firstRow)
  4654. var end = {row: firstRow, column: 0};
  4655. if (this.start.row > lastRow)
  4656. var start = {row: lastRow + 1, column: 0};
  4657. else if (this.start.row < firstRow)
  4658. var start = {row: firstRow, column: 0};
  4659. return Range.fromPoints(start || this.start, end || this.end);
  4660. };
  4661. this.extend = function(row, column) {
  4662. var cmp = this.compare(row, column);
  4663. if (cmp == 0)
  4664. return this;
  4665. else if (cmp == -1)
  4666. var start = {row: row, column: column};
  4667. else
  4668. var end = {row: row, column: column};
  4669. return Range.fromPoints(start || this.start, end || this.end);
  4670. };
  4671. this.isEmpty = function() {
  4672. return (this.start.row === this.end.row && this.start.column === this.end.column);
  4673. };
  4674. this.isMultiLine = function() {
  4675. return (this.start.row !== this.end.row);
  4676. };
  4677. this.clone = function() {
  4678. return Range.fromPoints(this.start, this.end);
  4679. };
  4680. this.collapseRows = function() {
  4681. if (this.end.column == 0)
  4682. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
  4683. else
  4684. return new Range(this.start.row, 0, this.end.row, 0);
  4685. };
  4686. this.toScreenRange = function(session) {
  4687. var screenPosStart = session.documentToScreenPosition(this.start);
  4688. var screenPosEnd = session.documentToScreenPosition(this.end);
  4689. return new Range(
  4690. screenPosStart.row, screenPosStart.column,
  4691. screenPosEnd.row, screenPosEnd.column
  4692. );
  4693. };
  4694. this.moveBy = function(row, column) {
  4695. this.start.row += row;
  4696. this.start.column += column;
  4697. this.end.row += row;
  4698. this.end.column += column;
  4699. };
  4700. }).call(Range.prototype);
  4701. Range.fromPoints = function(start, end) {
  4702. return new Range(start.row, start.column, end.row, end.column);
  4703. };
  4704. Range.comparePoints = comparePoints;
  4705. Range.comparePoints = function(p1, p2) {
  4706. return p1.row - p2.row || p1.column - p2.column;
  4707. };
  4708. exports.Range = Range;
  4709. });
  4710. define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  4711. "use strict";
  4712. var oop = require("./lib/oop");
  4713. var lang = require("./lib/lang");
  4714. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  4715. var Range = require("./range").Range;
  4716. var Selection = function(session) {
  4717. this.session = session;
  4718. this.doc = session.getDocument();
  4719. this.clearSelection();
  4720. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  4721. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  4722. var self = this;
  4723. this.lead.on("change", function(e) {
  4724. self._emit("changeCursor");
  4725. if (!self.$isEmpty)
  4726. self._emit("changeSelection");
  4727. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  4728. self.$desiredColumn = null;
  4729. });
  4730. this.selectionAnchor.on("change", function() {
  4731. if (!self.$isEmpty)
  4732. self._emit("changeSelection");
  4733. });
  4734. };
  4735. (function() {
  4736. oop.implement(this, EventEmitter);
  4737. this.isEmpty = function() {
  4738. return (this.$isEmpty || (
  4739. this.anchor.row == this.lead.row &&
  4740. this.anchor.column == this.lead.column
  4741. ));
  4742. };
  4743. this.isMultiLine = function() {
  4744. if (this.isEmpty()) {
  4745. return false;
  4746. }
  4747. return this.getRange().isMultiLine();
  4748. };
  4749. this.getCursor = function() {
  4750. return this.lead.getPosition();
  4751. };
  4752. this.setSelectionAnchor = function(row, column) {
  4753. this.anchor.setPosition(row, column);
  4754. if (this.$isEmpty) {
  4755. this.$isEmpty = false;
  4756. this._emit("changeSelection");
  4757. }
  4758. };
  4759. this.getSelectionAnchor = function() {
  4760. if (this.$isEmpty)
  4761. return this.getSelectionLead();
  4762. else
  4763. return this.anchor.getPosition();
  4764. };
  4765. this.getSelectionLead = function() {
  4766. return this.lead.getPosition();
  4767. };
  4768. this.shiftSelection = function(columns) {
  4769. if (this.$isEmpty) {
  4770. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  4771. return;
  4772. }
  4773. var anchor = this.getSelectionAnchor();
  4774. var lead = this.getSelectionLead();
  4775. var isBackwards = this.isBackwards();
  4776. if (!isBackwards || anchor.column !== 0)
  4777. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  4778. if (isBackwards || lead.column !== 0) {
  4779. this.$moveSelection(function() {
  4780. this.moveCursorTo(lead.row, lead.column + columns);
  4781. });
  4782. }
  4783. };
  4784. this.isBackwards = function() {
  4785. var anchor = this.anchor;
  4786. var lead = this.lead;
  4787. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  4788. };
  4789. this.getRange = function() {
  4790. var anchor = this.anchor;
  4791. var lead = this.lead;
  4792. if (this.isEmpty())
  4793. return Range.fromPoints(lead, lead);
  4794. if (this.isBackwards()) {
  4795. return Range.fromPoints(lead, anchor);
  4796. }
  4797. else {
  4798. return Range.fromPoints(anchor, lead);
  4799. }
  4800. };
  4801. this.clearSelection = function() {
  4802. if (!this.$isEmpty) {
  4803. this.$isEmpty = true;
  4804. this._emit("changeSelection");
  4805. }
  4806. };
  4807. this.selectAll = function() {
  4808. var lastRow = this.doc.getLength() - 1;
  4809. this.setSelectionAnchor(0, 0);
  4810. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  4811. };
  4812. this.setRange =
  4813. this.setSelectionRange = function(range, reverse) {
  4814. if (reverse) {
  4815. this.setSelectionAnchor(range.end.row, range.end.column);
  4816. this.selectTo(range.start.row, range.start.column);
  4817. } else {
  4818. this.setSelectionAnchor(range.start.row, range.start.column);
  4819. this.selectTo(range.end.row, range.end.column);
  4820. }
  4821. if (this.getRange().isEmpty())
  4822. this.$isEmpty = true;
  4823. this.$desiredColumn = null;
  4824. };
  4825. this.$moveSelection = function(mover) {
  4826. var lead = this.lead;
  4827. if (this.$isEmpty)
  4828. this.setSelectionAnchor(lead.row, lead.column);
  4829. mover.call(this);
  4830. };
  4831. this.selectTo = function(row, column) {
  4832. this.$moveSelection(function() {
  4833. this.moveCursorTo(row, column);
  4834. });
  4835. };
  4836. this.selectToPosition = function(pos) {
  4837. this.$moveSelection(function() {
  4838. this.moveCursorToPosition(pos);
  4839. });
  4840. };
  4841. this.moveTo = function(row, column) {
  4842. this.clearSelection();
  4843. this.moveCursorTo(row, column);
  4844. };
  4845. this.moveToPosition = function(pos) {
  4846. this.clearSelection();
  4847. this.moveCursorToPosition(pos);
  4848. };
  4849. this.selectUp = function() {
  4850. this.$moveSelection(this.moveCursorUp);
  4851. };
  4852. this.selectDown = function() {
  4853. this.$moveSelection(this.moveCursorDown);
  4854. };
  4855. this.selectRight = function() {
  4856. this.$moveSelection(this.moveCursorRight);
  4857. };
  4858. this.selectLeft = function() {
  4859. this.$moveSelection(this.moveCursorLeft);
  4860. };
  4861. this.selectLineStart = function() {
  4862. this.$moveSelection(this.moveCursorLineStart);
  4863. };
  4864. this.selectLineEnd = function() {
  4865. this.$moveSelection(this.moveCursorLineEnd);
  4866. };
  4867. this.selectFileEnd = function() {
  4868. this.$moveSelection(this.moveCursorFileEnd);
  4869. };
  4870. this.selectFileStart = function() {
  4871. this.$moveSelection(this.moveCursorFileStart);
  4872. };
  4873. this.selectWordRight = function() {
  4874. this.$moveSelection(this.moveCursorWordRight);
  4875. };
  4876. this.selectWordLeft = function() {
  4877. this.$moveSelection(this.moveCursorWordLeft);
  4878. };
  4879. this.getWordRange = function(row, column) {
  4880. if (typeof column == "undefined") {
  4881. var cursor = row || this.lead;
  4882. row = cursor.row;
  4883. column = cursor.column;
  4884. }
  4885. return this.session.getWordRange(row, column);
  4886. };
  4887. this.selectWord = function() {
  4888. this.setSelectionRange(this.getWordRange());
  4889. };
  4890. this.selectAWord = function() {
  4891. var cursor = this.getCursor();
  4892. var range = this.session.getAWordRange(cursor.row, cursor.column);
  4893. this.setSelectionRange(range);
  4894. };
  4895. this.getLineRange = function(row, excludeLastChar) {
  4896. var rowStart = typeof row == "number" ? row : this.lead.row;
  4897. var rowEnd;
  4898. var foldLine = this.session.getFoldLine(rowStart);
  4899. if (foldLine) {
  4900. rowStart = foldLine.start.row;
  4901. rowEnd = foldLine.end.row;
  4902. } else {
  4903. rowEnd = rowStart;
  4904. }
  4905. if (excludeLastChar === true)
  4906. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  4907. else
  4908. return new Range(rowStart, 0, rowEnd + 1, 0);
  4909. };
  4910. this.selectLine = function() {
  4911. this.setSelectionRange(this.getLineRange());
  4912. };
  4913. this.moveCursorUp = function() {
  4914. this.moveCursorBy(-1, 0);
  4915. };
  4916. this.moveCursorDown = function() {
  4917. this.moveCursorBy(1, 0);
  4918. };
  4919. this.wouldMoveIntoSoftTab = function(cursor, tabSize, direction) {
  4920. var start = cursor.column;
  4921. var end = cursor.column + tabSize;
  4922. if (direction < 0) {
  4923. start = cursor.column - tabSize;
  4924. end = cursor.column;
  4925. }
  4926. return this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(start, end).split(" ").length-1 == tabSize;
  4927. };
  4928. this.moveCursorLeft = function() {
  4929. var cursor = this.lead.getPosition(),
  4930. fold;
  4931. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  4932. this.moveCursorTo(fold.start.row, fold.start.column);
  4933. } else if (cursor.column === 0) {
  4934. if (cursor.row > 0) {
  4935. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  4936. }
  4937. }
  4938. else {
  4939. var tabSize = this.session.getTabSize();
  4940. if (this.wouldMoveIntoSoftTab(cursor, tabSize, -1) && !this.session.getNavigateWithinSoftTabs()) {
  4941. this.moveCursorBy(0, -tabSize);
  4942. } else {
  4943. this.moveCursorBy(0, -1);
  4944. }
  4945. }
  4946. };
  4947. this.moveCursorRight = function() {
  4948. var cursor = this.lead.getPosition(),
  4949. fold;
  4950. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4951. this.moveCursorTo(fold.end.row, fold.end.column);
  4952. }
  4953. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4954. if (this.lead.row < this.doc.getLength() - 1) {
  4955. this.moveCursorTo(this.lead.row + 1, 0);
  4956. }
  4957. }
  4958. else {
  4959. var tabSize = this.session.getTabSize();
  4960. var cursor = this.lead;
  4961. if (this.wouldMoveIntoSoftTab(cursor, tabSize, 1) && !this.session.getNavigateWithinSoftTabs()) {
  4962. this.moveCursorBy(0, tabSize);
  4963. } else {
  4964. this.moveCursorBy(0, 1);
  4965. }
  4966. }
  4967. };
  4968. this.moveCursorLineStart = function() {
  4969. var row = this.lead.row;
  4970. var column = this.lead.column;
  4971. var screenRow = this.session.documentToScreenRow(row, column);
  4972. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4973. var beforeCursor = this.session.getDisplayLine(
  4974. row, null, firstColumnPosition.row,
  4975. firstColumnPosition.column
  4976. );
  4977. var leadingSpace = beforeCursor.match(/^\s*/);
  4978. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4979. firstColumnPosition.column += leadingSpace[0].length;
  4980. this.moveCursorToPosition(firstColumnPosition);
  4981. };
  4982. this.moveCursorLineEnd = function() {
  4983. var lead = this.lead;
  4984. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4985. if (this.lead.column == lineEnd.column) {
  4986. var line = this.session.getLine(lineEnd.row);
  4987. if (lineEnd.column == line.length) {
  4988. var textEnd = line.search(/\s+$/);
  4989. if (textEnd > 0)
  4990. lineEnd.column = textEnd;
  4991. }
  4992. }
  4993. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4994. };
  4995. this.moveCursorFileEnd = function() {
  4996. var row = this.doc.getLength() - 1;
  4997. var column = this.doc.getLine(row).length;
  4998. this.moveCursorTo(row, column);
  4999. };
  5000. this.moveCursorFileStart = function() {
  5001. this.moveCursorTo(0, 0);
  5002. };
  5003. this.moveCursorLongWordRight = function() {
  5004. var row = this.lead.row;
  5005. var column = this.lead.column;
  5006. var line = this.doc.getLine(row);
  5007. var rightOfCursor = line.substring(column);
  5008. var match;
  5009. this.session.nonTokenRe.lastIndex = 0;
  5010. this.session.tokenRe.lastIndex = 0;
  5011. var fold = this.session.getFoldAt(row, column, 1);
  5012. if (fold) {
  5013. this.moveCursorTo(fold.end.row, fold.end.column);
  5014. return;
  5015. }
  5016. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  5017. column += this.session.nonTokenRe.lastIndex;
  5018. this.session.nonTokenRe.lastIndex = 0;
  5019. rightOfCursor = line.substring(column);
  5020. }
  5021. if (column >= line.length) {
  5022. this.moveCursorTo(row, line.length);
  5023. this.moveCursorRight();
  5024. if (row < this.doc.getLength() - 1)
  5025. this.moveCursorWordRight();
  5026. return;
  5027. }
  5028. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  5029. column += this.session.tokenRe.lastIndex;
  5030. this.session.tokenRe.lastIndex = 0;
  5031. }
  5032. this.moveCursorTo(row, column);
  5033. };
  5034. this.moveCursorLongWordLeft = function() {
  5035. var row = this.lead.row;
  5036. var column = this.lead.column;
  5037. var fold;
  5038. if (fold = this.session.getFoldAt(row, column, -1)) {
  5039. this.moveCursorTo(fold.start.row, fold.start.column);
  5040. return;
  5041. }
  5042. var str = this.session.getFoldStringAt(row, column, -1);
  5043. if (str == null) {
  5044. str = this.doc.getLine(row).substring(0, column);
  5045. }
  5046. var leftOfCursor = lang.stringReverse(str);
  5047. var match;
  5048. this.session.nonTokenRe.lastIndex = 0;
  5049. this.session.tokenRe.lastIndex = 0;
  5050. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  5051. column -= this.session.nonTokenRe.lastIndex;
  5052. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  5053. this.session.nonTokenRe.lastIndex = 0;
  5054. }
  5055. if (column <= 0) {
  5056. this.moveCursorTo(row, 0);
  5057. this.moveCursorLeft();
  5058. if (row > 0)
  5059. this.moveCursorWordLeft();
  5060. return;
  5061. }
  5062. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  5063. column -= this.session.tokenRe.lastIndex;
  5064. this.session.tokenRe.lastIndex = 0;
  5065. }
  5066. this.moveCursorTo(row, column);
  5067. };
  5068. this.$shortWordEndIndex = function(rightOfCursor) {
  5069. var match, index = 0, ch;
  5070. var whitespaceRe = /\s/;
  5071. var tokenRe = this.session.tokenRe;
  5072. tokenRe.lastIndex = 0;
  5073. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  5074. index = this.session.tokenRe.lastIndex;
  5075. } else {
  5076. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  5077. index ++;
  5078. if (index < 1) {
  5079. tokenRe.lastIndex = 0;
  5080. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  5081. tokenRe.lastIndex = 0;
  5082. index ++;
  5083. if (whitespaceRe.test(ch)) {
  5084. if (index > 2) {
  5085. index--;
  5086. break;
  5087. } else {
  5088. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  5089. index ++;
  5090. if (index > 2)
  5091. break;
  5092. }
  5093. }
  5094. }
  5095. }
  5096. }
  5097. tokenRe.lastIndex = 0;
  5098. return index;
  5099. };
  5100. this.moveCursorShortWordRight = function() {
  5101. var row = this.lead.row;
  5102. var column = this.lead.column;
  5103. var line = this.doc.getLine(row);
  5104. var rightOfCursor = line.substring(column);
  5105. var fold = this.session.getFoldAt(row, column, 1);
  5106. if (fold)
  5107. return this.moveCursorTo(fold.end.row, fold.end.column);
  5108. if (column == line.length) {
  5109. var l = this.doc.getLength();
  5110. do {
  5111. row++;
  5112. rightOfCursor = this.doc.getLine(row);
  5113. } while (row < l && /^\s*$/.test(rightOfCursor));
  5114. if (!/^\s+/.test(rightOfCursor))
  5115. rightOfCursor = "";
  5116. column = 0;
  5117. }
  5118. var index = this.$shortWordEndIndex(rightOfCursor);
  5119. this.moveCursorTo(row, column + index);
  5120. };
  5121. this.moveCursorShortWordLeft = function() {
  5122. var row = this.lead.row;
  5123. var column = this.lead.column;
  5124. var fold;
  5125. if (fold = this.session.getFoldAt(row, column, -1))
  5126. return this.moveCursorTo(fold.start.row, fold.start.column);
  5127. var line = this.session.getLine(row).substring(0, column);
  5128. if (column === 0) {
  5129. do {
  5130. row--;
  5131. line = this.doc.getLine(row);
  5132. } while (row > 0 && /^\s*$/.test(line));
  5133. column = line.length;
  5134. if (!/\s+$/.test(line))
  5135. line = "";
  5136. }
  5137. var leftOfCursor = lang.stringReverse(line);
  5138. var index = this.$shortWordEndIndex(leftOfCursor);
  5139. return this.moveCursorTo(row, column - index);
  5140. };
  5141. this.moveCursorWordRight = function() {
  5142. if (this.session.$selectLongWords)
  5143. this.moveCursorLongWordRight();
  5144. else
  5145. this.moveCursorShortWordRight();
  5146. };
  5147. this.moveCursorWordLeft = function() {
  5148. if (this.session.$selectLongWords)
  5149. this.moveCursorLongWordLeft();
  5150. else
  5151. this.moveCursorShortWordLeft();
  5152. };
  5153. this.moveCursorBy = function(rows, chars) {
  5154. var screenPos = this.session.documentToScreenPosition(
  5155. this.lead.row,
  5156. this.lead.column
  5157. );
  5158. var offsetX;
  5159. if (chars === 0) {
  5160. if (rows !== 0) {
  5161. if (this.session.$bidiHandler.isBidiRow(screenPos.row, this.lead.row)) {
  5162. offsetX = this.session.$bidiHandler.getPosLeft(screenPos.column);
  5163. screenPos.column = Math.round(offsetX / this.session.$bidiHandler.charWidths[0]);
  5164. } else {
  5165. offsetX = screenPos.column * this.session.$bidiHandler.charWidths[0];
  5166. }
  5167. }
  5168. if (this.$desiredColumn)
  5169. screenPos.column = this.$desiredColumn;
  5170. else
  5171. this.$desiredColumn = screenPos.column;
  5172. }
  5173. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column, offsetX);
  5174. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  5175. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
  5176. if (docPos.row > 0 || rows > 0)
  5177. docPos.row++;
  5178. }
  5179. }
  5180. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  5181. };
  5182. this.moveCursorToPosition = function(position) {
  5183. this.moveCursorTo(position.row, position.column);
  5184. };
  5185. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  5186. var fold = this.session.getFoldAt(row, column, 1);
  5187. if (fold) {
  5188. row = fold.start.row;
  5189. column = fold.start.column;
  5190. }
  5191. this.$keepDesiredColumnOnChange = true;
  5192. var line = this.session.getLine(row);
  5193. if (/[\uDC00-\uDFFF]/.test(line.charAt(column)) && line.charAt(column - 1)) {
  5194. if (this.lead.row == row && this.lead.column == column + 1)
  5195. column = column - 1;
  5196. else
  5197. column = column + 1;
  5198. }
  5199. this.lead.setPosition(row, column);
  5200. this.$keepDesiredColumnOnChange = false;
  5201. if (!keepDesiredColumn)
  5202. this.$desiredColumn = null;
  5203. };
  5204. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  5205. var pos = this.session.screenToDocumentPosition(row, column);
  5206. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  5207. };
  5208. this.detach = function() {
  5209. this.lead.detach();
  5210. this.anchor.detach();
  5211. this.session = this.doc = null;
  5212. };
  5213. this.fromOrientedRange = function(range) {
  5214. this.setSelectionRange(range, range.cursor == range.start);
  5215. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  5216. };
  5217. this.toOrientedRange = function(range) {
  5218. var r = this.getRange();
  5219. if (range) {
  5220. range.start.column = r.start.column;
  5221. range.start.row = r.start.row;
  5222. range.end.column = r.end.column;
  5223. range.end.row = r.end.row;
  5224. } else {
  5225. range = r;
  5226. }
  5227. range.cursor = this.isBackwards() ? range.start : range.end;
  5228. range.desiredColumn = this.$desiredColumn;
  5229. return range;
  5230. };
  5231. this.getRangeOfMovements = function(func) {
  5232. var start = this.getCursor();
  5233. try {
  5234. func(this);
  5235. var end = this.getCursor();
  5236. return Range.fromPoints(start,end);
  5237. } catch(e) {
  5238. return Range.fromPoints(start,start);
  5239. } finally {
  5240. this.moveCursorToPosition(start);
  5241. }
  5242. };
  5243. this.toJSON = function() {
  5244. if (this.rangeCount) {
  5245. var data = this.ranges.map(function(r) {
  5246. var r1 = r.clone();
  5247. r1.isBackwards = r.cursor == r.start;
  5248. return r1;
  5249. });
  5250. } else {
  5251. var data = this.getRange();
  5252. data.isBackwards = this.isBackwards();
  5253. }
  5254. return data;
  5255. };
  5256. this.fromJSON = function(data) {
  5257. if (data.start == undefined) {
  5258. if (this.rangeList) {
  5259. this.toSingleRange(data[0]);
  5260. for (var i = data.length; i--; ) {
  5261. var r = Range.fromPoints(data[i].start, data[i].end);
  5262. if (data[i].isBackwards)
  5263. r.cursor = r.start;
  5264. this.addRange(r, true);
  5265. }
  5266. return;
  5267. } else
  5268. data = data[0];
  5269. }
  5270. if (this.rangeList)
  5271. this.toSingleRange(data);
  5272. this.setSelectionRange(data, data.isBackwards);
  5273. };
  5274. this.isEqual = function(data) {
  5275. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  5276. return false;
  5277. if (!data.length || !this.ranges)
  5278. return this.getRange().isEqual(data);
  5279. for (var i = this.ranges.length; i--; ) {
  5280. if (!this.ranges[i].isEqual(data[i]))
  5281. return false;
  5282. }
  5283. return true;
  5284. };
  5285. }).call(Selection.prototype);
  5286. exports.Selection = Selection;
  5287. });
  5288. define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  5289. "use strict";
  5290. var config = require("./config");
  5291. var MAX_TOKEN_COUNT = 2000;
  5292. var Tokenizer = function(rules) {
  5293. this.states = rules;
  5294. this.regExps = {};
  5295. this.matchMappings = {};
  5296. for (var key in this.states) {
  5297. var state = this.states[key];
  5298. var ruleRegExps = [];
  5299. var matchTotal = 0;
  5300. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  5301. var flag = "g";
  5302. var splitterRurles = [];
  5303. for (var i = 0; i < state.length; i++) {
  5304. var rule = state[i];
  5305. if (rule.defaultToken)
  5306. mapping.defaultToken = rule.defaultToken;
  5307. if (rule.caseInsensitive)
  5308. flag = "gi";
  5309. if (rule.regex == null)
  5310. continue;
  5311. if (rule.regex instanceof RegExp)
  5312. rule.regex = rule.regex.toString().slice(1, -1);
  5313. var adjustedregex = rule.regex;
  5314. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  5315. if (Array.isArray(rule.token)) {
  5316. if (rule.token.length == 1 || matchcount == 1) {
  5317. rule.token = rule.token[0];
  5318. } else if (matchcount - 1 != rule.token.length) {
  5319. this.reportError("number of classes and regexp groups doesn't match", {
  5320. rule: rule,
  5321. groupCount: matchcount - 1
  5322. });
  5323. rule.token = rule.token[0];
  5324. } else {
  5325. rule.tokenArray = rule.token;
  5326. rule.token = null;
  5327. rule.onMatch = this.$arrayTokens;
  5328. }
  5329. } else if (typeof rule.token == "function" && !rule.onMatch) {
  5330. if (matchcount > 1)
  5331. rule.onMatch = this.$applyToken;
  5332. else
  5333. rule.onMatch = rule.token;
  5334. }
  5335. if (matchcount > 1) {
  5336. if (/\\\d/.test(rule.regex)) {
  5337. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  5338. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  5339. });
  5340. } else {
  5341. matchcount = 1;
  5342. adjustedregex = this.removeCapturingGroups(rule.regex);
  5343. }
  5344. if (!rule.splitRegex && typeof rule.token != "string")
  5345. splitterRurles.push(rule); // flag will be known only at the very end
  5346. }
  5347. mapping[matchTotal] = i;
  5348. matchTotal += matchcount;
  5349. ruleRegExps.push(adjustedregex);
  5350. if (!rule.onMatch)
  5351. rule.onMatch = null;
  5352. }
  5353. if (!ruleRegExps.length) {
  5354. mapping[0] = 0;
  5355. ruleRegExps.push("$");
  5356. }
  5357. splitterRurles.forEach(function(rule) {
  5358. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  5359. }, this);
  5360. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  5361. }
  5362. };
  5363. (function() {
  5364. this.$setMaxTokenCount = function(m) {
  5365. MAX_TOKEN_COUNT = m | 0;
  5366. };
  5367. this.$applyToken = function(str) {
  5368. var values = this.splitRegex.exec(str).slice(1);
  5369. var types = this.token.apply(this, values);
  5370. if (typeof types === "string")
  5371. return [{type: types, value: str}];
  5372. var tokens = [];
  5373. for (var i = 0, l = types.length; i < l; i++) {
  5374. if (values[i])
  5375. tokens[tokens.length] = {
  5376. type: types[i],
  5377. value: values[i]
  5378. };
  5379. }
  5380. return tokens;
  5381. };
  5382. this.$arrayTokens = function(str) {
  5383. if (!str)
  5384. return [];
  5385. var values = this.splitRegex.exec(str);
  5386. if (!values)
  5387. return "text";
  5388. var tokens = [];
  5389. var types = this.tokenArray;
  5390. for (var i = 0, l = types.length; i < l; i++) {
  5391. if (values[i + 1])
  5392. tokens[tokens.length] = {
  5393. type: types[i],
  5394. value: values[i + 1]
  5395. };
  5396. }
  5397. return tokens;
  5398. };
  5399. this.removeCapturingGroups = function(src) {
  5400. var r = src.replace(
  5401. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  5402. function(x, y) {return y ? "(?:" : x;}
  5403. );
  5404. return r;
  5405. };
  5406. this.createSplitterRegexp = function(src, flag) {
  5407. if (src.indexOf("(?=") != -1) {
  5408. var stack = 0;
  5409. var inChClass = false;
  5410. var lastCapture = {};
  5411. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  5412. m, esc, parenOpen, parenClose, square, index
  5413. ) {
  5414. if (inChClass) {
  5415. inChClass = square != "]";
  5416. } else if (square) {
  5417. inChClass = true;
  5418. } else if (parenClose) {
  5419. if (stack == lastCapture.stack) {
  5420. lastCapture.end = index+1;
  5421. lastCapture.stack = -1;
  5422. }
  5423. stack--;
  5424. } else if (parenOpen) {
  5425. stack++;
  5426. if (parenOpen.length != 1) {
  5427. lastCapture.stack = stack;
  5428. lastCapture.start = index;
  5429. }
  5430. }
  5431. return m;
  5432. });
  5433. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  5434. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  5435. }
  5436. if (src.charAt(0) != "^") src = "^" + src;
  5437. if (src.charAt(src.length - 1) != "$") src += "$";
  5438. return new RegExp(src, (flag||"").replace("g", ""));
  5439. };
  5440. this.getLineTokens = function(line, startState) {
  5441. if (startState && typeof startState != "string") {
  5442. var stack = startState.slice(0);
  5443. startState = stack[0];
  5444. if (startState === "#tmp") {
  5445. stack.shift();
  5446. startState = stack.shift();
  5447. }
  5448. } else
  5449. var stack = [];
  5450. var currentState = startState || "start";
  5451. var state = this.states[currentState];
  5452. if (!state) {
  5453. currentState = "start";
  5454. state = this.states[currentState];
  5455. }
  5456. var mapping = this.matchMappings[currentState];
  5457. var re = this.regExps[currentState];
  5458. re.lastIndex = 0;
  5459. var match, tokens = [];
  5460. var lastIndex = 0;
  5461. var matchAttempts = 0;
  5462. var token = {type: null, value: ""};
  5463. while (match = re.exec(line)) {
  5464. var type = mapping.defaultToken;
  5465. var rule = null;
  5466. var value = match[0];
  5467. var index = re.lastIndex;
  5468. if (index - value.length > lastIndex) {
  5469. var skipped = line.substring(lastIndex, index - value.length);
  5470. if (token.type == type) {
  5471. token.value += skipped;
  5472. } else {
  5473. if (token.type)
  5474. tokens.push(token);
  5475. token = {type: type, value: skipped};
  5476. }
  5477. }
  5478. for (var i = 0; i < match.length-2; i++) {
  5479. if (match[i + 1] === undefined)
  5480. continue;
  5481. rule = state[mapping[i]];
  5482. if (rule.onMatch)
  5483. type = rule.onMatch(value, currentState, stack, line);
  5484. else
  5485. type = rule.token;
  5486. if (rule.next) {
  5487. if (typeof rule.next == "string") {
  5488. currentState = rule.next;
  5489. } else {
  5490. currentState = rule.next(currentState, stack);
  5491. }
  5492. state = this.states[currentState];
  5493. if (!state) {
  5494. this.reportError("state doesn't exist", currentState);
  5495. currentState = "start";
  5496. state = this.states[currentState];
  5497. }
  5498. mapping = this.matchMappings[currentState];
  5499. lastIndex = index;
  5500. re = this.regExps[currentState];
  5501. re.lastIndex = index;
  5502. }
  5503. if (rule.consumeLineEnd)
  5504. lastIndex = index;
  5505. break;
  5506. }
  5507. if (value) {
  5508. if (typeof type === "string") {
  5509. if ((!rule || rule.merge !== false) && token.type === type) {
  5510. token.value += value;
  5511. } else {
  5512. if (token.type)
  5513. tokens.push(token);
  5514. token = {type: type, value: value};
  5515. }
  5516. } else if (type) {
  5517. if (token.type)
  5518. tokens.push(token);
  5519. token = {type: null, value: ""};
  5520. for (var i = 0; i < type.length; i++)
  5521. tokens.push(type[i]);
  5522. }
  5523. }
  5524. if (lastIndex == line.length)
  5525. break;
  5526. lastIndex = index;
  5527. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  5528. if (matchAttempts > 2 * line.length) {
  5529. this.reportError("infinite loop with in ace tokenizer", {
  5530. startState: startState,
  5531. line: line
  5532. });
  5533. }
  5534. while (lastIndex < line.length) {
  5535. if (token.type)
  5536. tokens.push(token);
  5537. token = {
  5538. value: line.substring(lastIndex, lastIndex += 2000),
  5539. type: "overflow"
  5540. };
  5541. }
  5542. currentState = "start";
  5543. stack = [];
  5544. break;
  5545. }
  5546. }
  5547. if (token.type)
  5548. tokens.push(token);
  5549. if (stack.length > 1) {
  5550. if (stack[0] !== currentState)
  5551. stack.unshift("#tmp", currentState);
  5552. }
  5553. return {
  5554. tokens : tokens,
  5555. state : stack.length ? stack : currentState
  5556. };
  5557. };
  5558. this.reportError = config.reportError;
  5559. }).call(Tokenizer.prototype);
  5560. exports.Tokenizer = Tokenizer;
  5561. });
  5562. define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  5563. "use strict";
  5564. var lang = require("../lib/lang");
  5565. var TextHighlightRules = function() {
  5566. this.$rules = {
  5567. "start" : [{
  5568. token : "empty_line",
  5569. regex : '^$'
  5570. }, {
  5571. defaultToken : "text"
  5572. }]
  5573. };
  5574. };
  5575. (function() {
  5576. this.addRules = function(rules, prefix) {
  5577. if (!prefix) {
  5578. for (var key in rules)
  5579. this.$rules[key] = rules[key];
  5580. return;
  5581. }
  5582. for (var key in rules) {
  5583. var state = rules[key];
  5584. for (var i = 0; i < state.length; i++) {
  5585. var rule = state[i];
  5586. if (rule.next || rule.onMatch) {
  5587. if (typeof rule.next == "string") {
  5588. if (rule.next.indexOf(prefix) !== 0)
  5589. rule.next = prefix + rule.next;
  5590. }
  5591. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  5592. rule.nextState = prefix + rule.nextState;
  5593. }
  5594. }
  5595. this.$rules[prefix + key] = state;
  5596. }
  5597. };
  5598. this.getRules = function() {
  5599. return this.$rules;
  5600. };
  5601. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  5602. var embedRules = typeof HighlightRules == "function"
  5603. ? new HighlightRules().getRules()
  5604. : HighlightRules;
  5605. if (states) {
  5606. for (var i = 0; i < states.length; i++)
  5607. states[i] = prefix + states[i];
  5608. } else {
  5609. states = [];
  5610. for (var key in embedRules)
  5611. states.push(prefix + key);
  5612. }
  5613. this.addRules(embedRules, prefix);
  5614. if (escapeRules) {
  5615. var addRules = Array.prototype[append ? "push" : "unshift"];
  5616. for (var i = 0; i < states.length; i++)
  5617. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  5618. }
  5619. if (!this.$embeds)
  5620. this.$embeds = [];
  5621. this.$embeds.push(prefix);
  5622. };
  5623. this.getEmbeds = function() {
  5624. return this.$embeds;
  5625. };
  5626. var pushState = function(currentState, stack) {
  5627. if (currentState != "start" || stack.length)
  5628. stack.unshift(this.nextState, currentState);
  5629. return this.nextState;
  5630. };
  5631. var popState = function(currentState, stack) {
  5632. stack.shift();
  5633. return stack.shift() || "start";
  5634. };
  5635. this.normalizeRules = function() {
  5636. var id = 0;
  5637. var rules = this.$rules;
  5638. function processState(key) {
  5639. var state = rules[key];
  5640. state.processed = true;
  5641. for (var i = 0; i < state.length; i++) {
  5642. var rule = state[i];
  5643. var toInsert = null;
  5644. if (Array.isArray(rule)) {
  5645. toInsert = rule;
  5646. rule = {};
  5647. }
  5648. if (!rule.regex && rule.start) {
  5649. rule.regex = rule.start;
  5650. if (!rule.next)
  5651. rule.next = [];
  5652. rule.next.push({
  5653. defaultToken: rule.token
  5654. }, {
  5655. token: rule.token + ".end",
  5656. regex: rule.end || rule.start,
  5657. next: "pop"
  5658. });
  5659. rule.token = rule.token + ".start";
  5660. rule.push = true;
  5661. }
  5662. var next = rule.next || rule.push;
  5663. if (next && Array.isArray(next)) {
  5664. var stateName = rule.stateName;
  5665. if (!stateName) {
  5666. stateName = rule.token;
  5667. if (typeof stateName != "string")
  5668. stateName = stateName[0] || "";
  5669. if (rules[stateName])
  5670. stateName += id++;
  5671. }
  5672. rules[stateName] = next;
  5673. rule.next = stateName;
  5674. processState(stateName);
  5675. } else if (next == "pop") {
  5676. rule.next = popState;
  5677. }
  5678. if (rule.push) {
  5679. rule.nextState = rule.next || rule.push;
  5680. rule.next = pushState;
  5681. delete rule.push;
  5682. }
  5683. if (rule.rules) {
  5684. for (var r in rule.rules) {
  5685. if (rules[r]) {
  5686. if (rules[r].push)
  5687. rules[r].push.apply(rules[r], rule.rules[r]);
  5688. } else {
  5689. rules[r] = rule.rules[r];
  5690. }
  5691. }
  5692. }
  5693. var includeName = typeof rule == "string" ? rule : rule.include;
  5694. if (includeName) {
  5695. if (Array.isArray(includeName))
  5696. toInsert = includeName.map(function(x) { return rules[x]; });
  5697. else
  5698. toInsert = rules[includeName];
  5699. }
  5700. if (toInsert) {
  5701. var args = [i, 1].concat(toInsert);
  5702. if (rule.noEscape)
  5703. args = args.filter(function(x) {return !x.next;});
  5704. state.splice.apply(state, args);
  5705. i--;
  5706. }
  5707. if (rule.keywordMap) {
  5708. rule.token = this.createKeywordMapper(
  5709. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  5710. );
  5711. delete rule.defaultToken;
  5712. }
  5713. }
  5714. }
  5715. Object.keys(rules).forEach(processState, this);
  5716. };
  5717. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  5718. var keywords = Object.create(null);
  5719. Object.keys(map).forEach(function(className) {
  5720. var a = map[className];
  5721. if (ignoreCase)
  5722. a = a.toLowerCase();
  5723. var list = a.split(splitChar || "|");
  5724. for (var i = list.length; i--; )
  5725. keywords[list[i]] = className;
  5726. });
  5727. if (Object.getPrototypeOf(keywords)) {
  5728. keywords.__proto__ = null;
  5729. }
  5730. this.$keywordList = Object.keys(keywords);
  5731. map = null;
  5732. return ignoreCase
  5733. ? function(value) {return keywords[value.toLowerCase()] || defaultToken; }
  5734. : function(value) {return keywords[value] || defaultToken; };
  5735. };
  5736. this.getKeywords = function() {
  5737. return this.$keywords;
  5738. };
  5739. }).call(TextHighlightRules.prototype);
  5740. exports.TextHighlightRules = TextHighlightRules;
  5741. });
  5742. define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  5743. "use strict";
  5744. var Behaviour = function() {
  5745. this.$behaviours = {};
  5746. };
  5747. (function () {
  5748. this.add = function (name, action, callback) {
  5749. switch (undefined) {
  5750. case this.$behaviours:
  5751. this.$behaviours = {};
  5752. case this.$behaviours[name]:
  5753. this.$behaviours[name] = {};
  5754. }
  5755. this.$behaviours[name][action] = callback;
  5756. };
  5757. this.addBehaviours = function (behaviours) {
  5758. for (var key in behaviours) {
  5759. for (var action in behaviours[key]) {
  5760. this.add(key, action, behaviours[key][action]);
  5761. }
  5762. }
  5763. };
  5764. this.remove = function (name) {
  5765. if (this.$behaviours && this.$behaviours[name]) {
  5766. delete this.$behaviours[name];
  5767. }
  5768. };
  5769. this.inherit = function (mode, filter) {
  5770. if (typeof mode === "function") {
  5771. var behaviours = new mode().getBehaviours(filter);
  5772. } else {
  5773. var behaviours = mode.getBehaviours(filter);
  5774. }
  5775. this.addBehaviours(behaviours);
  5776. };
  5777. this.getBehaviours = function (filter) {
  5778. if (!filter) {
  5779. return this.$behaviours;
  5780. } else {
  5781. var ret = {};
  5782. for (var i = 0; i < filter.length; i++) {
  5783. if (this.$behaviours[filter[i]]) {
  5784. ret[filter[i]] = this.$behaviours[filter[i]];
  5785. }
  5786. }
  5787. return ret;
  5788. }
  5789. };
  5790. }).call(Behaviour.prototype);
  5791. exports.Behaviour = Behaviour;
  5792. });
  5793. define("ace/token_iterator",["require","exports","module","ace/range"], function(require, exports, module) {
  5794. "use strict";
  5795. var Range = require("./range").Range;
  5796. var TokenIterator = function(session, initialRow, initialColumn) {
  5797. this.$session = session;
  5798. this.$row = initialRow;
  5799. this.$rowTokens = session.getTokens(initialRow);
  5800. var token = session.getTokenAt(initialRow, initialColumn);
  5801. this.$tokenIndex = token ? token.index : -1;
  5802. };
  5803. (function() {
  5804. this.stepBackward = function() {
  5805. this.$tokenIndex -= 1;
  5806. while (this.$tokenIndex < 0) {
  5807. this.$row -= 1;
  5808. if (this.$row < 0) {
  5809. this.$row = 0;
  5810. return null;
  5811. }
  5812. this.$rowTokens = this.$session.getTokens(this.$row);
  5813. this.$tokenIndex = this.$rowTokens.length - 1;
  5814. }
  5815. return this.$rowTokens[this.$tokenIndex];
  5816. };
  5817. this.stepForward = function() {
  5818. this.$tokenIndex += 1;
  5819. var rowCount;
  5820. while (this.$tokenIndex >= this.$rowTokens.length) {
  5821. this.$row += 1;
  5822. if (!rowCount)
  5823. rowCount = this.$session.getLength();
  5824. if (this.$row >= rowCount) {
  5825. this.$row = rowCount - 1;
  5826. return null;
  5827. }
  5828. this.$rowTokens = this.$session.getTokens(this.$row);
  5829. this.$tokenIndex = 0;
  5830. }
  5831. return this.$rowTokens[this.$tokenIndex];
  5832. };
  5833. this.getCurrentToken = function () {
  5834. return this.$rowTokens[this.$tokenIndex];
  5835. };
  5836. this.getCurrentTokenRow = function () {
  5837. return this.$row;
  5838. };
  5839. this.getCurrentTokenColumn = function() {
  5840. var rowTokens = this.$rowTokens;
  5841. var tokenIndex = this.$tokenIndex;
  5842. var column = rowTokens[tokenIndex].start;
  5843. if (column !== undefined)
  5844. return column;
  5845. column = 0;
  5846. while (tokenIndex > 0) {
  5847. tokenIndex -= 1;
  5848. column += rowTokens[tokenIndex].value.length;
  5849. }
  5850. return column;
  5851. };
  5852. this.getCurrentTokenPosition = function() {
  5853. return {row: this.$row, column: this.getCurrentTokenColumn()};
  5854. };
  5855. this.getCurrentTokenRange = function() {
  5856. var token = this.$rowTokens[this.$tokenIndex];
  5857. var column = this.getCurrentTokenColumn();
  5858. return new Range(this.$row, column, this.$row, column + token.value.length);
  5859. };
  5860. }).call(TokenIterator.prototype);
  5861. exports.TokenIterator = TokenIterator;
  5862. });
  5863. define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  5864. "use strict";
  5865. var oop = require("../../lib/oop");
  5866. var Behaviour = require("../behaviour").Behaviour;
  5867. var TokenIterator = require("../../token_iterator").TokenIterator;
  5868. var lang = require("../../lib/lang");
  5869. var SAFE_INSERT_IN_TOKENS =
  5870. ["text", "paren.rparen", "punctuation.operator"];
  5871. var SAFE_INSERT_BEFORE_TOKENS =
  5872. ["text", "paren.rparen", "punctuation.operator", "comment"];
  5873. var context;
  5874. var contextCache = {};
  5875. var defaultQuotes = {'"' : '"', "'" : "'"};
  5876. var initContext = function(editor) {
  5877. var id = -1;
  5878. if (editor.multiSelect) {
  5879. id = editor.selection.index;
  5880. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  5881. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  5882. }
  5883. if (contextCache[id])
  5884. return context = contextCache[id];
  5885. context = contextCache[id] = {
  5886. autoInsertedBrackets: 0,
  5887. autoInsertedRow: -1,
  5888. autoInsertedLineEnd: "",
  5889. maybeInsertedBrackets: 0,
  5890. maybeInsertedRow: -1,
  5891. maybeInsertedLineStart: "",
  5892. maybeInsertedLineEnd: ""
  5893. };
  5894. };
  5895. var getWrapped = function(selection, selected, opening, closing) {
  5896. var rowDiff = selection.end.row - selection.start.row;
  5897. return {
  5898. text: opening + selected + closing,
  5899. selection: [
  5900. 0,
  5901. selection.start.column + 1,
  5902. rowDiff,
  5903. selection.end.column + (rowDiff ? 0 : 1)
  5904. ]
  5905. };
  5906. };
  5907. var CstyleBehaviour = function(options) {
  5908. this.add("braces", "insertion", function(state, action, editor, session, text) {
  5909. var cursor = editor.getCursorPosition();
  5910. var line = session.doc.getLine(cursor.row);
  5911. if (text == '{') {
  5912. initContext(editor);
  5913. var selection = editor.getSelectionRange();
  5914. var selected = session.doc.getTextRange(selection);
  5915. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  5916. return getWrapped(selection, selected, '{', '}');
  5917. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  5918. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options && options.braces) {
  5919. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  5920. return {
  5921. text: '{}',
  5922. selection: [1, 1]
  5923. };
  5924. } else {
  5925. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  5926. return {
  5927. text: '{',
  5928. selection: [1, 1]
  5929. };
  5930. }
  5931. }
  5932. } else if (text == '}') {
  5933. initContext(editor);
  5934. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5935. if (rightChar == '}') {
  5936. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  5937. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  5938. CstyleBehaviour.popAutoInsertedClosing();
  5939. return {
  5940. text: '',
  5941. selection: [1, 1]
  5942. };
  5943. }
  5944. }
  5945. } else if (text == "\n" || text == "\r\n") {
  5946. initContext(editor);
  5947. var closing = "";
  5948. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  5949. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  5950. CstyleBehaviour.clearMaybeInsertedClosing();
  5951. }
  5952. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5953. if (rightChar === '}') {
  5954. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  5955. if (!openBracePos)
  5956. return null;
  5957. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  5958. } else if (closing) {
  5959. var next_indent = this.$getIndent(line);
  5960. } else {
  5961. CstyleBehaviour.clearMaybeInsertedClosing();
  5962. return;
  5963. }
  5964. var indent = next_indent + session.getTabString();
  5965. return {
  5966. text: '\n' + indent + '\n' + next_indent + closing,
  5967. selection: [1, indent.length, 1, indent.length]
  5968. };
  5969. } else {
  5970. CstyleBehaviour.clearMaybeInsertedClosing();
  5971. }
  5972. });
  5973. this.add("braces", "deletion", function(state, action, editor, session, range) {
  5974. var selected = session.doc.getTextRange(range);
  5975. if (!range.isMultiLine() && selected == '{') {
  5976. initContext(editor);
  5977. var line = session.doc.getLine(range.start.row);
  5978. var rightChar = line.substring(range.end.column, range.end.column + 1);
  5979. if (rightChar == '}') {
  5980. range.end.column++;
  5981. return range;
  5982. } else {
  5983. context.maybeInsertedBrackets--;
  5984. }
  5985. }
  5986. });
  5987. this.add("parens", "insertion", function(state, action, editor, session, text) {
  5988. if (text == '(') {
  5989. initContext(editor);
  5990. var selection = editor.getSelectionRange();
  5991. var selected = session.doc.getTextRange(selection);
  5992. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  5993. return getWrapped(selection, selected, '(', ')');
  5994. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  5995. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  5996. return {
  5997. text: '()',
  5998. selection: [1, 1]
  5999. };
  6000. }
  6001. } else if (text == ')') {
  6002. initContext(editor);
  6003. var cursor = editor.getCursorPosition();
  6004. var line = session.doc.getLine(cursor.row);
  6005. var rightChar = line.substring(cursor.column, cursor.column + 1);
  6006. if (rightChar == ')') {
  6007. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  6008. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  6009. CstyleBehaviour.popAutoInsertedClosing();
  6010. return {
  6011. text: '',
  6012. selection: [1, 1]
  6013. };
  6014. }
  6015. }
  6016. }
  6017. });
  6018. this.add("parens", "deletion", function(state, action, editor, session, range) {
  6019. var selected = session.doc.getTextRange(range);
  6020. if (!range.isMultiLine() && selected == '(') {
  6021. initContext(editor);
  6022. var line = session.doc.getLine(range.start.row);
  6023. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  6024. if (rightChar == ')') {
  6025. range.end.column++;
  6026. return range;
  6027. }
  6028. }
  6029. });
  6030. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  6031. if (text == '[') {
  6032. initContext(editor);
  6033. var selection = editor.getSelectionRange();
  6034. var selected = session.doc.getTextRange(selection);
  6035. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  6036. return getWrapped(selection, selected, '[', ']');
  6037. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  6038. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  6039. return {
  6040. text: '[]',
  6041. selection: [1, 1]
  6042. };
  6043. }
  6044. } else if (text == ']') {
  6045. initContext(editor);
  6046. var cursor = editor.getCursorPosition();
  6047. var line = session.doc.getLine(cursor.row);
  6048. var rightChar = line.substring(cursor.column, cursor.column + 1);
  6049. if (rightChar == ']') {
  6050. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  6051. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  6052. CstyleBehaviour.popAutoInsertedClosing();
  6053. return {
  6054. text: '',
  6055. selection: [1, 1]
  6056. };
  6057. }
  6058. }
  6059. }
  6060. });
  6061. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  6062. var selected = session.doc.getTextRange(range);
  6063. if (!range.isMultiLine() && selected == '[') {
  6064. initContext(editor);
  6065. var line = session.doc.getLine(range.start.row);
  6066. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  6067. if (rightChar == ']') {
  6068. range.end.column++;
  6069. return range;
  6070. }
  6071. }
  6072. });
  6073. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  6074. var quotes = session.$mode.$quotes || defaultQuotes;
  6075. if (text.length == 1 && quotes[text]) {
  6076. if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1)
  6077. return;
  6078. initContext(editor);
  6079. var quote = text;
  6080. var selection = editor.getSelectionRange();
  6081. var selected = session.doc.getTextRange(selection);
  6082. if (selected !== "" && (selected.length != 1 || !quotes[selected]) && editor.getWrapBehavioursEnabled()) {
  6083. return getWrapped(selection, selected, quote, quote);
  6084. } else if (!selected) {
  6085. var cursor = editor.getCursorPosition();
  6086. var line = session.doc.getLine(cursor.row);
  6087. var leftChar = line.substring(cursor.column-1, cursor.column);
  6088. var rightChar = line.substring(cursor.column, cursor.column + 1);
  6089. var token = session.getTokenAt(cursor.row, cursor.column);
  6090. var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
  6091. if (leftChar == "\\" && token && /escape/.test(token.type))
  6092. return null;
  6093. var stringBefore = token && /string|escape/.test(token.type);
  6094. var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
  6095. var pair;
  6096. if (rightChar == quote) {
  6097. pair = stringBefore !== stringAfter;
  6098. if (pair && /string\.end/.test(rightToken.type))
  6099. pair = false;
  6100. } else {
  6101. if (stringBefore && !stringAfter)
  6102. return null; // wrap string with different quote
  6103. if (stringBefore && stringAfter)
  6104. return null; // do not pair quotes inside strings
  6105. var wordRe = session.$mode.tokenRe;
  6106. wordRe.lastIndex = 0;
  6107. var isWordBefore = wordRe.test(leftChar);
  6108. wordRe.lastIndex = 0;
  6109. var isWordAfter = wordRe.test(leftChar);
  6110. if (isWordBefore || isWordAfter)
  6111. return null; // before or after alphanumeric
  6112. if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
  6113. return null; // there is rightChar and it isn't closing
  6114. pair = true;
  6115. }
  6116. return {
  6117. text: pair ? quote + quote : "",
  6118. selection: [1,1]
  6119. };
  6120. }
  6121. }
  6122. });
  6123. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  6124. var selected = session.doc.getTextRange(range);
  6125. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  6126. initContext(editor);
  6127. var line = session.doc.getLine(range.start.row);
  6128. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  6129. if (rightChar == selected) {
  6130. range.end.column++;
  6131. return range;
  6132. }
  6133. }
  6134. });
  6135. };
  6136. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  6137. var cursor = editor.getCursorPosition();
  6138. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  6139. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  6140. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  6141. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  6142. return false;
  6143. }
  6144. iterator.stepForward();
  6145. return iterator.getCurrentTokenRow() !== cursor.row ||
  6146. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  6147. };
  6148. CstyleBehaviour.$matchTokenType = function(token, types) {
  6149. return types.indexOf(token.type || token) > -1;
  6150. };
  6151. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  6152. var cursor = editor.getCursorPosition();
  6153. var line = session.doc.getLine(cursor.row);
  6154. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  6155. context.autoInsertedBrackets = 0;
  6156. context.autoInsertedRow = cursor.row;
  6157. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  6158. context.autoInsertedBrackets++;
  6159. };
  6160. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  6161. var cursor = editor.getCursorPosition();
  6162. var line = session.doc.getLine(cursor.row);
  6163. if (!this.isMaybeInsertedClosing(cursor, line))
  6164. context.maybeInsertedBrackets = 0;
  6165. context.maybeInsertedRow = cursor.row;
  6166. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  6167. context.maybeInsertedLineEnd = line.substr(cursor.column);
  6168. context.maybeInsertedBrackets++;
  6169. };
  6170. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  6171. return context.autoInsertedBrackets > 0 &&
  6172. cursor.row === context.autoInsertedRow &&
  6173. bracket === context.autoInsertedLineEnd[0] &&
  6174. line.substr(cursor.column) === context.autoInsertedLineEnd;
  6175. };
  6176. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  6177. return context.maybeInsertedBrackets > 0 &&
  6178. cursor.row === context.maybeInsertedRow &&
  6179. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  6180. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  6181. };
  6182. CstyleBehaviour.popAutoInsertedClosing = function() {
  6183. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  6184. context.autoInsertedBrackets--;
  6185. };
  6186. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  6187. if (context) {
  6188. context.maybeInsertedBrackets = 0;
  6189. context.maybeInsertedRow = -1;
  6190. }
  6191. };
  6192. oop.inherits(CstyleBehaviour, Behaviour);
  6193. exports.CstyleBehaviour = CstyleBehaviour;
  6194. });
  6195. define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  6196. "use strict";
  6197. exports.packages = {};
  6198. addUnicodePackage({
  6199. 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",
  6200. 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",
  6201. 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",
  6202. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  6203. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  6204. 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",
  6205. 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",
  6206. 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",
  6207. 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",
  6208. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  6209. 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",
  6210. 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",
  6211. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  6212. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  6213. 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",
  6214. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  6215. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  6216. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  6217. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  6218. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  6219. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  6220. 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",
  6221. 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",
  6222. 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",
  6223. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  6224. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  6225. 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",
  6226. Z: "002000A01680180E2000-200A20282029202F205F3000",
  6227. Zs: "002000A01680180E2000-200A202F205F3000",
  6228. Zl: "2028",
  6229. Zp: "2029",
  6230. 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",
  6231. Cc: "0000-001F007F-009F",
  6232. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  6233. Co: "E000-F8FF",
  6234. Cs: "D800-DFFF",
  6235. 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"
  6236. });
  6237. function addUnicodePackage (pack) {
  6238. var codePoint = /\w{4}/g;
  6239. for (var name in pack)
  6240. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  6241. }
  6242. });
  6243. define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
  6244. "use strict";
  6245. var Tokenizer = require("../tokenizer").Tokenizer;
  6246. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  6247. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  6248. var unicode = require("../unicode");
  6249. var lang = require("../lib/lang");
  6250. var TokenIterator = require("../token_iterator").TokenIterator;
  6251. var Range = require("../range").Range;
  6252. var Mode = function() {
  6253. this.HighlightRules = TextHighlightRules;
  6254. };
  6255. (function() {
  6256. this.$defaultBehaviour = new CstyleBehaviour();
  6257. this.tokenRe = new RegExp("^["
  6258. + unicode.packages.L
  6259. + unicode.packages.Mn + unicode.packages.Mc
  6260. + unicode.packages.Nd
  6261. + unicode.packages.Pc + "\\$_]+", "g"
  6262. );
  6263. this.nonTokenRe = new RegExp("^(?:[^"
  6264. + unicode.packages.L
  6265. + unicode.packages.Mn + unicode.packages.Mc
  6266. + unicode.packages.Nd
  6267. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  6268. );
  6269. this.getTokenizer = function() {
  6270. if (!this.$tokenizer) {
  6271. this.$highlightRules = this.$highlightRules || new this.HighlightRules(this.$highlightRuleConfig);
  6272. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  6273. }
  6274. return this.$tokenizer;
  6275. };
  6276. this.lineCommentStart = "";
  6277. this.blockComment = "";
  6278. this.toggleCommentLines = function(state, session, startRow, endRow) {
  6279. var doc = session.doc;
  6280. var ignoreBlankLines = true;
  6281. var shouldRemove = true;
  6282. var minIndent = Infinity;
  6283. var tabSize = session.getTabSize();
  6284. var insertAtTabStop = false;
  6285. if (!this.lineCommentStart) {
  6286. if (!this.blockComment)
  6287. return false;
  6288. var lineCommentStart = this.blockComment.start;
  6289. var lineCommentEnd = this.blockComment.end;
  6290. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  6291. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  6292. var comment = function(line, i) {
  6293. if (testRemove(line, i))
  6294. return;
  6295. if (!ignoreBlankLines || /\S/.test(line)) {
  6296. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  6297. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  6298. }
  6299. };
  6300. var uncomment = function(line, i) {
  6301. var m;
  6302. if (m = line.match(regexpEnd))
  6303. doc.removeInLine(i, line.length - m[0].length, line.length);
  6304. if (m = line.match(regexpStart))
  6305. doc.removeInLine(i, m[1].length, m[0].length);
  6306. };
  6307. var testRemove = function(line, row) {
  6308. if (regexpStart.test(line))
  6309. return true;
  6310. var tokens = session.getTokens(row);
  6311. for (var i = 0; i < tokens.length; i++) {
  6312. if (tokens[i].type === "comment")
  6313. return true;
  6314. }
  6315. };
  6316. } else {
  6317. if (Array.isArray(this.lineCommentStart)) {
  6318. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  6319. var lineCommentStart = this.lineCommentStart[0];
  6320. } else {
  6321. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  6322. var lineCommentStart = this.lineCommentStart;
  6323. }
  6324. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  6325. insertAtTabStop = session.getUseSoftTabs();
  6326. var uncomment = function(line, i) {
  6327. var m = line.match(regexpStart);
  6328. if (!m) return;
  6329. var start = m[1].length, end = m[0].length;
  6330. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  6331. end--;
  6332. doc.removeInLine(i, start, end);
  6333. };
  6334. var commentWithSpace = lineCommentStart + " ";
  6335. var comment = function(line, i) {
  6336. if (!ignoreBlankLines || /\S/.test(line)) {
  6337. if (shouldInsertSpace(line, minIndent, minIndent))
  6338. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  6339. else
  6340. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  6341. }
  6342. };
  6343. var testRemove = function(line, i) {
  6344. return regexpStart.test(line);
  6345. };
  6346. var shouldInsertSpace = function(line, before, after) {
  6347. var spaces = 0;
  6348. while (before-- && line.charAt(before) == " ")
  6349. spaces++;
  6350. if (spaces % tabSize != 0)
  6351. return false;
  6352. var spaces = 0;
  6353. while (line.charAt(after++) == " ")
  6354. spaces++;
  6355. if (tabSize > 2)
  6356. return spaces % tabSize != tabSize - 1;
  6357. else
  6358. return spaces % tabSize == 0;
  6359. return true;
  6360. };
  6361. }
  6362. function iter(fun) {
  6363. for (var i = startRow; i <= endRow; i++)
  6364. fun(doc.getLine(i), i);
  6365. }
  6366. var minEmptyLength = Infinity;
  6367. iter(function(line, i) {
  6368. var indent = line.search(/\S/);
  6369. if (indent !== -1) {
  6370. if (indent < minIndent)
  6371. minIndent = indent;
  6372. if (shouldRemove && !testRemove(line, i))
  6373. shouldRemove = false;
  6374. } else if (minEmptyLength > line.length) {
  6375. minEmptyLength = line.length;
  6376. }
  6377. });
  6378. if (minIndent == Infinity) {
  6379. minIndent = minEmptyLength;
  6380. ignoreBlankLines = false;
  6381. shouldRemove = false;
  6382. }
  6383. if (insertAtTabStop && minIndent % tabSize != 0)
  6384. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  6385. iter(shouldRemove ? uncomment : comment);
  6386. };
  6387. this.toggleBlockComment = function(state, session, range, cursor) {
  6388. var comment = this.blockComment;
  6389. if (!comment)
  6390. return;
  6391. if (!comment.start && comment[0])
  6392. comment = comment[0];
  6393. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  6394. var token = iterator.getCurrentToken();
  6395. var sel = session.selection;
  6396. var initialRange = session.selection.toOrientedRange();
  6397. var startRow, colDiff;
  6398. if (token && /comment/.test(token.type)) {
  6399. var startRange, endRange;
  6400. while (token && /comment/.test(token.type)) {
  6401. var i = token.value.indexOf(comment.start);
  6402. if (i != -1) {
  6403. var row = iterator.getCurrentTokenRow();
  6404. var column = iterator.getCurrentTokenColumn() + i;
  6405. startRange = new Range(row, column, row, column + comment.start.length);
  6406. break;
  6407. }
  6408. token = iterator.stepBackward();
  6409. }
  6410. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  6411. var token = iterator.getCurrentToken();
  6412. while (token && /comment/.test(token.type)) {
  6413. var i = token.value.indexOf(comment.end);
  6414. if (i != -1) {
  6415. var row = iterator.getCurrentTokenRow();
  6416. var column = iterator.getCurrentTokenColumn() + i;
  6417. endRange = new Range(row, column, row, column + comment.end.length);
  6418. break;
  6419. }
  6420. token = iterator.stepForward();
  6421. }
  6422. if (endRange)
  6423. session.remove(endRange);
  6424. if (startRange) {
  6425. session.remove(startRange);
  6426. startRow = startRange.start.row;
  6427. colDiff = -comment.start.length;
  6428. }
  6429. } else {
  6430. colDiff = comment.start.length;
  6431. startRow = range.start.row;
  6432. session.insert(range.end, comment.end);
  6433. session.insert(range.start, comment.start);
  6434. }
  6435. if (initialRange.start.row == startRow)
  6436. initialRange.start.column += colDiff;
  6437. if (initialRange.end.row == startRow)
  6438. initialRange.end.column += colDiff;
  6439. session.selection.fromOrientedRange(initialRange);
  6440. };
  6441. this.getNextLineIndent = function(state, line, tab) {
  6442. return this.$getIndent(line);
  6443. };
  6444. this.checkOutdent = function(state, line, input) {
  6445. return false;
  6446. };
  6447. this.autoOutdent = function(state, doc, row) {
  6448. };
  6449. this.$getIndent = function(line) {
  6450. return line.match(/^\s*/)[0];
  6451. };
  6452. this.createWorker = function(session) {
  6453. return null;
  6454. };
  6455. this.createModeDelegates = function (mapping) {
  6456. this.$embeds = [];
  6457. this.$modes = {};
  6458. for (var i in mapping) {
  6459. if (mapping[i]) {
  6460. this.$embeds.push(i);
  6461. this.$modes[i] = new mapping[i]();
  6462. }
  6463. }
  6464. var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent",
  6465. "checkOutdent", "autoOutdent", "transformAction", "getCompletions"];
  6466. for (var i = 0; i < delegations.length; i++) {
  6467. (function(scope) {
  6468. var functionName = delegations[i];
  6469. var defaultHandler = scope[functionName];
  6470. scope[delegations[i]] = function() {
  6471. return this.$delegator(functionName, arguments, defaultHandler);
  6472. };
  6473. }(this));
  6474. }
  6475. };
  6476. this.$delegator = function(method, args, defaultHandler) {
  6477. var state = args[0];
  6478. if (typeof state != "string")
  6479. state = state[0];
  6480. for (var i = 0; i < this.$embeds.length; i++) {
  6481. if (!this.$modes[this.$embeds[i]]) continue;
  6482. var split = state.split(this.$embeds[i]);
  6483. if (!split[0] && split[1]) {
  6484. args[0] = split[1];
  6485. var mode = this.$modes[this.$embeds[i]];
  6486. return mode[method].apply(mode, args);
  6487. }
  6488. }
  6489. var ret = defaultHandler.apply(this, args);
  6490. return defaultHandler ? ret : undefined;
  6491. };
  6492. this.transformAction = function(state, action, editor, session, param) {
  6493. if (this.$behaviour) {
  6494. var behaviours = this.$behaviour.getBehaviours();
  6495. for (var key in behaviours) {
  6496. if (behaviours[key][action]) {
  6497. var ret = behaviours[key][action].apply(this, arguments);
  6498. if (ret) {
  6499. return ret;
  6500. }
  6501. }
  6502. }
  6503. }
  6504. };
  6505. this.getKeywords = function(append) {
  6506. if (!this.completionKeywords) {
  6507. var rules = this.$tokenizer.rules;
  6508. var completionKeywords = [];
  6509. for (var rule in rules) {
  6510. var ruleItr = rules[rule];
  6511. for (var r = 0, l = ruleItr.length; r < l; r++) {
  6512. if (typeof ruleItr[r].token === "string") {
  6513. if (/keyword|support|storage/.test(ruleItr[r].token))
  6514. completionKeywords.push(ruleItr[r].regex);
  6515. }
  6516. else if (typeof ruleItr[r].token === "object") {
  6517. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  6518. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  6519. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  6520. completionKeywords.push(rule.substr(1, rule.length - 2));
  6521. }
  6522. }
  6523. }
  6524. }
  6525. }
  6526. this.completionKeywords = completionKeywords;
  6527. }
  6528. if (!append)
  6529. return this.$keywordList;
  6530. return completionKeywords.concat(this.$keywordList || []);
  6531. };
  6532. this.$createKeywordList = function() {
  6533. if (!this.$highlightRules)
  6534. this.getTokenizer();
  6535. return this.$keywordList = this.$highlightRules.$keywordList || [];
  6536. };
  6537. this.getCompletions = function(state, session, pos, prefix) {
  6538. var keywords = this.$keywordList || this.$createKeywordList();
  6539. return keywords.map(function(word) {
  6540. return {
  6541. name: word,
  6542. value: word,
  6543. score: 0,
  6544. meta: "keyword"
  6545. };
  6546. });
  6547. };
  6548. this.$id = "ace/mode/text";
  6549. }).call(Mode.prototype);
  6550. exports.Mode = Mode;
  6551. });
  6552. define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  6553. "use strict";
  6554. function throwDeltaError(delta, errorText){
  6555. console.log("Invalid Delta:", delta);
  6556. throw "Invalid Delta: " + errorText;
  6557. }
  6558. function positionInDocument(docLines, position) {
  6559. return position.row >= 0 && position.row < docLines.length &&
  6560. position.column >= 0 && position.column <= docLines[position.row].length;
  6561. }
  6562. function validateDelta(docLines, delta) {
  6563. if (delta.action != "insert" && delta.action != "remove")
  6564. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  6565. if (!(delta.lines instanceof Array))
  6566. throwDeltaError(delta, "delta.lines must be an Array");
  6567. if (!delta.start || !delta.end)
  6568. throwDeltaError(delta, "delta.start/end must be an present");
  6569. var start = delta.start;
  6570. if (!positionInDocument(docLines, delta.start))
  6571. throwDeltaError(delta, "delta.start must be contained in document");
  6572. var end = delta.end;
  6573. if (delta.action == "remove" && !positionInDocument(docLines, end))
  6574. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  6575. var numRangeRows = end.row - start.row;
  6576. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  6577. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  6578. throwDeltaError(delta, "delta.range must match delta lines");
  6579. }
  6580. exports.applyDelta = function(docLines, delta, doNotValidate) {
  6581. var row = delta.start.row;
  6582. var startColumn = delta.start.column;
  6583. var line = docLines[row] || "";
  6584. switch (delta.action) {
  6585. case "insert":
  6586. var lines = delta.lines;
  6587. if (lines.length === 1) {
  6588. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  6589. } else {
  6590. var args = [row, 1].concat(delta.lines);
  6591. docLines.splice.apply(docLines, args);
  6592. docLines[row] = line.substring(0, startColumn) + docLines[row];
  6593. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  6594. }
  6595. break;
  6596. case "remove":
  6597. var endColumn = delta.end.column;
  6598. var endRow = delta.end.row;
  6599. if (row === endRow) {
  6600. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  6601. } else {
  6602. docLines.splice(
  6603. row, endRow - row + 1,
  6604. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  6605. );
  6606. }
  6607. break;
  6608. }
  6609. };
  6610. });
  6611. define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  6612. "use strict";
  6613. var oop = require("./lib/oop");
  6614. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  6615. var Anchor = exports.Anchor = function(doc, row, column) {
  6616. this.$onChange = this.onChange.bind(this);
  6617. this.attach(doc);
  6618. if (typeof column == "undefined")
  6619. this.setPosition(row.row, row.column);
  6620. else
  6621. this.setPosition(row, column);
  6622. };
  6623. (function() {
  6624. oop.implement(this, EventEmitter);
  6625. this.getPosition = function() {
  6626. return this.$clipPositionToDocument(this.row, this.column);
  6627. };
  6628. this.getDocument = function() {
  6629. return this.document;
  6630. };
  6631. this.$insertRight = false;
  6632. this.onChange = function(delta) {
  6633. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  6634. return;
  6635. if (delta.start.row > this.row)
  6636. return;
  6637. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  6638. this.setPosition(point.row, point.column, true);
  6639. };
  6640. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  6641. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  6642. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  6643. }
  6644. function $getTransformedPoint(delta, point, moveIfEqual) {
  6645. var deltaIsInsert = delta.action == "insert";
  6646. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  6647. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  6648. var deltaStart = delta.start;
  6649. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  6650. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  6651. return {
  6652. row: point.row,
  6653. column: point.column
  6654. };
  6655. }
  6656. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  6657. return {
  6658. row: point.row + deltaRowShift,
  6659. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  6660. };
  6661. }
  6662. return {
  6663. row: deltaStart.row,
  6664. column: deltaStart.column
  6665. };
  6666. }
  6667. this.setPosition = function(row, column, noClip) {
  6668. var pos;
  6669. if (noClip) {
  6670. pos = {
  6671. row: row,
  6672. column: column
  6673. };
  6674. } else {
  6675. pos = this.$clipPositionToDocument(row, column);
  6676. }
  6677. if (this.row == pos.row && this.column == pos.column)
  6678. return;
  6679. var old = {
  6680. row: this.row,
  6681. column: this.column
  6682. };
  6683. this.row = pos.row;
  6684. this.column = pos.column;
  6685. this._signal("change", {
  6686. old: old,
  6687. value: pos
  6688. });
  6689. };
  6690. this.detach = function() {
  6691. this.document.removeEventListener("change", this.$onChange);
  6692. };
  6693. this.attach = function(doc) {
  6694. this.document = doc || this.document;
  6695. this.document.on("change", this.$onChange);
  6696. };
  6697. this.$clipPositionToDocument = function(row, column) {
  6698. var pos = {};
  6699. if (row >= this.document.getLength()) {
  6700. pos.row = Math.max(0, this.document.getLength() - 1);
  6701. pos.column = this.document.getLine(pos.row).length;
  6702. }
  6703. else if (row < 0) {
  6704. pos.row = 0;
  6705. pos.column = 0;
  6706. }
  6707. else {
  6708. pos.row = row;
  6709. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  6710. }
  6711. if (column < 0)
  6712. pos.column = 0;
  6713. return pos;
  6714. };
  6715. }).call(Anchor.prototype);
  6716. });
  6717. define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  6718. "use strict";
  6719. var oop = require("./lib/oop");
  6720. var applyDelta = require("./apply_delta").applyDelta;
  6721. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  6722. var Range = require("./range").Range;
  6723. var Anchor = require("./anchor").Anchor;
  6724. var Document = function(textOrLines) {
  6725. this.$lines = [""];
  6726. if (textOrLines.length === 0) {
  6727. this.$lines = [""];
  6728. } else if (Array.isArray(textOrLines)) {
  6729. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  6730. } else {
  6731. this.insert({row: 0, column:0}, textOrLines);
  6732. }
  6733. };
  6734. (function() {
  6735. oop.implement(this, EventEmitter);
  6736. this.setValue = function(text) {
  6737. var len = this.getLength() - 1;
  6738. this.remove(new Range(0, 0, len, this.getLine(len).length));
  6739. this.insert({row: 0, column: 0}, text);
  6740. };
  6741. this.getValue = function() {
  6742. return this.getAllLines().join(this.getNewLineCharacter());
  6743. };
  6744. this.createAnchor = function(row, column) {
  6745. return new Anchor(this, row, column);
  6746. };
  6747. if ("aaa".split(/a/).length === 0) {
  6748. this.$split = function(text) {
  6749. return text.replace(/\r\n|\r/g, "\n").split("\n");
  6750. };
  6751. } else {
  6752. this.$split = function(text) {
  6753. return text.split(/\r\n|\r|\n/);
  6754. };
  6755. }
  6756. this.$detectNewLine = function(text) {
  6757. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  6758. this.$autoNewLine = match ? match[1] : "\n";
  6759. this._signal("changeNewLineMode");
  6760. };
  6761. this.getNewLineCharacter = function() {
  6762. switch (this.$newLineMode) {
  6763. case "windows":
  6764. return "\r\n";
  6765. case "unix":
  6766. return "\n";
  6767. default:
  6768. return this.$autoNewLine || "\n";
  6769. }
  6770. };
  6771. this.$autoNewLine = "";
  6772. this.$newLineMode = "auto";
  6773. this.setNewLineMode = function(newLineMode) {
  6774. if (this.$newLineMode === newLineMode)
  6775. return;
  6776. this.$newLineMode = newLineMode;
  6777. this._signal("changeNewLineMode");
  6778. };
  6779. this.getNewLineMode = function() {
  6780. return this.$newLineMode;
  6781. };
  6782. this.isNewLine = function(text) {
  6783. return (text == "\r\n" || text == "\r" || text == "\n");
  6784. };
  6785. this.getLine = function(row) {
  6786. return this.$lines[row] || "";
  6787. };
  6788. this.getLines = function(firstRow, lastRow) {
  6789. return this.$lines.slice(firstRow, lastRow + 1);
  6790. };
  6791. this.getAllLines = function() {
  6792. return this.getLines(0, this.getLength());
  6793. };
  6794. this.getLength = function() {
  6795. return this.$lines.length;
  6796. };
  6797. this.getTextRange = function(range) {
  6798. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  6799. };
  6800. this.getLinesForRange = function(range) {
  6801. var lines;
  6802. if (range.start.row === range.end.row) {
  6803. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  6804. } else {
  6805. lines = this.getLines(range.start.row, range.end.row);
  6806. lines[0] = (lines[0] || "").substring(range.start.column);
  6807. var l = lines.length - 1;
  6808. if (range.end.row - range.start.row == l)
  6809. lines[l] = lines[l].substring(0, range.end.column);
  6810. }
  6811. return lines;
  6812. };
  6813. this.insertLines = function(row, lines) {
  6814. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  6815. return this.insertFullLines(row, lines);
  6816. };
  6817. this.removeLines = function(firstRow, lastRow) {
  6818. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  6819. return this.removeFullLines(firstRow, lastRow);
  6820. };
  6821. this.insertNewLine = function(position) {
  6822. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  6823. return this.insertMergedLines(position, ["", ""]);
  6824. };
  6825. this.insert = function(position, text) {
  6826. if (this.getLength() <= 1)
  6827. this.$detectNewLine(text);
  6828. return this.insertMergedLines(position, this.$split(text));
  6829. };
  6830. this.insertInLine = function(position, text) {
  6831. var start = this.clippedPos(position.row, position.column);
  6832. var end = this.pos(position.row, position.column + text.length);
  6833. this.applyDelta({
  6834. start: start,
  6835. end: end,
  6836. action: "insert",
  6837. lines: [text]
  6838. }, true);
  6839. return this.clonePos(end);
  6840. };
  6841. this.clippedPos = function(row, column) {
  6842. var length = this.getLength();
  6843. if (row === undefined) {
  6844. row = length;
  6845. } else if (row < 0) {
  6846. row = 0;
  6847. } else if (row >= length) {
  6848. row = length - 1;
  6849. column = undefined;
  6850. }
  6851. var line = this.getLine(row);
  6852. if (column == undefined)
  6853. column = line.length;
  6854. column = Math.min(Math.max(column, 0), line.length);
  6855. return {row: row, column: column};
  6856. };
  6857. this.clonePos = function(pos) {
  6858. return {row: pos.row, column: pos.column};
  6859. };
  6860. this.pos = function(row, column) {
  6861. return {row: row, column: column};
  6862. };
  6863. this.$clipPosition = function(position) {
  6864. var length = this.getLength();
  6865. if (position.row >= length) {
  6866. position.row = Math.max(0, length - 1);
  6867. position.column = this.getLine(length - 1).length;
  6868. } else {
  6869. position.row = Math.max(0, position.row);
  6870. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  6871. }
  6872. return position;
  6873. };
  6874. this.insertFullLines = function(row, lines) {
  6875. row = Math.min(Math.max(row, 0), this.getLength());
  6876. var column = 0;
  6877. if (row < this.getLength()) {
  6878. lines = lines.concat([""]);
  6879. column = 0;
  6880. } else {
  6881. lines = [""].concat(lines);
  6882. row--;
  6883. column = this.$lines[row].length;
  6884. }
  6885. this.insertMergedLines({row: row, column: column}, lines);
  6886. };
  6887. this.insertMergedLines = function(position, lines) {
  6888. var start = this.clippedPos(position.row, position.column);
  6889. var end = {
  6890. row: start.row + lines.length - 1,
  6891. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  6892. };
  6893. this.applyDelta({
  6894. start: start,
  6895. end: end,
  6896. action: "insert",
  6897. lines: lines
  6898. });
  6899. return this.clonePos(end);
  6900. };
  6901. this.remove = function(range) {
  6902. var start = this.clippedPos(range.start.row, range.start.column);
  6903. var end = this.clippedPos(range.end.row, range.end.column);
  6904. this.applyDelta({
  6905. start: start,
  6906. end: end,
  6907. action: "remove",
  6908. lines: this.getLinesForRange({start: start, end: end})
  6909. });
  6910. return this.clonePos(start);
  6911. };
  6912. this.removeInLine = function(row, startColumn, endColumn) {
  6913. var start = this.clippedPos(row, startColumn);
  6914. var end = this.clippedPos(row, endColumn);
  6915. this.applyDelta({
  6916. start: start,
  6917. end: end,
  6918. action: "remove",
  6919. lines: this.getLinesForRange({start: start, end: end})
  6920. }, true);
  6921. return this.clonePos(start);
  6922. };
  6923. this.removeFullLines = function(firstRow, lastRow) {
  6924. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  6925. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  6926. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  6927. var deleteLastNewLine = lastRow < this.getLength() - 1;
  6928. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  6929. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  6930. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  6931. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  6932. var range = new Range(startRow, startCol, endRow, endCol);
  6933. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  6934. this.applyDelta({
  6935. start: range.start,
  6936. end: range.end,
  6937. action: "remove",
  6938. lines: this.getLinesForRange(range)
  6939. });
  6940. return deletedLines;
  6941. };
  6942. this.removeNewLine = function(row) {
  6943. if (row < this.getLength() - 1 && row >= 0) {
  6944. this.applyDelta({
  6945. start: this.pos(row, this.getLine(row).length),
  6946. end: this.pos(row + 1, 0),
  6947. action: "remove",
  6948. lines: ["", ""]
  6949. });
  6950. }
  6951. };
  6952. this.replace = function(range, text) {
  6953. if (!(range instanceof Range))
  6954. range = Range.fromPoints(range.start, range.end);
  6955. if (text.length === 0 && range.isEmpty())
  6956. return range.start;
  6957. if (text == this.getTextRange(range))
  6958. return range.end;
  6959. this.remove(range);
  6960. var end;
  6961. if (text) {
  6962. end = this.insert(range.start, text);
  6963. }
  6964. else {
  6965. end = range.start;
  6966. }
  6967. return end;
  6968. };
  6969. this.applyDeltas = function(deltas) {
  6970. for (var i=0; i<deltas.length; i++) {
  6971. this.applyDelta(deltas[i]);
  6972. }
  6973. };
  6974. this.revertDeltas = function(deltas) {
  6975. for (var i=deltas.length-1; i>=0; i--) {
  6976. this.revertDelta(deltas[i]);
  6977. }
  6978. };
  6979. this.applyDelta = function(delta, doNotValidate) {
  6980. var isInsert = delta.action == "insert";
  6981. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  6982. : !Range.comparePoints(delta.start, delta.end)) {
  6983. return;
  6984. }
  6985. if (isInsert && delta.lines.length > 20000)
  6986. this.$splitAndapplyLargeDelta(delta, 20000);
  6987. applyDelta(this.$lines, delta, doNotValidate);
  6988. this._signal("change", delta);
  6989. };
  6990. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  6991. var lines = delta.lines;
  6992. var l = lines.length;
  6993. var row = delta.start.row;
  6994. var column = delta.start.column;
  6995. var from = 0, to = 0;
  6996. do {
  6997. from = to;
  6998. to += MAX - 1;
  6999. var chunk = lines.slice(from, to);
  7000. if (to > l) {
  7001. delta.lines = chunk;
  7002. delta.start.row = row + from;
  7003. delta.start.column = column;
  7004. break;
  7005. }
  7006. chunk.push("");
  7007. this.applyDelta({
  7008. start: this.pos(row + from, column),
  7009. end: this.pos(row + to, column = 0),
  7010. action: delta.action,
  7011. lines: chunk
  7012. }, true);
  7013. } while(true);
  7014. };
  7015. this.revertDelta = function(delta) {
  7016. this.applyDelta({
  7017. start: this.clonePos(delta.start),
  7018. end: this.clonePos(delta.end),
  7019. action: (delta.action == "insert" ? "remove" : "insert"),
  7020. lines: delta.lines.slice()
  7021. });
  7022. };
  7023. this.indexToPosition = function(index, startRow) {
  7024. var lines = this.$lines || this.getAllLines();
  7025. var newlineLength = this.getNewLineCharacter().length;
  7026. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  7027. index -= lines[i].length + newlineLength;
  7028. if (index < 0)
  7029. return {row: i, column: index + lines[i].length + newlineLength};
  7030. }
  7031. return {row: l-1, column: lines[l-1].length};
  7032. };
  7033. this.positionToIndex = function(pos, startRow) {
  7034. var lines = this.$lines || this.getAllLines();
  7035. var newlineLength = this.getNewLineCharacter().length;
  7036. var index = 0;
  7037. var row = Math.min(pos.row, lines.length);
  7038. for (var i = startRow || 0; i < row; ++i)
  7039. index += lines[i].length + newlineLength;
  7040. return index + pos.column;
  7041. };
  7042. }).call(Document.prototype);
  7043. exports.Document = Document;
  7044. });
  7045. define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  7046. "use strict";
  7047. var oop = require("./lib/oop");
  7048. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7049. var BackgroundTokenizer = function(tokenizer, editor) {
  7050. this.running = false;
  7051. this.lines = [];
  7052. this.states = [];
  7053. this.currentLine = 0;
  7054. this.tokenizer = tokenizer;
  7055. var self = this;
  7056. this.$worker = function() {
  7057. if (!self.running) { return; }
  7058. var workerStart = new Date();
  7059. var currentLine = self.currentLine;
  7060. var endLine = -1;
  7061. var doc = self.doc;
  7062. var startLine = currentLine;
  7063. while (self.lines[currentLine])
  7064. currentLine++;
  7065. var len = doc.getLength();
  7066. var processedLines = 0;
  7067. self.running = false;
  7068. while (currentLine < len) {
  7069. self.$tokenizeRow(currentLine);
  7070. endLine = currentLine;
  7071. do {
  7072. currentLine++;
  7073. } while (self.lines[currentLine]);
  7074. processedLines ++;
  7075. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  7076. self.running = setTimeout(self.$worker, 20);
  7077. break;
  7078. }
  7079. }
  7080. self.currentLine = currentLine;
  7081. if (endLine == -1)
  7082. endLine = currentLine;
  7083. if (startLine <= endLine)
  7084. self.fireUpdateEvent(startLine, endLine);
  7085. };
  7086. };
  7087. (function(){
  7088. oop.implement(this, EventEmitter);
  7089. this.setTokenizer = function(tokenizer) {
  7090. this.tokenizer = tokenizer;
  7091. this.lines = [];
  7092. this.states = [];
  7093. this.start(0);
  7094. };
  7095. this.setDocument = function(doc) {
  7096. this.doc = doc;
  7097. this.lines = [];
  7098. this.states = [];
  7099. this.stop();
  7100. };
  7101. this.fireUpdateEvent = function(firstRow, lastRow) {
  7102. var data = {
  7103. first: firstRow,
  7104. last: lastRow
  7105. };
  7106. this._signal("update", {data: data});
  7107. };
  7108. this.start = function(startRow) {
  7109. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  7110. this.lines.splice(this.currentLine, this.lines.length);
  7111. this.states.splice(this.currentLine, this.states.length);
  7112. this.stop();
  7113. this.running = setTimeout(this.$worker, 700);
  7114. };
  7115. this.scheduleStart = function() {
  7116. if (!this.running)
  7117. this.running = setTimeout(this.$worker, 700);
  7118. };
  7119. this.$updateOnChange = function(delta) {
  7120. var startRow = delta.start.row;
  7121. var len = delta.end.row - startRow;
  7122. if (len === 0) {
  7123. this.lines[startRow] = null;
  7124. } else if (delta.action == "remove") {
  7125. this.lines.splice(startRow, len + 1, null);
  7126. this.states.splice(startRow, len + 1, null);
  7127. } else {
  7128. var args = Array(len + 1);
  7129. args.unshift(startRow, 1);
  7130. this.lines.splice.apply(this.lines, args);
  7131. this.states.splice.apply(this.states, args);
  7132. }
  7133. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  7134. this.stop();
  7135. };
  7136. this.stop = function() {
  7137. if (this.running)
  7138. clearTimeout(this.running);
  7139. this.running = false;
  7140. };
  7141. this.getTokens = function(row) {
  7142. return this.lines[row] || this.$tokenizeRow(row);
  7143. };
  7144. this.getState = function(row) {
  7145. if (this.currentLine == row)
  7146. this.$tokenizeRow(row);
  7147. return this.states[row] || "start";
  7148. };
  7149. this.$tokenizeRow = function(row) {
  7150. var line = this.doc.getLine(row);
  7151. var state = this.states[row - 1];
  7152. var data = this.tokenizer.getLineTokens(line, state, row);
  7153. if (this.states[row] + "" !== data.state + "") {
  7154. this.states[row] = data.state;
  7155. this.lines[row + 1] = null;
  7156. if (this.currentLine > row + 1)
  7157. this.currentLine = row + 1;
  7158. } else if (this.currentLine == row) {
  7159. this.currentLine = row + 1;
  7160. }
  7161. return this.lines[row] = data.tokens;
  7162. };
  7163. }).call(BackgroundTokenizer.prototype);
  7164. exports.BackgroundTokenizer = BackgroundTokenizer;
  7165. });
  7166. define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  7167. "use strict";
  7168. var lang = require("./lib/lang");
  7169. var oop = require("./lib/oop");
  7170. var Range = require("./range").Range;
  7171. var SearchHighlight = function(regExp, clazz, type) {
  7172. this.setRegexp(regExp);
  7173. this.clazz = clazz;
  7174. this.type = type || "text";
  7175. };
  7176. (function() {
  7177. this.MAX_RANGES = 500;
  7178. this.setRegexp = function(regExp) {
  7179. if (this.regExp+"" == regExp+"")
  7180. return;
  7181. this.regExp = regExp;
  7182. this.cache = [];
  7183. };
  7184. this.update = function(html, markerLayer, session, config) {
  7185. if (!this.regExp)
  7186. return;
  7187. var start = config.firstRow, end = config.lastRow;
  7188. for (var i = start; i <= end; i++) {
  7189. var ranges = this.cache[i];
  7190. if (ranges == null) {
  7191. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  7192. if (ranges.length > this.MAX_RANGES)
  7193. ranges = ranges.slice(0, this.MAX_RANGES);
  7194. ranges = ranges.map(function(match) {
  7195. return new Range(i, match.offset, i, match.offset + match.length);
  7196. });
  7197. this.cache[i] = ranges.length ? ranges : "";
  7198. }
  7199. for (var j = ranges.length; j --; ) {
  7200. markerLayer.drawSingleLineMarker(
  7201. html, ranges[j].toScreenRange(session), this.clazz, config);
  7202. }
  7203. }
  7204. };
  7205. }).call(SearchHighlight.prototype);
  7206. exports.SearchHighlight = SearchHighlight;
  7207. });
  7208. define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  7209. "use strict";
  7210. var Range = require("../range").Range;
  7211. function FoldLine(foldData, folds) {
  7212. this.foldData = foldData;
  7213. if (Array.isArray(folds)) {
  7214. this.folds = folds;
  7215. } else {
  7216. folds = this.folds = [ folds ];
  7217. }
  7218. var last = folds[folds.length - 1];
  7219. this.range = new Range(folds[0].start.row, folds[0].start.column,
  7220. last.end.row, last.end.column);
  7221. this.start = this.range.start;
  7222. this.end = this.range.end;
  7223. this.folds.forEach(function(fold) {
  7224. fold.setFoldLine(this);
  7225. }, this);
  7226. }
  7227. (function() {
  7228. this.shiftRow = function(shift) {
  7229. this.start.row += shift;
  7230. this.end.row += shift;
  7231. this.folds.forEach(function(fold) {
  7232. fold.start.row += shift;
  7233. fold.end.row += shift;
  7234. });
  7235. };
  7236. this.addFold = function(fold) {
  7237. if (fold.sameRow) {
  7238. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  7239. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  7240. }
  7241. this.folds.push(fold);
  7242. this.folds.sort(function(a, b) {
  7243. return -a.range.compareEnd(b.start.row, b.start.column);
  7244. });
  7245. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  7246. this.end.row = fold.end.row;
  7247. this.end.column = fold.end.column;
  7248. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  7249. this.start.row = fold.start.row;
  7250. this.start.column = fold.start.column;
  7251. }
  7252. } else if (fold.start.row == this.end.row) {
  7253. this.folds.push(fold);
  7254. this.end.row = fold.end.row;
  7255. this.end.column = fold.end.column;
  7256. } else if (fold.end.row == this.start.row) {
  7257. this.folds.unshift(fold);
  7258. this.start.row = fold.start.row;
  7259. this.start.column = fold.start.column;
  7260. } else {
  7261. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  7262. }
  7263. fold.foldLine = this;
  7264. };
  7265. this.containsRow = function(row) {
  7266. return row >= this.start.row && row <= this.end.row;
  7267. };
  7268. this.walk = function(callback, endRow, endColumn) {
  7269. var lastEnd = 0,
  7270. folds = this.folds,
  7271. fold,
  7272. cmp, stop, isNewRow = true;
  7273. if (endRow == null) {
  7274. endRow = this.end.row;
  7275. endColumn = this.end.column;
  7276. }
  7277. for (var i = 0; i < folds.length; i++) {
  7278. fold = folds[i];
  7279. cmp = fold.range.compareStart(endRow, endColumn);
  7280. if (cmp == -1) {
  7281. callback(null, endRow, endColumn, lastEnd, isNewRow);
  7282. return;
  7283. }
  7284. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  7285. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  7286. if (stop || cmp === 0) {
  7287. return;
  7288. }
  7289. isNewRow = !fold.sameRow;
  7290. lastEnd = fold.end.column;
  7291. }
  7292. callback(null, endRow, endColumn, lastEnd, isNewRow);
  7293. };
  7294. this.getNextFoldTo = function(row, column) {
  7295. var fold, cmp;
  7296. for (var i = 0; i < this.folds.length; i++) {
  7297. fold = this.folds[i];
  7298. cmp = fold.range.compareEnd(row, column);
  7299. if (cmp == -1) {
  7300. return {
  7301. fold: fold,
  7302. kind: "after"
  7303. };
  7304. } else if (cmp === 0) {
  7305. return {
  7306. fold: fold,
  7307. kind: "inside"
  7308. };
  7309. }
  7310. }
  7311. return null;
  7312. };
  7313. this.addRemoveChars = function(row, column, len) {
  7314. var ret = this.getNextFoldTo(row, column),
  7315. fold, folds;
  7316. if (ret) {
  7317. fold = ret.fold;
  7318. if (ret.kind == "inside"
  7319. && fold.start.column != column
  7320. && fold.start.row != row)
  7321. {
  7322. window.console && window.console.log(row, column, fold);
  7323. } else if (fold.start.row == row) {
  7324. folds = this.folds;
  7325. var i = folds.indexOf(fold);
  7326. if (i === 0) {
  7327. this.start.column += len;
  7328. }
  7329. for (i; i < folds.length; i++) {
  7330. fold = folds[i];
  7331. fold.start.column += len;
  7332. if (!fold.sameRow) {
  7333. return;
  7334. }
  7335. fold.end.column += len;
  7336. }
  7337. this.end.column += len;
  7338. }
  7339. }
  7340. };
  7341. this.split = function(row, column) {
  7342. var pos = this.getNextFoldTo(row, column);
  7343. if (!pos || pos.kind == "inside")
  7344. return null;
  7345. var fold = pos.fold;
  7346. var folds = this.folds;
  7347. var foldData = this.foldData;
  7348. var i = folds.indexOf(fold);
  7349. var foldBefore = folds[i - 1];
  7350. this.end.row = foldBefore.end.row;
  7351. this.end.column = foldBefore.end.column;
  7352. folds = folds.splice(i, folds.length - i);
  7353. var newFoldLine = new FoldLine(foldData, folds);
  7354. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  7355. return newFoldLine;
  7356. };
  7357. this.merge = function(foldLineNext) {
  7358. var folds = foldLineNext.folds;
  7359. for (var i = 0; i < folds.length; i++) {
  7360. this.addFold(folds[i]);
  7361. }
  7362. var foldData = this.foldData;
  7363. foldData.splice(foldData.indexOf(foldLineNext), 1);
  7364. };
  7365. this.toString = function() {
  7366. var ret = [this.range.toString() + ": [" ];
  7367. this.folds.forEach(function(fold) {
  7368. ret.push(" " + fold.toString());
  7369. });
  7370. ret.push("]");
  7371. return ret.join("\n");
  7372. };
  7373. this.idxToPosition = function(idx) {
  7374. var lastFoldEndColumn = 0;
  7375. for (var i = 0; i < this.folds.length; i++) {
  7376. var fold = this.folds[i];
  7377. idx -= fold.start.column - lastFoldEndColumn;
  7378. if (idx < 0) {
  7379. return {
  7380. row: fold.start.row,
  7381. column: fold.start.column + idx
  7382. };
  7383. }
  7384. idx -= fold.placeholder.length;
  7385. if (idx < 0) {
  7386. return fold.start;
  7387. }
  7388. lastFoldEndColumn = fold.end.column;
  7389. }
  7390. return {
  7391. row: this.end.row,
  7392. column: this.end.column + idx
  7393. };
  7394. };
  7395. }).call(FoldLine.prototype);
  7396. exports.FoldLine = FoldLine;
  7397. });
  7398. define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  7399. "use strict";
  7400. var Range = require("./range").Range;
  7401. var comparePoints = Range.comparePoints;
  7402. var RangeList = function() {
  7403. this.ranges = [];
  7404. };
  7405. (function() {
  7406. this.comparePoints = comparePoints;
  7407. this.pointIndex = function(pos, excludeEdges, startIndex) {
  7408. var list = this.ranges;
  7409. for (var i = startIndex || 0; i < list.length; i++) {
  7410. var range = list[i];
  7411. var cmpEnd = comparePoints(pos, range.end);
  7412. if (cmpEnd > 0)
  7413. continue;
  7414. var cmpStart = comparePoints(pos, range.start);
  7415. if (cmpEnd === 0)
  7416. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  7417. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  7418. return i;
  7419. return -i-1;
  7420. }
  7421. return -i - 1;
  7422. };
  7423. this.add = function(range) {
  7424. var excludeEdges = !range.isEmpty();
  7425. var startIndex = this.pointIndex(range.start, excludeEdges);
  7426. if (startIndex < 0)
  7427. startIndex = -startIndex - 1;
  7428. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  7429. if (endIndex < 0)
  7430. endIndex = -endIndex - 1;
  7431. else
  7432. endIndex++;
  7433. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  7434. };
  7435. this.addList = function(list) {
  7436. var removed = [];
  7437. for (var i = list.length; i--; ) {
  7438. removed.push.apply(removed, this.add(list[i]));
  7439. }
  7440. return removed;
  7441. };
  7442. this.substractPoint = function(pos) {
  7443. var i = this.pointIndex(pos);
  7444. if (i >= 0)
  7445. return this.ranges.splice(i, 1);
  7446. };
  7447. this.merge = function() {
  7448. var removed = [];
  7449. var list = this.ranges;
  7450. list = list.sort(function(a, b) {
  7451. return comparePoints(a.start, b.start);
  7452. });
  7453. var next = list[0], range;
  7454. for (var i = 1; i < list.length; i++) {
  7455. range = next;
  7456. next = list[i];
  7457. var cmp = comparePoints(range.end, next.start);
  7458. if (cmp < 0)
  7459. continue;
  7460. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  7461. continue;
  7462. if (comparePoints(range.end, next.end) < 0) {
  7463. range.end.row = next.end.row;
  7464. range.end.column = next.end.column;
  7465. }
  7466. list.splice(i, 1);
  7467. removed.push(next);
  7468. next = range;
  7469. i--;
  7470. }
  7471. this.ranges = list;
  7472. return removed;
  7473. };
  7474. this.contains = function(row, column) {
  7475. return this.pointIndex({row: row, column: column}) >= 0;
  7476. };
  7477. this.containsPoint = function(pos) {
  7478. return this.pointIndex(pos) >= 0;
  7479. };
  7480. this.rangeAtPoint = function(pos) {
  7481. var i = this.pointIndex(pos);
  7482. if (i >= 0)
  7483. return this.ranges[i];
  7484. };
  7485. this.clipRows = function(startRow, endRow) {
  7486. var list = this.ranges;
  7487. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  7488. return [];
  7489. var startIndex = this.pointIndex({row: startRow, column: 0});
  7490. if (startIndex < 0)
  7491. startIndex = -startIndex - 1;
  7492. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  7493. if (endIndex < 0)
  7494. endIndex = -endIndex - 1;
  7495. var clipped = [];
  7496. for (var i = startIndex; i < endIndex; i++) {
  7497. clipped.push(list[i]);
  7498. }
  7499. return clipped;
  7500. };
  7501. this.removeAll = function() {
  7502. return this.ranges.splice(0, this.ranges.length);
  7503. };
  7504. this.attach = function(session) {
  7505. if (this.session)
  7506. this.detach();
  7507. this.session = session;
  7508. this.onChange = this.$onChange.bind(this);
  7509. this.session.on('change', this.onChange);
  7510. };
  7511. this.detach = function() {
  7512. if (!this.session)
  7513. return;
  7514. this.session.removeListener('change', this.onChange);
  7515. this.session = null;
  7516. };
  7517. this.$onChange = function(delta) {
  7518. if (delta.action == "insert"){
  7519. var start = delta.start;
  7520. var end = delta.end;
  7521. } else {
  7522. var end = delta.start;
  7523. var start = delta.end;
  7524. }
  7525. var startRow = start.row;
  7526. var endRow = end.row;
  7527. var lineDif = endRow - startRow;
  7528. var colDiff = -start.column + end.column;
  7529. var ranges = this.ranges;
  7530. for (var i = 0, n = ranges.length; i < n; i++) {
  7531. var r = ranges[i];
  7532. if (r.end.row < startRow)
  7533. continue;
  7534. if (r.start.row > startRow)
  7535. break;
  7536. if (r.start.row == startRow && r.start.column >= start.column ) {
  7537. if (r.start.column == start.column && this.$insertRight) {
  7538. } else {
  7539. r.start.column += colDiff;
  7540. r.start.row += lineDif;
  7541. }
  7542. }
  7543. if (r.end.row == startRow && r.end.column >= start.column) {
  7544. if (r.end.column == start.column && this.$insertRight) {
  7545. continue;
  7546. }
  7547. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  7548. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  7549. r.end.column -= colDiff;
  7550. }
  7551. r.end.column += colDiff;
  7552. r.end.row += lineDif;
  7553. }
  7554. }
  7555. if (lineDif != 0 && i < n) {
  7556. for (; i < n; i++) {
  7557. var r = ranges[i];
  7558. r.start.row += lineDif;
  7559. r.end.row += lineDif;
  7560. }
  7561. }
  7562. };
  7563. }).call(RangeList.prototype);
  7564. exports.RangeList = RangeList;
  7565. });
  7566. define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  7567. "use strict";
  7568. var Range = require("../range").Range;
  7569. var RangeList = require("../range_list").RangeList;
  7570. var oop = require("../lib/oop");
  7571. var Fold = exports.Fold = function(range, placeholder) {
  7572. this.foldLine = null;
  7573. this.placeholder = placeholder;
  7574. this.range = range;
  7575. this.start = range.start;
  7576. this.end = range.end;
  7577. this.sameRow = range.start.row == range.end.row;
  7578. this.subFolds = this.ranges = [];
  7579. };
  7580. oop.inherits(Fold, RangeList);
  7581. (function() {
  7582. this.toString = function() {
  7583. return '"' + this.placeholder + '" ' + this.range.toString();
  7584. };
  7585. this.setFoldLine = function(foldLine) {
  7586. this.foldLine = foldLine;
  7587. this.subFolds.forEach(function(fold) {
  7588. fold.setFoldLine(foldLine);
  7589. });
  7590. };
  7591. this.clone = function() {
  7592. var range = this.range.clone();
  7593. var fold = new Fold(range, this.placeholder);
  7594. this.subFolds.forEach(function(subFold) {
  7595. fold.subFolds.push(subFold.clone());
  7596. });
  7597. fold.collapseChildren = this.collapseChildren;
  7598. return fold;
  7599. };
  7600. this.addSubFold = function(fold) {
  7601. if (this.range.isEqual(fold))
  7602. return;
  7603. if (!this.range.containsRange(fold))
  7604. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  7605. consumeRange(fold, this.start);
  7606. var row = fold.start.row, column = fold.start.column;
  7607. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  7608. cmp = this.subFolds[i].range.compare(row, column);
  7609. if (cmp != 1)
  7610. break;
  7611. }
  7612. var afterStart = this.subFolds[i];
  7613. if (cmp == 0)
  7614. return afterStart.addSubFold(fold);
  7615. var row = fold.range.end.row, column = fold.range.end.column;
  7616. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  7617. cmp = this.subFolds[j].range.compare(row, column);
  7618. if (cmp != 1)
  7619. break;
  7620. }
  7621. var afterEnd = this.subFolds[j];
  7622. if (cmp == 0)
  7623. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  7624. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  7625. fold.setFoldLine(this.foldLine);
  7626. return fold;
  7627. };
  7628. this.restoreRange = function(range) {
  7629. return restoreRange(range, this.start);
  7630. };
  7631. }).call(Fold.prototype);
  7632. function consumePoint(point, anchor) {
  7633. point.row -= anchor.row;
  7634. if (point.row == 0)
  7635. point.column -= anchor.column;
  7636. }
  7637. function consumeRange(range, anchor) {
  7638. consumePoint(range.start, anchor);
  7639. consumePoint(range.end, anchor);
  7640. }
  7641. function restorePoint(point, anchor) {
  7642. if (point.row == 0)
  7643. point.column += anchor.column;
  7644. point.row += anchor.row;
  7645. }
  7646. function restoreRange(range, anchor) {
  7647. restorePoint(range.start, anchor);
  7648. restorePoint(range.end, anchor);
  7649. }
  7650. });
  7651. 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) {
  7652. "use strict";
  7653. var Range = require("../range").Range;
  7654. var FoldLine = require("./fold_line").FoldLine;
  7655. var Fold = require("./fold").Fold;
  7656. var TokenIterator = require("../token_iterator").TokenIterator;
  7657. function Folding() {
  7658. this.getFoldAt = function(row, column, side) {
  7659. var foldLine = this.getFoldLine(row);
  7660. if (!foldLine)
  7661. return null;
  7662. var folds = foldLine.folds;
  7663. for (var i = 0; i < folds.length; i++) {
  7664. var fold = folds[i];
  7665. if (fold.range.contains(row, column)) {
  7666. if (side == 1 && fold.range.isEnd(row, column)) {
  7667. continue;
  7668. } else if (side == -1 && fold.range.isStart(row, column)) {
  7669. continue;
  7670. }
  7671. return fold;
  7672. }
  7673. }
  7674. };
  7675. this.getFoldsInRange = function(range) {
  7676. var start = range.start;
  7677. var end = range.end;
  7678. var foldLines = this.$foldData;
  7679. var foundFolds = [];
  7680. start.column += 1;
  7681. end.column -= 1;
  7682. for (var i = 0; i < foldLines.length; i++) {
  7683. var cmp = foldLines[i].range.compareRange(range);
  7684. if (cmp == 2) {
  7685. continue;
  7686. }
  7687. else if (cmp == -2) {
  7688. break;
  7689. }
  7690. var folds = foldLines[i].folds;
  7691. for (var j = 0; j < folds.length; j++) {
  7692. var fold = folds[j];
  7693. cmp = fold.range.compareRange(range);
  7694. if (cmp == -2) {
  7695. break;
  7696. } else if (cmp == 2) {
  7697. continue;
  7698. } else
  7699. if (cmp == 42) {
  7700. break;
  7701. }
  7702. foundFolds.push(fold);
  7703. }
  7704. }
  7705. start.column -= 1;
  7706. end.column += 1;
  7707. return foundFolds;
  7708. };
  7709. this.getFoldsInRangeList = function(ranges) {
  7710. if (Array.isArray(ranges)) {
  7711. var folds = [];
  7712. ranges.forEach(function(range) {
  7713. folds = folds.concat(this.getFoldsInRange(range));
  7714. }, this);
  7715. } else {
  7716. var folds = this.getFoldsInRange(ranges);
  7717. }
  7718. return folds;
  7719. };
  7720. this.getAllFolds = function() {
  7721. var folds = [];
  7722. var foldLines = this.$foldData;
  7723. for (var i = 0; i < foldLines.length; i++)
  7724. for (var j = 0; j < foldLines[i].folds.length; j++)
  7725. folds.push(foldLines[i].folds[j]);
  7726. return folds;
  7727. };
  7728. this.getFoldStringAt = function(row, column, trim, foldLine) {
  7729. foldLine = foldLine || this.getFoldLine(row);
  7730. if (!foldLine)
  7731. return null;
  7732. var lastFold = {
  7733. end: { column: 0 }
  7734. };
  7735. var str, fold;
  7736. for (var i = 0; i < foldLine.folds.length; i++) {
  7737. fold = foldLine.folds[i];
  7738. var cmp = fold.range.compareEnd(row, column);
  7739. if (cmp == -1) {
  7740. str = this
  7741. .getLine(fold.start.row)
  7742. .substring(lastFold.end.column, fold.start.column);
  7743. break;
  7744. }
  7745. else if (cmp === 0) {
  7746. return null;
  7747. }
  7748. lastFold = fold;
  7749. }
  7750. if (!str)
  7751. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  7752. if (trim == -1)
  7753. return str.substring(0, column - lastFold.end.column);
  7754. else if (trim == 1)
  7755. return str.substring(column - lastFold.end.column);
  7756. else
  7757. return str;
  7758. };
  7759. this.getFoldLine = function(docRow, startFoldLine) {
  7760. var foldData = this.$foldData;
  7761. var i = 0;
  7762. if (startFoldLine)
  7763. i = foldData.indexOf(startFoldLine);
  7764. if (i == -1)
  7765. i = 0;
  7766. for (i; i < foldData.length; i++) {
  7767. var foldLine = foldData[i];
  7768. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  7769. return foldLine;
  7770. } else if (foldLine.end.row > docRow) {
  7771. return null;
  7772. }
  7773. }
  7774. return null;
  7775. };
  7776. this.getNextFoldLine = function(docRow, startFoldLine) {
  7777. var foldData = this.$foldData;
  7778. var i = 0;
  7779. if (startFoldLine)
  7780. i = foldData.indexOf(startFoldLine);
  7781. if (i == -1)
  7782. i = 0;
  7783. for (i; i < foldData.length; i++) {
  7784. var foldLine = foldData[i];
  7785. if (foldLine.end.row >= docRow) {
  7786. return foldLine;
  7787. }
  7788. }
  7789. return null;
  7790. };
  7791. this.getFoldedRowCount = function(first, last) {
  7792. var foldData = this.$foldData, rowCount = last-first+1;
  7793. for (var i = 0; i < foldData.length; i++) {
  7794. var foldLine = foldData[i],
  7795. end = foldLine.end.row,
  7796. start = foldLine.start.row;
  7797. if (end >= last) {
  7798. if (start < last) {
  7799. if (start >= first)
  7800. rowCount -= last-start;
  7801. else
  7802. rowCount = 0; // in one fold
  7803. }
  7804. break;
  7805. } else if (end >= first){
  7806. if (start >= first) // fold inside range
  7807. rowCount -= end-start;
  7808. else
  7809. rowCount -= end-first+1;
  7810. }
  7811. }
  7812. return rowCount;
  7813. };
  7814. this.$addFoldLine = function(foldLine) {
  7815. this.$foldData.push(foldLine);
  7816. this.$foldData.sort(function(a, b) {
  7817. return a.start.row - b.start.row;
  7818. });
  7819. return foldLine;
  7820. };
  7821. this.addFold = function(placeholder, range) {
  7822. var foldData = this.$foldData;
  7823. var added = false;
  7824. var fold;
  7825. if (placeholder instanceof Fold)
  7826. fold = placeholder;
  7827. else {
  7828. fold = new Fold(range, placeholder);
  7829. fold.collapseChildren = range.collapseChildren;
  7830. }
  7831. this.$clipRangeToDocument(fold.range);
  7832. var startRow = fold.start.row;
  7833. var startColumn = fold.start.column;
  7834. var endRow = fold.end.row;
  7835. var endColumn = fold.end.column;
  7836. if (!(startRow < endRow ||
  7837. startRow == endRow && startColumn <= endColumn - 2))
  7838. throw new Error("The range has to be at least 2 characters width");
  7839. var startFold = this.getFoldAt(startRow, startColumn, 1);
  7840. var endFold = this.getFoldAt(endRow, endColumn, -1);
  7841. if (startFold && endFold == startFold)
  7842. return startFold.addSubFold(fold);
  7843. if (startFold && !startFold.range.isStart(startRow, startColumn))
  7844. this.removeFold(startFold);
  7845. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  7846. this.removeFold(endFold);
  7847. var folds = this.getFoldsInRange(fold.range);
  7848. if (folds.length > 0) {
  7849. this.removeFolds(folds);
  7850. folds.forEach(function(subFold) {
  7851. fold.addSubFold(subFold);
  7852. });
  7853. }
  7854. for (var i = 0; i < foldData.length; i++) {
  7855. var foldLine = foldData[i];
  7856. if (endRow == foldLine.start.row) {
  7857. foldLine.addFold(fold);
  7858. added = true;
  7859. break;
  7860. } else if (startRow == foldLine.end.row) {
  7861. foldLine.addFold(fold);
  7862. added = true;
  7863. if (!fold.sameRow) {
  7864. var foldLineNext = foldData[i + 1];
  7865. if (foldLineNext && foldLineNext.start.row == endRow) {
  7866. foldLine.merge(foldLineNext);
  7867. break;
  7868. }
  7869. }
  7870. break;
  7871. } else if (endRow <= foldLine.start.row) {
  7872. break;
  7873. }
  7874. }
  7875. if (!added)
  7876. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  7877. if (this.$useWrapMode)
  7878. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  7879. else
  7880. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  7881. this.$modified = true;
  7882. this._signal("changeFold", { data: fold, action: "add" });
  7883. return fold;
  7884. };
  7885. this.addFolds = function(folds) {
  7886. folds.forEach(function(fold) {
  7887. this.addFold(fold);
  7888. }, this);
  7889. };
  7890. this.removeFold = function(fold) {
  7891. var foldLine = fold.foldLine;
  7892. var startRow = foldLine.start.row;
  7893. var endRow = foldLine.end.row;
  7894. var foldLines = this.$foldData;
  7895. var folds = foldLine.folds;
  7896. if (folds.length == 1) {
  7897. foldLines.splice(foldLines.indexOf(foldLine), 1);
  7898. } else
  7899. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  7900. folds.pop();
  7901. foldLine.end.row = folds[folds.length - 1].end.row;
  7902. foldLine.end.column = folds[folds.length - 1].end.column;
  7903. } else
  7904. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  7905. folds.shift();
  7906. foldLine.start.row = folds[0].start.row;
  7907. foldLine.start.column = folds[0].start.column;
  7908. } else
  7909. if (fold.sameRow) {
  7910. folds.splice(folds.indexOf(fold), 1);
  7911. } else
  7912. {
  7913. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  7914. folds = newFoldLine.folds;
  7915. folds.shift();
  7916. newFoldLine.start.row = folds[0].start.row;
  7917. newFoldLine.start.column = folds[0].start.column;
  7918. }
  7919. if (!this.$updating) {
  7920. if (this.$useWrapMode)
  7921. this.$updateWrapData(startRow, endRow);
  7922. else
  7923. this.$updateRowLengthCache(startRow, endRow);
  7924. }
  7925. this.$modified = true;
  7926. this._signal("changeFold", { data: fold, action: "remove" });
  7927. };
  7928. this.removeFolds = function(folds) {
  7929. var cloneFolds = [];
  7930. for (var i = 0; i < folds.length; i++) {
  7931. cloneFolds.push(folds[i]);
  7932. }
  7933. cloneFolds.forEach(function(fold) {
  7934. this.removeFold(fold);
  7935. }, this);
  7936. this.$modified = true;
  7937. };
  7938. this.expandFold = function(fold) {
  7939. this.removeFold(fold);
  7940. fold.subFolds.forEach(function(subFold) {
  7941. fold.restoreRange(subFold);
  7942. this.addFold(subFold);
  7943. }, this);
  7944. if (fold.collapseChildren > 0) {
  7945. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  7946. }
  7947. fold.subFolds = [];
  7948. };
  7949. this.expandFolds = function(folds) {
  7950. folds.forEach(function(fold) {
  7951. this.expandFold(fold);
  7952. }, this);
  7953. };
  7954. this.unfold = function(location, expandInner) {
  7955. var range, folds;
  7956. if (location == null) {
  7957. range = new Range(0, 0, this.getLength(), 0);
  7958. expandInner = true;
  7959. } else if (typeof location == "number")
  7960. range = new Range(location, 0, location, this.getLine(location).length);
  7961. else if ("row" in location)
  7962. range = Range.fromPoints(location, location);
  7963. else
  7964. range = location;
  7965. folds = this.getFoldsInRangeList(range);
  7966. if (expandInner) {
  7967. this.removeFolds(folds);
  7968. } else {
  7969. var subFolds = folds;
  7970. while (subFolds.length) {
  7971. this.expandFolds(subFolds);
  7972. subFolds = this.getFoldsInRangeList(range);
  7973. }
  7974. }
  7975. if (folds.length)
  7976. return folds;
  7977. };
  7978. this.isRowFolded = function(docRow, startFoldRow) {
  7979. return !!this.getFoldLine(docRow, startFoldRow);
  7980. };
  7981. this.getRowFoldEnd = function(docRow, startFoldRow) {
  7982. var foldLine = this.getFoldLine(docRow, startFoldRow);
  7983. return foldLine ? foldLine.end.row : docRow;
  7984. };
  7985. this.getRowFoldStart = function(docRow, startFoldRow) {
  7986. var foldLine = this.getFoldLine(docRow, startFoldRow);
  7987. return foldLine ? foldLine.start.row : docRow;
  7988. };
  7989. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  7990. if (startRow == null)
  7991. startRow = foldLine.start.row;
  7992. if (startColumn == null)
  7993. startColumn = 0;
  7994. if (endRow == null)
  7995. endRow = foldLine.end.row;
  7996. if (endColumn == null)
  7997. endColumn = this.getLine(endRow).length;
  7998. var doc = this.doc;
  7999. var textLine = "";
  8000. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8001. if (row < startRow)
  8002. return;
  8003. if (row == startRow) {
  8004. if (column < startColumn)
  8005. return;
  8006. lastColumn = Math.max(startColumn, lastColumn);
  8007. }
  8008. if (placeholder != null) {
  8009. textLine += placeholder;
  8010. } else {
  8011. textLine += doc.getLine(row).substring(lastColumn, column);
  8012. }
  8013. }, endRow, endColumn);
  8014. return textLine;
  8015. };
  8016. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  8017. var foldLine = this.getFoldLine(row);
  8018. if (!foldLine) {
  8019. var line;
  8020. line = this.doc.getLine(row);
  8021. return line.substring(startColumn || 0, endColumn || line.length);
  8022. } else {
  8023. return this.getFoldDisplayLine(
  8024. foldLine, row, endColumn, startRow, startColumn);
  8025. }
  8026. };
  8027. this.$cloneFoldData = function() {
  8028. var fd = [];
  8029. fd = this.$foldData.map(function(foldLine) {
  8030. var folds = foldLine.folds.map(function(fold) {
  8031. return fold.clone();
  8032. });
  8033. return new FoldLine(fd, folds);
  8034. });
  8035. return fd;
  8036. };
  8037. this.toggleFold = function(tryToUnfold) {
  8038. var selection = this.selection;
  8039. var range = selection.getRange();
  8040. var fold;
  8041. var bracketPos;
  8042. if (range.isEmpty()) {
  8043. var cursor = range.start;
  8044. fold = this.getFoldAt(cursor.row, cursor.column);
  8045. if (fold) {
  8046. this.expandFold(fold);
  8047. return;
  8048. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  8049. if (range.comparePoint(bracketPos) == 1) {
  8050. range.end = bracketPos;
  8051. } else {
  8052. range.start = bracketPos;
  8053. range.start.column++;
  8054. range.end.column--;
  8055. }
  8056. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  8057. if (range.comparePoint(bracketPos) == 1)
  8058. range.end = bracketPos;
  8059. else
  8060. range.start = bracketPos;
  8061. range.start.column++;
  8062. } else {
  8063. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  8064. }
  8065. } else {
  8066. var folds = this.getFoldsInRange(range);
  8067. if (tryToUnfold && folds.length) {
  8068. this.expandFolds(folds);
  8069. return;
  8070. } else if (folds.length == 1 ) {
  8071. fold = folds[0];
  8072. }
  8073. }
  8074. if (!fold)
  8075. fold = this.getFoldAt(range.start.row, range.start.column);
  8076. if (fold && fold.range.toString() == range.toString()) {
  8077. this.expandFold(fold);
  8078. return;
  8079. }
  8080. var placeholder = "...";
  8081. if (!range.isMultiLine()) {
  8082. placeholder = this.getTextRange(range);
  8083. if (placeholder.length < 4)
  8084. return;
  8085. placeholder = placeholder.trim().substring(0, 2) + "..";
  8086. }
  8087. this.addFold(placeholder, range);
  8088. };
  8089. this.getCommentFoldRange = function(row, column, dir) {
  8090. var iterator = new TokenIterator(this, row, column);
  8091. var token = iterator.getCurrentToken();
  8092. var type = token.type;
  8093. if (token && /^comment|string/.test(type)) {
  8094. type = type.match(/comment|string/)[0];
  8095. if (type == "comment")
  8096. type += "|doc-start";
  8097. var re = new RegExp(type);
  8098. var range = new Range();
  8099. if (dir != 1) {
  8100. do {
  8101. token = iterator.stepBackward();
  8102. } while (token && re.test(token.type));
  8103. iterator.stepForward();
  8104. }
  8105. range.start.row = iterator.getCurrentTokenRow();
  8106. range.start.column = iterator.getCurrentTokenColumn() + 2;
  8107. iterator = new TokenIterator(this, row, column);
  8108. if (dir != -1) {
  8109. var lastRow = -1;
  8110. do {
  8111. token = iterator.stepForward();
  8112. if (lastRow == -1) {
  8113. var state = this.getState(iterator.$row);
  8114. if (!re.test(state))
  8115. lastRow = iterator.$row;
  8116. } else if (iterator.$row > lastRow) {
  8117. break;
  8118. }
  8119. } while (token && re.test(token.type));
  8120. token = iterator.stepBackward();
  8121. } else
  8122. token = iterator.getCurrentToken();
  8123. range.end.row = iterator.getCurrentTokenRow();
  8124. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  8125. return range;
  8126. }
  8127. };
  8128. this.foldAll = function(startRow, endRow, depth) {
  8129. if (depth == undefined)
  8130. depth = 100000; // JSON.stringify doesn't hanle Infinity
  8131. var foldWidgets = this.foldWidgets;
  8132. if (!foldWidgets)
  8133. return; // mode doesn't support folding
  8134. endRow = endRow || this.getLength();
  8135. startRow = startRow || 0;
  8136. for (var row = startRow; row < endRow; row++) {
  8137. if (foldWidgets[row] == null)
  8138. foldWidgets[row] = this.getFoldWidget(row);
  8139. if (foldWidgets[row] != "start")
  8140. continue;
  8141. var range = this.getFoldWidgetRange(row);
  8142. if (range && range.isMultiLine()
  8143. && range.end.row <= endRow
  8144. && range.start.row >= startRow
  8145. ) {
  8146. row = range.end.row;
  8147. try {
  8148. var fold = this.addFold("...", range);
  8149. if (fold)
  8150. fold.collapseChildren = depth;
  8151. } catch(e) {}
  8152. }
  8153. }
  8154. };
  8155. this.$foldStyles = {
  8156. "manual": 1,
  8157. "markbegin": 1,
  8158. "markbeginend": 1
  8159. };
  8160. this.$foldStyle = "markbegin";
  8161. this.setFoldStyle = function(style) {
  8162. if (!this.$foldStyles[style])
  8163. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  8164. if (this.$foldStyle == style)
  8165. return;
  8166. this.$foldStyle = style;
  8167. if (style == "manual")
  8168. this.unfold();
  8169. var mode = this.$foldMode;
  8170. this.$setFolding(null);
  8171. this.$setFolding(mode);
  8172. };
  8173. this.$setFolding = function(foldMode) {
  8174. if (this.$foldMode == foldMode)
  8175. return;
  8176. this.$foldMode = foldMode;
  8177. this.off('change', this.$updateFoldWidgets);
  8178. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  8179. this._signal("changeAnnotation");
  8180. if (!foldMode || this.$foldStyle == "manual") {
  8181. this.foldWidgets = null;
  8182. return;
  8183. }
  8184. this.foldWidgets = [];
  8185. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  8186. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  8187. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  8188. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  8189. this.on('change', this.$updateFoldWidgets);
  8190. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  8191. };
  8192. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  8193. var fw = this.foldWidgets;
  8194. if (!fw || (ignoreCurrent && fw[row]))
  8195. return {};
  8196. var i = row - 1, firstRange;
  8197. while (i >= 0) {
  8198. var c = fw[i];
  8199. if (c == null)
  8200. c = fw[i] = this.getFoldWidget(i);
  8201. if (c == "start") {
  8202. var range = this.getFoldWidgetRange(i);
  8203. if (!firstRange)
  8204. firstRange = range;
  8205. if (range && range.end.row >= row)
  8206. break;
  8207. }
  8208. i--;
  8209. }
  8210. return {
  8211. range: i !== -1 && range,
  8212. firstRange: firstRange
  8213. };
  8214. };
  8215. this.onFoldWidgetClick = function(row, e) {
  8216. e = e.domEvent;
  8217. var options = {
  8218. children: e.shiftKey,
  8219. all: e.ctrlKey || e.metaKey,
  8220. siblings: e.altKey
  8221. };
  8222. var range = this.$toggleFoldWidget(row, options);
  8223. if (!range) {
  8224. var el = (e.target || e.srcElement);
  8225. if (el && /ace_fold-widget/.test(el.className))
  8226. el.className += " ace_invalid";
  8227. }
  8228. };
  8229. this.$toggleFoldWidget = function(row, options) {
  8230. if (!this.getFoldWidget)
  8231. return;
  8232. var type = this.getFoldWidget(row);
  8233. var line = this.getLine(row);
  8234. var dir = type === "end" ? -1 : 1;
  8235. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  8236. if (fold) {
  8237. if (options.children || options.all)
  8238. this.removeFold(fold);
  8239. else
  8240. this.expandFold(fold);
  8241. return fold;
  8242. }
  8243. var range = this.getFoldWidgetRange(row, true);
  8244. if (range && !range.isMultiLine()) {
  8245. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  8246. if (fold && range.isEqual(fold.range)) {
  8247. this.removeFold(fold);
  8248. return fold;
  8249. }
  8250. }
  8251. if (options.siblings) {
  8252. var data = this.getParentFoldRangeData(row);
  8253. if (data.range) {
  8254. var startRow = data.range.start.row + 1;
  8255. var endRow = data.range.end.row;
  8256. }
  8257. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  8258. } else if (options.children) {
  8259. endRow = range ? range.end.row : this.getLength();
  8260. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  8261. } else if (range) {
  8262. if (options.all)
  8263. range.collapseChildren = 10000;
  8264. this.addFold("...", range);
  8265. }
  8266. return range;
  8267. };
  8268. this.toggleFoldWidget = function(toggleParent) {
  8269. var row = this.selection.getCursor().row;
  8270. row = this.getRowFoldStart(row);
  8271. var range = this.$toggleFoldWidget(row, {});
  8272. if (range)
  8273. return;
  8274. var data = this.getParentFoldRangeData(row, true);
  8275. range = data.range || data.firstRange;
  8276. if (range) {
  8277. row = range.start.row;
  8278. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  8279. if (fold) {
  8280. this.removeFold(fold);
  8281. } else {
  8282. this.addFold("...", range);
  8283. }
  8284. }
  8285. };
  8286. this.updateFoldWidgets = function(delta) {
  8287. var firstRow = delta.start.row;
  8288. var len = delta.end.row - firstRow;
  8289. if (len === 0) {
  8290. this.foldWidgets[firstRow] = null;
  8291. } else if (delta.action == 'remove') {
  8292. this.foldWidgets.splice(firstRow, len + 1, null);
  8293. } else {
  8294. var args = Array(len + 1);
  8295. args.unshift(firstRow, 1);
  8296. this.foldWidgets.splice.apply(this.foldWidgets, args);
  8297. }
  8298. };
  8299. this.tokenizerUpdateFoldWidgets = function(e) {
  8300. var rows = e.data;
  8301. if (rows.first != rows.last) {
  8302. if (this.foldWidgets.length > rows.first)
  8303. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  8304. }
  8305. };
  8306. }
  8307. exports.Folding = Folding;
  8308. });
  8309. define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  8310. "use strict";
  8311. var TokenIterator = require("../token_iterator").TokenIterator;
  8312. var Range = require("../range").Range;
  8313. function BracketMatch() {
  8314. this.findMatchingBracket = function(position, chr) {
  8315. if (position.column == 0) return null;
  8316. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  8317. if (charBeforeCursor == "") return null;
  8318. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  8319. if (!match)
  8320. return null;
  8321. if (match[1])
  8322. return this.$findClosingBracket(match[1], position);
  8323. else
  8324. return this.$findOpeningBracket(match[2], position);
  8325. };
  8326. this.getBracketRange = function(pos) {
  8327. var line = this.getLine(pos.row);
  8328. var before = true, range;
  8329. var chr = line.charAt(pos.column-1);
  8330. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  8331. if (!match) {
  8332. chr = line.charAt(pos.column);
  8333. pos = {row: pos.row, column: pos.column + 1};
  8334. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  8335. before = false;
  8336. }
  8337. if (!match)
  8338. return null;
  8339. if (match[1]) {
  8340. var bracketPos = this.$findClosingBracket(match[1], pos);
  8341. if (!bracketPos)
  8342. return null;
  8343. range = Range.fromPoints(pos, bracketPos);
  8344. if (!before) {
  8345. range.end.column++;
  8346. range.start.column--;
  8347. }
  8348. range.cursor = range.end;
  8349. } else {
  8350. var bracketPos = this.$findOpeningBracket(match[2], pos);
  8351. if (!bracketPos)
  8352. return null;
  8353. range = Range.fromPoints(bracketPos, pos);
  8354. if (!before) {
  8355. range.start.column++;
  8356. range.end.column--;
  8357. }
  8358. range.cursor = range.start;
  8359. }
  8360. return range;
  8361. };
  8362. this.$brackets = {
  8363. ")": "(",
  8364. "(": ")",
  8365. "]": "[",
  8366. "[": "]",
  8367. "{": "}",
  8368. "}": "{"
  8369. };
  8370. this.$findOpeningBracket = function(bracket, position, typeRe) {
  8371. var openBracket = this.$brackets[bracket];
  8372. var depth = 1;
  8373. var iterator = new TokenIterator(this, position.row, position.column);
  8374. var token = iterator.getCurrentToken();
  8375. if (!token)
  8376. token = iterator.stepForward();
  8377. if (!token)
  8378. return;
  8379. if (!typeRe){
  8380. typeRe = new RegExp(
  8381. "(\\.?" +
  8382. token.type.replace(".", "\\.").replace("rparen", ".paren")
  8383. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  8384. + ")+"
  8385. );
  8386. }
  8387. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  8388. var value = token.value;
  8389. while (true) {
  8390. while (valueIndex >= 0) {
  8391. var chr = value.charAt(valueIndex);
  8392. if (chr == openBracket) {
  8393. depth -= 1;
  8394. if (depth == 0) {
  8395. return {row: iterator.getCurrentTokenRow(),
  8396. column: valueIndex + iterator.getCurrentTokenColumn()};
  8397. }
  8398. }
  8399. else if (chr == bracket) {
  8400. depth += 1;
  8401. }
  8402. valueIndex -= 1;
  8403. }
  8404. do {
  8405. token = iterator.stepBackward();
  8406. } while (token && !typeRe.test(token.type));
  8407. if (token == null)
  8408. break;
  8409. value = token.value;
  8410. valueIndex = value.length - 1;
  8411. }
  8412. return null;
  8413. };
  8414. this.$findClosingBracket = function(bracket, position, typeRe) {
  8415. var closingBracket = this.$brackets[bracket];
  8416. var depth = 1;
  8417. var iterator = new TokenIterator(this, position.row, position.column);
  8418. var token = iterator.getCurrentToken();
  8419. if (!token)
  8420. token = iterator.stepForward();
  8421. if (!token)
  8422. return;
  8423. if (!typeRe){
  8424. typeRe = new RegExp(
  8425. "(\\.?" +
  8426. token.type.replace(".", "\\.").replace("lparen", ".paren")
  8427. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  8428. + ")+"
  8429. );
  8430. }
  8431. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  8432. while (true) {
  8433. var value = token.value;
  8434. var valueLength = value.length;
  8435. while (valueIndex < valueLength) {
  8436. var chr = value.charAt(valueIndex);
  8437. if (chr == closingBracket) {
  8438. depth -= 1;
  8439. if (depth == 0) {
  8440. return {row: iterator.getCurrentTokenRow(),
  8441. column: valueIndex + iterator.getCurrentTokenColumn()};
  8442. }
  8443. }
  8444. else if (chr == bracket) {
  8445. depth += 1;
  8446. }
  8447. valueIndex += 1;
  8448. }
  8449. do {
  8450. token = iterator.stepForward();
  8451. } while (token && !typeRe.test(token.type));
  8452. if (token == null)
  8453. break;
  8454. valueIndex = 0;
  8455. }
  8456. return null;
  8457. };
  8458. }
  8459. exports.BracketMatch = BracketMatch;
  8460. });
  8461. define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/bidihandler","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) {
  8462. "use strict";
  8463. var oop = require("./lib/oop");
  8464. var lang = require("./lib/lang");
  8465. var BidiHandler = require("./bidihandler").BidiHandler;
  8466. var config = require("./config");
  8467. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  8468. var Selection = require("./selection").Selection;
  8469. var TextMode = require("./mode/text").Mode;
  8470. var Range = require("./range").Range;
  8471. var Document = require("./document").Document;
  8472. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  8473. var SearchHighlight = require("./search_highlight").SearchHighlight;
  8474. var EditSession = function(text, mode) {
  8475. this.$breakpoints = [];
  8476. this.$decorations = [];
  8477. this.$frontMarkers = {};
  8478. this.$backMarkers = {};
  8479. this.$markerId = 1;
  8480. this.$undoSelect = true;
  8481. this.$foldData = [];
  8482. this.id = "session" + (++EditSession.$uid);
  8483. this.$foldData.toString = function() {
  8484. return this.join("\n");
  8485. };
  8486. this.on("changeFold", this.onChangeFold.bind(this));
  8487. this.$onChange = this.onChange.bind(this);
  8488. if (typeof text != "object" || !text.getLine)
  8489. text = new Document(text);
  8490. this.$bidiHandler = new BidiHandler(this);
  8491. this.setDocument(text);
  8492. this.selection = new Selection(this);
  8493. config.resetOptions(this);
  8494. this.setMode(mode);
  8495. config._signal("session", this);
  8496. };
  8497. EditSession.$uid = 0;
  8498. (function() {
  8499. oop.implement(this, EventEmitter);
  8500. this.setDocument = function(doc) {
  8501. if (this.doc)
  8502. this.doc.removeListener("change", this.$onChange);
  8503. this.doc = doc;
  8504. doc.on("change", this.$onChange);
  8505. if (this.bgTokenizer)
  8506. this.bgTokenizer.setDocument(this.getDocument());
  8507. this.resetCaches();
  8508. };
  8509. this.getDocument = function() {
  8510. return this.doc;
  8511. };
  8512. this.$resetRowCache = function(docRow) {
  8513. if (!docRow) {
  8514. this.$docRowCache = [];
  8515. this.$screenRowCache = [];
  8516. return;
  8517. }
  8518. var l = this.$docRowCache.length;
  8519. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  8520. if (l > i) {
  8521. this.$docRowCache.splice(i, l);
  8522. this.$screenRowCache.splice(i, l);
  8523. }
  8524. };
  8525. this.$getRowCacheIndex = function(cacheArray, val) {
  8526. var low = 0;
  8527. var hi = cacheArray.length - 1;
  8528. while (low <= hi) {
  8529. var mid = (low + hi) >> 1;
  8530. var c = cacheArray[mid];
  8531. if (val > c)
  8532. low = mid + 1;
  8533. else if (val < c)
  8534. hi = mid - 1;
  8535. else
  8536. return mid;
  8537. }
  8538. return low -1;
  8539. };
  8540. this.resetCaches = function() {
  8541. this.$modified = true;
  8542. this.$wrapData = [];
  8543. this.$rowLengthCache = [];
  8544. this.$resetRowCache(0);
  8545. if (this.bgTokenizer)
  8546. this.bgTokenizer.start(0);
  8547. };
  8548. this.onChangeFold = function(e) {
  8549. var fold = e.data;
  8550. this.$resetRowCache(fold.start.row);
  8551. };
  8552. this.onChange = function(delta) {
  8553. this.$modified = true;
  8554. this.$bidiHandler.onChange(delta);
  8555. this.$resetRowCache(delta.start.row);
  8556. var removedFolds = this.$updateInternalDataOnChange(delta);
  8557. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  8558. this.$deltasDoc.push(delta);
  8559. if (removedFolds && removedFolds.length != 0) {
  8560. this.$deltasFold.push({
  8561. action: "removeFolds",
  8562. folds: removedFolds
  8563. });
  8564. }
  8565. this.$informUndoManager.schedule();
  8566. }
  8567. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  8568. this._signal("change", delta);
  8569. };
  8570. this.setValue = function(text) {
  8571. this.doc.setValue(text);
  8572. this.selection.moveTo(0, 0);
  8573. this.$resetRowCache(0);
  8574. this.$deltas = [];
  8575. this.$deltasDoc = [];
  8576. this.$deltasFold = [];
  8577. this.setUndoManager(this.$undoManager);
  8578. this.getUndoManager().reset();
  8579. };
  8580. this.getValue =
  8581. this.toString = function() {
  8582. return this.doc.getValue();
  8583. };
  8584. this.getSelection = function() {
  8585. return this.selection;
  8586. };
  8587. this.getState = function(row) {
  8588. return this.bgTokenizer.getState(row);
  8589. };
  8590. this.getTokens = function(row) {
  8591. return this.bgTokenizer.getTokens(row);
  8592. };
  8593. this.getTokenAt = function(row, column) {
  8594. var tokens = this.bgTokenizer.getTokens(row);
  8595. var token, c = 0;
  8596. if (column == null) {
  8597. var i = tokens.length - 1;
  8598. c = this.getLine(row).length;
  8599. } else {
  8600. for (var i = 0; i < tokens.length; i++) {
  8601. c += tokens[i].value.length;
  8602. if (c >= column)
  8603. break;
  8604. }
  8605. }
  8606. token = tokens[i];
  8607. if (!token)
  8608. return null;
  8609. token.index = i;
  8610. token.start = c - token.value.length;
  8611. return token;
  8612. };
  8613. this.setUndoManager = function(undoManager) {
  8614. this.$undoManager = undoManager;
  8615. this.$deltas = [];
  8616. this.$deltasDoc = [];
  8617. this.$deltasFold = [];
  8618. if (this.$informUndoManager)
  8619. this.$informUndoManager.cancel();
  8620. if (undoManager) {
  8621. var self = this;
  8622. this.$syncInformUndoManager = function() {
  8623. self.$informUndoManager.cancel();
  8624. if (self.$deltasFold.length) {
  8625. self.$deltas.push({
  8626. group: "fold",
  8627. deltas: self.$deltasFold
  8628. });
  8629. self.$deltasFold = [];
  8630. }
  8631. if (self.$deltasDoc.length) {
  8632. self.$deltas.push({
  8633. group: "doc",
  8634. deltas: self.$deltasDoc
  8635. });
  8636. self.$deltasDoc = [];
  8637. }
  8638. if (self.$deltas.length > 0) {
  8639. undoManager.execute({
  8640. action: "aceupdate",
  8641. args: [self.$deltas, self],
  8642. merge: self.mergeUndoDeltas
  8643. });
  8644. }
  8645. self.mergeUndoDeltas = false;
  8646. self.$deltas = [];
  8647. };
  8648. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  8649. }
  8650. };
  8651. this.markUndoGroup = function() {
  8652. if (this.$syncInformUndoManager)
  8653. this.$syncInformUndoManager();
  8654. };
  8655. this.$defaultUndoManager = {
  8656. undo: function() {},
  8657. redo: function() {},
  8658. reset: function() {}
  8659. };
  8660. this.getUndoManager = function() {
  8661. return this.$undoManager || this.$defaultUndoManager;
  8662. };
  8663. this.getTabString = function() {
  8664. if (this.getUseSoftTabs()) {
  8665. return lang.stringRepeat(" ", this.getTabSize());
  8666. } else {
  8667. return "\t";
  8668. }
  8669. };
  8670. this.setUseSoftTabs = function(val) {
  8671. this.setOption("useSoftTabs", val);
  8672. };
  8673. this.getUseSoftTabs = function() {
  8674. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  8675. };
  8676. this.setTabSize = function(tabSize) {
  8677. this.setOption("tabSize", tabSize);
  8678. };
  8679. this.getTabSize = function() {
  8680. return this.$tabSize;
  8681. };
  8682. this.isTabStop = function(position) {
  8683. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  8684. };
  8685. this.setNavigateWithinSoftTabs = function (navigateWithinSoftTabs) {
  8686. this.setOption("navigateWithinSoftTabs", navigateWithinSoftTabs);
  8687. };
  8688. this.getNavigateWithinSoftTabs = function() {
  8689. return this.$navigateWithinSoftTabs;
  8690. };
  8691. this.$overwrite = false;
  8692. this.setOverwrite = function(overwrite) {
  8693. this.setOption("overwrite", overwrite);
  8694. };
  8695. this.getOverwrite = function() {
  8696. return this.$overwrite;
  8697. };
  8698. this.toggleOverwrite = function() {
  8699. this.setOverwrite(!this.$overwrite);
  8700. };
  8701. this.addGutterDecoration = function(row, className) {
  8702. if (!this.$decorations[row])
  8703. this.$decorations[row] = "";
  8704. this.$decorations[row] += " " + className;
  8705. this._signal("changeBreakpoint", {});
  8706. };
  8707. this.removeGutterDecoration = function(row, className) {
  8708. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  8709. this._signal("changeBreakpoint", {});
  8710. };
  8711. this.getBreakpoints = function() {
  8712. return this.$breakpoints;
  8713. };
  8714. this.setBreakpoints = function(rows) {
  8715. this.$breakpoints = [];
  8716. for (var i=0; i<rows.length; i++) {
  8717. this.$breakpoints[rows[i]] = "ace_breakpoint";
  8718. }
  8719. this._signal("changeBreakpoint", {});
  8720. };
  8721. this.clearBreakpoints = function() {
  8722. this.$breakpoints = [];
  8723. this._signal("changeBreakpoint", {});
  8724. };
  8725. this.setBreakpoint = function(row, className) {
  8726. if (className === undefined)
  8727. className = "ace_breakpoint";
  8728. if (className)
  8729. this.$breakpoints[row] = className;
  8730. else
  8731. delete this.$breakpoints[row];
  8732. this._signal("changeBreakpoint", {});
  8733. };
  8734. this.clearBreakpoint = function(row) {
  8735. delete this.$breakpoints[row];
  8736. this._signal("changeBreakpoint", {});
  8737. };
  8738. this.addMarker = function(range, clazz, type, inFront) {
  8739. var id = this.$markerId++;
  8740. var marker = {
  8741. range : range,
  8742. type : type || "line",
  8743. renderer: typeof type == "function" ? type : null,
  8744. clazz : clazz,
  8745. inFront: !!inFront,
  8746. id: id
  8747. };
  8748. if (inFront) {
  8749. this.$frontMarkers[id] = marker;
  8750. this._signal("changeFrontMarker");
  8751. } else {
  8752. this.$backMarkers[id] = marker;
  8753. this._signal("changeBackMarker");
  8754. }
  8755. return id;
  8756. };
  8757. this.addDynamicMarker = function(marker, inFront) {
  8758. if (!marker.update)
  8759. return;
  8760. var id = this.$markerId++;
  8761. marker.id = id;
  8762. marker.inFront = !!inFront;
  8763. if (inFront) {
  8764. this.$frontMarkers[id] = marker;
  8765. this._signal("changeFrontMarker");
  8766. } else {
  8767. this.$backMarkers[id] = marker;
  8768. this._signal("changeBackMarker");
  8769. }
  8770. return marker;
  8771. };
  8772. this.removeMarker = function(markerId) {
  8773. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  8774. if (!marker)
  8775. return;
  8776. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  8777. if (marker) {
  8778. delete (markers[markerId]);
  8779. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  8780. }
  8781. };
  8782. this.getMarkers = function(inFront) {
  8783. return inFront ? this.$frontMarkers : this.$backMarkers;
  8784. };
  8785. this.highlight = function(re) {
  8786. if (!this.$searchHighlight) {
  8787. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  8788. this.$searchHighlight = this.addDynamicMarker(highlight);
  8789. }
  8790. this.$searchHighlight.setRegexp(re);
  8791. };
  8792. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  8793. if (typeof endRow != "number") {
  8794. clazz = endRow;
  8795. endRow = startRow;
  8796. }
  8797. if (!clazz)
  8798. clazz = "ace_step";
  8799. var range = new Range(startRow, 0, endRow, Infinity);
  8800. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  8801. return range;
  8802. };
  8803. this.setAnnotations = function(annotations) {
  8804. this.$annotations = annotations;
  8805. this._signal("changeAnnotation", {});
  8806. };
  8807. this.getAnnotations = function() {
  8808. return this.$annotations || [];
  8809. };
  8810. this.clearAnnotations = function() {
  8811. this.setAnnotations([]);
  8812. };
  8813. this.$detectNewLine = function(text) {
  8814. var match = text.match(/^.*?(\r?\n)/m);
  8815. if (match) {
  8816. this.$autoNewLine = match[1];
  8817. } else {
  8818. this.$autoNewLine = "\n";
  8819. }
  8820. };
  8821. this.getWordRange = function(row, column) {
  8822. var line = this.getLine(row);
  8823. var inToken = false;
  8824. if (column > 0)
  8825. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  8826. if (!inToken)
  8827. inToken = !!line.charAt(column).match(this.tokenRe);
  8828. if (inToken)
  8829. var re = this.tokenRe;
  8830. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  8831. var re = /\s/;
  8832. else
  8833. var re = this.nonTokenRe;
  8834. var start = column;
  8835. if (start > 0) {
  8836. do {
  8837. start--;
  8838. }
  8839. while (start >= 0 && line.charAt(start).match(re));
  8840. start++;
  8841. }
  8842. var end = column;
  8843. while (end < line.length && line.charAt(end).match(re)) {
  8844. end++;
  8845. }
  8846. return new Range(row, start, row, end);
  8847. };
  8848. this.getAWordRange = function(row, column) {
  8849. var wordRange = this.getWordRange(row, column);
  8850. var line = this.getLine(wordRange.end.row);
  8851. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  8852. wordRange.end.column += 1;
  8853. }
  8854. return wordRange;
  8855. };
  8856. this.setNewLineMode = function(newLineMode) {
  8857. this.doc.setNewLineMode(newLineMode);
  8858. };
  8859. this.getNewLineMode = function() {
  8860. return this.doc.getNewLineMode();
  8861. };
  8862. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  8863. this.getUseWorker = function() { return this.$useWorker; };
  8864. this.onReloadTokenizer = function(e) {
  8865. var rows = e.data;
  8866. this.bgTokenizer.start(rows.first);
  8867. this._signal("tokenizerUpdate", e);
  8868. };
  8869. this.$modes = {};
  8870. this.$mode = null;
  8871. this.$modeId = null;
  8872. this.setMode = function(mode, cb) {
  8873. if (mode && typeof mode === "object") {
  8874. if (mode.getTokenizer)
  8875. return this.$onChangeMode(mode);
  8876. var options = mode;
  8877. var path = options.path;
  8878. } else {
  8879. path = mode || "ace/mode/text";
  8880. }
  8881. if (!this.$modes["ace/mode/text"])
  8882. this.$modes["ace/mode/text"] = new TextMode();
  8883. if (this.$modes[path] && !options) {
  8884. this.$onChangeMode(this.$modes[path]);
  8885. cb && cb();
  8886. return;
  8887. }
  8888. this.$modeId = path;
  8889. config.loadModule(["mode", path], function(m) {
  8890. if (this.$modeId !== path)
  8891. return cb && cb();
  8892. if (this.$modes[path] && !options) {
  8893. this.$onChangeMode(this.$modes[path]);
  8894. } else if (m && m.Mode) {
  8895. m = new m.Mode(options);
  8896. if (!options) {
  8897. this.$modes[path] = m;
  8898. m.$id = path;
  8899. }
  8900. this.$onChangeMode(m);
  8901. }
  8902. cb && cb();
  8903. }.bind(this));
  8904. if (!this.$mode)
  8905. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  8906. };
  8907. this.$onChangeMode = function(mode, $isPlaceholder) {
  8908. if (!$isPlaceholder)
  8909. this.$modeId = mode.$id;
  8910. if (this.$mode === mode)
  8911. return;
  8912. this.$mode = mode;
  8913. this.$stopWorker();
  8914. if (this.$useWorker)
  8915. this.$startWorker();
  8916. var tokenizer = mode.getTokenizer();
  8917. if(tokenizer.addEventListener !== undefined) {
  8918. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  8919. tokenizer.addEventListener("update", onReloadTokenizer);
  8920. }
  8921. if (!this.bgTokenizer) {
  8922. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  8923. var _self = this;
  8924. this.bgTokenizer.addEventListener("update", function(e) {
  8925. _self._signal("tokenizerUpdate", e);
  8926. });
  8927. } else {
  8928. this.bgTokenizer.setTokenizer(tokenizer);
  8929. }
  8930. this.bgTokenizer.setDocument(this.getDocument());
  8931. this.tokenRe = mode.tokenRe;
  8932. this.nonTokenRe = mode.nonTokenRe;
  8933. if (!$isPlaceholder) {
  8934. if (mode.attachToSession)
  8935. mode.attachToSession(this);
  8936. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  8937. this.$setFolding(mode.foldingRules);
  8938. this.bgTokenizer.start(0);
  8939. this._emit("changeMode");
  8940. }
  8941. };
  8942. this.$stopWorker = function() {
  8943. if (this.$worker) {
  8944. this.$worker.terminate();
  8945. this.$worker = null;
  8946. }
  8947. };
  8948. this.$startWorker = function() {
  8949. try {
  8950. this.$worker = this.$mode.createWorker(this);
  8951. } catch (e) {
  8952. config.warn("Could not load worker", e);
  8953. this.$worker = null;
  8954. }
  8955. };
  8956. this.getMode = function() {
  8957. return this.$mode;
  8958. };
  8959. this.$scrollTop = 0;
  8960. this.setScrollTop = function(scrollTop) {
  8961. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  8962. return;
  8963. this.$scrollTop = scrollTop;
  8964. this._signal("changeScrollTop", scrollTop);
  8965. };
  8966. this.getScrollTop = function() {
  8967. return this.$scrollTop;
  8968. };
  8969. this.$scrollLeft = 0;
  8970. this.setScrollLeft = function(scrollLeft) {
  8971. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  8972. return;
  8973. this.$scrollLeft = scrollLeft;
  8974. this._signal("changeScrollLeft", scrollLeft);
  8975. };
  8976. this.getScrollLeft = function() {
  8977. return this.$scrollLeft;
  8978. };
  8979. this.getScreenWidth = function() {
  8980. this.$computeWidth();
  8981. if (this.lineWidgets)
  8982. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  8983. return this.screenWidth;
  8984. };
  8985. this.getLineWidgetMaxWidth = function() {
  8986. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  8987. var width = 0;
  8988. this.lineWidgets.forEach(function(w) {
  8989. if (w && w.screenWidth > width)
  8990. width = w.screenWidth;
  8991. });
  8992. return this.lineWidgetWidth = width;
  8993. };
  8994. this.$computeWidth = function(force) {
  8995. if (this.$modified || force) {
  8996. this.$modified = false;
  8997. if (this.$useWrapMode)
  8998. return this.screenWidth = this.$wrapLimit;
  8999. var lines = this.doc.getAllLines();
  9000. var cache = this.$rowLengthCache;
  9001. var longestScreenLine = 0;
  9002. var foldIndex = 0;
  9003. var foldLine = this.$foldData[foldIndex];
  9004. var foldStart = foldLine ? foldLine.start.row : Infinity;
  9005. var len = lines.length;
  9006. for (var i = 0; i < len; i++) {
  9007. if (i > foldStart) {
  9008. i = foldLine.end.row + 1;
  9009. if (i >= len)
  9010. break;
  9011. foldLine = this.$foldData[foldIndex++];
  9012. foldStart = foldLine ? foldLine.start.row : Infinity;
  9013. }
  9014. if (cache[i] == null)
  9015. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  9016. if (cache[i] > longestScreenLine)
  9017. longestScreenLine = cache[i];
  9018. }
  9019. this.screenWidth = longestScreenLine;
  9020. }
  9021. };
  9022. this.getLine = function(row) {
  9023. return this.doc.getLine(row);
  9024. };
  9025. this.getLines = function(firstRow, lastRow) {
  9026. return this.doc.getLines(firstRow, lastRow);
  9027. };
  9028. this.getLength = function() {
  9029. return this.doc.getLength();
  9030. };
  9031. this.getTextRange = function(range) {
  9032. return this.doc.getTextRange(range || this.selection.getRange());
  9033. };
  9034. this.insert = function(position, text) {
  9035. return this.doc.insert(position, text);
  9036. };
  9037. this.remove = function(range) {
  9038. return this.doc.remove(range);
  9039. };
  9040. this.removeFullLines = function(firstRow, lastRow){
  9041. return this.doc.removeFullLines(firstRow, lastRow);
  9042. };
  9043. this.undoChanges = function(deltas, dontSelect) {
  9044. if (!deltas.length)
  9045. return;
  9046. this.$fromUndo = true;
  9047. var lastUndoRange = null;
  9048. for (var i = deltas.length - 1; i != -1; i--) {
  9049. var delta = deltas[i];
  9050. if (delta.group == "doc") {
  9051. this.doc.revertDeltas(delta.deltas);
  9052. lastUndoRange =
  9053. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  9054. } else {
  9055. delta.deltas.forEach(function(foldDelta) {
  9056. this.addFolds(foldDelta.folds);
  9057. }, this);
  9058. }
  9059. }
  9060. this.$fromUndo = false;
  9061. lastUndoRange &&
  9062. this.$undoSelect &&
  9063. !dontSelect &&
  9064. this.selection.setSelectionRange(lastUndoRange);
  9065. return lastUndoRange;
  9066. };
  9067. this.redoChanges = function(deltas, dontSelect) {
  9068. if (!deltas.length)
  9069. return;
  9070. this.$fromUndo = true;
  9071. var lastUndoRange = null;
  9072. for (var i = 0; i < deltas.length; i++) {
  9073. var delta = deltas[i];
  9074. if (delta.group == "doc") {
  9075. this.doc.applyDeltas(delta.deltas);
  9076. lastUndoRange =
  9077. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  9078. }
  9079. }
  9080. this.$fromUndo = false;
  9081. lastUndoRange &&
  9082. this.$undoSelect &&
  9083. !dontSelect &&
  9084. this.selection.setSelectionRange(lastUndoRange);
  9085. return lastUndoRange;
  9086. };
  9087. this.setUndoSelect = function(enable) {
  9088. this.$undoSelect = enable;
  9089. };
  9090. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  9091. function isInsert(delta) {
  9092. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  9093. }
  9094. var delta = deltas[0];
  9095. var range, point;
  9096. var lastDeltaIsInsert = false;
  9097. if (isInsert(delta)) {
  9098. range = Range.fromPoints(delta.start, delta.end);
  9099. lastDeltaIsInsert = true;
  9100. } else {
  9101. range = Range.fromPoints(delta.start, delta.start);
  9102. lastDeltaIsInsert = false;
  9103. }
  9104. for (var i = 1; i < deltas.length; i++) {
  9105. delta = deltas[i];
  9106. if (isInsert(delta)) {
  9107. point = delta.start;
  9108. if (range.compare(point.row, point.column) == -1) {
  9109. range.setStart(point);
  9110. }
  9111. point = delta.end;
  9112. if (range.compare(point.row, point.column) == 1) {
  9113. range.setEnd(point);
  9114. }
  9115. lastDeltaIsInsert = true;
  9116. } else {
  9117. point = delta.start;
  9118. if (range.compare(point.row, point.column) == -1) {
  9119. range = Range.fromPoints(delta.start, delta.start);
  9120. }
  9121. lastDeltaIsInsert = false;
  9122. }
  9123. }
  9124. if (lastUndoRange != null) {
  9125. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  9126. lastUndoRange.start.column += range.end.column - range.start.column;
  9127. lastUndoRange.end.column += range.end.column - range.start.column;
  9128. }
  9129. var cmp = lastUndoRange.compareRange(range);
  9130. if (cmp == 1) {
  9131. range.setStart(lastUndoRange.start);
  9132. } else if (cmp == -1) {
  9133. range.setEnd(lastUndoRange.end);
  9134. }
  9135. }
  9136. return range;
  9137. };
  9138. this.replace = function(range, text) {
  9139. return this.doc.replace(range, text);
  9140. };
  9141. this.moveText = function(fromRange, toPosition, copy) {
  9142. var text = this.getTextRange(fromRange);
  9143. var folds = this.getFoldsInRange(fromRange);
  9144. var toRange = Range.fromPoints(toPosition, toPosition);
  9145. if (!copy) {
  9146. this.remove(fromRange);
  9147. var rowDiff = fromRange.start.row - fromRange.end.row;
  9148. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  9149. if (collDiff) {
  9150. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  9151. toRange.start.column += collDiff;
  9152. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  9153. toRange.end.column += collDiff;
  9154. }
  9155. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  9156. toRange.start.row += rowDiff;
  9157. toRange.end.row += rowDiff;
  9158. }
  9159. }
  9160. toRange.end = this.insert(toRange.start, text);
  9161. if (folds.length) {
  9162. var oldStart = fromRange.start;
  9163. var newStart = toRange.start;
  9164. var rowDiff = newStart.row - oldStart.row;
  9165. var collDiff = newStart.column - oldStart.column;
  9166. this.addFolds(folds.map(function(x) {
  9167. x = x.clone();
  9168. if (x.start.row == oldStart.row)
  9169. x.start.column += collDiff;
  9170. if (x.end.row == oldStart.row)
  9171. x.end.column += collDiff;
  9172. x.start.row += rowDiff;
  9173. x.end.row += rowDiff;
  9174. return x;
  9175. }));
  9176. }
  9177. return toRange;
  9178. };
  9179. this.indentRows = function(startRow, endRow, indentString) {
  9180. indentString = indentString.replace(/\t/g, this.getTabString());
  9181. for (var row=startRow; row<=endRow; row++)
  9182. this.doc.insertInLine({row: row, column: 0}, indentString);
  9183. };
  9184. this.outdentRows = function (range) {
  9185. var rowRange = range.collapseRows();
  9186. var deleteRange = new Range(0, 0, 0, 0);
  9187. var size = this.getTabSize();
  9188. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  9189. var line = this.getLine(i);
  9190. deleteRange.start.row = i;
  9191. deleteRange.end.row = i;
  9192. for (var j = 0; j < size; ++j)
  9193. if (line.charAt(j) != ' ')
  9194. break;
  9195. if (j < size && line.charAt(j) == '\t') {
  9196. deleteRange.start.column = j;
  9197. deleteRange.end.column = j + 1;
  9198. } else {
  9199. deleteRange.start.column = 0;
  9200. deleteRange.end.column = j;
  9201. }
  9202. this.remove(deleteRange);
  9203. }
  9204. };
  9205. this.$moveLines = function(firstRow, lastRow, dir) {
  9206. firstRow = this.getRowFoldStart(firstRow);
  9207. lastRow = this.getRowFoldEnd(lastRow);
  9208. if (dir < 0) {
  9209. var row = this.getRowFoldStart(firstRow + dir);
  9210. if (row < 0) return 0;
  9211. var diff = row-firstRow;
  9212. } else if (dir > 0) {
  9213. var row = this.getRowFoldEnd(lastRow + dir);
  9214. if (row > this.doc.getLength()-1) return 0;
  9215. var diff = row-lastRow;
  9216. } else {
  9217. firstRow = this.$clipRowToDocument(firstRow);
  9218. lastRow = this.$clipRowToDocument(lastRow);
  9219. var diff = lastRow - firstRow + 1;
  9220. }
  9221. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  9222. var folds = this.getFoldsInRange(range).map(function(x){
  9223. x = x.clone();
  9224. x.start.row += diff;
  9225. x.end.row += diff;
  9226. return x;
  9227. });
  9228. var lines = dir == 0
  9229. ? this.doc.getLines(firstRow, lastRow)
  9230. : this.doc.removeFullLines(firstRow, lastRow);
  9231. this.doc.insertFullLines(firstRow+diff, lines);
  9232. folds.length && this.addFolds(folds);
  9233. return diff;
  9234. };
  9235. this.moveLinesUp = function(firstRow, lastRow) {
  9236. return this.$moveLines(firstRow, lastRow, -1);
  9237. };
  9238. this.moveLinesDown = function(firstRow, lastRow) {
  9239. return this.$moveLines(firstRow, lastRow, 1);
  9240. };
  9241. this.duplicateLines = function(firstRow, lastRow) {
  9242. return this.$moveLines(firstRow, lastRow, 0);
  9243. };
  9244. this.$clipRowToDocument = function(row) {
  9245. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  9246. };
  9247. this.$clipColumnToRow = function(row, column) {
  9248. if (column < 0)
  9249. return 0;
  9250. return Math.min(this.doc.getLine(row).length, column);
  9251. };
  9252. this.$clipPositionToDocument = function(row, column) {
  9253. column = Math.max(0, column);
  9254. if (row < 0) {
  9255. row = 0;
  9256. column = 0;
  9257. } else {
  9258. var len = this.doc.getLength();
  9259. if (row >= len) {
  9260. row = len - 1;
  9261. column = this.doc.getLine(len-1).length;
  9262. } else {
  9263. column = Math.min(this.doc.getLine(row).length, column);
  9264. }
  9265. }
  9266. return {
  9267. row: row,
  9268. column: column
  9269. };
  9270. };
  9271. this.$clipRangeToDocument = function(range) {
  9272. if (range.start.row < 0) {
  9273. range.start.row = 0;
  9274. range.start.column = 0;
  9275. } else {
  9276. range.start.column = this.$clipColumnToRow(
  9277. range.start.row,
  9278. range.start.column
  9279. );
  9280. }
  9281. var len = this.doc.getLength() - 1;
  9282. if (range.end.row > len) {
  9283. range.end.row = len;
  9284. range.end.column = this.doc.getLine(len).length;
  9285. } else {
  9286. range.end.column = this.$clipColumnToRow(
  9287. range.end.row,
  9288. range.end.column
  9289. );
  9290. }
  9291. return range;
  9292. };
  9293. this.$wrapLimit = 80;
  9294. this.$useWrapMode = false;
  9295. this.$wrapLimitRange = {
  9296. min : null,
  9297. max : null
  9298. };
  9299. this.setUseWrapMode = function(useWrapMode) {
  9300. if (useWrapMode != this.$useWrapMode) {
  9301. this.$useWrapMode = useWrapMode;
  9302. this.$modified = true;
  9303. this.$resetRowCache(0);
  9304. if (useWrapMode) {
  9305. var len = this.getLength();
  9306. this.$wrapData = Array(len);
  9307. this.$updateWrapData(0, len - 1);
  9308. }
  9309. this._signal("changeWrapMode");
  9310. }
  9311. };
  9312. this.getUseWrapMode = function() {
  9313. return this.$useWrapMode;
  9314. };
  9315. this.setWrapLimitRange = function(min, max) {
  9316. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  9317. this.$wrapLimitRange = { min: min, max: max };
  9318. this.$modified = true;
  9319. this.$bidiHandler.markAsDirty();
  9320. if (this.$useWrapMode)
  9321. this._signal("changeWrapMode");
  9322. }
  9323. };
  9324. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  9325. var limits = this.$wrapLimitRange;
  9326. if (limits.max < 0)
  9327. limits = {min: $printMargin, max: $printMargin};
  9328. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  9329. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  9330. this.$wrapLimit = wrapLimit;
  9331. this.$modified = true;
  9332. if (this.$useWrapMode) {
  9333. this.$updateWrapData(0, this.getLength() - 1);
  9334. this.$resetRowCache(0);
  9335. this._signal("changeWrapLimit");
  9336. }
  9337. return true;
  9338. }
  9339. return false;
  9340. };
  9341. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  9342. if (min)
  9343. wrapLimit = Math.max(min, wrapLimit);
  9344. if (max)
  9345. wrapLimit = Math.min(max, wrapLimit);
  9346. return wrapLimit;
  9347. };
  9348. this.getWrapLimit = function() {
  9349. return this.$wrapLimit;
  9350. };
  9351. this.setWrapLimit = function (limit) {
  9352. this.setWrapLimitRange(limit, limit);
  9353. };
  9354. this.getWrapLimitRange = function() {
  9355. return {
  9356. min : this.$wrapLimitRange.min,
  9357. max : this.$wrapLimitRange.max
  9358. };
  9359. };
  9360. this.$updateInternalDataOnChange = function(delta) {
  9361. var useWrapMode = this.$useWrapMode;
  9362. var action = delta.action;
  9363. var start = delta.start;
  9364. var end = delta.end;
  9365. var firstRow = start.row;
  9366. var lastRow = end.row;
  9367. var len = lastRow - firstRow;
  9368. var removedFolds = null;
  9369. this.$updating = true;
  9370. if (len != 0) {
  9371. if (action === "remove") {
  9372. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  9373. var foldLines = this.$foldData;
  9374. removedFolds = this.getFoldsInRange(delta);
  9375. this.removeFolds(removedFolds);
  9376. var foldLine = this.getFoldLine(end.row);
  9377. var idx = 0;
  9378. if (foldLine) {
  9379. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  9380. foldLine.shiftRow(-len);
  9381. var foldLineBefore = this.getFoldLine(firstRow);
  9382. if (foldLineBefore && foldLineBefore !== foldLine) {
  9383. foldLineBefore.merge(foldLine);
  9384. foldLine = foldLineBefore;
  9385. }
  9386. idx = foldLines.indexOf(foldLine) + 1;
  9387. }
  9388. for (idx; idx < foldLines.length; idx++) {
  9389. var foldLine = foldLines[idx];
  9390. if (foldLine.start.row >= end.row) {
  9391. foldLine.shiftRow(-len);
  9392. }
  9393. }
  9394. lastRow = firstRow;
  9395. } else {
  9396. var args = Array(len);
  9397. args.unshift(firstRow, 0);
  9398. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache;
  9399. arr.splice.apply(arr, args);
  9400. var foldLines = this.$foldData;
  9401. var foldLine = this.getFoldLine(firstRow);
  9402. var idx = 0;
  9403. if (foldLine) {
  9404. var cmp = foldLine.range.compareInside(start.row, start.column);
  9405. if (cmp == 0) {
  9406. foldLine = foldLine.split(start.row, start.column);
  9407. if (foldLine) {
  9408. foldLine.shiftRow(len);
  9409. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  9410. }
  9411. } else
  9412. if (cmp == -1) {
  9413. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  9414. foldLine.shiftRow(len);
  9415. }
  9416. idx = foldLines.indexOf(foldLine) + 1;
  9417. }
  9418. for (idx; idx < foldLines.length; idx++) {
  9419. var foldLine = foldLines[idx];
  9420. if (foldLine.start.row >= firstRow) {
  9421. foldLine.shiftRow(len);
  9422. }
  9423. }
  9424. }
  9425. } else {
  9426. len = Math.abs(delta.start.column - delta.end.column);
  9427. if (action === "remove") {
  9428. removedFolds = this.getFoldsInRange(delta);
  9429. this.removeFolds(removedFolds);
  9430. len = -len;
  9431. }
  9432. var foldLine = this.getFoldLine(firstRow);
  9433. if (foldLine) {
  9434. foldLine.addRemoveChars(firstRow, start.column, len);
  9435. }
  9436. }
  9437. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  9438. console.error("doc.getLength() and $wrapData.length have to be the same!");
  9439. }
  9440. this.$updating = false;
  9441. if (useWrapMode)
  9442. this.$updateWrapData(firstRow, lastRow);
  9443. else
  9444. this.$updateRowLengthCache(firstRow, lastRow);
  9445. return removedFolds;
  9446. };
  9447. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  9448. this.$rowLengthCache[firstRow] = null;
  9449. this.$rowLengthCache[lastRow] = null;
  9450. };
  9451. this.$updateWrapData = function(firstRow, lastRow) {
  9452. var lines = this.doc.getAllLines();
  9453. var tabSize = this.getTabSize();
  9454. var wrapData = this.$wrapData;
  9455. var wrapLimit = this.$wrapLimit;
  9456. var tokens;
  9457. var foldLine;
  9458. var row = firstRow;
  9459. lastRow = Math.min(lastRow, lines.length - 1);
  9460. while (row <= lastRow) {
  9461. foldLine = this.getFoldLine(row, foldLine);
  9462. if (!foldLine) {
  9463. tokens = this.$getDisplayTokens(lines[row]);
  9464. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  9465. row ++;
  9466. } else {
  9467. tokens = [];
  9468. foldLine.walk(function(placeholder, row, column, lastColumn) {
  9469. var walkTokens;
  9470. if (placeholder != null) {
  9471. walkTokens = this.$getDisplayTokens(
  9472. placeholder, tokens.length);
  9473. walkTokens[0] = PLACEHOLDER_START;
  9474. for (var i = 1; i < walkTokens.length; i++) {
  9475. walkTokens[i] = PLACEHOLDER_BODY;
  9476. }
  9477. } else {
  9478. walkTokens = this.$getDisplayTokens(
  9479. lines[row].substring(lastColumn, column),
  9480. tokens.length);
  9481. }
  9482. tokens = tokens.concat(walkTokens);
  9483. }.bind(this),
  9484. foldLine.end.row,
  9485. lines[foldLine.end.row].length + 1
  9486. );
  9487. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  9488. row = foldLine.end.row + 1;
  9489. }
  9490. }
  9491. };
  9492. var CHAR = 1,
  9493. CHAR_EXT = 2,
  9494. PLACEHOLDER_START = 3,
  9495. PLACEHOLDER_BODY = 4,
  9496. PUNCTUATION = 9,
  9497. SPACE = 10,
  9498. TAB = 11,
  9499. TAB_SPACE = 12;
  9500. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  9501. if (tokens.length == 0) {
  9502. return [];
  9503. }
  9504. var splits = [];
  9505. var displayLength = tokens.length;
  9506. var lastSplit = 0, lastDocSplit = 0;
  9507. var isCode = this.$wrapAsCode;
  9508. var indentedSoftWrap = this.$indentedSoftWrap;
  9509. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  9510. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  9511. function getWrapIndent() {
  9512. var indentation = 0;
  9513. if (maxIndent === 0)
  9514. return indentation;
  9515. if (indentedSoftWrap) {
  9516. for (var i = 0; i < tokens.length; i++) {
  9517. var token = tokens[i];
  9518. if (token == SPACE)
  9519. indentation += 1;
  9520. else if (token == TAB)
  9521. indentation += tabSize;
  9522. else if (token == TAB_SPACE)
  9523. continue;
  9524. else
  9525. break;
  9526. }
  9527. }
  9528. if (isCode && indentedSoftWrap !== false)
  9529. indentation += tabSize;
  9530. return Math.min(indentation, maxIndent);
  9531. }
  9532. function addSplit(screenPos) {
  9533. var displayed = tokens.slice(lastSplit, screenPos);
  9534. var len = displayed.length;
  9535. displayed.join("")
  9536. .replace(/12/g, function() {
  9537. len -= 1;
  9538. })
  9539. .replace(/2/g, function() {
  9540. len -= 1;
  9541. });
  9542. if (!splits.length) {
  9543. indent = getWrapIndent();
  9544. splits.indent = indent;
  9545. }
  9546. lastDocSplit += len;
  9547. splits.push(lastDocSplit);
  9548. lastSplit = screenPos;
  9549. }
  9550. var indent = 0;
  9551. while (displayLength - lastSplit > wrapLimit - indent) {
  9552. var split = lastSplit + wrapLimit - indent;
  9553. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  9554. addSplit(split);
  9555. continue;
  9556. }
  9557. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  9558. for (split; split != lastSplit - 1; split--) {
  9559. if (tokens[split] == PLACEHOLDER_START) {
  9560. break;
  9561. }
  9562. }
  9563. if (split > lastSplit) {
  9564. addSplit(split);
  9565. continue;
  9566. }
  9567. split = lastSplit + wrapLimit;
  9568. for (split; split < tokens.length; split++) {
  9569. if (tokens[split] != PLACEHOLDER_BODY) {
  9570. break;
  9571. }
  9572. }
  9573. if (split == tokens.length) {
  9574. break; // Breaks the while-loop.
  9575. }
  9576. addSplit(split);
  9577. continue;
  9578. }
  9579. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  9580. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  9581. split --;
  9582. }
  9583. if (isCode) {
  9584. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  9585. split --;
  9586. }
  9587. while (split > minSplit && tokens[split] == PUNCTUATION) {
  9588. split --;
  9589. }
  9590. } else {
  9591. while (split > minSplit && tokens[split] < SPACE) {
  9592. split --;
  9593. }
  9594. }
  9595. if (split > minSplit) {
  9596. addSplit(++split);
  9597. continue;
  9598. }
  9599. split = lastSplit + wrapLimit;
  9600. if (tokens[split] == CHAR_EXT)
  9601. split--;
  9602. addSplit(split - indent);
  9603. }
  9604. return splits;
  9605. };
  9606. this.$getDisplayTokens = function(str, offset) {
  9607. var arr = [];
  9608. var tabSize;
  9609. offset = offset || 0;
  9610. for (var i = 0; i < str.length; i++) {
  9611. var c = str.charCodeAt(i);
  9612. if (c == 9) {
  9613. tabSize = this.getScreenTabSize(arr.length + offset);
  9614. arr.push(TAB);
  9615. for (var n = 1; n < tabSize; n++) {
  9616. arr.push(TAB_SPACE);
  9617. }
  9618. }
  9619. else if (c == 32) {
  9620. arr.push(SPACE);
  9621. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  9622. arr.push(PUNCTUATION);
  9623. }
  9624. else if (c >= 0x1100 && isFullWidth(c)) {
  9625. arr.push(CHAR, CHAR_EXT);
  9626. } else {
  9627. arr.push(CHAR);
  9628. }
  9629. }
  9630. return arr;
  9631. };
  9632. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  9633. if (maxScreenColumn == 0)
  9634. return [0, 0];
  9635. if (maxScreenColumn == null)
  9636. maxScreenColumn = Infinity;
  9637. screenColumn = screenColumn || 0;
  9638. var c, column;
  9639. for (column = 0; column < str.length; column++) {
  9640. c = str.charCodeAt(column);
  9641. if (c == 9) {
  9642. screenColumn += this.getScreenTabSize(screenColumn);
  9643. }
  9644. else if (c >= 0x1100 && isFullWidth(c)) {
  9645. screenColumn += 2;
  9646. } else {
  9647. screenColumn += 1;
  9648. }
  9649. if (screenColumn > maxScreenColumn) {
  9650. break;
  9651. }
  9652. }
  9653. return [screenColumn, column];
  9654. };
  9655. this.lineWidgets = null;
  9656. this.getRowLength = function(row) {
  9657. if (this.lineWidgets)
  9658. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  9659. else
  9660. h = 0;
  9661. if (!this.$useWrapMode || !this.$wrapData[row]) {
  9662. return 1 + h;
  9663. } else {
  9664. return this.$wrapData[row].length + 1 + h;
  9665. }
  9666. };
  9667. this.getRowLineCount = function(row) {
  9668. if (!this.$useWrapMode || !this.$wrapData[row]) {
  9669. return 1;
  9670. } else {
  9671. return this.$wrapData[row].length + 1;
  9672. }
  9673. };
  9674. this.getRowWrapIndent = function(screenRow) {
  9675. if (this.$useWrapMode) {
  9676. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  9677. var splits = this.$wrapData[pos.row];
  9678. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  9679. } else {
  9680. return 0;
  9681. }
  9682. };
  9683. this.getScreenLastRowColumn = function(screenRow) {
  9684. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  9685. return this.documentToScreenColumn(pos.row, pos.column);
  9686. };
  9687. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  9688. var screenRow = this.documentToScreenRow(docRow, docColumn);
  9689. return this.getScreenLastRowColumn(screenRow);
  9690. };
  9691. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  9692. var screenRow = this.documentToScreenRow(docRow, docColumn);
  9693. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  9694. };
  9695. this.getRowSplitData = function(row) {
  9696. if (!this.$useWrapMode) {
  9697. return undefined;
  9698. } else {
  9699. return this.$wrapData[row];
  9700. }
  9701. };
  9702. this.getScreenTabSize = function(screenColumn) {
  9703. return this.$tabSize - screenColumn % this.$tabSize;
  9704. };
  9705. this.screenToDocumentRow = function(screenRow, screenColumn) {
  9706. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  9707. };
  9708. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  9709. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  9710. };
  9711. this.screenToDocumentPosition = function(screenRow, screenColumn, offsetX) {
  9712. if (screenRow < 0)
  9713. return {row: 0, column: 0};
  9714. var line;
  9715. var docRow = 0;
  9716. var docColumn = 0;
  9717. var column;
  9718. var row = 0;
  9719. var rowLength = 0;
  9720. var rowCache = this.$screenRowCache;
  9721. var i = this.$getRowCacheIndex(rowCache, screenRow);
  9722. var l = rowCache.length;
  9723. if (l && i >= 0) {
  9724. var row = rowCache[i];
  9725. var docRow = this.$docRowCache[i];
  9726. var doCache = screenRow > rowCache[l - 1];
  9727. } else {
  9728. var doCache = !l;
  9729. }
  9730. var maxRow = this.getLength() - 1;
  9731. var foldLine = this.getNextFoldLine(docRow);
  9732. var foldStart = foldLine ? foldLine.start.row : Infinity;
  9733. while (row <= screenRow) {
  9734. rowLength = this.getRowLength(docRow);
  9735. if (row + rowLength > screenRow || docRow >= maxRow) {
  9736. break;
  9737. } else {
  9738. row += rowLength;
  9739. docRow++;
  9740. if (docRow > foldStart) {
  9741. docRow = foldLine.end.row+1;
  9742. foldLine = this.getNextFoldLine(docRow, foldLine);
  9743. foldStart = foldLine ? foldLine.start.row : Infinity;
  9744. }
  9745. }
  9746. if (doCache) {
  9747. this.$docRowCache.push(docRow);
  9748. this.$screenRowCache.push(row);
  9749. }
  9750. }
  9751. if (foldLine && foldLine.start.row <= docRow) {
  9752. line = this.getFoldDisplayLine(foldLine);
  9753. docRow = foldLine.start.row;
  9754. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  9755. return {
  9756. row: maxRow,
  9757. column: this.getLine(maxRow).length
  9758. };
  9759. } else {
  9760. line = this.getLine(docRow);
  9761. foldLine = null;
  9762. }
  9763. var wrapIndent = 0, splitIndex = Math.floor(screenRow - row);
  9764. if (this.$useWrapMode) {
  9765. var splits = this.$wrapData[docRow];
  9766. if (splits) {
  9767. column = splits[splitIndex];
  9768. if(splitIndex > 0 && splits.length) {
  9769. wrapIndent = splits.indent;
  9770. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  9771. line = line.substring(docColumn);
  9772. }
  9773. }
  9774. }
  9775. if (offsetX !== undefined && this.$bidiHandler.isBidiRow(row + splitIndex, docRow, splitIndex))
  9776. screenColumn = this.$bidiHandler.offsetToCol(offsetX);
  9777. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  9778. if (this.$useWrapMode && docColumn >= column)
  9779. docColumn = column - 1;
  9780. if (foldLine)
  9781. return foldLine.idxToPosition(docColumn);
  9782. return {row: docRow, column: docColumn};
  9783. };
  9784. this.documentToScreenPosition = function(docRow, docColumn) {
  9785. if (typeof docColumn === "undefined")
  9786. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  9787. else
  9788. pos = this.$clipPositionToDocument(docRow, docColumn);
  9789. docRow = pos.row;
  9790. docColumn = pos.column;
  9791. var screenRow = 0;
  9792. var foldStartRow = null;
  9793. var fold = null;
  9794. fold = this.getFoldAt(docRow, docColumn, 1);
  9795. if (fold) {
  9796. docRow = fold.start.row;
  9797. docColumn = fold.start.column;
  9798. }
  9799. var rowEnd, row = 0;
  9800. var rowCache = this.$docRowCache;
  9801. var i = this.$getRowCacheIndex(rowCache, docRow);
  9802. var l = rowCache.length;
  9803. if (l && i >= 0) {
  9804. var row = rowCache[i];
  9805. var screenRow = this.$screenRowCache[i];
  9806. var doCache = docRow > rowCache[l - 1];
  9807. } else {
  9808. var doCache = !l;
  9809. }
  9810. var foldLine = this.getNextFoldLine(row);
  9811. var foldStart = foldLine ?foldLine.start.row :Infinity;
  9812. while (row < docRow) {
  9813. if (row >= foldStart) {
  9814. rowEnd = foldLine.end.row + 1;
  9815. if (rowEnd > docRow)
  9816. break;
  9817. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  9818. foldStart = foldLine ?foldLine.start.row :Infinity;
  9819. }
  9820. else {
  9821. rowEnd = row + 1;
  9822. }
  9823. screenRow += this.getRowLength(row);
  9824. row = rowEnd;
  9825. if (doCache) {
  9826. this.$docRowCache.push(row);
  9827. this.$screenRowCache.push(screenRow);
  9828. }
  9829. }
  9830. var textLine = "";
  9831. if (foldLine && row >= foldStart) {
  9832. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  9833. foldStartRow = foldLine.start.row;
  9834. } else {
  9835. textLine = this.getLine(docRow).substring(0, docColumn);
  9836. foldStartRow = docRow;
  9837. }
  9838. var wrapIndent = 0;
  9839. if (this.$useWrapMode) {
  9840. var wrapRow = this.$wrapData[foldStartRow];
  9841. if (wrapRow) {
  9842. var screenRowOffset = 0;
  9843. while (textLine.length >= wrapRow[screenRowOffset]) {
  9844. screenRow ++;
  9845. screenRowOffset++;
  9846. }
  9847. textLine = textLine.substring(
  9848. wrapRow[screenRowOffset - 1] || 0, textLine.length
  9849. );
  9850. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  9851. }
  9852. }
  9853. return {
  9854. row: screenRow,
  9855. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  9856. };
  9857. };
  9858. this.documentToScreenColumn = function(row, docColumn) {
  9859. return this.documentToScreenPosition(row, docColumn).column;
  9860. };
  9861. this.documentToScreenRow = function(docRow, docColumn) {
  9862. return this.documentToScreenPosition(docRow, docColumn).row;
  9863. };
  9864. this.getScreenLength = function() {
  9865. var screenRows = 0;
  9866. var fold = null;
  9867. if (!this.$useWrapMode) {
  9868. screenRows = this.getLength();
  9869. var foldData = this.$foldData;
  9870. for (var i = 0; i < foldData.length; i++) {
  9871. fold = foldData[i];
  9872. screenRows -= fold.end.row - fold.start.row;
  9873. }
  9874. } else {
  9875. var lastRow = this.$wrapData.length;
  9876. var row = 0, i = 0;
  9877. var fold = this.$foldData[i++];
  9878. var foldStart = fold ? fold.start.row :Infinity;
  9879. while (row < lastRow) {
  9880. var splits = this.$wrapData[row];
  9881. screenRows += splits ? splits.length + 1 : 1;
  9882. row ++;
  9883. if (row > foldStart) {
  9884. row = fold.end.row+1;
  9885. fold = this.$foldData[i++];
  9886. foldStart = fold ?fold.start.row :Infinity;
  9887. }
  9888. }
  9889. }
  9890. if (this.lineWidgets)
  9891. screenRows += this.$getWidgetScreenLength();
  9892. return screenRows;
  9893. };
  9894. this.$setFontMetrics = function(fm) {
  9895. if (!this.$enableVarChar) return;
  9896. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  9897. if (maxScreenColumn === 0)
  9898. return [0, 0];
  9899. if (!maxScreenColumn)
  9900. maxScreenColumn = Infinity;
  9901. screenColumn = screenColumn || 0;
  9902. var c, column;
  9903. for (column = 0; column < str.length; column++) {
  9904. c = str.charAt(column);
  9905. if (c === "\t") {
  9906. screenColumn += this.getScreenTabSize(screenColumn);
  9907. } else {
  9908. screenColumn += fm.getCharacterWidth(c);
  9909. }
  9910. if (screenColumn > maxScreenColumn) {
  9911. break;
  9912. }
  9913. }
  9914. return [screenColumn, column];
  9915. };
  9916. };
  9917. this.destroy = function() {
  9918. if (this.bgTokenizer) {
  9919. this.bgTokenizer.setDocument(null);
  9920. this.bgTokenizer = null;
  9921. }
  9922. this.$stopWorker();
  9923. };
  9924. this.isFullWidth = isFullWidth;
  9925. function isFullWidth(c) {
  9926. if (c < 0x1100)
  9927. return false;
  9928. return c >= 0x1100 && c <= 0x115F ||
  9929. c >= 0x11A3 && c <= 0x11A7 ||
  9930. c >= 0x11FA && c <= 0x11FF ||
  9931. c >= 0x2329 && c <= 0x232A ||
  9932. c >= 0x2E80 && c <= 0x2E99 ||
  9933. c >= 0x2E9B && c <= 0x2EF3 ||
  9934. c >= 0x2F00 && c <= 0x2FD5 ||
  9935. c >= 0x2FF0 && c <= 0x2FFB ||
  9936. c >= 0x3000 && c <= 0x303E ||
  9937. c >= 0x3041 && c <= 0x3096 ||
  9938. c >= 0x3099 && c <= 0x30FF ||
  9939. c >= 0x3105 && c <= 0x312D ||
  9940. c >= 0x3131 && c <= 0x318E ||
  9941. c >= 0x3190 && c <= 0x31BA ||
  9942. c >= 0x31C0 && c <= 0x31E3 ||
  9943. c >= 0x31F0 && c <= 0x321E ||
  9944. c >= 0x3220 && c <= 0x3247 ||
  9945. c >= 0x3250 && c <= 0x32FE ||
  9946. c >= 0x3300 && c <= 0x4DBF ||
  9947. c >= 0x4E00 && c <= 0xA48C ||
  9948. c >= 0xA490 && c <= 0xA4C6 ||
  9949. c >= 0xA960 && c <= 0xA97C ||
  9950. c >= 0xAC00 && c <= 0xD7A3 ||
  9951. c >= 0xD7B0 && c <= 0xD7C6 ||
  9952. c >= 0xD7CB && c <= 0xD7FB ||
  9953. c >= 0xF900 && c <= 0xFAFF ||
  9954. c >= 0xFE10 && c <= 0xFE19 ||
  9955. c >= 0xFE30 && c <= 0xFE52 ||
  9956. c >= 0xFE54 && c <= 0xFE66 ||
  9957. c >= 0xFE68 && c <= 0xFE6B ||
  9958. c >= 0xFF01 && c <= 0xFF60 ||
  9959. c >= 0xFFE0 && c <= 0xFFE6;
  9960. }
  9961. }).call(EditSession.prototype);
  9962. require("./edit_session/folding").Folding.call(EditSession.prototype);
  9963. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  9964. config.defineOptions(EditSession.prototype, "session", {
  9965. wrap: {
  9966. set: function(value) {
  9967. if (!value || value == "off")
  9968. value = false;
  9969. else if (value == "free")
  9970. value = true;
  9971. else if (value == "printMargin")
  9972. value = -1;
  9973. else if (typeof value == "string")
  9974. value = parseInt(value, 10) || false;
  9975. if (this.$wrap == value)
  9976. return;
  9977. this.$wrap = value;
  9978. if (!value) {
  9979. this.setUseWrapMode(false);
  9980. } else {
  9981. var col = typeof value == "number" ? value : null;
  9982. this.setWrapLimitRange(col, col);
  9983. this.setUseWrapMode(true);
  9984. }
  9985. },
  9986. get: function() {
  9987. if (this.getUseWrapMode()) {
  9988. if (this.$wrap == -1)
  9989. return "printMargin";
  9990. if (!this.getWrapLimitRange().min)
  9991. return "free";
  9992. return this.$wrap;
  9993. }
  9994. return "off";
  9995. },
  9996. handlesSet: true
  9997. },
  9998. wrapMethod: {
  9999. set: function(val) {
  10000. val = val == "auto"
  10001. ? this.$mode.type != "text"
  10002. : val != "text";
  10003. if (val != this.$wrapAsCode) {
  10004. this.$wrapAsCode = val;
  10005. if (this.$useWrapMode) {
  10006. this.$modified = true;
  10007. this.$resetRowCache(0);
  10008. this.$updateWrapData(0, this.getLength() - 1);
  10009. }
  10010. }
  10011. },
  10012. initialValue: "auto"
  10013. },
  10014. indentedSoftWrap: { initialValue: true },
  10015. firstLineNumber: {
  10016. set: function() {this._signal("changeBreakpoint");},
  10017. initialValue: 1
  10018. },
  10019. useWorker: {
  10020. set: function(useWorker) {
  10021. this.$useWorker = useWorker;
  10022. this.$stopWorker();
  10023. if (useWorker)
  10024. this.$startWorker();
  10025. },
  10026. initialValue: true
  10027. },
  10028. useSoftTabs: {initialValue: true},
  10029. tabSize: {
  10030. set: function(tabSize) {
  10031. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  10032. this.$modified = true;
  10033. this.$rowLengthCache = [];
  10034. this.$tabSize = tabSize;
  10035. this._signal("changeTabSize");
  10036. },
  10037. initialValue: 4,
  10038. handlesSet: true
  10039. },
  10040. navigateWithinSoftTabs: {initialValue: false},
  10041. overwrite: {
  10042. set: function(val) {this._signal("changeOverwrite");},
  10043. initialValue: false
  10044. },
  10045. newLineMode: {
  10046. set: function(val) {this.doc.setNewLineMode(val);},
  10047. get: function() {return this.doc.getNewLineMode();},
  10048. handlesSet: true
  10049. },
  10050. mode: {
  10051. set: function(val) { this.setMode(val); },
  10052. get: function() { return this.$modeId; }
  10053. }
  10054. });
  10055. exports.EditSession = EditSession;
  10056. });
  10057. define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  10058. "use strict";
  10059. var lang = require("./lib/lang");
  10060. var oop = require("./lib/oop");
  10061. var Range = require("./range").Range;
  10062. var Search = function() {
  10063. this.$options = {};
  10064. };
  10065. (function() {
  10066. this.set = function(options) {
  10067. oop.mixin(this.$options, options);
  10068. return this;
  10069. };
  10070. this.getOptions = function() {
  10071. return lang.copyObject(this.$options);
  10072. };
  10073. this.setOptions = function(options) {
  10074. this.$options = options;
  10075. };
  10076. this.find = function(session) {
  10077. var options = this.$options;
  10078. var iterator = this.$matchIterator(session, options);
  10079. if (!iterator)
  10080. return false;
  10081. var firstRange = null;
  10082. iterator.forEach(function(sr, sc, er, ec) {
  10083. firstRange = new Range(sr, sc, er, ec);
  10084. if (sc == ec && options.start && options.start.start
  10085. && options.skipCurrent != false && firstRange.isEqual(options.start)
  10086. ) {
  10087. firstRange = null;
  10088. return false;
  10089. }
  10090. return true;
  10091. });
  10092. return firstRange;
  10093. };
  10094. this.findAll = function(session) {
  10095. var options = this.$options;
  10096. if (!options.needle)
  10097. return [];
  10098. this.$assembleRegExp(options);
  10099. var range = options.range;
  10100. var lines = range
  10101. ? session.getLines(range.start.row, range.end.row)
  10102. : session.doc.getAllLines();
  10103. var ranges = [];
  10104. var re = options.re;
  10105. if (options.$isMultiLine) {
  10106. var len = re.length;
  10107. var maxRow = lines.length - len;
  10108. var prevRange;
  10109. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  10110. for (var j = 0; j < len; j++)
  10111. if (lines[row + j].search(re[j]) == -1)
  10112. continue outer;
  10113. var startLine = lines[row];
  10114. var line = lines[row + len - 1];
  10115. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  10116. var endIndex = line.match(re[len - 1])[0].length;
  10117. if (prevRange && prevRange.end.row === row &&
  10118. prevRange.end.column > startIndex
  10119. ) {
  10120. continue;
  10121. }
  10122. ranges.push(prevRange = new Range(
  10123. row, startIndex, row + len - 1, endIndex
  10124. ));
  10125. if (len > 2)
  10126. row = row + len - 2;
  10127. }
  10128. } else {
  10129. for (var i = 0; i < lines.length; i++) {
  10130. var matches = lang.getMatchOffsets(lines[i], re);
  10131. for (var j = 0; j < matches.length; j++) {
  10132. var match = matches[j];
  10133. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  10134. }
  10135. }
  10136. }
  10137. if (range) {
  10138. var startColumn = range.start.column;
  10139. var endColumn = range.start.column;
  10140. var i = 0, j = ranges.length - 1;
  10141. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  10142. i++;
  10143. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  10144. j--;
  10145. ranges = ranges.slice(i, j + 1);
  10146. for (i = 0, j = ranges.length; i < j; i++) {
  10147. ranges[i].start.row += range.start.row;
  10148. ranges[i].end.row += range.start.row;
  10149. }
  10150. }
  10151. return ranges;
  10152. };
  10153. this.replace = function(input, replacement) {
  10154. var options = this.$options;
  10155. var re = this.$assembleRegExp(options);
  10156. if (options.$isMultiLine)
  10157. return replacement;
  10158. if (!re)
  10159. return;
  10160. var match = re.exec(input);
  10161. if (!match || match[0].length != input.length)
  10162. return null;
  10163. replacement = input.replace(re, replacement);
  10164. if (options.preserveCase) {
  10165. replacement = replacement.split("");
  10166. for (var i = Math.min(input.length, input.length); i--; ) {
  10167. var ch = input[i];
  10168. if (ch && ch.toLowerCase() != ch)
  10169. replacement[i] = replacement[i].toUpperCase();
  10170. else
  10171. replacement[i] = replacement[i].toLowerCase();
  10172. }
  10173. replacement = replacement.join("");
  10174. }
  10175. return replacement;
  10176. };
  10177. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  10178. if (options.needle instanceof RegExp)
  10179. return options.re = options.needle;
  10180. var needle = options.needle;
  10181. if (!options.needle)
  10182. return options.re = false;
  10183. if (!options.regExp)
  10184. needle = lang.escapeRegExp(needle);
  10185. if (options.wholeWord)
  10186. needle = addWordBoundary(needle, options);
  10187. var modifier = options.caseSensitive ? "gm" : "gmi";
  10188. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  10189. if (options.$isMultiLine)
  10190. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  10191. try {
  10192. var re = new RegExp(needle, modifier);
  10193. } catch(e) {
  10194. re = false;
  10195. }
  10196. return options.re = re;
  10197. };
  10198. this.$assembleMultilineRegExp = function(needle, modifier) {
  10199. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  10200. var re = [];
  10201. for (var i = 0; i < parts.length; i++) try {
  10202. re.push(new RegExp(parts[i], modifier));
  10203. } catch(e) {
  10204. return false;
  10205. }
  10206. return re;
  10207. };
  10208. this.$matchIterator = function(session, options) {
  10209. var re = this.$assembleRegExp(options);
  10210. if (!re)
  10211. return false;
  10212. var backwards = options.backwards == true;
  10213. var skipCurrent = options.skipCurrent != false;
  10214. var range = options.range;
  10215. var start = options.start;
  10216. if (!start)
  10217. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  10218. if (start.start)
  10219. start = start[skipCurrent != backwards ? "end" : "start"];
  10220. var firstRow = range ? range.start.row : 0;
  10221. var lastRow = range ? range.end.row : session.getLength() - 1;
  10222. if (backwards) {
  10223. var forEach = function(callback) {
  10224. var row = start.row;
  10225. if (forEachInLine(row, start.column, callback))
  10226. return;
  10227. for (row--; row >= firstRow; row--)
  10228. if (forEachInLine(row, Number.MAX_VALUE, callback))
  10229. return;
  10230. if (options.wrap == false)
  10231. return;
  10232. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  10233. if (forEachInLine(row, Number.MAX_VALUE, callback))
  10234. return;
  10235. };
  10236. }
  10237. else {
  10238. var forEach = function(callback) {
  10239. var row = start.row;
  10240. if (forEachInLine(row, start.column, callback))
  10241. return;
  10242. for (row = row + 1; row <= lastRow; row++)
  10243. if (forEachInLine(row, 0, callback))
  10244. return;
  10245. if (options.wrap == false)
  10246. return;
  10247. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  10248. if (forEachInLine(row, 0, callback))
  10249. return;
  10250. };
  10251. }
  10252. if (options.$isMultiLine) {
  10253. var len = re.length;
  10254. var forEachInLine = function(row, offset, callback) {
  10255. var startRow = backwards ? row - len + 1 : row;
  10256. if (startRow < 0) return;
  10257. var line = session.getLine(startRow);
  10258. var startIndex = line.search(re[0]);
  10259. if (!backwards && startIndex < offset || startIndex === -1) return;
  10260. for (var i = 1; i < len; i++) {
  10261. line = session.getLine(startRow + i);
  10262. if (line.search(re[i]) == -1)
  10263. return;
  10264. }
  10265. var endIndex = line.match(re[len - 1])[0].length;
  10266. if (backwards && endIndex > offset) return;
  10267. if (callback(startRow, startIndex, startRow + len - 1, endIndex))
  10268. return true;
  10269. };
  10270. }
  10271. else if (backwards) {
  10272. var forEachInLine = function(row, endIndex, callback) {
  10273. var line = session.getLine(row);
  10274. var matches = [];
  10275. var m, last = 0;
  10276. re.lastIndex = 0;
  10277. while((m = re.exec(line))) {
  10278. var length = m[0].length;
  10279. last = m.index;
  10280. if (!length) {
  10281. if (last >= line.length) break;
  10282. re.lastIndex = last += 1;
  10283. }
  10284. if (m.index + length > endIndex)
  10285. break;
  10286. matches.push(m.index, length);
  10287. }
  10288. for (var i = matches.length - 1; i >= 0; i -= 2) {
  10289. var column = matches[i - 1];
  10290. var length = matches[i];
  10291. if (callback(row, column, row, column + length))
  10292. return true;
  10293. }
  10294. };
  10295. }
  10296. else {
  10297. var forEachInLine = function(row, startIndex, callback) {
  10298. var line = session.getLine(row);
  10299. var m;
  10300. var last = startIndex;
  10301. re.lastIndex = startIndex;
  10302. while((m = re.exec(line))) {
  10303. var length = m[0].length;
  10304. last = m.index;
  10305. if (callback(row, last, row,last + length))
  10306. return true;
  10307. if (!length) {
  10308. re.lastIndex = last += 1;
  10309. if (last >= line.length) return false;
  10310. }
  10311. }
  10312. };
  10313. }
  10314. return {forEach: forEach};
  10315. };
  10316. }).call(Search.prototype);
  10317. function addWordBoundary(needle, options) {
  10318. function wordBoundary(c) {
  10319. if (/\w/.test(c) || options.regExp) return "\\b";
  10320. return "";
  10321. }
  10322. return wordBoundary(needle[0]) + needle
  10323. + wordBoundary(needle[needle.length - 1]);
  10324. }
  10325. exports.Search = Search;
  10326. });
  10327. define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  10328. "use strict";
  10329. var keyUtil = require("../lib/keys");
  10330. var useragent = require("../lib/useragent");
  10331. var KEY_MODS = keyUtil.KEY_MODS;
  10332. function HashHandler(config, platform) {
  10333. this.platform = platform || (useragent.isMac ? "mac" : "win");
  10334. this.commands = {};
  10335. this.commandKeyBinding = {};
  10336. this.addCommands(config);
  10337. this.$singleCommand = true;
  10338. }
  10339. function MultiHashHandler(config, platform) {
  10340. HashHandler.call(this, config, platform);
  10341. this.$singleCommand = false;
  10342. }
  10343. MultiHashHandler.prototype = HashHandler.prototype;
  10344. (function() {
  10345. this.addCommand = function(command) {
  10346. if (this.commands[command.name])
  10347. this.removeCommand(command);
  10348. this.commands[command.name] = command;
  10349. if (command.bindKey)
  10350. this._buildKeyHash(command);
  10351. };
  10352. this.removeCommand = function(command, keepCommand) {
  10353. var name = command && (typeof command === 'string' ? command : command.name);
  10354. command = this.commands[name];
  10355. if (!keepCommand)
  10356. delete this.commands[name];
  10357. var ckb = this.commandKeyBinding;
  10358. for (var keyId in ckb) {
  10359. var cmdGroup = ckb[keyId];
  10360. if (cmdGroup == command) {
  10361. delete ckb[keyId];
  10362. } else if (Array.isArray(cmdGroup)) {
  10363. var i = cmdGroup.indexOf(command);
  10364. if (i != -1) {
  10365. cmdGroup.splice(i, 1);
  10366. if (cmdGroup.length == 1)
  10367. ckb[keyId] = cmdGroup[0];
  10368. }
  10369. }
  10370. }
  10371. };
  10372. this.bindKey = function(key, command, position) {
  10373. if (typeof key == "object" && key) {
  10374. if (position == undefined)
  10375. position = key.position;
  10376. key = key[this.platform];
  10377. }
  10378. if (!key)
  10379. return;
  10380. if (typeof command == "function")
  10381. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  10382. key.split("|").forEach(function(keyPart) {
  10383. var chain = "";
  10384. if (keyPart.indexOf(" ") != -1) {
  10385. var parts = keyPart.split(/\s+/);
  10386. keyPart = parts.pop();
  10387. parts.forEach(function(keyPart) {
  10388. var binding = this.parseKeys(keyPart);
  10389. var id = KEY_MODS[binding.hashId] + binding.key;
  10390. chain += (chain ? " " : "") + id;
  10391. this._addCommandToBinding(chain, "chainKeys");
  10392. }, this);
  10393. chain += " ";
  10394. }
  10395. var binding = this.parseKeys(keyPart);
  10396. var id = KEY_MODS[binding.hashId] + binding.key;
  10397. this._addCommandToBinding(chain + id, command, position);
  10398. }, this);
  10399. };
  10400. function getPosition(command) {
  10401. return typeof command == "object" && command.bindKey
  10402. && command.bindKey.position
  10403. || (command.isDefault ? -100 : 0);
  10404. }
  10405. this._addCommandToBinding = function(keyId, command, position) {
  10406. var ckb = this.commandKeyBinding, i;
  10407. if (!command) {
  10408. delete ckb[keyId];
  10409. } else if (!ckb[keyId] || this.$singleCommand) {
  10410. ckb[keyId] = command;
  10411. } else {
  10412. if (!Array.isArray(ckb[keyId])) {
  10413. ckb[keyId] = [ckb[keyId]];
  10414. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  10415. ckb[keyId].splice(i, 1);
  10416. }
  10417. if (typeof position != "number") {
  10418. position = getPosition(command);
  10419. }
  10420. var commands = ckb[keyId];
  10421. for (i = 0; i < commands.length; i++) {
  10422. var other = commands[i];
  10423. var otherPos = getPosition(other);
  10424. if (otherPos > position)
  10425. break;
  10426. }
  10427. commands.splice(i, 0, command);
  10428. }
  10429. };
  10430. this.addCommands = function(commands) {
  10431. commands && Object.keys(commands).forEach(function(name) {
  10432. var command = commands[name];
  10433. if (!command)
  10434. return;
  10435. if (typeof command === "string")
  10436. return this.bindKey(command, name);
  10437. if (typeof command === "function")
  10438. command = { exec: command };
  10439. if (typeof command !== "object")
  10440. return;
  10441. if (!command.name)
  10442. command.name = name;
  10443. this.addCommand(command);
  10444. }, this);
  10445. };
  10446. this.removeCommands = function(commands) {
  10447. Object.keys(commands).forEach(function(name) {
  10448. this.removeCommand(commands[name]);
  10449. }, this);
  10450. };
  10451. this.bindKeys = function(keyList) {
  10452. Object.keys(keyList).forEach(function(key) {
  10453. this.bindKey(key, keyList[key]);
  10454. }, this);
  10455. };
  10456. this._buildKeyHash = function(command) {
  10457. this.bindKey(command.bindKey, command);
  10458. };
  10459. this.parseKeys = function(keys) {
  10460. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x;});
  10461. var key = parts.pop();
  10462. var keyCode = keyUtil[key];
  10463. if (keyUtil.FUNCTION_KEYS[keyCode])
  10464. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  10465. else if (!parts.length)
  10466. return {key: key, hashId: -1};
  10467. else if (parts.length == 1 && parts[0] == "shift")
  10468. return {key: key.toUpperCase(), hashId: -1};
  10469. var hashId = 0;
  10470. for (var i = parts.length; i--;) {
  10471. var modifier = keyUtil.KEY_MODS[parts[i]];
  10472. if (modifier == null) {
  10473. if (typeof console != "undefined")
  10474. console.error("invalid modifier " + parts[i] + " in " + keys);
  10475. return false;
  10476. }
  10477. hashId |= modifier;
  10478. }
  10479. return {key: key, hashId: hashId};
  10480. };
  10481. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  10482. var key = KEY_MODS[hashId] + keyString;
  10483. return this.commandKeyBinding[key];
  10484. };
  10485. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  10486. if (keyCode < 0) return;
  10487. var key = KEY_MODS[hashId] + keyString;
  10488. var command = this.commandKeyBinding[key];
  10489. if (data.$keyChain) {
  10490. data.$keyChain += " " + key;
  10491. command = this.commandKeyBinding[data.$keyChain] || command;
  10492. }
  10493. if (command) {
  10494. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  10495. data.$keyChain = data.$keyChain || key;
  10496. return {command: "null"};
  10497. }
  10498. }
  10499. if (data.$keyChain) {
  10500. if ((!hashId || hashId == 4) && keyString.length == 1)
  10501. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  10502. else if (hashId == -1 || keyCode > 0)
  10503. data.$keyChain = ""; // reset keyChain
  10504. }
  10505. return {command: command};
  10506. };
  10507. this.getStatusText = function(editor, data) {
  10508. return data.$keyChain || "";
  10509. };
  10510. }).call(HashHandler.prototype);
  10511. exports.HashHandler = HashHandler;
  10512. exports.MultiHashHandler = MultiHashHandler;
  10513. });
  10514. define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  10515. "use strict";
  10516. var oop = require("../lib/oop");
  10517. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  10518. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  10519. var CommandManager = function(platform, commands) {
  10520. MultiHashHandler.call(this, commands, platform);
  10521. this.byName = this.commands;
  10522. this.setDefaultHandler("exec", function(e) {
  10523. return e.command.exec(e.editor, e.args || {});
  10524. });
  10525. };
  10526. oop.inherits(CommandManager, MultiHashHandler);
  10527. (function() {
  10528. oop.implement(this, EventEmitter);
  10529. this.exec = function(command, editor, args) {
  10530. if (Array.isArray(command)) {
  10531. for (var i = command.length; i--; ) {
  10532. if (this.exec(command[i], editor, args)) return true;
  10533. }
  10534. return false;
  10535. }
  10536. if (typeof command === "string")
  10537. command = this.commands[command];
  10538. if (!command)
  10539. return false;
  10540. if (editor && editor.$readOnly && !command.readOnly)
  10541. return false;
  10542. if (command.isAvailable && !command.isAvailable(editor))
  10543. return false;
  10544. var e = {editor: editor, command: command, args: args};
  10545. e.returnValue = this._emit("exec", e);
  10546. this._signal("afterExec", e);
  10547. return e.returnValue === false ? false : true;
  10548. };
  10549. this.toggleRecording = function(editor) {
  10550. if (this.$inReplay)
  10551. return;
  10552. editor && editor._emit("changeStatus");
  10553. if (this.recording) {
  10554. this.macro.pop();
  10555. this.removeEventListener("exec", this.$addCommandToMacro);
  10556. if (!this.macro.length)
  10557. this.macro = this.oldMacro;
  10558. return this.recording = false;
  10559. }
  10560. if (!this.$addCommandToMacro) {
  10561. this.$addCommandToMacro = function(e) {
  10562. this.macro.push([e.command, e.args]);
  10563. }.bind(this);
  10564. }
  10565. this.oldMacro = this.macro;
  10566. this.macro = [];
  10567. this.on("exec", this.$addCommandToMacro);
  10568. return this.recording = true;
  10569. };
  10570. this.replay = function(editor) {
  10571. if (this.$inReplay || !this.macro)
  10572. return;
  10573. if (this.recording)
  10574. return this.toggleRecording(editor);
  10575. try {
  10576. this.$inReplay = true;
  10577. this.macro.forEach(function(x) {
  10578. if (typeof x == "string")
  10579. this.exec(x, editor);
  10580. else
  10581. this.exec(x[0], editor, x[1]);
  10582. }, this);
  10583. } finally {
  10584. this.$inReplay = false;
  10585. }
  10586. };
  10587. this.trimMacro = function(m) {
  10588. return m.map(function(x){
  10589. if (typeof x[0] != "string")
  10590. x[0] = x[0].name;
  10591. if (!x[1])
  10592. x = x[0];
  10593. return x;
  10594. });
  10595. };
  10596. }).call(CommandManager.prototype);
  10597. exports.CommandManager = CommandManager;
  10598. });
  10599. define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  10600. "use strict";
  10601. var lang = require("../lib/lang");
  10602. var config = require("../config");
  10603. var Range = require("../range").Range;
  10604. function bindKey(win, mac) {
  10605. return {win: win, mac: mac};
  10606. }
  10607. exports.commands = [{
  10608. name: "showSettingsMenu",
  10609. bindKey: bindKey("Ctrl-,", "Command-,"),
  10610. exec: function(editor) {
  10611. config.loadModule("ace/ext/settings_menu", function(module) {
  10612. module.init(editor);
  10613. editor.showSettingsMenu();
  10614. });
  10615. },
  10616. readOnly: true
  10617. }, {
  10618. name: "goToNextError",
  10619. bindKey: bindKey("Alt-E", "F4"),
  10620. exec: function(editor) {
  10621. config.loadModule("ace/ext/error_marker", function(module) {
  10622. module.showErrorMarker(editor, 1);
  10623. });
  10624. },
  10625. scrollIntoView: "animate",
  10626. readOnly: true
  10627. }, {
  10628. name: "goToPreviousError",
  10629. bindKey: bindKey("Alt-Shift-E", "Shift-F4"),
  10630. exec: function(editor) {
  10631. config.loadModule("ace/ext/error_marker", function(module) {
  10632. module.showErrorMarker(editor, -1);
  10633. });
  10634. },
  10635. scrollIntoView: "animate",
  10636. readOnly: true
  10637. }, {
  10638. name: "selectall",
  10639. bindKey: bindKey("Ctrl-A", "Command-A"),
  10640. exec: function(editor) { editor.selectAll(); },
  10641. readOnly: true
  10642. }, {
  10643. name: "centerselection",
  10644. bindKey: bindKey(null, "Ctrl-L"),
  10645. exec: function(editor) { editor.centerSelection(); },
  10646. readOnly: true
  10647. }, {
  10648. name: "gotoline",
  10649. bindKey: bindKey("Ctrl-L", "Command-L"),
  10650. exec: function(editor) {
  10651. var line = parseInt(prompt("Enter line number:"), 10);
  10652. if (!isNaN(line)) {
  10653. editor.gotoLine(line);
  10654. }
  10655. },
  10656. readOnly: true
  10657. }, {
  10658. name: "fold",
  10659. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  10660. exec: function(editor) { editor.session.toggleFold(false); },
  10661. multiSelectAction: "forEach",
  10662. scrollIntoView: "center",
  10663. readOnly: true
  10664. }, {
  10665. name: "unfold",
  10666. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  10667. exec: function(editor) { editor.session.toggleFold(true); },
  10668. multiSelectAction: "forEach",
  10669. scrollIntoView: "center",
  10670. readOnly: true
  10671. }, {
  10672. name: "toggleFoldWidget",
  10673. bindKey: bindKey("F2", "F2"),
  10674. exec: function(editor) { editor.session.toggleFoldWidget(); },
  10675. multiSelectAction: "forEach",
  10676. scrollIntoView: "center",
  10677. readOnly: true
  10678. }, {
  10679. name: "toggleParentFoldWidget",
  10680. bindKey: bindKey("Alt-F2", "Alt-F2"),
  10681. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  10682. multiSelectAction: "forEach",
  10683. scrollIntoView: "center",
  10684. readOnly: true
  10685. }, {
  10686. name: "foldall",
  10687. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  10688. exec: function(editor) { editor.session.foldAll(); },
  10689. scrollIntoView: "center",
  10690. readOnly: true
  10691. }, {
  10692. name: "foldOther",
  10693. bindKey: bindKey("Alt-0", "Command-Option-0"),
  10694. exec: function(editor) {
  10695. editor.session.foldAll();
  10696. editor.session.unfold(editor.selection.getAllRanges());
  10697. },
  10698. scrollIntoView: "center",
  10699. readOnly: true
  10700. }, {
  10701. name: "unfoldall",
  10702. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  10703. exec: function(editor) { editor.session.unfold(); },
  10704. scrollIntoView: "center",
  10705. readOnly: true
  10706. }, {
  10707. name: "findnext",
  10708. bindKey: bindKey("Ctrl-K", "Command-G"),
  10709. exec: function(editor) { editor.findNext(); },
  10710. multiSelectAction: "forEach",
  10711. scrollIntoView: "center",
  10712. readOnly: true
  10713. }, {
  10714. name: "findprevious",
  10715. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  10716. exec: function(editor) { editor.findPrevious(); },
  10717. multiSelectAction: "forEach",
  10718. scrollIntoView: "center",
  10719. readOnly: true
  10720. }, {
  10721. name: "selectOrFindNext",
  10722. bindKey: bindKey("Alt-K", "Ctrl-G"),
  10723. exec: function(editor) {
  10724. if (editor.selection.isEmpty())
  10725. editor.selection.selectWord();
  10726. else
  10727. editor.findNext();
  10728. },
  10729. readOnly: true
  10730. }, {
  10731. name: "selectOrFindPrevious",
  10732. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  10733. exec: function(editor) {
  10734. if (editor.selection.isEmpty())
  10735. editor.selection.selectWord();
  10736. else
  10737. editor.findPrevious();
  10738. },
  10739. readOnly: true
  10740. }, {
  10741. name: "find",
  10742. bindKey: bindKey("Ctrl-F", "Command-F"),
  10743. exec: function(editor) {
  10744. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor);});
  10745. },
  10746. readOnly: true
  10747. }, {
  10748. name: "overwrite",
  10749. bindKey: "Insert",
  10750. exec: function(editor) { editor.toggleOverwrite(); },
  10751. readOnly: true
  10752. }, {
  10753. name: "selecttostart",
  10754. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Home|Command-Shift-Up"),
  10755. exec: function(editor) { editor.getSelection().selectFileStart(); },
  10756. multiSelectAction: "forEach",
  10757. readOnly: true,
  10758. scrollIntoView: "animate",
  10759. aceCommandGroup: "fileJump"
  10760. }, {
  10761. name: "gotostart",
  10762. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  10763. exec: function(editor) { editor.navigateFileStart(); },
  10764. multiSelectAction: "forEach",
  10765. readOnly: true,
  10766. scrollIntoView: "animate",
  10767. aceCommandGroup: "fileJump"
  10768. }, {
  10769. name: "selectup",
  10770. bindKey: bindKey("Shift-Up", "Shift-Up|Ctrl-Shift-P"),
  10771. exec: function(editor) { editor.getSelection().selectUp(); },
  10772. multiSelectAction: "forEach",
  10773. scrollIntoView: "cursor",
  10774. readOnly: true
  10775. }, {
  10776. name: "golineup",
  10777. bindKey: bindKey("Up", "Up|Ctrl-P"),
  10778. exec: function(editor, args) { editor.navigateUp(args.times); },
  10779. multiSelectAction: "forEach",
  10780. scrollIntoView: "cursor",
  10781. readOnly: true
  10782. }, {
  10783. name: "selecttoend",
  10784. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-End|Command-Shift-Down"),
  10785. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  10786. multiSelectAction: "forEach",
  10787. readOnly: true,
  10788. scrollIntoView: "animate",
  10789. aceCommandGroup: "fileJump"
  10790. }, {
  10791. name: "gotoend",
  10792. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  10793. exec: function(editor) { editor.navigateFileEnd(); },
  10794. multiSelectAction: "forEach",
  10795. readOnly: true,
  10796. scrollIntoView: "animate",
  10797. aceCommandGroup: "fileJump"
  10798. }, {
  10799. name: "selectdown",
  10800. bindKey: bindKey("Shift-Down", "Shift-Down|Ctrl-Shift-N"),
  10801. exec: function(editor) { editor.getSelection().selectDown(); },
  10802. multiSelectAction: "forEach",
  10803. scrollIntoView: "cursor",
  10804. readOnly: true
  10805. }, {
  10806. name: "golinedown",
  10807. bindKey: bindKey("Down", "Down|Ctrl-N"),
  10808. exec: function(editor, args) { editor.navigateDown(args.times); },
  10809. multiSelectAction: "forEach",
  10810. scrollIntoView: "cursor",
  10811. readOnly: true
  10812. }, {
  10813. name: "selectwordleft",
  10814. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  10815. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  10816. multiSelectAction: "forEach",
  10817. scrollIntoView: "cursor",
  10818. readOnly: true
  10819. }, {
  10820. name: "gotowordleft",
  10821. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  10822. exec: function(editor) { editor.navigateWordLeft(); },
  10823. multiSelectAction: "forEach",
  10824. scrollIntoView: "cursor",
  10825. readOnly: true
  10826. }, {
  10827. name: "selecttolinestart",
  10828. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left|Ctrl-Shift-A"),
  10829. exec: function(editor) { editor.getSelection().selectLineStart(); },
  10830. multiSelectAction: "forEach",
  10831. scrollIntoView: "cursor",
  10832. readOnly: true
  10833. }, {
  10834. name: "gotolinestart",
  10835. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  10836. exec: function(editor) { editor.navigateLineStart(); },
  10837. multiSelectAction: "forEach",
  10838. scrollIntoView: "cursor",
  10839. readOnly: true
  10840. }, {
  10841. name: "selectleft",
  10842. bindKey: bindKey("Shift-Left", "Shift-Left|Ctrl-Shift-B"),
  10843. exec: function(editor) { editor.getSelection().selectLeft(); },
  10844. multiSelectAction: "forEach",
  10845. scrollIntoView: "cursor",
  10846. readOnly: true
  10847. }, {
  10848. name: "gotoleft",
  10849. bindKey: bindKey("Left", "Left|Ctrl-B"),
  10850. exec: function(editor, args) { editor.navigateLeft(args.times); },
  10851. multiSelectAction: "forEach",
  10852. scrollIntoView: "cursor",
  10853. readOnly: true
  10854. }, {
  10855. name: "selectwordright",
  10856. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  10857. exec: function(editor) { editor.getSelection().selectWordRight(); },
  10858. multiSelectAction: "forEach",
  10859. scrollIntoView: "cursor",
  10860. readOnly: true
  10861. }, {
  10862. name: "gotowordright",
  10863. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  10864. exec: function(editor) { editor.navigateWordRight(); },
  10865. multiSelectAction: "forEach",
  10866. scrollIntoView: "cursor",
  10867. readOnly: true
  10868. }, {
  10869. name: "selecttolineend",
  10870. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right|Shift-End|Ctrl-Shift-E"),
  10871. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  10872. multiSelectAction: "forEach",
  10873. scrollIntoView: "cursor",
  10874. readOnly: true
  10875. }, {
  10876. name: "gotolineend",
  10877. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  10878. exec: function(editor) { editor.navigateLineEnd(); },
  10879. multiSelectAction: "forEach",
  10880. scrollIntoView: "cursor",
  10881. readOnly: true
  10882. }, {
  10883. name: "selectright",
  10884. bindKey: bindKey("Shift-Right", "Shift-Right"),
  10885. exec: function(editor) { editor.getSelection().selectRight(); },
  10886. multiSelectAction: "forEach",
  10887. scrollIntoView: "cursor",
  10888. readOnly: true
  10889. }, {
  10890. name: "gotoright",
  10891. bindKey: bindKey("Right", "Right|Ctrl-F"),
  10892. exec: function(editor, args) { editor.navigateRight(args.times); },
  10893. multiSelectAction: "forEach",
  10894. scrollIntoView: "cursor",
  10895. readOnly: true
  10896. }, {
  10897. name: "selectpagedown",
  10898. bindKey: "Shift-PageDown",
  10899. exec: function(editor) { editor.selectPageDown(); },
  10900. readOnly: true
  10901. }, {
  10902. name: "pagedown",
  10903. bindKey: bindKey(null, "Option-PageDown"),
  10904. exec: function(editor) { editor.scrollPageDown(); },
  10905. readOnly: true
  10906. }, {
  10907. name: "gotopagedown",
  10908. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  10909. exec: function(editor) { editor.gotoPageDown(); },
  10910. readOnly: true
  10911. }, {
  10912. name: "selectpageup",
  10913. bindKey: "Shift-PageUp",
  10914. exec: function(editor) { editor.selectPageUp(); },
  10915. readOnly: true
  10916. }, {
  10917. name: "pageup",
  10918. bindKey: bindKey(null, "Option-PageUp"),
  10919. exec: function(editor) { editor.scrollPageUp(); },
  10920. readOnly: true
  10921. }, {
  10922. name: "gotopageup",
  10923. bindKey: "PageUp",
  10924. exec: function(editor) { editor.gotoPageUp(); },
  10925. readOnly: true
  10926. }, {
  10927. name: "scrollup",
  10928. bindKey: bindKey("Ctrl-Up", null),
  10929. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  10930. readOnly: true
  10931. }, {
  10932. name: "scrolldown",
  10933. bindKey: bindKey("Ctrl-Down", null),
  10934. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  10935. readOnly: true
  10936. }, {
  10937. name: "selectlinestart",
  10938. bindKey: "Shift-Home",
  10939. exec: function(editor) { editor.getSelection().selectLineStart(); },
  10940. multiSelectAction: "forEach",
  10941. scrollIntoView: "cursor",
  10942. readOnly: true
  10943. }, {
  10944. name: "selectlineend",
  10945. bindKey: "Shift-End",
  10946. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  10947. multiSelectAction: "forEach",
  10948. scrollIntoView: "cursor",
  10949. readOnly: true
  10950. }, {
  10951. name: "togglerecording",
  10952. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  10953. exec: function(editor) { editor.commands.toggleRecording(editor); },
  10954. readOnly: true
  10955. }, {
  10956. name: "replaymacro",
  10957. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  10958. exec: function(editor) { editor.commands.replay(editor); },
  10959. readOnly: true
  10960. }, {
  10961. name: "jumptomatching",
  10962. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  10963. exec: function(editor) { editor.jumpToMatching(); },
  10964. multiSelectAction: "forEach",
  10965. scrollIntoView: "animate",
  10966. readOnly: true
  10967. }, {
  10968. name: "selecttomatching",
  10969. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  10970. exec: function(editor) { editor.jumpToMatching(true); },
  10971. multiSelectAction: "forEach",
  10972. scrollIntoView: "animate",
  10973. readOnly: true
  10974. }, {
  10975. name: "expandToMatching",
  10976. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  10977. exec: function(editor) { editor.jumpToMatching(true, true); },
  10978. multiSelectAction: "forEach",
  10979. scrollIntoView: "animate",
  10980. readOnly: true
  10981. }, {
  10982. name: "passKeysToBrowser",
  10983. bindKey: bindKey(null, null),
  10984. exec: function() {},
  10985. passEvent: true,
  10986. readOnly: true
  10987. }, {
  10988. name: "copy",
  10989. exec: function(editor) {
  10990. },
  10991. readOnly: true
  10992. },
  10993. {
  10994. name: "cut",
  10995. exec: function(editor) {
  10996. var range = editor.getSelectionRange();
  10997. editor._emit("cut", range);
  10998. if (!editor.selection.isEmpty()) {
  10999. editor.session.remove(range);
  11000. editor.clearSelection();
  11001. }
  11002. },
  11003. scrollIntoView: "cursor",
  11004. multiSelectAction: "forEach"
  11005. }, {
  11006. name: "paste",
  11007. exec: function(editor, args) {
  11008. editor.$handlePaste(args);
  11009. },
  11010. scrollIntoView: "cursor"
  11011. }, {
  11012. name: "removeline",
  11013. bindKey: bindKey("Ctrl-D", "Command-D"),
  11014. exec: function(editor) { editor.removeLines(); },
  11015. scrollIntoView: "cursor",
  11016. multiSelectAction: "forEachLine"
  11017. }, {
  11018. name: "duplicateSelection",
  11019. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  11020. exec: function(editor) { editor.duplicateSelection(); },
  11021. scrollIntoView: "cursor",
  11022. multiSelectAction: "forEach"
  11023. }, {
  11024. name: "sortlines",
  11025. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  11026. exec: function(editor) { editor.sortLines(); },
  11027. scrollIntoView: "selection",
  11028. multiSelectAction: "forEachLine"
  11029. }, {
  11030. name: "togglecomment",
  11031. bindKey: bindKey("Ctrl-/", "Command-/"),
  11032. exec: function(editor) { editor.toggleCommentLines(); },
  11033. multiSelectAction: "forEachLine",
  11034. scrollIntoView: "selectionPart"
  11035. }, {
  11036. name: "toggleBlockComment",
  11037. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  11038. exec: function(editor) { editor.toggleBlockComment(); },
  11039. multiSelectAction: "forEach",
  11040. scrollIntoView: "selectionPart"
  11041. }, {
  11042. name: "modifyNumberUp",
  11043. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  11044. exec: function(editor) { editor.modifyNumber(1); },
  11045. scrollIntoView: "cursor",
  11046. multiSelectAction: "forEach"
  11047. }, {
  11048. name: "modifyNumberDown",
  11049. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  11050. exec: function(editor) { editor.modifyNumber(-1); },
  11051. scrollIntoView: "cursor",
  11052. multiSelectAction: "forEach"
  11053. }, {
  11054. name: "replace",
  11055. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  11056. exec: function(editor) {
  11057. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true);});
  11058. }
  11059. }, {
  11060. name: "undo",
  11061. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  11062. exec: function(editor) { editor.undo(); }
  11063. }, {
  11064. name: "redo",
  11065. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  11066. exec: function(editor) { editor.redo(); }
  11067. }, {
  11068. name: "copylinesup",
  11069. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  11070. exec: function(editor) { editor.copyLinesUp(); },
  11071. scrollIntoView: "cursor"
  11072. }, {
  11073. name: "movelinesup",
  11074. bindKey: bindKey("Alt-Up", "Option-Up"),
  11075. exec: function(editor) { editor.moveLinesUp(); },
  11076. scrollIntoView: "cursor"
  11077. }, {
  11078. name: "copylinesdown",
  11079. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  11080. exec: function(editor) { editor.copyLinesDown(); },
  11081. scrollIntoView: "cursor"
  11082. }, {
  11083. name: "movelinesdown",
  11084. bindKey: bindKey("Alt-Down", "Option-Down"),
  11085. exec: function(editor) { editor.moveLinesDown(); },
  11086. scrollIntoView: "cursor"
  11087. }, {
  11088. name: "del",
  11089. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  11090. exec: function(editor) { editor.remove("right"); },
  11091. multiSelectAction: "forEach",
  11092. scrollIntoView: "cursor"
  11093. }, {
  11094. name: "backspace",
  11095. bindKey: bindKey(
  11096. "Shift-Backspace|Backspace",
  11097. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  11098. ),
  11099. exec: function(editor) { editor.remove("left"); },
  11100. multiSelectAction: "forEach",
  11101. scrollIntoView: "cursor"
  11102. }, {
  11103. name: "cut_or_delete",
  11104. bindKey: bindKey("Shift-Delete", null),
  11105. exec: function(editor) {
  11106. if (editor.selection.isEmpty()) {
  11107. editor.remove("left");
  11108. } else {
  11109. return false;
  11110. }
  11111. },
  11112. multiSelectAction: "forEach",
  11113. scrollIntoView: "cursor"
  11114. }, {
  11115. name: "removetolinestart",
  11116. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  11117. exec: function(editor) { editor.removeToLineStart(); },
  11118. multiSelectAction: "forEach",
  11119. scrollIntoView: "cursor"
  11120. }, {
  11121. name: "removetolineend",
  11122. bindKey: bindKey("Alt-Delete", "Ctrl-K|Command-Delete"),
  11123. exec: function(editor) { editor.removeToLineEnd(); },
  11124. multiSelectAction: "forEach",
  11125. scrollIntoView: "cursor"
  11126. }, {
  11127. name: "removetolinestarthard",
  11128. bindKey: bindKey("Ctrl-Shift-Backspace", null),
  11129. exec: function(editor) {
  11130. var range = editor.selection.getRange();
  11131. range.start.column = 0;
  11132. editor.session.remove(range);
  11133. },
  11134. multiSelectAction: "forEach",
  11135. scrollIntoView: "cursor"
  11136. }, {
  11137. name: "removetolineendhard",
  11138. bindKey: bindKey("Ctrl-Shift-Delete", null),
  11139. exec: function(editor) {
  11140. var range = editor.selection.getRange();
  11141. range.end.column = Number.MAX_VALUE;
  11142. editor.session.remove(range);
  11143. },
  11144. multiSelectAction: "forEach",
  11145. scrollIntoView: "cursor"
  11146. }, {
  11147. name: "removewordleft",
  11148. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  11149. exec: function(editor) { editor.removeWordLeft(); },
  11150. multiSelectAction: "forEach",
  11151. scrollIntoView: "cursor"
  11152. }, {
  11153. name: "removewordright",
  11154. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  11155. exec: function(editor) { editor.removeWordRight(); },
  11156. multiSelectAction: "forEach",
  11157. scrollIntoView: "cursor"
  11158. }, {
  11159. name: "outdent",
  11160. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  11161. exec: function(editor) { editor.blockOutdent(); },
  11162. multiSelectAction: "forEach",
  11163. scrollIntoView: "selectionPart"
  11164. }, {
  11165. name: "indent",
  11166. bindKey: bindKey("Tab", "Tab"),
  11167. exec: function(editor) { editor.indent(); },
  11168. multiSelectAction: "forEach",
  11169. scrollIntoView: "selectionPart"
  11170. }, {
  11171. name: "blockoutdent",
  11172. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  11173. exec: function(editor) { editor.blockOutdent(); },
  11174. multiSelectAction: "forEachLine",
  11175. scrollIntoView: "selectionPart"
  11176. }, {
  11177. name: "blockindent",
  11178. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  11179. exec: function(editor) { editor.blockIndent(); },
  11180. multiSelectAction: "forEachLine",
  11181. scrollIntoView: "selectionPart"
  11182. }, {
  11183. name: "insertstring",
  11184. exec: function(editor, str) { editor.insert(str); },
  11185. multiSelectAction: "forEach",
  11186. scrollIntoView: "cursor"
  11187. }, {
  11188. name: "inserttext",
  11189. exec: function(editor, args) {
  11190. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  11191. },
  11192. multiSelectAction: "forEach",
  11193. scrollIntoView: "cursor"
  11194. }, {
  11195. name: "splitline",
  11196. bindKey: bindKey(null, "Ctrl-O"),
  11197. exec: function(editor) { editor.splitLine(); },
  11198. multiSelectAction: "forEach",
  11199. scrollIntoView: "cursor"
  11200. }, {
  11201. name: "transposeletters",
  11202. bindKey: bindKey("Alt-Shift-X", "Ctrl-T"),
  11203. exec: function(editor) { editor.transposeLetters(); },
  11204. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  11205. scrollIntoView: "cursor"
  11206. }, {
  11207. name: "touppercase",
  11208. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  11209. exec: function(editor) { editor.toUpperCase(); },
  11210. multiSelectAction: "forEach",
  11211. scrollIntoView: "cursor"
  11212. }, {
  11213. name: "tolowercase",
  11214. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  11215. exec: function(editor) { editor.toLowerCase(); },
  11216. multiSelectAction: "forEach",
  11217. scrollIntoView: "cursor"
  11218. }, {
  11219. name: "expandtoline",
  11220. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  11221. exec: function(editor) {
  11222. var range = editor.selection.getRange();
  11223. range.start.column = range.end.column = 0;
  11224. range.end.row++;
  11225. editor.selection.setRange(range, false);
  11226. },
  11227. multiSelectAction: "forEach",
  11228. scrollIntoView: "cursor",
  11229. readOnly: true
  11230. }, {
  11231. name: "joinlines",
  11232. bindKey: bindKey(null, null),
  11233. exec: function(editor) {
  11234. var isBackwards = editor.selection.isBackwards();
  11235. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  11236. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  11237. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  11238. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  11239. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  11240. var insertLine = editor.session.doc.getLine(selectionStart.row);
  11241. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  11242. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  11243. if (curLine.length !== 0) {
  11244. curLine = " " + curLine;
  11245. }
  11246. insertLine += curLine;
  11247. }
  11248. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  11249. insertLine += editor.session.doc.getNewLineCharacter();
  11250. }
  11251. editor.clearSelection();
  11252. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  11253. if (selectedCount > 0) {
  11254. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  11255. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  11256. } else {
  11257. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  11258. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  11259. }
  11260. },
  11261. multiSelectAction: "forEach",
  11262. readOnly: true
  11263. }, {
  11264. name: "invertSelection",
  11265. bindKey: bindKey(null, null),
  11266. exec: function(editor) {
  11267. var endRow = editor.session.doc.getLength() - 1;
  11268. var endCol = editor.session.doc.getLine(endRow).length;
  11269. var ranges = editor.selection.rangeList.ranges;
  11270. var newRanges = [];
  11271. if (ranges.length < 1) {
  11272. ranges = [editor.selection.getRange()];
  11273. }
  11274. for (var i = 0; i < ranges.length; i++) {
  11275. if (i == (ranges.length - 1)) {
  11276. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  11277. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  11278. }
  11279. }
  11280. if (i === 0) {
  11281. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  11282. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  11283. }
  11284. } else {
  11285. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  11286. }
  11287. }
  11288. editor.exitMultiSelectMode();
  11289. editor.clearSelection();
  11290. for(var i = 0; i < newRanges.length; i++) {
  11291. editor.selection.addRange(newRanges[i], false);
  11292. }
  11293. },
  11294. readOnly: true,
  11295. scrollIntoView: "none"
  11296. }];
  11297. });
  11298. 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) {
  11299. "use strict";
  11300. require("./lib/fixoldbrowsers");
  11301. var oop = require("./lib/oop");
  11302. var dom = require("./lib/dom");
  11303. var lang = require("./lib/lang");
  11304. var useragent = require("./lib/useragent");
  11305. var TextInput = require("./keyboard/textinput").TextInput;
  11306. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  11307. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  11308. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  11309. var EditSession = require("./edit_session").EditSession;
  11310. var Search = require("./search").Search;
  11311. var Range = require("./range").Range;
  11312. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  11313. var CommandManager = require("./commands/command_manager").CommandManager;
  11314. var defaultCommands = require("./commands/default_commands").commands;
  11315. var config = require("./config");
  11316. var TokenIterator = require("./token_iterator").TokenIterator;
  11317. var Editor = function(renderer, session) {
  11318. var container = renderer.getContainerElement();
  11319. this.container = container;
  11320. this.renderer = renderer;
  11321. this.id = "editor" + (++Editor.$uid);
  11322. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  11323. if (typeof document == "object") {
  11324. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  11325. this.renderer.textarea = this.textInput.getElement();
  11326. this.$mouseHandler = new MouseHandler(this);
  11327. new FoldHandler(this);
  11328. }
  11329. this.keyBinding = new KeyBinding(this);
  11330. this.$blockScrolling = 0;
  11331. this.$search = new Search().set({
  11332. wrap: true
  11333. });
  11334. this.$historyTracker = this.$historyTracker.bind(this);
  11335. this.commands.on("exec", this.$historyTracker);
  11336. this.$initOperationListeners();
  11337. this._$emitInputEvent = lang.delayedCall(function() {
  11338. this._signal("input", {});
  11339. if (this.session && this.session.bgTokenizer)
  11340. this.session.bgTokenizer.scheduleStart();
  11341. }.bind(this));
  11342. this.on("change", function(_, _self) {
  11343. _self._$emitInputEvent.schedule(31);
  11344. });
  11345. this.setSession(session || new EditSession(""));
  11346. config.resetOptions(this);
  11347. config._signal("editor", this);
  11348. };
  11349. Editor.$uid = 0;
  11350. (function(){
  11351. oop.implement(this, EventEmitter);
  11352. this.$initOperationListeners = function() {
  11353. function last(a) {return a[a.length - 1];}
  11354. this.selections = [];
  11355. this.commands.on("exec", this.startOperation.bind(this), true);
  11356. this.commands.on("afterExec", this.endOperation.bind(this), true);
  11357. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  11358. this.on("change", function() {
  11359. this.curOp || this.startOperation();
  11360. this.curOp.docChanged = true;
  11361. }.bind(this), true);
  11362. this.on("changeSelection", function() {
  11363. this.curOp || this.startOperation();
  11364. this.curOp.selectionChanged = true;
  11365. }.bind(this), true);
  11366. };
  11367. this.curOp = null;
  11368. this.prevOp = {};
  11369. this.startOperation = function(commadEvent) {
  11370. if (this.curOp) {
  11371. if (!commadEvent || this.curOp.command)
  11372. return;
  11373. this.prevOp = this.curOp;
  11374. }
  11375. if (!commadEvent) {
  11376. this.previousCommand = null;
  11377. commadEvent = {};
  11378. }
  11379. this.$opResetTimer.schedule();
  11380. this.curOp = {
  11381. command: commadEvent.command || {},
  11382. args: commadEvent.args,
  11383. scrollTop: this.renderer.scrollTop
  11384. };
  11385. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  11386. this.$blockScrolling++;
  11387. };
  11388. this.endOperation = function(e) {
  11389. if (this.curOp) {
  11390. if (e && e.returnValue === false)
  11391. return this.curOp = null;
  11392. this._signal("beforeEndOperation");
  11393. var command = this.curOp.command;
  11394. if (command.name && this.$blockScrolling > 0)
  11395. this.$blockScrolling--;
  11396. var scrollIntoView = command && command.scrollIntoView;
  11397. if (scrollIntoView) {
  11398. switch (scrollIntoView) {
  11399. case "center-animate":
  11400. scrollIntoView = "animate";
  11401. case "center":
  11402. this.renderer.scrollCursorIntoView(null, 0.5);
  11403. break;
  11404. case "animate":
  11405. case "cursor":
  11406. this.renderer.scrollCursorIntoView();
  11407. break;
  11408. case "selectionPart":
  11409. var range = this.selection.getRange();
  11410. var config = this.renderer.layerConfig;
  11411. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  11412. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  11413. }
  11414. break;
  11415. default:
  11416. break;
  11417. }
  11418. if (scrollIntoView == "animate")
  11419. this.renderer.animateScrolling(this.curOp.scrollTop);
  11420. }
  11421. this.prevOp = this.curOp;
  11422. this.curOp = null;
  11423. }
  11424. };
  11425. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  11426. this.$historyTracker = function(e) {
  11427. if (!this.$mergeUndoDeltas)
  11428. return;
  11429. var prev = this.prevOp;
  11430. var mergeableCommands = this.$mergeableCommands;
  11431. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  11432. if (e.command.name == "insertstring") {
  11433. var text = e.args;
  11434. if (this.mergeNextCommand === undefined)
  11435. this.mergeNextCommand = true;
  11436. shouldMerge = shouldMerge
  11437. && this.mergeNextCommand // previous command allows to coalesce with
  11438. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  11439. this.mergeNextCommand = true;
  11440. } else {
  11441. shouldMerge = shouldMerge
  11442. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  11443. }
  11444. if (
  11445. this.$mergeUndoDeltas != "always"
  11446. && Date.now() - this.sequenceStartTime > 2000
  11447. ) {
  11448. shouldMerge = false; // the sequence is too long
  11449. }
  11450. if (shouldMerge)
  11451. this.session.mergeUndoDeltas = true;
  11452. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  11453. this.sequenceStartTime = Date.now();
  11454. };
  11455. this.setKeyboardHandler = function(keyboardHandler, cb) {
  11456. if (keyboardHandler && typeof keyboardHandler === "string") {
  11457. this.$keybindingId = keyboardHandler;
  11458. var _self = this;
  11459. config.loadModule(["keybinding", keyboardHandler], function(module) {
  11460. if (_self.$keybindingId == keyboardHandler)
  11461. _self.keyBinding.setKeyboardHandler(module && module.handler);
  11462. cb && cb();
  11463. });
  11464. } else {
  11465. this.$keybindingId = null;
  11466. this.keyBinding.setKeyboardHandler(keyboardHandler);
  11467. cb && cb();
  11468. }
  11469. };
  11470. this.getKeyboardHandler = function() {
  11471. return this.keyBinding.getKeyboardHandler();
  11472. };
  11473. this.setSession = function(session) {
  11474. if (this.session == session)
  11475. return;
  11476. if (this.curOp) this.endOperation();
  11477. this.curOp = {};
  11478. var oldSession = this.session;
  11479. if (oldSession) {
  11480. this.session.off("change", this.$onDocumentChange);
  11481. this.session.off("changeMode", this.$onChangeMode);
  11482. this.session.off("tokenizerUpdate", this.$onTokenizerUpdate);
  11483. this.session.off("changeTabSize", this.$onChangeTabSize);
  11484. this.session.off("changeWrapLimit", this.$onChangeWrapLimit);
  11485. this.session.off("changeWrapMode", this.$onChangeWrapMode);
  11486. this.session.off("changeFold", this.$onChangeFold);
  11487. this.session.off("changeFrontMarker", this.$onChangeFrontMarker);
  11488. this.session.off("changeBackMarker", this.$onChangeBackMarker);
  11489. this.session.off("changeBreakpoint", this.$onChangeBreakpoint);
  11490. this.session.off("changeAnnotation", this.$onChangeAnnotation);
  11491. this.session.off("changeOverwrite", this.$onCursorChange);
  11492. this.session.off("changeScrollTop", this.$onScrollTopChange);
  11493. this.session.off("changeScrollLeft", this.$onScrollLeftChange);
  11494. var selection = this.session.getSelection();
  11495. selection.off("changeCursor", this.$onCursorChange);
  11496. selection.off("changeSelection", this.$onSelectionChange);
  11497. }
  11498. this.session = session;
  11499. if (session) {
  11500. this.$onDocumentChange = this.onDocumentChange.bind(this);
  11501. session.on("change", this.$onDocumentChange);
  11502. this.renderer.setSession(session);
  11503. this.$onChangeMode = this.onChangeMode.bind(this);
  11504. session.on("changeMode", this.$onChangeMode);
  11505. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  11506. session.on("tokenizerUpdate", this.$onTokenizerUpdate);
  11507. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  11508. session.on("changeTabSize", this.$onChangeTabSize);
  11509. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  11510. session.on("changeWrapLimit", this.$onChangeWrapLimit);
  11511. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  11512. session.on("changeWrapMode", this.$onChangeWrapMode);
  11513. this.$onChangeFold = this.onChangeFold.bind(this);
  11514. session.on("changeFold", this.$onChangeFold);
  11515. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  11516. this.session.on("changeFrontMarker", this.$onChangeFrontMarker);
  11517. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  11518. this.session.on("changeBackMarker", this.$onChangeBackMarker);
  11519. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  11520. this.session.on("changeBreakpoint", this.$onChangeBreakpoint);
  11521. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  11522. this.session.on("changeAnnotation", this.$onChangeAnnotation);
  11523. this.$onCursorChange = this.onCursorChange.bind(this);
  11524. this.session.on("changeOverwrite", this.$onCursorChange);
  11525. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  11526. this.session.on("changeScrollTop", this.$onScrollTopChange);
  11527. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  11528. this.session.on("changeScrollLeft", this.$onScrollLeftChange);
  11529. this.selection = session.getSelection();
  11530. this.selection.on("changeCursor", this.$onCursorChange);
  11531. this.$onSelectionChange = this.onSelectionChange.bind(this);
  11532. this.selection.on("changeSelection", this.$onSelectionChange);
  11533. this.onChangeMode();
  11534. this.$blockScrolling += 1;
  11535. this.onCursorChange();
  11536. this.$blockScrolling -= 1;
  11537. this.onScrollTopChange();
  11538. this.onScrollLeftChange();
  11539. this.onSelectionChange();
  11540. this.onChangeFrontMarker();
  11541. this.onChangeBackMarker();
  11542. this.onChangeBreakpoint();
  11543. this.onChangeAnnotation();
  11544. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  11545. this.renderer.updateFull();
  11546. } else {
  11547. this.selection = null;
  11548. this.renderer.setSession(session);
  11549. }
  11550. this._signal("changeSession", {
  11551. session: session,
  11552. oldSession: oldSession
  11553. });
  11554. this.curOp = null;
  11555. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  11556. session && session._signal("changeEditor", {editor: this});
  11557. if (session && session.bgTokenizer)
  11558. session.bgTokenizer.scheduleStart();
  11559. };
  11560. this.getSession = function() {
  11561. return this.session;
  11562. };
  11563. this.setValue = function(val, cursorPos) {
  11564. this.session.doc.setValue(val);
  11565. if (!cursorPos)
  11566. this.selectAll();
  11567. else if (cursorPos == 1)
  11568. this.navigateFileEnd();
  11569. else if (cursorPos == -1)
  11570. this.navigateFileStart();
  11571. return val;
  11572. };
  11573. this.getValue = function() {
  11574. return this.session.getValue();
  11575. };
  11576. this.getSelection = function() {
  11577. return this.selection;
  11578. };
  11579. this.resize = function(force) {
  11580. this.renderer.onResize(force);
  11581. };
  11582. this.setTheme = function(theme, cb) {
  11583. this.renderer.setTheme(theme, cb);
  11584. };
  11585. this.getTheme = function() {
  11586. return this.renderer.getTheme();
  11587. };
  11588. this.setStyle = function(style) {
  11589. this.renderer.setStyle(style);
  11590. };
  11591. this.unsetStyle = function(style) {
  11592. this.renderer.unsetStyle(style);
  11593. };
  11594. this.getFontSize = function () {
  11595. return this.getOption("fontSize") ||
  11596. dom.computedStyle(this.container, "fontSize");
  11597. };
  11598. this.setFontSize = function(size) {
  11599. this.setOption("fontSize", size);
  11600. };
  11601. this.$highlightBrackets = function() {
  11602. if (this.session.$bracketHighlight) {
  11603. this.session.removeMarker(this.session.$bracketHighlight);
  11604. this.session.$bracketHighlight = null;
  11605. }
  11606. if (this.$highlightPending) {
  11607. return;
  11608. }
  11609. var self = this;
  11610. this.$highlightPending = true;
  11611. setTimeout(function() {
  11612. self.$highlightPending = false;
  11613. var session = self.session;
  11614. if (!session || !session.bgTokenizer) return;
  11615. var pos = session.findMatchingBracket(self.getCursorPosition());
  11616. if (pos) {
  11617. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  11618. } else if (session.$mode.getMatching) {
  11619. var range = session.$mode.getMatching(self.session);
  11620. }
  11621. if (range)
  11622. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  11623. }, 50);
  11624. };
  11625. this.$highlightTags = function() {
  11626. if (this.$highlightTagPending)
  11627. return;
  11628. var self = this;
  11629. this.$highlightTagPending = true;
  11630. setTimeout(function() {
  11631. self.$highlightTagPending = false;
  11632. var session = self.session;
  11633. if (!session || !session.bgTokenizer) return;
  11634. var pos = self.getCursorPosition();
  11635. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  11636. var token = iterator.getCurrentToken();
  11637. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  11638. session.removeMarker(session.$tagHighlight);
  11639. session.$tagHighlight = null;
  11640. return;
  11641. }
  11642. if (token.type.indexOf("tag-open") != -1) {
  11643. token = iterator.stepForward();
  11644. if (!token)
  11645. return;
  11646. }
  11647. var tag = token.value;
  11648. var depth = 0;
  11649. var prevToken = iterator.stepBackward();
  11650. if (prevToken.value == '<'){
  11651. do {
  11652. prevToken = token;
  11653. token = iterator.stepForward();
  11654. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11655. if (prevToken.value === '<'){
  11656. depth++;
  11657. } else if (prevToken.value === '</'){
  11658. depth--;
  11659. }
  11660. }
  11661. } while (token && depth >= 0);
  11662. } else {
  11663. do {
  11664. token = prevToken;
  11665. prevToken = iterator.stepBackward();
  11666. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11667. if (prevToken.value === '<') {
  11668. depth++;
  11669. } else if (prevToken.value === '</') {
  11670. depth--;
  11671. }
  11672. }
  11673. } while (prevToken && depth <= 0);
  11674. iterator.stepForward();
  11675. }
  11676. if (!token) {
  11677. session.removeMarker(session.$tagHighlight);
  11678. session.$tagHighlight = null;
  11679. return;
  11680. }
  11681. var row = iterator.getCurrentTokenRow();
  11682. var column = iterator.getCurrentTokenColumn();
  11683. var range = new Range(row, column, row, column+token.value.length);
  11684. var sbm = session.$backMarkers[session.$tagHighlight];
  11685. if (session.$tagHighlight && sbm != undefined && range.compareRange(sbm.range) !== 0) {
  11686. session.removeMarker(session.$tagHighlight);
  11687. session.$tagHighlight = null;
  11688. }
  11689. if (range && !session.$tagHighlight)
  11690. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  11691. }, 50);
  11692. };
  11693. this.focus = function() {
  11694. var _self = this;
  11695. setTimeout(function() {
  11696. _self.textInput.focus();
  11697. });
  11698. this.textInput.focus();
  11699. };
  11700. this.isFocused = function() {
  11701. return this.textInput.isFocused();
  11702. };
  11703. this.blur = function() {
  11704. this.textInput.blur();
  11705. };
  11706. this.onFocus = function(e) {
  11707. if (this.$isFocused)
  11708. return;
  11709. this.$isFocused = true;
  11710. this.renderer.showCursor();
  11711. this.renderer.visualizeFocus();
  11712. this._emit("focus", e);
  11713. };
  11714. this.onBlur = function(e) {
  11715. if (!this.$isFocused)
  11716. return;
  11717. this.$isFocused = false;
  11718. this.renderer.hideCursor();
  11719. this.renderer.visualizeBlur();
  11720. this._emit("blur", e);
  11721. };
  11722. this.$cursorChange = function() {
  11723. this.renderer.updateCursor();
  11724. };
  11725. this.onDocumentChange = function(delta) {
  11726. var wrap = this.session.$useWrapMode;
  11727. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  11728. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  11729. this._signal("change", delta);
  11730. this.$cursorChange();
  11731. this.$updateHighlightActiveLine();
  11732. };
  11733. this.onTokenizerUpdate = function(e) {
  11734. var rows = e.data;
  11735. this.renderer.updateLines(rows.first, rows.last);
  11736. };
  11737. this.onScrollTopChange = function() {
  11738. this.renderer.scrollToY(this.session.getScrollTop());
  11739. };
  11740. this.onScrollLeftChange = function() {
  11741. this.renderer.scrollToX(this.session.getScrollLeft());
  11742. };
  11743. this.onCursorChange = function() {
  11744. this.$cursorChange();
  11745. if (!this.$blockScrolling) {
  11746. config.warn("Automatically scrolling cursor into view after selection change",
  11747. "this will be disabled in the next version",
  11748. "set editor.$blockScrolling = Infinity to disable this message"
  11749. );
  11750. this.renderer.scrollCursorIntoView();
  11751. }
  11752. this.$highlightBrackets();
  11753. this.$highlightTags();
  11754. this.$updateHighlightActiveLine();
  11755. this._signal("changeSelection");
  11756. };
  11757. this.$updateHighlightActiveLine = function() {
  11758. var session = this.getSession();
  11759. var highlight;
  11760. if (this.$highlightActiveLine) {
  11761. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  11762. highlight = this.getCursorPosition();
  11763. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  11764. highlight = false;
  11765. }
  11766. if (session.$highlightLineMarker && !highlight) {
  11767. session.removeMarker(session.$highlightLineMarker.id);
  11768. session.$highlightLineMarker = null;
  11769. } else if (!session.$highlightLineMarker && highlight) {
  11770. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  11771. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  11772. session.$highlightLineMarker = range;
  11773. } else if (highlight) {
  11774. session.$highlightLineMarker.start.row = highlight.row;
  11775. session.$highlightLineMarker.end.row = highlight.row;
  11776. session.$highlightLineMarker.start.column = highlight.column;
  11777. session._signal("changeBackMarker");
  11778. }
  11779. };
  11780. this.onSelectionChange = function(e) {
  11781. var session = this.session;
  11782. if (session.$selectionMarker) {
  11783. session.removeMarker(session.$selectionMarker);
  11784. }
  11785. session.$selectionMarker = null;
  11786. if (!this.selection.isEmpty()) {
  11787. var range = this.selection.getRange();
  11788. var style = this.getSelectionStyle();
  11789. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  11790. } else {
  11791. this.$updateHighlightActiveLine();
  11792. }
  11793. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  11794. this.session.highlight(re);
  11795. this._signal("changeSelection");
  11796. };
  11797. this.$getSelectionHighLightRegexp = function() {
  11798. var session = this.session;
  11799. var selection = this.getSelectionRange();
  11800. if (selection.isEmpty() || selection.isMultiLine())
  11801. return;
  11802. var startOuter = selection.start.column - 1;
  11803. var endOuter = selection.end.column + 1;
  11804. var line = session.getLine(selection.start.row);
  11805. var lineCols = line.length;
  11806. var needle = line.substring(Math.max(startOuter, 0),
  11807. Math.min(endOuter, lineCols));
  11808. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  11809. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  11810. return;
  11811. needle = line.substring(selection.start.column, selection.end.column);
  11812. if (!/^[\w\d]+$/.test(needle))
  11813. return;
  11814. var re = this.$search.$assembleRegExp({
  11815. wholeWord: true,
  11816. caseSensitive: true,
  11817. needle: needle
  11818. });
  11819. return re;
  11820. };
  11821. this.onChangeFrontMarker = function() {
  11822. this.renderer.updateFrontMarkers();
  11823. };
  11824. this.onChangeBackMarker = function() {
  11825. this.renderer.updateBackMarkers();
  11826. };
  11827. this.onChangeBreakpoint = function() {
  11828. this.renderer.updateBreakpoints();
  11829. };
  11830. this.onChangeAnnotation = function() {
  11831. this.renderer.setAnnotations(this.session.getAnnotations());
  11832. };
  11833. this.onChangeMode = function(e) {
  11834. this.renderer.updateText();
  11835. this._emit("changeMode", e);
  11836. };
  11837. this.onChangeWrapLimit = function() {
  11838. this.renderer.updateFull();
  11839. };
  11840. this.onChangeWrapMode = function() {
  11841. this.renderer.onResize(true);
  11842. };
  11843. this.onChangeFold = function() {
  11844. this.$updateHighlightActiveLine();
  11845. this.renderer.updateFull();
  11846. };
  11847. this.getSelectedText = function() {
  11848. return this.session.getTextRange(this.getSelectionRange());
  11849. };
  11850. this.getCopyText = function() {
  11851. var text = this.getSelectedText();
  11852. this._signal("copy", text);
  11853. return text;
  11854. };
  11855. this.onCopy = function() {
  11856. this.commands.exec("copy", this);
  11857. };
  11858. this.onCut = function() {
  11859. this.commands.exec("cut", this);
  11860. };
  11861. this.onPaste = function(text, event) {
  11862. var e = {text: text, event: event};
  11863. this.commands.exec("paste", this, e);
  11864. };
  11865. this.$handlePaste = function(e) {
  11866. if (typeof e == "string")
  11867. e = {text: e};
  11868. this._signal("paste", e);
  11869. var text = e.text;
  11870. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  11871. this.insert(text);
  11872. } else {
  11873. var lines = text.split(/\r\n|\r|\n/);
  11874. var ranges = this.selection.rangeList.ranges;
  11875. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  11876. return this.commands.exec("insertstring", this, text);
  11877. for (var i = ranges.length; i--;) {
  11878. var range = ranges[i];
  11879. if (!range.isEmpty())
  11880. this.session.remove(range);
  11881. this.session.insert(range.start, lines[i]);
  11882. }
  11883. }
  11884. };
  11885. this.execCommand = function(command, args) {
  11886. return this.commands.exec(command, this, args);
  11887. };
  11888. this.insert = function(text, pasted) {
  11889. var session = this.session;
  11890. var mode = session.getMode();
  11891. var cursor = this.getCursorPosition();
  11892. if (this.getBehavioursEnabled() && !pasted) {
  11893. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  11894. if (transform) {
  11895. if (text !== transform.text) {
  11896. this.session.mergeUndoDeltas = false;
  11897. this.$mergeNextCommand = false;
  11898. }
  11899. text = transform.text;
  11900. }
  11901. }
  11902. if (text == "\t")
  11903. text = this.session.getTabString();
  11904. if (!this.selection.isEmpty()) {
  11905. var range = this.getSelectionRange();
  11906. cursor = this.session.remove(range);
  11907. this.clearSelection();
  11908. }
  11909. else if (this.session.getOverwrite() && text.indexOf("\n") == -1) {
  11910. var range = new Range.fromPoints(cursor, cursor);
  11911. range.end.column += text.length;
  11912. this.session.remove(range);
  11913. }
  11914. if (text == "\n" || text == "\r\n") {
  11915. var line = session.getLine(cursor.row);
  11916. if (cursor.column > line.search(/\S|$/)) {
  11917. var d = line.substr(cursor.column).search(/\S|$/);
  11918. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  11919. }
  11920. }
  11921. this.clearSelection();
  11922. var start = cursor.column;
  11923. var lineState = session.getState(cursor.row);
  11924. var line = session.getLine(cursor.row);
  11925. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  11926. var end = session.insert(cursor, text);
  11927. if (transform && transform.selection) {
  11928. if (transform.selection.length == 2) { // Transform relative to the current column
  11929. this.selection.setSelectionRange(
  11930. new Range(cursor.row, start + transform.selection[0],
  11931. cursor.row, start + transform.selection[1]));
  11932. } else { // Transform relative to the current row.
  11933. this.selection.setSelectionRange(
  11934. new Range(cursor.row + transform.selection[0],
  11935. transform.selection[1],
  11936. cursor.row + transform.selection[2],
  11937. transform.selection[3]));
  11938. }
  11939. }
  11940. if (session.getDocument().isNewLine(text)) {
  11941. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  11942. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  11943. }
  11944. if (shouldOutdent)
  11945. mode.autoOutdent(lineState, session, cursor.row);
  11946. };
  11947. this.onTextInput = function(text) {
  11948. this.keyBinding.onTextInput(text);
  11949. };
  11950. this.onCommandKey = function(e, hashId, keyCode) {
  11951. this.keyBinding.onCommandKey(e, hashId, keyCode);
  11952. };
  11953. this.setOverwrite = function(overwrite) {
  11954. this.session.setOverwrite(overwrite);
  11955. };
  11956. this.getOverwrite = function() {
  11957. return this.session.getOverwrite();
  11958. };
  11959. this.toggleOverwrite = function() {
  11960. this.session.toggleOverwrite();
  11961. };
  11962. this.setScrollSpeed = function(speed) {
  11963. this.setOption("scrollSpeed", speed);
  11964. };
  11965. this.getScrollSpeed = function() {
  11966. return this.getOption("scrollSpeed");
  11967. };
  11968. this.setDragDelay = function(dragDelay) {
  11969. this.setOption("dragDelay", dragDelay);
  11970. };
  11971. this.getDragDelay = function() {
  11972. return this.getOption("dragDelay");
  11973. };
  11974. this.setSelectionStyle = function(val) {
  11975. this.setOption("selectionStyle", val);
  11976. };
  11977. this.getSelectionStyle = function() {
  11978. return this.getOption("selectionStyle");
  11979. };
  11980. this.setHighlightActiveLine = function(shouldHighlight) {
  11981. this.setOption("highlightActiveLine", shouldHighlight);
  11982. };
  11983. this.getHighlightActiveLine = function() {
  11984. return this.getOption("highlightActiveLine");
  11985. };
  11986. this.setHighlightGutterLine = function(shouldHighlight) {
  11987. this.setOption("highlightGutterLine", shouldHighlight);
  11988. };
  11989. this.getHighlightGutterLine = function() {
  11990. return this.getOption("highlightGutterLine");
  11991. };
  11992. this.setHighlightSelectedWord = function(shouldHighlight) {
  11993. this.setOption("highlightSelectedWord", shouldHighlight);
  11994. };
  11995. this.getHighlightSelectedWord = function() {
  11996. return this.$highlightSelectedWord;
  11997. };
  11998. this.setAnimatedScroll = function(shouldAnimate){
  11999. this.renderer.setAnimatedScroll(shouldAnimate);
  12000. };
  12001. this.getAnimatedScroll = function(){
  12002. return this.renderer.getAnimatedScroll();
  12003. };
  12004. this.setShowInvisibles = function(showInvisibles) {
  12005. this.renderer.setShowInvisibles(showInvisibles);
  12006. };
  12007. this.getShowInvisibles = function() {
  12008. return this.renderer.getShowInvisibles();
  12009. };
  12010. this.setDisplayIndentGuides = function(display) {
  12011. this.renderer.setDisplayIndentGuides(display);
  12012. };
  12013. this.getDisplayIndentGuides = function() {
  12014. return this.renderer.getDisplayIndentGuides();
  12015. };
  12016. this.setShowPrintMargin = function(showPrintMargin) {
  12017. this.renderer.setShowPrintMargin(showPrintMargin);
  12018. };
  12019. this.getShowPrintMargin = function() {
  12020. return this.renderer.getShowPrintMargin();
  12021. };
  12022. this.setPrintMarginColumn = function(showPrintMargin) {
  12023. this.renderer.setPrintMarginColumn(showPrintMargin);
  12024. };
  12025. this.getPrintMarginColumn = function() {
  12026. return this.renderer.getPrintMarginColumn();
  12027. };
  12028. this.setReadOnly = function(readOnly) {
  12029. this.setOption("readOnly", readOnly);
  12030. };
  12031. this.getReadOnly = function() {
  12032. return this.getOption("readOnly");
  12033. };
  12034. this.setBehavioursEnabled = function (enabled) {
  12035. this.setOption("behavioursEnabled", enabled);
  12036. };
  12037. this.getBehavioursEnabled = function () {
  12038. return this.getOption("behavioursEnabled");
  12039. };
  12040. this.setWrapBehavioursEnabled = function (enabled) {
  12041. this.setOption("wrapBehavioursEnabled", enabled);
  12042. };
  12043. this.getWrapBehavioursEnabled = function () {
  12044. return this.getOption("wrapBehavioursEnabled");
  12045. };
  12046. this.setShowFoldWidgets = function(show) {
  12047. this.setOption("showFoldWidgets", show);
  12048. };
  12049. this.getShowFoldWidgets = function() {
  12050. return this.getOption("showFoldWidgets");
  12051. };
  12052. this.setFadeFoldWidgets = function(fade) {
  12053. this.setOption("fadeFoldWidgets", fade);
  12054. };
  12055. this.getFadeFoldWidgets = function() {
  12056. return this.getOption("fadeFoldWidgets");
  12057. };
  12058. this.remove = function(dir) {
  12059. if (this.selection.isEmpty()){
  12060. if (dir == "left")
  12061. this.selection.selectLeft();
  12062. else
  12063. this.selection.selectRight();
  12064. }
  12065. var range = this.getSelectionRange();
  12066. if (this.getBehavioursEnabled()) {
  12067. var session = this.session;
  12068. var state = session.getState(range.start.row);
  12069. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  12070. if (range.end.column === 0) {
  12071. var text = session.getTextRange(range);
  12072. if (text[text.length - 1] == "\n") {
  12073. var line = session.getLine(range.end.row);
  12074. if (/^\s+$/.test(line)) {
  12075. range.end.column = line.length;
  12076. }
  12077. }
  12078. }
  12079. if (new_range)
  12080. range = new_range;
  12081. }
  12082. this.session.remove(range);
  12083. this.clearSelection();
  12084. };
  12085. this.removeWordRight = function() {
  12086. if (this.selection.isEmpty())
  12087. this.selection.selectWordRight();
  12088. this.session.remove(this.getSelectionRange());
  12089. this.clearSelection();
  12090. };
  12091. this.removeWordLeft = function() {
  12092. if (this.selection.isEmpty())
  12093. this.selection.selectWordLeft();
  12094. this.session.remove(this.getSelectionRange());
  12095. this.clearSelection();
  12096. };
  12097. this.removeToLineStart = function() {
  12098. if (this.selection.isEmpty())
  12099. this.selection.selectLineStart();
  12100. this.session.remove(this.getSelectionRange());
  12101. this.clearSelection();
  12102. };
  12103. this.removeToLineEnd = function() {
  12104. if (this.selection.isEmpty())
  12105. this.selection.selectLineEnd();
  12106. var range = this.getSelectionRange();
  12107. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  12108. range.end.column = 0;
  12109. range.end.row++;
  12110. }
  12111. this.session.remove(range);
  12112. this.clearSelection();
  12113. };
  12114. this.splitLine = function() {
  12115. if (!this.selection.isEmpty()) {
  12116. this.session.remove(this.getSelectionRange());
  12117. this.clearSelection();
  12118. }
  12119. var cursor = this.getCursorPosition();
  12120. this.insert("\n");
  12121. this.moveCursorToPosition(cursor);
  12122. };
  12123. this.transposeLetters = function() {
  12124. if (!this.selection.isEmpty()) {
  12125. return;
  12126. }
  12127. var cursor = this.getCursorPosition();
  12128. var column = cursor.column;
  12129. if (column === 0)
  12130. return;
  12131. var line = this.session.getLine(cursor.row);
  12132. var swap, range;
  12133. if (column < line.length) {
  12134. swap = line.charAt(column) + line.charAt(column-1);
  12135. range = new Range(cursor.row, column-1, cursor.row, column+1);
  12136. }
  12137. else {
  12138. swap = line.charAt(column-1) + line.charAt(column-2);
  12139. range = new Range(cursor.row, column-2, cursor.row, column);
  12140. }
  12141. this.session.replace(range, swap);
  12142. this.session.selection.moveToPosition(range.end);
  12143. };
  12144. this.toLowerCase = function() {
  12145. var originalRange = this.getSelectionRange();
  12146. if (this.selection.isEmpty()) {
  12147. this.selection.selectWord();
  12148. }
  12149. var range = this.getSelectionRange();
  12150. var text = this.session.getTextRange(range);
  12151. this.session.replace(range, text.toLowerCase());
  12152. this.selection.setSelectionRange(originalRange);
  12153. };
  12154. this.toUpperCase = function() {
  12155. var originalRange = this.getSelectionRange();
  12156. if (this.selection.isEmpty()) {
  12157. this.selection.selectWord();
  12158. }
  12159. var range = this.getSelectionRange();
  12160. var text = this.session.getTextRange(range);
  12161. this.session.replace(range, text.toUpperCase());
  12162. this.selection.setSelectionRange(originalRange);
  12163. };
  12164. this.indent = function() {
  12165. var session = this.session;
  12166. var range = this.getSelectionRange();
  12167. if (range.start.row < range.end.row) {
  12168. var rows = this.$getSelectedRows();
  12169. session.indentRows(rows.first, rows.last, "\t");
  12170. return;
  12171. } else if (range.start.column < range.end.column) {
  12172. var text = session.getTextRange(range);
  12173. if (!/^\s+$/.test(text)) {
  12174. var rows = this.$getSelectedRows();
  12175. session.indentRows(rows.first, rows.last, "\t");
  12176. return;
  12177. }
  12178. }
  12179. var line = session.getLine(range.start.row);
  12180. var position = range.start;
  12181. var size = session.getTabSize();
  12182. var column = session.documentToScreenColumn(position.row, position.column);
  12183. if (this.session.getUseSoftTabs()) {
  12184. var count = (size - column % size);
  12185. var indentString = lang.stringRepeat(" ", count);
  12186. } else {
  12187. var count = column % size;
  12188. while (line[range.start.column - 1] == " " && count) {
  12189. range.start.column--;
  12190. count--;
  12191. }
  12192. this.selection.setSelectionRange(range);
  12193. indentString = "\t";
  12194. }
  12195. return this.insert(indentString);
  12196. };
  12197. this.blockIndent = function() {
  12198. var rows = this.$getSelectedRows();
  12199. this.session.indentRows(rows.first, rows.last, "\t");
  12200. };
  12201. this.blockOutdent = function() {
  12202. var selection = this.session.getSelection();
  12203. this.session.outdentRows(selection.getRange());
  12204. };
  12205. this.sortLines = function() {
  12206. var rows = this.$getSelectedRows();
  12207. var session = this.session;
  12208. var lines = [];
  12209. for (var i = rows.first; i <= rows.last; i++)
  12210. lines.push(session.getLine(i));
  12211. lines.sort(function(a, b) {
  12212. if (a.toLowerCase() < b.toLowerCase()) return -1;
  12213. if (a.toLowerCase() > b.toLowerCase()) return 1;
  12214. return 0;
  12215. });
  12216. var deleteRange = new Range(0, 0, 0, 0);
  12217. for (var i = rows.first; i <= rows.last; i++) {
  12218. var line = session.getLine(i);
  12219. deleteRange.start.row = i;
  12220. deleteRange.end.row = i;
  12221. deleteRange.end.column = line.length;
  12222. session.replace(deleteRange, lines[i-rows.first]);
  12223. }
  12224. };
  12225. this.toggleCommentLines = function() {
  12226. var state = this.session.getState(this.getCursorPosition().row);
  12227. var rows = this.$getSelectedRows();
  12228. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  12229. };
  12230. this.toggleBlockComment = function() {
  12231. var cursor = this.getCursorPosition();
  12232. var state = this.session.getState(cursor.row);
  12233. var range = this.getSelectionRange();
  12234. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  12235. };
  12236. this.getNumberAt = function(row, column) {
  12237. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  12238. _numberRx.lastIndex = 0;
  12239. var s = this.session.getLine(row);
  12240. while (_numberRx.lastIndex < column) {
  12241. var m = _numberRx.exec(s);
  12242. if(m.index <= column && m.index+m[0].length >= column){
  12243. var number = {
  12244. value: m[0],
  12245. start: m.index,
  12246. end: m.index+m[0].length
  12247. };
  12248. return number;
  12249. }
  12250. }
  12251. return null;
  12252. };
  12253. this.modifyNumber = function(amount) {
  12254. var row = this.selection.getCursor().row;
  12255. var column = this.selection.getCursor().column;
  12256. var charRange = new Range(row, column-1, row, column);
  12257. var c = this.session.getTextRange(charRange);
  12258. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  12259. var nr = this.getNumberAt(row, column);
  12260. if (nr) {
  12261. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  12262. var decimals = nr.start + nr.value.length - fp;
  12263. var t = parseFloat(nr.value);
  12264. t *= Math.pow(10, decimals);
  12265. if(fp !== nr.end && column < fp){
  12266. amount *= Math.pow(10, nr.end - column - 1);
  12267. } else {
  12268. amount *= Math.pow(10, nr.end - column);
  12269. }
  12270. t += amount;
  12271. t /= Math.pow(10, decimals);
  12272. var nnr = t.toFixed(decimals);
  12273. var replaceRange = new Range(row, nr.start, row, nr.end);
  12274. this.session.replace(replaceRange, nnr);
  12275. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  12276. }
  12277. }
  12278. };
  12279. this.removeLines = function() {
  12280. var rows = this.$getSelectedRows();
  12281. this.session.removeFullLines(rows.first, rows.last);
  12282. this.clearSelection();
  12283. };
  12284. this.duplicateSelection = function() {
  12285. var sel = this.selection;
  12286. var doc = this.session;
  12287. var range = sel.getRange();
  12288. var reverse = sel.isBackwards();
  12289. if (range.isEmpty()) {
  12290. var row = range.start.row;
  12291. doc.duplicateLines(row, row);
  12292. } else {
  12293. var point = reverse ? range.start : range.end;
  12294. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  12295. range.start = point;
  12296. range.end = endPoint;
  12297. sel.setSelectionRange(range, reverse);
  12298. }
  12299. };
  12300. this.moveLinesDown = function() {
  12301. this.$moveLines(1, false);
  12302. };
  12303. this.moveLinesUp = function() {
  12304. this.$moveLines(-1, false);
  12305. };
  12306. this.moveText = function(range, toPosition, copy) {
  12307. return this.session.moveText(range, toPosition, copy);
  12308. };
  12309. this.copyLinesUp = function() {
  12310. this.$moveLines(-1, true);
  12311. };
  12312. this.copyLinesDown = function() {
  12313. this.$moveLines(1, true);
  12314. };
  12315. this.$moveLines = function(dir, copy) {
  12316. var rows, moved;
  12317. var selection = this.selection;
  12318. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  12319. var range = selection.toOrientedRange();
  12320. rows = this.$getSelectedRows(range);
  12321. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  12322. if (copy && dir == -1) moved = 0;
  12323. range.moveBy(moved, 0);
  12324. selection.fromOrientedRange(range);
  12325. } else {
  12326. var ranges = selection.rangeList.ranges;
  12327. selection.rangeList.detach(this.session);
  12328. this.inVirtualSelectionMode = true;
  12329. var diff = 0;
  12330. var totalDiff = 0;
  12331. var l = ranges.length;
  12332. for (var i = 0; i < l; i++) {
  12333. var rangeIndex = i;
  12334. ranges[i].moveBy(diff, 0);
  12335. rows = this.$getSelectedRows(ranges[i]);
  12336. var first = rows.first;
  12337. var last = rows.last;
  12338. while (++i < l) {
  12339. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  12340. var subRows = this.$getSelectedRows(ranges[i]);
  12341. if (copy && subRows.first != last)
  12342. break;
  12343. else if (!copy && subRows.first > last + 1)
  12344. break;
  12345. last = subRows.last;
  12346. }
  12347. i--;
  12348. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  12349. if (copy && dir == -1) rangeIndex = i + 1;
  12350. while (rangeIndex <= i) {
  12351. ranges[rangeIndex].moveBy(diff, 0);
  12352. rangeIndex++;
  12353. }
  12354. if (!copy) diff = 0;
  12355. totalDiff += diff;
  12356. }
  12357. selection.fromOrientedRange(selection.ranges[0]);
  12358. selection.rangeList.attach(this.session);
  12359. this.inVirtualSelectionMode = false;
  12360. }
  12361. };
  12362. this.$getSelectedRows = function(range) {
  12363. range = (range || this.getSelectionRange()).collapseRows();
  12364. return {
  12365. first: this.session.getRowFoldStart(range.start.row),
  12366. last: this.session.getRowFoldEnd(range.end.row)
  12367. };
  12368. };
  12369. this.onCompositionStart = function(text) {
  12370. this.renderer.showComposition(this.getCursorPosition());
  12371. };
  12372. this.onCompositionUpdate = function(text) {
  12373. this.renderer.setCompositionText(text);
  12374. };
  12375. this.onCompositionEnd = function() {
  12376. this.renderer.hideComposition();
  12377. };
  12378. this.getFirstVisibleRow = function() {
  12379. return this.renderer.getFirstVisibleRow();
  12380. };
  12381. this.getLastVisibleRow = function() {
  12382. return this.renderer.getLastVisibleRow();
  12383. };
  12384. this.isRowVisible = function(row) {
  12385. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  12386. };
  12387. this.isRowFullyVisible = function(row) {
  12388. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  12389. };
  12390. this.$getVisibleRowCount = function() {
  12391. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  12392. };
  12393. this.$moveByPage = function(dir, select) {
  12394. var renderer = this.renderer;
  12395. var config = this.renderer.layerConfig;
  12396. var rows = dir * Math.floor(config.height / config.lineHeight);
  12397. this.$blockScrolling++;
  12398. if (select === true) {
  12399. this.selection.$moveSelection(function(){
  12400. this.moveCursorBy(rows, 0);
  12401. });
  12402. } else if (select === false) {
  12403. this.selection.moveCursorBy(rows, 0);
  12404. this.selection.clearSelection();
  12405. }
  12406. this.$blockScrolling--;
  12407. var scrollTop = renderer.scrollTop;
  12408. renderer.scrollBy(0, rows * config.lineHeight);
  12409. if (select != null)
  12410. renderer.scrollCursorIntoView(null, 0.5);
  12411. renderer.animateScrolling(scrollTop);
  12412. };
  12413. this.selectPageDown = function() {
  12414. this.$moveByPage(1, true);
  12415. };
  12416. this.selectPageUp = function() {
  12417. this.$moveByPage(-1, true);
  12418. };
  12419. this.gotoPageDown = function() {
  12420. this.$moveByPage(1, false);
  12421. };
  12422. this.gotoPageUp = function() {
  12423. this.$moveByPage(-1, false);
  12424. };
  12425. this.scrollPageDown = function() {
  12426. this.$moveByPage(1);
  12427. };
  12428. this.scrollPageUp = function() {
  12429. this.$moveByPage(-1);
  12430. };
  12431. this.scrollToRow = function(row) {
  12432. this.renderer.scrollToRow(row);
  12433. };
  12434. this.scrollToLine = function(line, center, animate, callback) {
  12435. this.renderer.scrollToLine(line, center, animate, callback);
  12436. };
  12437. this.centerSelection = function() {
  12438. var range = this.getSelectionRange();
  12439. var pos = {
  12440. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  12441. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  12442. };
  12443. this.renderer.alignCursor(pos, 0.5);
  12444. };
  12445. this.getCursorPosition = function() {
  12446. return this.selection.getCursor();
  12447. };
  12448. this.getCursorPositionScreen = function() {
  12449. return this.session.documentToScreenPosition(this.getCursorPosition());
  12450. };
  12451. this.getSelectionRange = function() {
  12452. return this.selection.getRange();
  12453. };
  12454. this.selectAll = function() {
  12455. this.$blockScrolling += 1;
  12456. this.selection.selectAll();
  12457. this.$blockScrolling -= 1;
  12458. };
  12459. this.clearSelection = function() {
  12460. this.selection.clearSelection();
  12461. };
  12462. this.moveCursorTo = function(row, column) {
  12463. this.selection.moveCursorTo(row, column);
  12464. };
  12465. this.moveCursorToPosition = function(pos) {
  12466. this.selection.moveCursorToPosition(pos);
  12467. };
  12468. this.jumpToMatching = function(select, expand) {
  12469. var cursor = this.getCursorPosition();
  12470. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  12471. var prevToken = iterator.getCurrentToken();
  12472. var token = prevToken || iterator.stepForward();
  12473. if (!token) return;
  12474. var matchType;
  12475. var found = false;
  12476. var depth = {};
  12477. var i = cursor.column - token.start;
  12478. var bracketType;
  12479. var brackets = {
  12480. ")": "(",
  12481. "(": "(",
  12482. "]": "[",
  12483. "[": "[",
  12484. "{": "{",
  12485. "}": "{"
  12486. };
  12487. do {
  12488. if (token.value.match(/[{}()\[\]]/g)) {
  12489. for (; i < token.value.length && !found; i++) {
  12490. if (!brackets[token.value[i]]) {
  12491. continue;
  12492. }
  12493. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  12494. if (isNaN(depth[bracketType])) {
  12495. depth[bracketType] = 0;
  12496. }
  12497. switch (token.value[i]) {
  12498. case '(':
  12499. case '[':
  12500. case '{':
  12501. depth[bracketType]++;
  12502. break;
  12503. case ')':
  12504. case ']':
  12505. case '}':
  12506. depth[bracketType]--;
  12507. if (depth[bracketType] === -1) {
  12508. matchType = 'bracket';
  12509. found = true;
  12510. }
  12511. break;
  12512. }
  12513. }
  12514. }
  12515. else if (token && token.type.indexOf('tag-name') !== -1) {
  12516. if (isNaN(depth[token.value])) {
  12517. depth[token.value] = 0;
  12518. }
  12519. if (prevToken.value === '<') {
  12520. depth[token.value]++;
  12521. }
  12522. else if (prevToken.value === '</') {
  12523. depth[token.value]--;
  12524. }
  12525. if (depth[token.value] === -1) {
  12526. matchType = 'tag';
  12527. found = true;
  12528. }
  12529. }
  12530. if (!found) {
  12531. prevToken = token;
  12532. token = iterator.stepForward();
  12533. i = 0;
  12534. }
  12535. } while (token && !found);
  12536. if (!matchType)
  12537. return;
  12538. var range, pos;
  12539. if (matchType === 'bracket') {
  12540. range = this.session.getBracketRange(cursor);
  12541. if (!range) {
  12542. range = new Range(
  12543. iterator.getCurrentTokenRow(),
  12544. iterator.getCurrentTokenColumn() + i - 1,
  12545. iterator.getCurrentTokenRow(),
  12546. iterator.getCurrentTokenColumn() + i - 1
  12547. );
  12548. pos = range.start;
  12549. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  12550. range = this.session.getBracketRange(pos);
  12551. }
  12552. }
  12553. else if (matchType === 'tag') {
  12554. if (token && token.type.indexOf('tag-name') !== -1)
  12555. var tag = token.value;
  12556. else
  12557. return;
  12558. range = new Range(
  12559. iterator.getCurrentTokenRow(),
  12560. iterator.getCurrentTokenColumn() - 2,
  12561. iterator.getCurrentTokenRow(),
  12562. iterator.getCurrentTokenColumn() - 2
  12563. );
  12564. if (range.compare(cursor.row, cursor.column) === 0) {
  12565. found = false;
  12566. do {
  12567. token = prevToken;
  12568. prevToken = iterator.stepBackward();
  12569. if (prevToken) {
  12570. if (prevToken.type.indexOf('tag-close') !== -1) {
  12571. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  12572. }
  12573. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  12574. if (prevToken.value === '<') {
  12575. depth[tag]++;
  12576. }
  12577. else if (prevToken.value === '</') {
  12578. depth[tag]--;
  12579. }
  12580. if (depth[tag] === 0)
  12581. found = true;
  12582. }
  12583. }
  12584. } while (prevToken && !found);
  12585. }
  12586. if (token && token.type.indexOf('tag-name')) {
  12587. pos = range.start;
  12588. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  12589. pos = range.end;
  12590. }
  12591. }
  12592. pos = range && range.cursor || pos;
  12593. if (pos) {
  12594. if (select) {
  12595. if (range && expand) {
  12596. this.selection.setRange(range);
  12597. } else if (range && range.isEqual(this.getSelectionRange())) {
  12598. this.clearSelection();
  12599. } else {
  12600. this.selection.selectTo(pos.row, pos.column);
  12601. }
  12602. } else {
  12603. this.selection.moveTo(pos.row, pos.column);
  12604. }
  12605. }
  12606. };
  12607. this.gotoLine = function(lineNumber, column, animate) {
  12608. this.selection.clearSelection();
  12609. this.session.unfold({row: lineNumber - 1, column: column || 0});
  12610. this.$blockScrolling += 1;
  12611. this.exitMultiSelectMode && this.exitMultiSelectMode();
  12612. this.moveCursorTo(lineNumber - 1, column || 0);
  12613. this.$blockScrolling -= 1;
  12614. if (!this.isRowFullyVisible(lineNumber - 1))
  12615. this.scrollToLine(lineNumber - 1, true, animate);
  12616. };
  12617. this.navigateTo = function(row, column) {
  12618. this.selection.moveTo(row, column);
  12619. };
  12620. this.navigateUp = function(times) {
  12621. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  12622. var selectionStart = this.selection.anchor.getPosition();
  12623. return this.moveCursorToPosition(selectionStart);
  12624. }
  12625. this.selection.clearSelection();
  12626. this.selection.moveCursorBy(-times || -1, 0);
  12627. };
  12628. this.navigateDown = function(times) {
  12629. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  12630. var selectionEnd = this.selection.anchor.getPosition();
  12631. return this.moveCursorToPosition(selectionEnd);
  12632. }
  12633. this.selection.clearSelection();
  12634. this.selection.moveCursorBy(times || 1, 0);
  12635. };
  12636. this.navigateLeft = function(times) {
  12637. if (!this.selection.isEmpty()) {
  12638. var selectionStart = this.getSelectionRange().start;
  12639. this.moveCursorToPosition(selectionStart);
  12640. }
  12641. else {
  12642. times = times || 1;
  12643. while (times--) {
  12644. this.selection.moveCursorLeft();
  12645. }
  12646. }
  12647. this.clearSelection();
  12648. };
  12649. this.navigateRight = function(times) {
  12650. if (!this.selection.isEmpty()) {
  12651. var selectionEnd = this.getSelectionRange().end;
  12652. this.moveCursorToPosition(selectionEnd);
  12653. }
  12654. else {
  12655. times = times || 1;
  12656. while (times--) {
  12657. this.selection.moveCursorRight();
  12658. }
  12659. }
  12660. this.clearSelection();
  12661. };
  12662. this.navigateLineStart = function() {
  12663. this.selection.moveCursorLineStart();
  12664. this.clearSelection();
  12665. };
  12666. this.navigateLineEnd = function() {
  12667. this.selection.moveCursorLineEnd();
  12668. this.clearSelection();
  12669. };
  12670. this.navigateFileEnd = function() {
  12671. this.selection.moveCursorFileEnd();
  12672. this.clearSelection();
  12673. };
  12674. this.navigateFileStart = function() {
  12675. this.selection.moveCursorFileStart();
  12676. this.clearSelection();
  12677. };
  12678. this.navigateWordRight = function() {
  12679. this.selection.moveCursorWordRight();
  12680. this.clearSelection();
  12681. };
  12682. this.navigateWordLeft = function() {
  12683. this.selection.moveCursorWordLeft();
  12684. this.clearSelection();
  12685. };
  12686. this.replace = function(replacement, options) {
  12687. if (options)
  12688. this.$search.set(options);
  12689. var range = this.$search.find(this.session);
  12690. var replaced = 0;
  12691. if (!range)
  12692. return replaced;
  12693. if (this.$tryReplace(range, replacement)) {
  12694. replaced = 1;
  12695. }
  12696. this.selection.setSelectionRange(range);
  12697. this.renderer.scrollSelectionIntoView(range.start, range.end);
  12698. return replaced;
  12699. };
  12700. this.replaceAll = function(replacement, options) {
  12701. if (options) {
  12702. this.$search.set(options);
  12703. }
  12704. var ranges = this.$search.findAll(this.session);
  12705. var replaced = 0;
  12706. if (!ranges.length)
  12707. return replaced;
  12708. this.$blockScrolling += 1;
  12709. var selection = this.getSelectionRange();
  12710. this.selection.moveTo(0, 0);
  12711. for (var i = ranges.length - 1; i >= 0; --i) {
  12712. if(this.$tryReplace(ranges[i], replacement)) {
  12713. replaced++;
  12714. }
  12715. }
  12716. this.selection.setSelectionRange(selection);
  12717. this.$blockScrolling -= 1;
  12718. return replaced;
  12719. };
  12720. this.$tryReplace = function(range, replacement) {
  12721. var input = this.session.getTextRange(range);
  12722. replacement = this.$search.replace(input, replacement);
  12723. if (replacement !== null) {
  12724. range.end = this.session.replace(range, replacement);
  12725. return range;
  12726. } else {
  12727. return null;
  12728. }
  12729. };
  12730. this.getLastSearchOptions = function() {
  12731. return this.$search.getOptions();
  12732. };
  12733. this.find = function(needle, options, animate) {
  12734. if (!options)
  12735. options = {};
  12736. if (typeof needle == "string" || needle instanceof RegExp)
  12737. options.needle = needle;
  12738. else if (typeof needle == "object")
  12739. oop.mixin(options, needle);
  12740. var range = this.selection.getRange();
  12741. if (options.needle == null) {
  12742. needle = this.session.getTextRange(range)
  12743. || this.$search.$options.needle;
  12744. if (!needle) {
  12745. range = this.session.getWordRange(range.start.row, range.start.column);
  12746. needle = this.session.getTextRange(range);
  12747. }
  12748. this.$search.set({needle: needle});
  12749. }
  12750. this.$search.set(options);
  12751. if (!options.start)
  12752. this.$search.set({start: range});
  12753. var newRange = this.$search.find(this.session);
  12754. if (options.preventScroll)
  12755. return newRange;
  12756. if (newRange) {
  12757. this.revealRange(newRange, animate);
  12758. return newRange;
  12759. }
  12760. if (options.backwards)
  12761. range.start = range.end;
  12762. else
  12763. range.end = range.start;
  12764. this.selection.setRange(range);
  12765. };
  12766. this.findNext = function(options, animate) {
  12767. this.find({skipCurrent: true, backwards: false}, options, animate);
  12768. };
  12769. this.findPrevious = function(options, animate) {
  12770. this.find(options, {skipCurrent: true, backwards: true}, animate);
  12771. };
  12772. this.revealRange = function(range, animate) {
  12773. this.$blockScrolling += 1;
  12774. this.session.unfold(range);
  12775. this.selection.setSelectionRange(range);
  12776. this.$blockScrolling -= 1;
  12777. var scrollTop = this.renderer.scrollTop;
  12778. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  12779. if (animate !== false)
  12780. this.renderer.animateScrolling(scrollTop);
  12781. };
  12782. this.undo = function() {
  12783. this.$blockScrolling++;
  12784. this.session.getUndoManager().undo();
  12785. this.$blockScrolling--;
  12786. this.renderer.scrollCursorIntoView(null, 0.5);
  12787. };
  12788. this.redo = function() {
  12789. this.$blockScrolling++;
  12790. this.session.getUndoManager().redo();
  12791. this.$blockScrolling--;
  12792. this.renderer.scrollCursorIntoView(null, 0.5);
  12793. };
  12794. this.destroy = function() {
  12795. this.renderer.destroy();
  12796. this._signal("destroy", this);
  12797. if (this.session) {
  12798. this.session.destroy();
  12799. }
  12800. };
  12801. this.setAutoScrollEditorIntoView = function(enable) {
  12802. if (!enable)
  12803. return;
  12804. var rect;
  12805. var self = this;
  12806. var shouldScroll = false;
  12807. if (!this.$scrollAnchor)
  12808. this.$scrollAnchor = document.createElement("div");
  12809. var scrollAnchor = this.$scrollAnchor;
  12810. scrollAnchor.style.cssText = "position:absolute";
  12811. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  12812. var onChangeSelection = this.on("changeSelection", function() {
  12813. shouldScroll = true;
  12814. });
  12815. var onBeforeRender = this.renderer.on("beforeRender", function() {
  12816. if (shouldScroll)
  12817. rect = self.renderer.container.getBoundingClientRect();
  12818. });
  12819. var onAfterRender = this.renderer.on("afterRender", function() {
  12820. if (shouldScroll && rect && (self.isFocused()
  12821. || self.searchBox && self.searchBox.isFocused())
  12822. ) {
  12823. var renderer = self.renderer;
  12824. var pos = renderer.$cursorLayer.$pixelPos;
  12825. var config = renderer.layerConfig;
  12826. var top = pos.top - config.offset;
  12827. if (pos.top >= 0 && top + rect.top < 0) {
  12828. shouldScroll = true;
  12829. } else if (pos.top < config.height &&
  12830. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  12831. shouldScroll = false;
  12832. } else {
  12833. shouldScroll = null;
  12834. }
  12835. if (shouldScroll != null) {
  12836. scrollAnchor.style.top = top + "px";
  12837. scrollAnchor.style.left = pos.left + "px";
  12838. scrollAnchor.style.height = config.lineHeight + "px";
  12839. scrollAnchor.scrollIntoView(shouldScroll);
  12840. }
  12841. shouldScroll = rect = null;
  12842. }
  12843. });
  12844. this.setAutoScrollEditorIntoView = function(enable) {
  12845. if (enable)
  12846. return;
  12847. delete this.setAutoScrollEditorIntoView;
  12848. this.off("changeSelection", onChangeSelection);
  12849. this.renderer.off("afterRender", onAfterRender);
  12850. this.renderer.off("beforeRender", onBeforeRender);
  12851. };
  12852. };
  12853. this.$resetCursorStyle = function() {
  12854. var style = this.$cursorStyle || "ace";
  12855. var cursorLayer = this.renderer.$cursorLayer;
  12856. if (!cursorLayer)
  12857. return;
  12858. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  12859. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  12860. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  12861. };
  12862. }).call(Editor.prototype);
  12863. config.defineOptions(Editor.prototype, "editor", {
  12864. selectionStyle: {
  12865. set: function(style) {
  12866. this.onSelectionChange();
  12867. this._signal("changeSelectionStyle", {data: style});
  12868. },
  12869. initialValue: "line"
  12870. },
  12871. highlightActiveLine: {
  12872. set: function() {this.$updateHighlightActiveLine();},
  12873. initialValue: true
  12874. },
  12875. highlightSelectedWord: {
  12876. set: function(shouldHighlight) {this.$onSelectionChange();},
  12877. initialValue: true
  12878. },
  12879. readOnly: {
  12880. set: function(readOnly) {
  12881. this.$resetCursorStyle();
  12882. },
  12883. initialValue: false
  12884. },
  12885. cursorStyle: {
  12886. set: function(val) { this.$resetCursorStyle(); },
  12887. values: ["ace", "slim", "smooth", "wide"],
  12888. initialValue: "ace"
  12889. },
  12890. mergeUndoDeltas: {
  12891. values: [false, true, "always"],
  12892. initialValue: true
  12893. },
  12894. behavioursEnabled: {initialValue: true},
  12895. wrapBehavioursEnabled: {initialValue: true},
  12896. autoScrollEditorIntoView: {
  12897. set: function(val) {this.setAutoScrollEditorIntoView(val);}
  12898. },
  12899. keyboardHandler: {
  12900. set: function(val) { this.setKeyboardHandler(val); },
  12901. get: function() { return this.keybindingId; },
  12902. handlesSet: true
  12903. },
  12904. hScrollBarAlwaysVisible: "renderer",
  12905. vScrollBarAlwaysVisible: "renderer",
  12906. highlightGutterLine: "renderer",
  12907. animatedScroll: "renderer",
  12908. showInvisibles: "renderer",
  12909. showPrintMargin: "renderer",
  12910. printMarginColumn: "renderer",
  12911. printMargin: "renderer",
  12912. fadeFoldWidgets: "renderer",
  12913. showFoldWidgets: "renderer",
  12914. showLineNumbers: "renderer",
  12915. showGutter: "renderer",
  12916. displayIndentGuides: "renderer",
  12917. fontSize: "renderer",
  12918. fontFamily: "renderer",
  12919. maxLines: "renderer",
  12920. minLines: "renderer",
  12921. scrollPastEnd: "renderer",
  12922. fixedWidthGutter: "renderer",
  12923. theme: "renderer",
  12924. scrollSpeed: "$mouseHandler",
  12925. dragDelay: "$mouseHandler",
  12926. dragEnabled: "$mouseHandler",
  12927. focusTimout: "$mouseHandler",
  12928. tooltipFollowsMouse: "$mouseHandler",
  12929. firstLineNumber: "session",
  12930. overwrite: "session",
  12931. newLineMode: "session",
  12932. useWorker: "session",
  12933. useSoftTabs: "session",
  12934. tabSize: "session",
  12935. wrap: "session",
  12936. indentedSoftWrap: "session",
  12937. foldStyle: "session",
  12938. mode: "session"
  12939. });
  12940. exports.Editor = Editor;
  12941. });
  12942. define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  12943. "use strict";
  12944. var UndoManager = function() {
  12945. this.reset();
  12946. };
  12947. (function() {
  12948. this.execute = function(options) {
  12949. var deltaSets = options.args[0];
  12950. this.$doc = options.args[1];
  12951. if (options.merge && this.hasUndo()){
  12952. this.dirtyCounter--;
  12953. deltaSets = this.$undoStack.pop().concat(deltaSets);
  12954. }
  12955. this.$undoStack.push(deltaSets);
  12956. this.$redoStack = [];
  12957. if (this.dirtyCounter < 0) {
  12958. this.dirtyCounter = NaN;
  12959. }
  12960. this.dirtyCounter++;
  12961. };
  12962. this.undo = function(dontSelect) {
  12963. var deltaSets = this.$undoStack.pop();
  12964. var undoSelectionRange = null;
  12965. if (deltaSets) {
  12966. undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
  12967. this.$redoStack.push(deltaSets);
  12968. this.dirtyCounter--;
  12969. }
  12970. return undoSelectionRange;
  12971. };
  12972. this.redo = function(dontSelect) {
  12973. var deltaSets = this.$redoStack.pop();
  12974. var redoSelectionRange = null;
  12975. if (deltaSets) {
  12976. redoSelectionRange =
  12977. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  12978. this.$undoStack.push(deltaSets);
  12979. this.dirtyCounter++;
  12980. }
  12981. return redoSelectionRange;
  12982. };
  12983. this.reset = function() {
  12984. this.$undoStack = [];
  12985. this.$redoStack = [];
  12986. this.dirtyCounter = 0;
  12987. };
  12988. this.hasUndo = function() {
  12989. return this.$undoStack.length > 0;
  12990. };
  12991. this.hasRedo = function() {
  12992. return this.$redoStack.length > 0;
  12993. };
  12994. this.markClean = function() {
  12995. this.dirtyCounter = 0;
  12996. };
  12997. this.isClean = function() {
  12998. return this.dirtyCounter === 0;
  12999. };
  13000. this.$serializeDeltas = function(deltaSets) {
  13001. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  13002. };
  13003. this.$deserializeDeltas = function(deltaSets) {
  13004. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  13005. };
  13006. function $serializeDelta(delta){
  13007. return {
  13008. action: delta.action,
  13009. start: delta.start,
  13010. end: delta.end,
  13011. lines: delta.lines.length == 1 ? null : delta.lines,
  13012. text: delta.lines.length == 1 ? delta.lines[0] : null
  13013. };
  13014. }
  13015. function $deserializeDelta(delta) {
  13016. return {
  13017. action: delta.action,
  13018. start: delta.start,
  13019. end: delta.end,
  13020. lines: delta.lines || [delta.text]
  13021. };
  13022. }
  13023. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  13024. var deltaSets_new = new Array(deltaSets_old.length);
  13025. for (var i = 0; i < deltaSets_old.length; i++) {
  13026. var deltaSet_old = deltaSets_old[i];
  13027. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  13028. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  13029. var delta_old = deltaSet_old.deltas[j];
  13030. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  13031. }
  13032. deltaSets_new[i] = deltaSet_new;
  13033. }
  13034. return deltaSets_new;
  13035. }
  13036. }).call(UndoManager.prototype);
  13037. exports.UndoManager = UndoManager;
  13038. });
  13039. define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
  13040. "use strict";
  13041. var dom = require("../lib/dom");
  13042. var oop = require("../lib/oop");
  13043. var lang = require("../lib/lang");
  13044. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  13045. var Gutter = function(parentEl) {
  13046. this.element = dom.createElement("div");
  13047. this.element.className = "ace_layer ace_gutter-layer";
  13048. parentEl.appendChild(this.element);
  13049. this.setShowFoldWidgets(this.$showFoldWidgets);
  13050. this.gutterWidth = 0;
  13051. this.$annotations = [];
  13052. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  13053. this.$cells = [];
  13054. };
  13055. (function() {
  13056. oop.implement(this, EventEmitter);
  13057. this.setSession = function(session) {
  13058. if (this.session)
  13059. this.session.removeEventListener("change", this.$updateAnnotations);
  13060. this.session = session;
  13061. if (session)
  13062. session.on("change", this.$updateAnnotations);
  13063. };
  13064. this.addGutterDecoration = function(row, className){
  13065. if (window.console)
  13066. console.warn && console.warn("deprecated use session.addGutterDecoration");
  13067. this.session.addGutterDecoration(row, className);
  13068. };
  13069. this.removeGutterDecoration = function(row, className){
  13070. if (window.console)
  13071. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  13072. this.session.removeGutterDecoration(row, className);
  13073. };
  13074. this.setAnnotations = function(annotations) {
  13075. this.$annotations = [];
  13076. for (var i = 0; i < annotations.length; i++) {
  13077. var annotation = annotations[i];
  13078. var row = annotation.row;
  13079. var rowInfo = this.$annotations[row];
  13080. if (!rowInfo)
  13081. rowInfo = this.$annotations[row] = {text: []};
  13082. var annoText = annotation.text;
  13083. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  13084. if (rowInfo.text.indexOf(annoText) === -1)
  13085. rowInfo.text.push(annoText);
  13086. var type = annotation.type;
  13087. if (type == "error")
  13088. rowInfo.className = " ace_error";
  13089. else if (type == "warning" && rowInfo.className != " ace_error")
  13090. rowInfo.className = " ace_warning";
  13091. else if (type == "info" && (!rowInfo.className))
  13092. rowInfo.className = " ace_info";
  13093. }
  13094. };
  13095. this.$updateAnnotations = function (delta) {
  13096. if (!this.$annotations.length)
  13097. return;
  13098. var firstRow = delta.start.row;
  13099. var len = delta.end.row - firstRow;
  13100. if (len === 0) {
  13101. } else if (delta.action == 'remove') {
  13102. this.$annotations.splice(firstRow, len + 1, null);
  13103. } else {
  13104. var args = new Array(len + 1);
  13105. args.unshift(firstRow, 1);
  13106. this.$annotations.splice.apply(this.$annotations, args);
  13107. }
  13108. };
  13109. this.update = function(config) {
  13110. var session = this.session;
  13111. var firstRow = config.firstRow;
  13112. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  13113. session.getLength() - 1);
  13114. var fold = session.getNextFoldLine(firstRow);
  13115. var foldStart = fold ? fold.start.row : Infinity;
  13116. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  13117. var breakpoints = session.$breakpoints;
  13118. var decorations = session.$decorations;
  13119. var firstLineNumber = session.$firstLineNumber;
  13120. var lastLineNumber = 0;
  13121. var gutterRenderer = session.gutterRenderer || this.$renderer;
  13122. var cell = null;
  13123. var index = -1;
  13124. var row = firstRow;
  13125. while (true) {
  13126. if (row > foldStart) {
  13127. row = fold.end.row + 1;
  13128. fold = session.getNextFoldLine(row, fold);
  13129. foldStart = fold ? fold.start.row : Infinity;
  13130. }
  13131. if (row > lastRow) {
  13132. while (this.$cells.length > index + 1) {
  13133. cell = this.$cells.pop();
  13134. this.element.removeChild(cell.element);
  13135. }
  13136. break;
  13137. }
  13138. cell = this.$cells[++index];
  13139. if (!cell) {
  13140. cell = {element: null, textNode: null, foldWidget: null};
  13141. cell.element = dom.createElement("div");
  13142. cell.textNode = document.createTextNode('');
  13143. cell.element.appendChild(cell.textNode);
  13144. this.element.appendChild(cell.element);
  13145. this.$cells[index] = cell;
  13146. }
  13147. var className = "ace_gutter-cell ";
  13148. if (breakpoints[row])
  13149. className += breakpoints[row];
  13150. if (decorations[row])
  13151. className += decorations[row];
  13152. if (this.$annotations[row])
  13153. className += this.$annotations[row].className;
  13154. if (cell.element.className != className)
  13155. cell.element.className = className;
  13156. var height = session.getRowLength(row) * config.lineHeight + "px";
  13157. if (height != cell.element.style.height)
  13158. cell.element.style.height = height;
  13159. if (foldWidgets) {
  13160. var c = foldWidgets[row];
  13161. if (c == null)
  13162. c = foldWidgets[row] = session.getFoldWidget(row);
  13163. }
  13164. if (c) {
  13165. if (!cell.foldWidget) {
  13166. cell.foldWidget = dom.createElement("span");
  13167. cell.element.appendChild(cell.foldWidget);
  13168. }
  13169. var className = "ace_fold-widget ace_" + c;
  13170. if (c == "start" && row == foldStart && row < fold.end.row)
  13171. className += " ace_closed";
  13172. else
  13173. className += " ace_open";
  13174. if (cell.foldWidget.className != className)
  13175. cell.foldWidget.className = className;
  13176. var height = config.lineHeight + "px";
  13177. if (cell.foldWidget.style.height != height)
  13178. cell.foldWidget.style.height = height;
  13179. } else {
  13180. if (cell.foldWidget) {
  13181. cell.element.removeChild(cell.foldWidget);
  13182. cell.foldWidget = null;
  13183. }
  13184. }
  13185. var text = lastLineNumber = gutterRenderer
  13186. ? gutterRenderer.getText(session, row)
  13187. : row + firstLineNumber;
  13188. if (text !== cell.textNode.data)
  13189. cell.textNode.data = text;
  13190. row++;
  13191. }
  13192. this.element.style.height = config.minHeight + "px";
  13193. if (this.$fixedWidth || session.$useWrapMode)
  13194. lastLineNumber = session.getLength() + firstLineNumber;
  13195. var gutterWidth = gutterRenderer
  13196. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  13197. : lastLineNumber.toString().length * config.characterWidth;
  13198. var padding = this.$padding || this.$computePadding();
  13199. gutterWidth += padding.left + padding.right;
  13200. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  13201. this.gutterWidth = gutterWidth;
  13202. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  13203. this._emit("changeGutterWidth", gutterWidth);
  13204. }
  13205. };
  13206. this.$fixedWidth = false;
  13207. this.$showLineNumbers = true;
  13208. this.$renderer = "";
  13209. this.setShowLineNumbers = function(show) {
  13210. this.$renderer = !show && {
  13211. getWidth: function() {return "";},
  13212. getText: function() {return "";}
  13213. };
  13214. };
  13215. this.getShowLineNumbers = function() {
  13216. return this.$showLineNumbers;
  13217. };
  13218. this.$showFoldWidgets = true;
  13219. this.setShowFoldWidgets = function(show) {
  13220. if (show)
  13221. dom.addCssClass(this.element, "ace_folding-enabled");
  13222. else
  13223. dom.removeCssClass(this.element, "ace_folding-enabled");
  13224. this.$showFoldWidgets = show;
  13225. this.$padding = null;
  13226. };
  13227. this.getShowFoldWidgets = function() {
  13228. return this.$showFoldWidgets;
  13229. };
  13230. this.$computePadding = function() {
  13231. if (!this.element.firstChild)
  13232. return {left: 0, right: 0};
  13233. var style = dom.computedStyle(this.element.firstChild);
  13234. this.$padding = {};
  13235. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  13236. this.$padding.right = parseInt(style.paddingRight) || 0;
  13237. return this.$padding;
  13238. };
  13239. this.getRegion = function(point) {
  13240. var padding = this.$padding || this.$computePadding();
  13241. var rect = this.element.getBoundingClientRect();
  13242. if (point.x < padding.left + rect.left)
  13243. return "markers";
  13244. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  13245. return "foldWidgets";
  13246. };
  13247. }).call(Gutter.prototype);
  13248. exports.Gutter = Gutter;
  13249. });
  13250. define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  13251. "use strict";
  13252. var Range = require("../range").Range;
  13253. var dom = require("../lib/dom");
  13254. var Marker = function(parentEl) {
  13255. this.element = dom.createElement("div");
  13256. this.element.className = "ace_layer ace_marker-layer";
  13257. parentEl.appendChild(this.element);
  13258. };
  13259. (function() {
  13260. this.$padding = 0;
  13261. this.setPadding = function(padding) {
  13262. this.$padding = padding;
  13263. };
  13264. this.setSession = function(session) {
  13265. this.session = session;
  13266. };
  13267. this.setMarkers = function(markers) {
  13268. this.markers = markers;
  13269. };
  13270. this.update = function(config) {
  13271. if (!config) return;
  13272. this.config = config;
  13273. var html = [];
  13274. for (var key in this.markers) {
  13275. var marker = this.markers[key];
  13276. if (!marker.range) {
  13277. marker.update(html, this, this.session, config);
  13278. continue;
  13279. }
  13280. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  13281. if (range.isEmpty()) continue;
  13282. range = range.toScreenRange(this.session);
  13283. if (marker.renderer) {
  13284. var top = this.$getTop(range.start.row, config);
  13285. var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row)
  13286. ? this.session.$bidiHandler.getPosLeft(range.start.column)
  13287. : range.start.column * config.characterWidth);
  13288. marker.renderer(html, range, left, top, config);
  13289. } else if (marker.type == "fullLine") {
  13290. this.drawFullLineMarker(html, range, marker.clazz, config);
  13291. } else if (marker.type == "screenLine") {
  13292. this.drawScreenLineMarker(html, range, marker.clazz, config);
  13293. } else if (range.isMultiLine()) {
  13294. if (marker.type == "text")
  13295. this.drawTextMarker(html, range, marker.clazz, config);
  13296. else
  13297. this.drawMultiLineMarker(html, range, marker.clazz, config);
  13298. } else {
  13299. if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
  13300. this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  13301. } else {
  13302. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  13303. }
  13304. }
  13305. }
  13306. this.element.innerHTML = html.join("");
  13307. };
  13308. this.$getTop = function(row, layerConfig) {
  13309. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  13310. };
  13311. function getBorderClass(tl, tr, br, bl) {
  13312. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  13313. }
  13314. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  13315. var session = this.session;
  13316. var start = range.start.row;
  13317. var end = range.end.row;
  13318. var row = start;
  13319. var prev = 0;
  13320. var curr = 0;
  13321. var next = session.getScreenLastRowColumn(row);
  13322. var clazzModified = null;
  13323. var lineRange = new Range(row, range.start.column, row, curr);
  13324. for (; row <= end; row++) {
  13325. lineRange.start.row = lineRange.end.row = row;
  13326. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  13327. lineRange.end.column = next;
  13328. prev = curr;
  13329. curr = next;
  13330. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  13331. clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br"
  13332. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end);
  13333. if (this.session.$bidiHandler.isBidiRow(row)) {
  13334. this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified,
  13335. layerConfig, row == end ? 0 : 1, extraStyle);
  13336. } else {
  13337. this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified,
  13338. layerConfig, row == end ? 0 : 1, extraStyle);
  13339. }
  13340. }
  13341. };
  13342. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  13343. var padding = this.$padding;
  13344. var height, top, left;
  13345. extraStyle = extraStyle || "";
  13346. if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
  13347. var range1 = range.clone();
  13348. range1.end.row = range1.start.row;
  13349. range1.end.column = this.session.getLine(range1.start.row).length;
  13350. this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle);
  13351. } else {
  13352. height = config.lineHeight;
  13353. top = this.$getTop(range.start.row, config);
  13354. left = padding + range.start.column * config.characterWidth;
  13355. stringBuilder.push(
  13356. "<div class='", clazz, " ace_br1 ace_start' style='",
  13357. "height:", height, "px;",
  13358. "right:0;",
  13359. "top:", top, "px;",
  13360. "left:", left, "px;", extraStyle, "'></div>"
  13361. );
  13362. }
  13363. if (this.session.$bidiHandler.isBidiRow(range.end.row)) {
  13364. var range1 = range.clone();
  13365. range1.start.row = range1.end.row;
  13366. range1.start.column = 0;
  13367. this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle);
  13368. } else {
  13369. var width = range.end.column * config.characterWidth;
  13370. height = config.lineHeight;
  13371. top = this.$getTop(range.end.row, config);
  13372. stringBuilder.push(
  13373. "<div class='", clazz, " ace_br12' style='",
  13374. "height:", height, "px;",
  13375. "width:", width, "px;",
  13376. "top:", top, "px;",
  13377. "left:", padding, "px;", extraStyle, "'></div>"
  13378. );
  13379. }
  13380. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  13381. if (height <= 0)
  13382. return;
  13383. top = this.$getTop(range.start.row + 1, config);
  13384. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  13385. stringBuilder.push(
  13386. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  13387. "height:", height, "px;",
  13388. "right:0;",
  13389. "top:", top, "px;",
  13390. "left:", padding, "px;", extraStyle, "'></div>"
  13391. );
  13392. };
  13393. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  13394. var height = config.lineHeight;
  13395. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  13396. var top = this.$getTop(range.start.row, config);
  13397. var left = this.$padding + range.start.column * config.characterWidth;
  13398. stringBuilder.push(
  13399. "<div class='", clazz, "' style='",
  13400. "height:", height, "px;",
  13401. "width:", width, "px;",
  13402. "top:", top, "px;",
  13403. "left:", left, "px;", extraStyle || "", "'></div>"
  13404. );
  13405. };
  13406. this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  13407. var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding;
  13408. var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column);
  13409. selections.forEach(function(selection) {
  13410. stringBuilder.push(
  13411. "<div class='", clazz, "' style='",
  13412. "height:", height, "px;",
  13413. "width:", selection.width + (extraLength || 0), "px;",
  13414. "top:", top, "px;",
  13415. "left:", padding + selection.left, "px;", extraStyle || "", "'></div>"
  13416. );
  13417. });
  13418. };
  13419. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  13420. var top = this.$getTop(range.start.row, config);
  13421. var height = config.lineHeight;
  13422. if (range.start.row != range.end.row)
  13423. height += this.$getTop(range.end.row, config) - top;
  13424. stringBuilder.push(
  13425. "<div class='", clazz, "' style='",
  13426. "height:", height, "px;",
  13427. "top:", top, "px;",
  13428. "left:0;right:0;", extraStyle || "", "'></div>"
  13429. );
  13430. };
  13431. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  13432. var top = this.$getTop(range.start.row, config);
  13433. var height = config.lineHeight;
  13434. stringBuilder.push(
  13435. "<div class='", clazz, "' style='",
  13436. "height:", height, "px;",
  13437. "top:", top, "px;",
  13438. "left:0;right:0;", extraStyle || "", "'></div>"
  13439. );
  13440. };
  13441. }).call(Marker.prototype);
  13442. exports.Marker = Marker;
  13443. });
  13444. 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) {
  13445. "use strict";
  13446. var oop = require("../lib/oop");
  13447. var dom = require("../lib/dom");
  13448. var lang = require("../lib/lang");
  13449. var useragent = require("../lib/useragent");
  13450. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  13451. var Text = function(parentEl) {
  13452. this.element = dom.createElement("div");
  13453. this.element.className = "ace_layer ace_text-layer";
  13454. parentEl.appendChild(this.element);
  13455. this.$updateEolChar = this.$updateEolChar.bind(this);
  13456. };
  13457. (function() {
  13458. oop.implement(this, EventEmitter);
  13459. this.EOF_CHAR = "\xB6";
  13460. this.EOL_CHAR_LF = "\xAC";
  13461. this.EOL_CHAR_CRLF = "\xa4";
  13462. this.EOL_CHAR = this.EOL_CHAR_LF;
  13463. this.TAB_CHAR = "\u2014"; //"\u21E5";
  13464. this.SPACE_CHAR = "\xB7";
  13465. this.$padding = 0;
  13466. this.$updateEolChar = function() {
  13467. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  13468. ? this.EOL_CHAR_LF
  13469. : this.EOL_CHAR_CRLF;
  13470. if (this.EOL_CHAR != EOL_CHAR) {
  13471. this.EOL_CHAR = EOL_CHAR;
  13472. return true;
  13473. }
  13474. };
  13475. this.setPadding = function(padding) {
  13476. this.$padding = padding;
  13477. this.element.style.padding = "0 " + padding + "px";
  13478. };
  13479. this.getLineHeight = function() {
  13480. return this.$fontMetrics.$characterSize.height || 0;
  13481. };
  13482. this.getCharacterWidth = function() {
  13483. return this.$fontMetrics.$characterSize.width || 0;
  13484. };
  13485. this.$setFontMetrics = function(measure) {
  13486. this.$fontMetrics = measure;
  13487. this.$fontMetrics.on("changeCharacterSize", function(e) {
  13488. this._signal("changeCharacterSize", e);
  13489. }.bind(this));
  13490. this.$pollSizeChanges();
  13491. };
  13492. this.checkForSizeChanges = function() {
  13493. this.$fontMetrics.checkForSizeChanges();
  13494. };
  13495. this.$pollSizeChanges = function() {
  13496. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  13497. };
  13498. this.setSession = function(session) {
  13499. this.session = session;
  13500. if (session)
  13501. this.$computeTabString();
  13502. };
  13503. this.showInvisibles = false;
  13504. this.setShowInvisibles = function(showInvisibles) {
  13505. if (this.showInvisibles == showInvisibles)
  13506. return false;
  13507. this.showInvisibles = showInvisibles;
  13508. this.$computeTabString();
  13509. return true;
  13510. };
  13511. this.displayIndentGuides = true;
  13512. this.setDisplayIndentGuides = function(display) {
  13513. if (this.displayIndentGuides == display)
  13514. return false;
  13515. this.displayIndentGuides = display;
  13516. this.$computeTabString();
  13517. return true;
  13518. };
  13519. this.$tabStrings = [];
  13520. this.onChangeTabSize =
  13521. this.$computeTabString = function() {
  13522. var tabSize = this.session.getTabSize();
  13523. this.tabSize = tabSize;
  13524. var tabStr = this.$tabStrings = [0];
  13525. for (var i = 1; i < tabSize + 1; i++) {
  13526. if (this.showInvisibles) {
  13527. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  13528. + lang.stringRepeat(this.TAB_CHAR, i)
  13529. + "</span>");
  13530. } else {
  13531. tabStr.push(lang.stringRepeat(" ", i));
  13532. }
  13533. }
  13534. if (this.displayIndentGuides) {
  13535. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  13536. var className = "ace_indent-guide";
  13537. var spaceClass = "";
  13538. var tabClass = "";
  13539. if (this.showInvisibles) {
  13540. className += " ace_invisible";
  13541. spaceClass = " ace_invisible_space";
  13542. tabClass = " ace_invisible_tab";
  13543. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  13544. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  13545. } else{
  13546. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  13547. var tabContent = spaceContent;
  13548. }
  13549. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  13550. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  13551. }
  13552. };
  13553. this.updateLines = function(config, firstRow, lastRow) {
  13554. if (this.config.lastRow != config.lastRow ||
  13555. this.config.firstRow != config.firstRow) {
  13556. this.scrollLines(config);
  13557. }
  13558. this.config = config;
  13559. var first = Math.max(firstRow, config.firstRow);
  13560. var last = Math.min(lastRow, config.lastRow);
  13561. var lineElements = this.element.childNodes;
  13562. var lineElementsIdx = 0;
  13563. for (var row = config.firstRow; row < first; row++) {
  13564. var foldLine = this.session.getFoldLine(row);
  13565. if (foldLine) {
  13566. if (foldLine.containsRow(first)) {
  13567. first = foldLine.start.row;
  13568. break;
  13569. } else {
  13570. row = foldLine.end.row;
  13571. }
  13572. }
  13573. lineElementsIdx ++;
  13574. }
  13575. var row = first;
  13576. var foldLine = this.session.getNextFoldLine(row);
  13577. var foldStart = foldLine ? foldLine.start.row : Infinity;
  13578. while (true) {
  13579. if (row > foldStart) {
  13580. row = foldLine.end.row+1;
  13581. foldLine = this.session.getNextFoldLine(row, foldLine);
  13582. foldStart = foldLine ? foldLine.start.row :Infinity;
  13583. }
  13584. if (row > last)
  13585. break;
  13586. var lineElement = lineElements[lineElementsIdx++];
  13587. if (lineElement) {
  13588. var html = [];
  13589. this.$renderLine(
  13590. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  13591. );
  13592. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  13593. lineElement.innerHTML = html.join("");
  13594. }
  13595. row++;
  13596. }
  13597. };
  13598. this.scrollLines = function(config) {
  13599. var oldConfig = this.config;
  13600. this.config = config;
  13601. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  13602. return this.update(config);
  13603. if (config.lastRow < oldConfig.firstRow)
  13604. return this.update(config);
  13605. var el = this.element;
  13606. if (oldConfig.firstRow < config.firstRow)
  13607. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  13608. el.removeChild(el.firstChild);
  13609. if (oldConfig.lastRow > config.lastRow)
  13610. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  13611. el.removeChild(el.lastChild);
  13612. if (config.firstRow < oldConfig.firstRow) {
  13613. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  13614. if (el.firstChild)
  13615. el.insertBefore(fragment, el.firstChild);
  13616. else
  13617. el.appendChild(fragment);
  13618. }
  13619. if (config.lastRow > oldConfig.lastRow) {
  13620. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  13621. el.appendChild(fragment);
  13622. }
  13623. };
  13624. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  13625. var fragment = this.element.ownerDocument.createDocumentFragment();
  13626. var row = firstRow;
  13627. var foldLine = this.session.getNextFoldLine(row);
  13628. var foldStart = foldLine ? foldLine.start.row : Infinity;
  13629. while (true) {
  13630. if (row > foldStart) {
  13631. row = foldLine.end.row+1;
  13632. foldLine = this.session.getNextFoldLine(row, foldLine);
  13633. foldStart = foldLine ? foldLine.start.row : Infinity;
  13634. }
  13635. if (row > lastRow)
  13636. break;
  13637. var container = dom.createElement("div");
  13638. var html = [];
  13639. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  13640. container.innerHTML = html.join("");
  13641. if (this.$useLineGroups()) {
  13642. container.className = 'ace_line_group';
  13643. fragment.appendChild(container);
  13644. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  13645. } else {
  13646. while(container.firstChild)
  13647. fragment.appendChild(container.firstChild);
  13648. }
  13649. row++;
  13650. }
  13651. return fragment;
  13652. };
  13653. this.update = function(config) {
  13654. this.config = config;
  13655. var html = [];
  13656. var firstRow = config.firstRow, lastRow = config.lastRow;
  13657. var row = firstRow;
  13658. var foldLine = this.session.getNextFoldLine(row);
  13659. var foldStart = foldLine ? foldLine.start.row : Infinity;
  13660. while (true) {
  13661. if (row > foldStart) {
  13662. row = foldLine.end.row+1;
  13663. foldLine = this.session.getNextFoldLine(row, foldLine);
  13664. foldStart = foldLine ? foldLine.start.row :Infinity;
  13665. }
  13666. if (row > lastRow)
  13667. break;
  13668. if (this.$useLineGroups())
  13669. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>");
  13670. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  13671. if (this.$useLineGroups())
  13672. html.push("</div>"); // end the line group
  13673. row++;
  13674. }
  13675. this.element.innerHTML = html.join("");
  13676. };
  13677. this.$textToken = {
  13678. "text": true,
  13679. "rparen": true,
  13680. "lparen": true
  13681. };
  13682. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  13683. var self = this;
  13684. var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  13685. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  13686. if (a) {
  13687. return self.showInvisibles
  13688. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  13689. : c;
  13690. } else if (c == "&") {
  13691. return "&#38;";
  13692. } else if (c == "<") {
  13693. return "&#60;";
  13694. } else if (c == ">") {
  13695. return "&#62;";
  13696. } else if (c == "\t") {
  13697. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  13698. screenColumn += tabSize - 1;
  13699. return self.$tabStrings[tabSize];
  13700. } else if (c == "\u3000") {
  13701. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  13702. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  13703. screenColumn += 1;
  13704. return "<span class='" + classToUse + "' style='width:" +
  13705. (self.config.characterWidth * 2) +
  13706. "px'>" + space + "</span>";
  13707. } else if (b) {
  13708. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  13709. } else {
  13710. screenColumn += 1;
  13711. return "<span class='ace_cjk' style='width:" +
  13712. (self.config.characterWidth * 2) +
  13713. "px'>" + c + "</span>";
  13714. }
  13715. };
  13716. var output = value.replace(replaceReg, replaceFunc);
  13717. if (!this.$textToken[token.type]) {
  13718. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  13719. var style = "";
  13720. if (token.type == "fold")
  13721. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  13722. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  13723. }
  13724. else {
  13725. stringBuilder.push(output);
  13726. }
  13727. return screenColumn + value.length;
  13728. };
  13729. this.renderIndentGuide = function(stringBuilder, value, max) {
  13730. var cols = value.search(this.$indentGuideRe);
  13731. if (cols <= 0 || cols >= max)
  13732. return value;
  13733. if (value[0] == " ") {
  13734. cols -= cols % this.tabSize;
  13735. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  13736. return value.substr(cols);
  13737. } else if (value[0] == "\t") {
  13738. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  13739. return value.substr(cols);
  13740. }
  13741. return value;
  13742. };
  13743. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  13744. var chars = 0;
  13745. var split = 0;
  13746. var splitChars = splits[0];
  13747. var screenColumn = 0;
  13748. for (var i = 0; i < tokens.length; i++) {
  13749. var token = tokens[i];
  13750. var value = token.value;
  13751. if (i == 0 && this.displayIndentGuides) {
  13752. chars = value.length;
  13753. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  13754. if (!value)
  13755. continue;
  13756. chars -= value.length;
  13757. }
  13758. if (chars + value.length < splitChars) {
  13759. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  13760. chars += value.length;
  13761. } else {
  13762. while (chars + value.length >= splitChars) {
  13763. screenColumn = this.$renderToken(
  13764. stringBuilder, screenColumn,
  13765. token, value.substring(0, splitChars - chars)
  13766. );
  13767. value = value.substring(splitChars - chars);
  13768. chars = splitChars;
  13769. if (!onlyContents) {
  13770. stringBuilder.push("</div>",
  13771. "<div class='ace_line' style='height:",
  13772. this.config.lineHeight, "px'>"
  13773. );
  13774. }
  13775. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  13776. split ++;
  13777. screenColumn = 0;
  13778. splitChars = splits[split] || Number.MAX_VALUE;
  13779. }
  13780. if (value.length != 0) {
  13781. chars += value.length;
  13782. screenColumn = this.$renderToken(
  13783. stringBuilder, screenColumn, token, value
  13784. );
  13785. }
  13786. }
  13787. }
  13788. };
  13789. this.$renderSimpleLine = function(stringBuilder, tokens) {
  13790. var screenColumn = 0;
  13791. var token = tokens[0];
  13792. var value = token.value;
  13793. if (this.displayIndentGuides)
  13794. value = this.renderIndentGuide(stringBuilder, value);
  13795. if (value)
  13796. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  13797. for (var i = 1; i < tokens.length; i++) {
  13798. token = tokens[i];
  13799. value = token.value;
  13800. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  13801. }
  13802. };
  13803. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  13804. if (!foldLine && foldLine != false)
  13805. foldLine = this.session.getFoldLine(row);
  13806. if (foldLine)
  13807. var tokens = this.$getFoldLineTokens(row, foldLine);
  13808. else
  13809. var tokens = this.session.getTokens(row);
  13810. if (!onlyContents) {
  13811. stringBuilder.push(
  13812. "<div class='ace_line' style='height:",
  13813. this.config.lineHeight * (
  13814. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  13815. ), "px'>"
  13816. );
  13817. }
  13818. if (tokens.length) {
  13819. var splits = this.session.getRowSplitData(row);
  13820. if (splits && splits.length)
  13821. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  13822. else
  13823. this.$renderSimpleLine(stringBuilder, tokens);
  13824. }
  13825. if (this.showInvisibles) {
  13826. if (foldLine)
  13827. row = foldLine.end.row;
  13828. stringBuilder.push(
  13829. "<span class='ace_invisible ace_invisible_eol'>",
  13830. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  13831. "</span>"
  13832. );
  13833. }
  13834. if (!onlyContents)
  13835. stringBuilder.push("</div>");
  13836. };
  13837. this.$getFoldLineTokens = function(row, foldLine) {
  13838. var session = this.session;
  13839. var renderTokens = [];
  13840. function addTokens(tokens, from, to) {
  13841. var idx = 0, col = 0;
  13842. while ((col + tokens[idx].value.length) < from) {
  13843. col += tokens[idx].value.length;
  13844. idx++;
  13845. if (idx == tokens.length)
  13846. return;
  13847. }
  13848. if (col != from) {
  13849. var value = tokens[idx].value.substring(from - col);
  13850. if (value.length > (to - from))
  13851. value = value.substring(0, to - from);
  13852. renderTokens.push({
  13853. type: tokens[idx].type,
  13854. value: value
  13855. });
  13856. col = from + value.length;
  13857. idx += 1;
  13858. }
  13859. while (col < to && idx < tokens.length) {
  13860. var value = tokens[idx].value;
  13861. if (value.length + col > to) {
  13862. renderTokens.push({
  13863. type: tokens[idx].type,
  13864. value: value.substring(0, to - col)
  13865. });
  13866. } else
  13867. renderTokens.push(tokens[idx]);
  13868. col += value.length;
  13869. idx += 1;
  13870. }
  13871. }
  13872. var tokens = session.getTokens(row);
  13873. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  13874. if (placeholder != null) {
  13875. renderTokens.push({
  13876. type: "fold",
  13877. value: placeholder
  13878. });
  13879. } else {
  13880. if (isNewRow)
  13881. tokens = session.getTokens(row);
  13882. if (tokens.length)
  13883. addTokens(tokens, lastColumn, column);
  13884. }
  13885. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  13886. return renderTokens;
  13887. };
  13888. this.$useLineGroups = function() {
  13889. return this.session.getUseWrapMode();
  13890. };
  13891. this.destroy = function() {
  13892. clearInterval(this.$pollSizeChangesTimer);
  13893. if (this.$measureNode)
  13894. this.$measureNode.parentNode.removeChild(this.$measureNode);
  13895. delete this.$measureNode;
  13896. };
  13897. }).call(Text.prototype);
  13898. exports.Text = Text;
  13899. });
  13900. define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  13901. "use strict";
  13902. var dom = require("../lib/dom");
  13903. var isIE8;
  13904. var Cursor = function(parentEl) {
  13905. this.element = dom.createElement("div");
  13906. this.element.className = "ace_layer ace_cursor-layer";
  13907. parentEl.appendChild(this.element);
  13908. if (isIE8 === undefined)
  13909. isIE8 = !("opacity" in this.element.style);
  13910. this.isVisible = false;
  13911. this.isBlinking = true;
  13912. this.blinkInterval = 1000;
  13913. this.smoothBlinking = false;
  13914. this.cursors = [];
  13915. this.cursor = this.addCursor();
  13916. dom.addCssClass(this.element, "ace_hidden-cursors");
  13917. this.$updateCursors = (isIE8
  13918. ? this.$updateVisibility
  13919. : this.$updateOpacity).bind(this);
  13920. };
  13921. (function() {
  13922. this.$updateVisibility = function(val) {
  13923. var cursors = this.cursors;
  13924. for (var i = cursors.length; i--; )
  13925. cursors[i].style.visibility = val ? "" : "hidden";
  13926. };
  13927. this.$updateOpacity = function(val) {
  13928. var cursors = this.cursors;
  13929. for (var i = cursors.length; i--; )
  13930. cursors[i].style.opacity = val ? "" : "0";
  13931. };
  13932. this.$padding = 0;
  13933. this.setPadding = function(padding) {
  13934. this.$padding = padding;
  13935. };
  13936. this.setSession = function(session) {
  13937. this.session = session;
  13938. };
  13939. this.setBlinking = function(blinking) {
  13940. if (blinking != this.isBlinking){
  13941. this.isBlinking = blinking;
  13942. this.restartTimer();
  13943. }
  13944. };
  13945. this.setBlinkInterval = function(blinkInterval) {
  13946. if (blinkInterval != this.blinkInterval){
  13947. this.blinkInterval = blinkInterval;
  13948. this.restartTimer();
  13949. }
  13950. };
  13951. this.setSmoothBlinking = function(smoothBlinking) {
  13952. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  13953. this.smoothBlinking = smoothBlinking;
  13954. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  13955. this.$updateCursors(true);
  13956. this.$updateCursors = (this.$updateOpacity).bind(this);
  13957. this.restartTimer();
  13958. }
  13959. };
  13960. this.addCursor = function() {
  13961. var el = dom.createElement("div");
  13962. el.className = "ace_cursor";
  13963. this.element.appendChild(el);
  13964. this.cursors.push(el);
  13965. return el;
  13966. };
  13967. this.removeCursor = function() {
  13968. if (this.cursors.length > 1) {
  13969. var el = this.cursors.pop();
  13970. el.parentNode.removeChild(el);
  13971. return el;
  13972. }
  13973. };
  13974. this.hideCursor = function() {
  13975. this.isVisible = false;
  13976. dom.addCssClass(this.element, "ace_hidden-cursors");
  13977. this.restartTimer();
  13978. };
  13979. this.showCursor = function() {
  13980. this.isVisible = true;
  13981. dom.removeCssClass(this.element, "ace_hidden-cursors");
  13982. this.restartTimer();
  13983. };
  13984. this.restartTimer = function() {
  13985. var update = this.$updateCursors;
  13986. clearInterval(this.intervalId);
  13987. clearTimeout(this.timeoutId);
  13988. if (this.smoothBlinking) {
  13989. dom.removeCssClass(this.element, "ace_smooth-blinking");
  13990. }
  13991. update(true);
  13992. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  13993. return;
  13994. if (this.smoothBlinking) {
  13995. setTimeout(function(){
  13996. dom.addCssClass(this.element, "ace_smooth-blinking");
  13997. }.bind(this));
  13998. }
  13999. var blink = function(){
  14000. this.timeoutId = setTimeout(function() {
  14001. update(false);
  14002. }, 0.6 * this.blinkInterval);
  14003. }.bind(this);
  14004. this.intervalId = setInterval(function() {
  14005. update(true);
  14006. blink();
  14007. }, this.blinkInterval);
  14008. blink();
  14009. };
  14010. this.getPixelPosition = function(position, onScreen) {
  14011. if (!this.config || !this.session)
  14012. return {left : 0, top : 0};
  14013. if (!position)
  14014. position = this.session.selection.getCursor();
  14015. var pos = this.session.documentToScreenPosition(position);
  14016. var cursorLeft = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, position.row)
  14017. ? this.session.$bidiHandler.getPosLeft(pos.column)
  14018. : pos.column * this.config.characterWidth);
  14019. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  14020. this.config.lineHeight;
  14021. return {left : cursorLeft, top : cursorTop};
  14022. };
  14023. this.update = function(config) {
  14024. this.config = config;
  14025. var selections = this.session.$selectionMarkers;
  14026. var i = 0, cursorIndex = 0;
  14027. if (selections === undefined || selections.length === 0){
  14028. selections = [{cursor: null}];
  14029. }
  14030. for (var i = 0, n = selections.length; i < n; i++) {
  14031. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  14032. if ((pixelPos.top > config.height + config.offset ||
  14033. pixelPos.top < 0) && i > 1) {
  14034. continue;
  14035. }
  14036. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  14037. if (!this.drawCursor) {
  14038. style.left = pixelPos.left + "px";
  14039. style.top = pixelPos.top + "px";
  14040. style.width = config.characterWidth + "px";
  14041. style.height = config.lineHeight + "px";
  14042. } else {
  14043. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  14044. }
  14045. }
  14046. while (this.cursors.length > cursorIndex)
  14047. this.removeCursor();
  14048. var overwrite = this.session.getOverwrite();
  14049. this.$setOverwrite(overwrite);
  14050. this.$pixelPos = pixelPos;
  14051. this.restartTimer();
  14052. };
  14053. this.drawCursor = null;
  14054. this.$setOverwrite = function(overwrite) {
  14055. if (overwrite != this.overwrite) {
  14056. this.overwrite = overwrite;
  14057. if (overwrite)
  14058. dom.addCssClass(this.element, "ace_overwrite-cursors");
  14059. else
  14060. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  14061. }
  14062. };
  14063. this.destroy = function() {
  14064. clearInterval(this.intervalId);
  14065. clearTimeout(this.timeoutId);
  14066. };
  14067. }).call(Cursor.prototype);
  14068. exports.Cursor = Cursor;
  14069. });
  14070. define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  14071. "use strict";
  14072. var oop = require("./lib/oop");
  14073. var dom = require("./lib/dom");
  14074. var event = require("./lib/event");
  14075. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14076. var MAX_SCROLL_H = 0x8000;
  14077. var ScrollBar = function(parent) {
  14078. this.element = dom.createElement("div");
  14079. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  14080. this.inner = dom.createElement("div");
  14081. this.inner.className = "ace_scrollbar-inner";
  14082. this.element.appendChild(this.inner);
  14083. parent.appendChild(this.element);
  14084. this.setVisible(false);
  14085. this.skipEvent = false;
  14086. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  14087. event.addListener(this.element, "mousedown", event.preventDefault);
  14088. };
  14089. (function() {
  14090. oop.implement(this, EventEmitter);
  14091. this.setVisible = function(isVisible) {
  14092. this.element.style.display = isVisible ? "" : "none";
  14093. this.isVisible = isVisible;
  14094. this.coeff = 1;
  14095. };
  14096. }).call(ScrollBar.prototype);
  14097. var VScrollBar = function(parent, renderer) {
  14098. ScrollBar.call(this, parent);
  14099. this.scrollTop = 0;
  14100. this.scrollHeight = 0;
  14101. renderer.$scrollbarWidth =
  14102. this.width = dom.scrollbarWidth(parent.ownerDocument);
  14103. this.inner.style.width =
  14104. this.element.style.width = (this.width || 15) + 5 + "px";
  14105. this.$minWidth = 0;
  14106. };
  14107. oop.inherits(VScrollBar, ScrollBar);
  14108. (function() {
  14109. this.classSuffix = '-v';
  14110. this.onScroll = function() {
  14111. if (!this.skipEvent) {
  14112. this.scrollTop = this.element.scrollTop;
  14113. if (this.coeff != 1) {
  14114. var h = this.element.clientHeight / this.scrollHeight;
  14115. this.scrollTop = this.scrollTop * (1 - h) / (this.coeff - h);
  14116. }
  14117. this._emit("scroll", {data: this.scrollTop});
  14118. }
  14119. this.skipEvent = false;
  14120. };
  14121. this.getWidth = function() {
  14122. return Math.max(this.isVisible ? this.width : 0, this.$minWidth || 0);
  14123. };
  14124. this.setHeight = function(height) {
  14125. this.element.style.height = height + "px";
  14126. };
  14127. this.setInnerHeight =
  14128. this.setScrollHeight = function(height) {
  14129. this.scrollHeight = height;
  14130. if (height > MAX_SCROLL_H) {
  14131. this.coeff = MAX_SCROLL_H / height;
  14132. height = MAX_SCROLL_H;
  14133. } else if (this.coeff != 1) {
  14134. this.coeff = 1;
  14135. }
  14136. this.inner.style.height = height + "px";
  14137. };
  14138. this.setScrollTop = function(scrollTop) {
  14139. if (this.scrollTop != scrollTop) {
  14140. this.skipEvent = true;
  14141. this.scrollTop = scrollTop;
  14142. this.element.scrollTop = scrollTop * this.coeff;
  14143. }
  14144. };
  14145. }).call(VScrollBar.prototype);
  14146. var HScrollBar = function(parent, renderer) {
  14147. ScrollBar.call(this, parent);
  14148. this.scrollLeft = 0;
  14149. this.height = renderer.$scrollbarWidth;
  14150. this.inner.style.height =
  14151. this.element.style.height = (this.height || 15) + 5 + "px";
  14152. };
  14153. oop.inherits(HScrollBar, ScrollBar);
  14154. (function() {
  14155. this.classSuffix = '-h';
  14156. this.onScroll = function() {
  14157. if (!this.skipEvent) {
  14158. this.scrollLeft = this.element.scrollLeft;
  14159. this._emit("scroll", {data: this.scrollLeft});
  14160. }
  14161. this.skipEvent = false;
  14162. };
  14163. this.getHeight = function() {
  14164. return this.isVisible ? this.height : 0;
  14165. };
  14166. this.setWidth = function(width) {
  14167. this.element.style.width = width + "px";
  14168. };
  14169. this.setInnerWidth = function(width) {
  14170. this.inner.style.width = width + "px";
  14171. };
  14172. this.setScrollWidth = function(width) {
  14173. this.inner.style.width = width + "px";
  14174. };
  14175. this.setScrollLeft = function(scrollLeft) {
  14176. if (this.scrollLeft != scrollLeft) {
  14177. this.skipEvent = true;
  14178. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  14179. }
  14180. };
  14181. }).call(HScrollBar.prototype);
  14182. exports.ScrollBar = VScrollBar; // backward compatibility
  14183. exports.ScrollBarV = VScrollBar; // backward compatibility
  14184. exports.ScrollBarH = HScrollBar; // backward compatibility
  14185. exports.VScrollBar = VScrollBar;
  14186. exports.HScrollBar = HScrollBar;
  14187. });
  14188. define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  14189. "use strict";
  14190. var event = require("./lib/event");
  14191. var RenderLoop = function(onRender, win) {
  14192. this.onRender = onRender;
  14193. this.pending = false;
  14194. this.changes = 0;
  14195. this.window = win || window;
  14196. };
  14197. (function() {
  14198. this.schedule = function(change) {
  14199. this.changes = this.changes | change;
  14200. if (!this.pending && this.changes) {
  14201. this.pending = true;
  14202. var _self = this;
  14203. event.nextFrame(function() {
  14204. _self.pending = false;
  14205. var changes;
  14206. while (changes = _self.changes) {
  14207. _self.changes = 0;
  14208. _self.onRender(changes);
  14209. }
  14210. }, this.window);
  14211. }
  14212. };
  14213. }).call(RenderLoop.prototype);
  14214. exports.RenderLoop = RenderLoop;
  14215. });
  14216. 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) {
  14217. var oop = require("../lib/oop");
  14218. var dom = require("../lib/dom");
  14219. var lang = require("../lib/lang");
  14220. var useragent = require("../lib/useragent");
  14221. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14222. var CHAR_COUNT = 0;
  14223. var FontMetrics = exports.FontMetrics = function(parentEl) {
  14224. this.el = dom.createElement("div");
  14225. this.$setMeasureNodeStyles(this.el.style, true);
  14226. this.$main = dom.createElement("div");
  14227. this.$setMeasureNodeStyles(this.$main.style);
  14228. this.$measureNode = dom.createElement("div");
  14229. this.$setMeasureNodeStyles(this.$measureNode.style);
  14230. this.el.appendChild(this.$main);
  14231. this.el.appendChild(this.$measureNode);
  14232. parentEl.appendChild(this.el);
  14233. if (!CHAR_COUNT)
  14234. this.$testFractionalRect();
  14235. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  14236. this.$characterSize = {width: 0, height: 0};
  14237. this.checkForSizeChanges();
  14238. };
  14239. (function() {
  14240. oop.implement(this, EventEmitter);
  14241. this.$characterSize = {width: 0, height: 0};
  14242. this.$testFractionalRect = function() {
  14243. var el = dom.createElement("div");
  14244. this.$setMeasureNodeStyles(el.style);
  14245. el.style.width = "0.2px";
  14246. document.documentElement.appendChild(el);
  14247. var w = el.getBoundingClientRect().width;
  14248. if (w > 0 && w < 1)
  14249. CHAR_COUNT = 50;
  14250. else
  14251. CHAR_COUNT = 100;
  14252. el.parentNode.removeChild(el);
  14253. };
  14254. this.$setMeasureNodeStyles = function(style, isRoot) {
  14255. style.width = style.height = "auto";
  14256. style.left = style.top = "0px";
  14257. style.visibility = "hidden";
  14258. style.position = "absolute";
  14259. style.whiteSpace = "pre";
  14260. if (useragent.isIE < 8) {
  14261. style["font-family"] = "inherit";
  14262. } else {
  14263. style.font = "inherit";
  14264. }
  14265. style.overflow = isRoot ? "hidden" : "visible";
  14266. };
  14267. this.checkForSizeChanges = function() {
  14268. var size = this.$measureSizes();
  14269. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  14270. this.$measureNode.style.fontWeight = "bold";
  14271. var boldSize = this.$measureSizes();
  14272. this.$measureNode.style.fontWeight = "";
  14273. this.$characterSize = size;
  14274. this.charSizes = Object.create(null);
  14275. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  14276. this._emit("changeCharacterSize", {data: size});
  14277. }
  14278. };
  14279. this.$pollSizeChanges = function() {
  14280. if (this.$pollSizeChangesTimer)
  14281. return this.$pollSizeChangesTimer;
  14282. var self = this;
  14283. return this.$pollSizeChangesTimer = setInterval(function() {
  14284. self.checkForSizeChanges();
  14285. }, 500);
  14286. };
  14287. this.setPolling = function(val) {
  14288. if (val) {
  14289. this.$pollSizeChanges();
  14290. } else if (this.$pollSizeChangesTimer) {
  14291. clearInterval(this.$pollSizeChangesTimer);
  14292. this.$pollSizeChangesTimer = 0;
  14293. }
  14294. };
  14295. this.$measureSizes = function() {
  14296. if (CHAR_COUNT === 50) {
  14297. var rect = null;
  14298. try {
  14299. rect = this.$measureNode.getBoundingClientRect();
  14300. } catch(e) {
  14301. rect = {width: 0, height:0 };
  14302. }
  14303. var size = {
  14304. height: rect.height,
  14305. width: rect.width / CHAR_COUNT
  14306. };
  14307. } else {
  14308. var size = {
  14309. height: this.$measureNode.clientHeight,
  14310. width: this.$measureNode.clientWidth / CHAR_COUNT
  14311. };
  14312. }
  14313. if (size.width === 0 || size.height === 0)
  14314. return null;
  14315. return size;
  14316. };
  14317. this.$measureCharWidth = function(ch) {
  14318. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  14319. var rect = this.$main.getBoundingClientRect();
  14320. return rect.width / CHAR_COUNT;
  14321. };
  14322. this.getCharacterWidth = function(ch) {
  14323. var w = this.charSizes[ch];
  14324. if (w === undefined) {
  14325. w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  14326. }
  14327. return w;
  14328. };
  14329. this.destroy = function() {
  14330. clearInterval(this.$pollSizeChangesTimer);
  14331. if (this.el && this.el.parentNode)
  14332. this.el.parentNode.removeChild(this.el);
  14333. };
  14334. }).call(FontMetrics.prototype);
  14335. });
  14336. 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) {
  14337. "use strict";
  14338. var oop = require("./lib/oop");
  14339. var dom = require("./lib/dom");
  14340. var config = require("./config");
  14341. var useragent = require("./lib/useragent");
  14342. var GutterLayer = require("./layer/gutter").Gutter;
  14343. var MarkerLayer = require("./layer/marker").Marker;
  14344. var TextLayer = require("./layer/text").Text;
  14345. var CursorLayer = require("./layer/cursor").Cursor;
  14346. var HScrollBar = require("./scrollbar").HScrollBar;
  14347. var VScrollBar = require("./scrollbar").VScrollBar;
  14348. var RenderLoop = require("./renderloop").RenderLoop;
  14349. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  14350. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14351. var editorCss = ".ace_editor {\
  14352. position: relative;\
  14353. overflow: hidden;\
  14354. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  14355. direction: ltr;\
  14356. text-align: left;\
  14357. -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\
  14358. }\
  14359. .ace_scroller {\
  14360. position: absolute;\
  14361. overflow: hidden;\
  14362. top: 0;\
  14363. bottom: 0;\
  14364. background-color: inherit;\
  14365. -ms-user-select: none;\
  14366. -moz-user-select: none;\
  14367. -webkit-user-select: none;\
  14368. user-select: none;\
  14369. cursor: text;\
  14370. }\
  14371. .ace_content {\
  14372. position: absolute;\
  14373. -moz-box-sizing: border-box;\
  14374. -webkit-box-sizing: border-box;\
  14375. box-sizing: border-box;\
  14376. min-width: 100%;\
  14377. }\
  14378. .ace_dragging .ace_scroller:before{\
  14379. position: absolute;\
  14380. top: 0;\
  14381. left: 0;\
  14382. right: 0;\
  14383. bottom: 0;\
  14384. content: '';\
  14385. background: rgba(250, 250, 250, 0.01);\
  14386. z-index: 1000;\
  14387. }\
  14388. .ace_dragging.ace_dark .ace_scroller:before{\
  14389. background: rgba(0, 0, 0, 0.01);\
  14390. }\
  14391. .ace_selecting, .ace_selecting * {\
  14392. cursor: text !important;\
  14393. }\
  14394. .ace_gutter {\
  14395. position: absolute;\
  14396. overflow : hidden;\
  14397. width: auto;\
  14398. top: 0;\
  14399. bottom: 0;\
  14400. left: 0;\
  14401. cursor: default;\
  14402. z-index: 4;\
  14403. -ms-user-select: none;\
  14404. -moz-user-select: none;\
  14405. -webkit-user-select: none;\
  14406. user-select: none;\
  14407. }\
  14408. .ace_gutter-active-line {\
  14409. position: absolute;\
  14410. left: 0;\
  14411. right: 0;\
  14412. }\
  14413. .ace_scroller.ace_scroll-left {\
  14414. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  14415. }\
  14416. .ace_gutter-cell {\
  14417. padding-left: 19px;\
  14418. padding-right: 6px;\
  14419. background-repeat: no-repeat;\
  14420. }\
  14421. .ace_gutter-cell.ace_error {\
  14422. 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==\");\
  14423. background-repeat: no-repeat;\
  14424. background-position: 2px center;\
  14425. }\
  14426. .ace_gutter-cell.ace_warning {\
  14427. 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==\");\
  14428. background-position: 2px center;\
  14429. }\
  14430. .ace_gutter-cell.ace_info {\
  14431. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  14432. background-position: 2px center;\
  14433. }\
  14434. .ace_dark .ace_gutter-cell.ace_info {\
  14435. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  14436. }\
  14437. .ace_scrollbar {\
  14438. position: absolute;\
  14439. right: 0;\
  14440. bottom: 0;\
  14441. z-index: 6;\
  14442. }\
  14443. .ace_scrollbar-inner {\
  14444. position: absolute;\
  14445. cursor: text;\
  14446. left: 0;\
  14447. top: 0;\
  14448. }\
  14449. .ace_scrollbar-v{\
  14450. overflow-x: hidden;\
  14451. overflow-y: scroll;\
  14452. top: 0;\
  14453. }\
  14454. .ace_scrollbar-h {\
  14455. overflow-x: scroll;\
  14456. overflow-y: hidden;\
  14457. left: 0;\
  14458. }\
  14459. .ace_print-margin {\
  14460. position: absolute;\
  14461. height: 100%;\
  14462. }\
  14463. .ace_text-input {\
  14464. position: absolute;\
  14465. z-index: 0;\
  14466. width: 0.5em;\
  14467. height: 1em;\
  14468. opacity: 0;\
  14469. background: transparent;\
  14470. -moz-appearance: none;\
  14471. appearance: none;\
  14472. border: none;\
  14473. resize: none;\
  14474. outline: none;\
  14475. overflow: hidden;\
  14476. font: inherit;\
  14477. padding: 0 1px;\
  14478. margin: 0 -1px;\
  14479. text-indent: -1em;\
  14480. -ms-user-select: text;\
  14481. -moz-user-select: text;\
  14482. -webkit-user-select: text;\
  14483. user-select: text;\
  14484. white-space: pre!important;\
  14485. }\
  14486. .ace_text-input.ace_composition {\
  14487. background: inherit;\
  14488. color: inherit;\
  14489. z-index: 1000;\
  14490. opacity: 1;\
  14491. text-indent: 0;\
  14492. }\
  14493. .ace_layer {\
  14494. z-index: 1;\
  14495. position: absolute;\
  14496. overflow: hidden;\
  14497. word-wrap: normal;\
  14498. white-space: pre;\
  14499. height: 100%;\
  14500. width: 100%;\
  14501. -moz-box-sizing: border-box;\
  14502. -webkit-box-sizing: border-box;\
  14503. box-sizing: border-box;\
  14504. pointer-events: none;\
  14505. }\
  14506. .ace_gutter-layer {\
  14507. position: relative;\
  14508. width: auto;\
  14509. text-align: right;\
  14510. pointer-events: auto;\
  14511. }\
  14512. .ace_text-layer {\
  14513. font: inherit !important;\
  14514. }\
  14515. .ace_cjk {\
  14516. display: inline-block;\
  14517. text-align: center;\
  14518. }\
  14519. .ace_cursor-layer {\
  14520. z-index: 4;\
  14521. }\
  14522. .ace_cursor {\
  14523. z-index: 4;\
  14524. position: absolute;\
  14525. -moz-box-sizing: border-box;\
  14526. -webkit-box-sizing: border-box;\
  14527. box-sizing: border-box;\
  14528. border-left: 2px solid;\
  14529. transform: translatez(0);\
  14530. }\
  14531. .ace_multiselect .ace_cursor {\
  14532. border-left-width: 1px;\
  14533. }\
  14534. .ace_slim-cursors .ace_cursor {\
  14535. border-left-width: 1px;\
  14536. }\
  14537. .ace_overwrite-cursors .ace_cursor {\
  14538. border-left-width: 0;\
  14539. border-bottom: 1px solid;\
  14540. }\
  14541. .ace_hidden-cursors .ace_cursor {\
  14542. opacity: 0.2;\
  14543. }\
  14544. .ace_smooth-blinking .ace_cursor {\
  14545. -webkit-transition: opacity 0.18s;\
  14546. transition: opacity 0.18s;\
  14547. }\
  14548. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  14549. position: absolute;\
  14550. z-index: 3;\
  14551. }\
  14552. .ace_marker-layer .ace_selection {\
  14553. position: absolute;\
  14554. z-index: 5;\
  14555. }\
  14556. .ace_marker-layer .ace_bracket {\
  14557. position: absolute;\
  14558. z-index: 6;\
  14559. }\
  14560. .ace_marker-layer .ace_active-line {\
  14561. position: absolute;\
  14562. z-index: 2;\
  14563. }\
  14564. .ace_marker-layer .ace_selected-word {\
  14565. position: absolute;\
  14566. z-index: 4;\
  14567. -moz-box-sizing: border-box;\
  14568. -webkit-box-sizing: border-box;\
  14569. box-sizing: border-box;\
  14570. }\
  14571. .ace_line .ace_fold {\
  14572. -moz-box-sizing: border-box;\
  14573. -webkit-box-sizing: border-box;\
  14574. box-sizing: border-box;\
  14575. display: inline-block;\
  14576. height: 11px;\
  14577. margin-top: -2px;\
  14578. vertical-align: middle;\
  14579. background-image:\
  14580. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  14581. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  14582. background-repeat: no-repeat, repeat-x;\
  14583. background-position: center center, top left;\
  14584. color: transparent;\
  14585. border: 1px solid black;\
  14586. border-radius: 2px;\
  14587. cursor: pointer;\
  14588. pointer-events: auto;\
  14589. }\
  14590. .ace_dark .ace_fold {\
  14591. }\
  14592. .ace_fold:hover{\
  14593. background-image:\
  14594. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  14595. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  14596. }\
  14597. .ace_tooltip {\
  14598. background-color: #FFF;\
  14599. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  14600. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  14601. border: 1px solid gray;\
  14602. border-radius: 1px;\
  14603. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  14604. color: black;\
  14605. max-width: 100%;\
  14606. padding: 3px 4px;\
  14607. position: fixed;\
  14608. z-index: 999999;\
  14609. -moz-box-sizing: border-box;\
  14610. -webkit-box-sizing: border-box;\
  14611. box-sizing: border-box;\
  14612. cursor: default;\
  14613. white-space: pre;\
  14614. word-wrap: break-word;\
  14615. line-height: normal;\
  14616. font-style: normal;\
  14617. font-weight: normal;\
  14618. letter-spacing: normal;\
  14619. pointer-events: none;\
  14620. }\
  14621. .ace_folding-enabled > .ace_gutter-cell {\
  14622. padding-right: 13px;\
  14623. }\
  14624. .ace_fold-widget {\
  14625. -moz-box-sizing: border-box;\
  14626. -webkit-box-sizing: border-box;\
  14627. box-sizing: border-box;\
  14628. margin: 0 -12px 0 1px;\
  14629. display: none;\
  14630. width: 11px;\
  14631. vertical-align: top;\
  14632. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  14633. background-repeat: no-repeat;\
  14634. background-position: center;\
  14635. border-radius: 3px;\
  14636. border: 1px solid transparent;\
  14637. cursor: pointer;\
  14638. }\
  14639. .ace_folding-enabled .ace_fold-widget {\
  14640. display: inline-block; \
  14641. }\
  14642. .ace_fold-widget.ace_end {\
  14643. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  14644. }\
  14645. .ace_fold-widget.ace_closed {\
  14646. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  14647. }\
  14648. .ace_fold-widget:hover {\
  14649. border: 1px solid rgba(0, 0, 0, 0.3);\
  14650. background-color: rgba(255, 255, 255, 0.2);\
  14651. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  14652. }\
  14653. .ace_fold-widget:active {\
  14654. border: 1px solid rgba(0, 0, 0, 0.4);\
  14655. background-color: rgba(0, 0, 0, 0.05);\
  14656. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  14657. }\
  14658. .ace_dark .ace_fold-widget {\
  14659. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  14660. }\
  14661. .ace_dark .ace_fold-widget.ace_end {\
  14662. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  14663. }\
  14664. .ace_dark .ace_fold-widget.ace_closed {\
  14665. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  14666. }\
  14667. .ace_dark .ace_fold-widget:hover {\
  14668. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  14669. background-color: rgba(255, 255, 255, 0.1);\
  14670. }\
  14671. .ace_dark .ace_fold-widget:active {\
  14672. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  14673. }\
  14674. .ace_fold-widget.ace_invalid {\
  14675. background-color: #FFB4B4;\
  14676. border-color: #DE5555;\
  14677. }\
  14678. .ace_fade-fold-widgets .ace_fold-widget {\
  14679. -webkit-transition: opacity 0.4s ease 0.05s;\
  14680. transition: opacity 0.4s ease 0.05s;\
  14681. opacity: 0;\
  14682. }\
  14683. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  14684. -webkit-transition: opacity 0.05s ease 0.05s;\
  14685. transition: opacity 0.05s ease 0.05s;\
  14686. opacity:1;\
  14687. }\
  14688. .ace_underline {\
  14689. text-decoration: underline;\
  14690. }\
  14691. .ace_bold {\
  14692. font-weight: bold;\
  14693. }\
  14694. .ace_nobold .ace_bold {\
  14695. font-weight: normal;\
  14696. }\
  14697. .ace_italic {\
  14698. font-style: italic;\
  14699. }\
  14700. .ace_error-marker {\
  14701. background-color: rgba(255, 0, 0,0.2);\
  14702. position: absolute;\
  14703. z-index: 9;\
  14704. }\
  14705. .ace_highlight-marker {\
  14706. background-color: rgba(255, 255, 0,0.2);\
  14707. position: absolute;\
  14708. z-index: 8;\
  14709. }\
  14710. .ace_br1 {border-top-left-radius : 3px;}\
  14711. .ace_br2 {border-top-right-radius : 3px;}\
  14712. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  14713. .ace_br4 {border-bottom-right-radius: 3px;}\
  14714. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  14715. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  14716. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  14717. .ace_br8 {border-bottom-left-radius : 3px;}\
  14718. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  14719. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  14720. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  14721. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  14722. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  14723. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  14724. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  14725. .ace_text-input-ios {\
  14726. position: absolute !important;\
  14727. top: -100000px !important;\
  14728. left: -100000px !important;\
  14729. }\
  14730. ";
  14731. dom.importCssString(editorCss, "ace_editor.css");
  14732. var VirtualRenderer = function(container, theme) {
  14733. var _self = this;
  14734. this.container = container || dom.createElement("div");
  14735. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  14736. dom.addCssClass(this.container, "ace_editor");
  14737. this.setTheme(theme);
  14738. this.$gutter = dom.createElement("div");
  14739. this.$gutter.className = "ace_gutter";
  14740. this.container.appendChild(this.$gutter);
  14741. this.$gutter.setAttribute("aria-hidden", true);
  14742. this.scroller = dom.createElement("div");
  14743. this.scroller.className = "ace_scroller";
  14744. this.container.appendChild(this.scroller);
  14745. this.content = dom.createElement("div");
  14746. this.content.className = "ace_content";
  14747. this.scroller.appendChild(this.content);
  14748. this.$gutterLayer = new GutterLayer(this.$gutter);
  14749. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  14750. this.$markerBack = new MarkerLayer(this.content);
  14751. var textLayer = this.$textLayer = new TextLayer(this.content);
  14752. this.canvas = textLayer.element;
  14753. this.$markerFront = new MarkerLayer(this.content);
  14754. this.$cursorLayer = new CursorLayer(this.content);
  14755. this.$horizScroll = false;
  14756. this.$vScroll = false;
  14757. this.scrollBar =
  14758. this.scrollBarV = new VScrollBar(this.container, this);
  14759. this.scrollBarH = new HScrollBar(this.container, this);
  14760. this.scrollBarV.addEventListener("scroll", function(e) {
  14761. if (!_self.$scrollAnimation)
  14762. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  14763. });
  14764. this.scrollBarH.addEventListener("scroll", function(e) {
  14765. if (!_self.$scrollAnimation)
  14766. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  14767. });
  14768. this.scrollTop = 0;
  14769. this.scrollLeft = 0;
  14770. this.cursorPos = {
  14771. row : 0,
  14772. column : 0
  14773. };
  14774. this.$fontMetrics = new FontMetrics(this.container);
  14775. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  14776. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  14777. _self.updateCharacterSize();
  14778. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  14779. _self._signal("changeCharacterSize", e);
  14780. });
  14781. this.$size = {
  14782. width: 0,
  14783. height: 0,
  14784. scrollerHeight: 0,
  14785. scrollerWidth: 0,
  14786. $dirty: true
  14787. };
  14788. this.layerConfig = {
  14789. width : 1,
  14790. padding : 0,
  14791. firstRow : 0,
  14792. firstRowScreen: 0,
  14793. lastRow : 0,
  14794. lineHeight : 0,
  14795. characterWidth : 0,
  14796. minHeight : 1,
  14797. maxHeight : 1,
  14798. offset : 0,
  14799. height : 1,
  14800. gutterOffset: 1
  14801. };
  14802. this.scrollMargin = {
  14803. left: 0,
  14804. right: 0,
  14805. top: 0,
  14806. bottom: 0,
  14807. v: 0,
  14808. h: 0
  14809. };
  14810. this.$loop = new RenderLoop(
  14811. this.$renderChanges.bind(this),
  14812. this.container.ownerDocument.defaultView
  14813. );
  14814. this.$loop.schedule(this.CHANGE_FULL);
  14815. this.updateCharacterSize();
  14816. this.setPadding(4);
  14817. config.resetOptions(this);
  14818. config._emit("renderer", this);
  14819. };
  14820. (function() {
  14821. this.CHANGE_CURSOR = 1;
  14822. this.CHANGE_MARKER = 2;
  14823. this.CHANGE_GUTTER = 4;
  14824. this.CHANGE_SCROLL = 8;
  14825. this.CHANGE_LINES = 16;
  14826. this.CHANGE_TEXT = 32;
  14827. this.CHANGE_SIZE = 64;
  14828. this.CHANGE_MARKER_BACK = 128;
  14829. this.CHANGE_MARKER_FRONT = 256;
  14830. this.CHANGE_FULL = 512;
  14831. this.CHANGE_H_SCROLL = 1024;
  14832. oop.implement(this, EventEmitter);
  14833. this.updateCharacterSize = function() {
  14834. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  14835. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  14836. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  14837. }
  14838. this.layerConfig.characterWidth =
  14839. this.characterWidth = this.$textLayer.getCharacterWidth();
  14840. this.layerConfig.lineHeight =
  14841. this.lineHeight = this.$textLayer.getLineHeight();
  14842. this.$updatePrintMargin();
  14843. };
  14844. this.setSession = function(session) {
  14845. if (this.session)
  14846. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  14847. this.session = session;
  14848. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  14849. session.setScrollTop(-this.scrollMargin.top);
  14850. this.$cursorLayer.setSession(session);
  14851. this.$markerBack.setSession(session);
  14852. this.$markerFront.setSession(session);
  14853. this.$gutterLayer.setSession(session);
  14854. this.$textLayer.setSession(session);
  14855. if (!session)
  14856. return;
  14857. this.$loop.schedule(this.CHANGE_FULL);
  14858. this.session.$setFontMetrics(this.$fontMetrics);
  14859. this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null;
  14860. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  14861. this.onChangeNewLineMode();
  14862. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  14863. };
  14864. this.updateLines = function(firstRow, lastRow, force) {
  14865. if (lastRow === undefined)
  14866. lastRow = Infinity;
  14867. if (!this.$changedLines) {
  14868. this.$changedLines = {
  14869. firstRow: firstRow,
  14870. lastRow: lastRow
  14871. };
  14872. }
  14873. else {
  14874. if (this.$changedLines.firstRow > firstRow)
  14875. this.$changedLines.firstRow = firstRow;
  14876. if (this.$changedLines.lastRow < lastRow)
  14877. this.$changedLines.lastRow = lastRow;
  14878. }
  14879. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  14880. if (force)
  14881. this.$changedLines.lastRow = this.layerConfig.lastRow;
  14882. else
  14883. return;
  14884. }
  14885. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  14886. return;
  14887. this.$loop.schedule(this.CHANGE_LINES);
  14888. };
  14889. this.onChangeNewLineMode = function() {
  14890. this.$loop.schedule(this.CHANGE_TEXT);
  14891. this.$textLayer.$updateEolChar();
  14892. this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR);
  14893. };
  14894. this.onChangeTabSize = function() {
  14895. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  14896. this.$textLayer.onChangeTabSize();
  14897. };
  14898. this.updateText = function() {
  14899. this.$loop.schedule(this.CHANGE_TEXT);
  14900. };
  14901. this.updateFull = function(force) {
  14902. if (force)
  14903. this.$renderChanges(this.CHANGE_FULL, true);
  14904. else
  14905. this.$loop.schedule(this.CHANGE_FULL);
  14906. };
  14907. this.updateFontSize = function() {
  14908. this.$textLayer.checkForSizeChanges();
  14909. };
  14910. this.$changes = 0;
  14911. this.$updateSizeAsync = function() {
  14912. if (this.$loop.pending)
  14913. this.$size.$dirty = true;
  14914. else
  14915. this.onResize();
  14916. };
  14917. this.onResize = function(force, gutterWidth, width, height) {
  14918. if (this.resizing > 2)
  14919. return;
  14920. else if (this.resizing > 0)
  14921. this.resizing++;
  14922. else
  14923. this.resizing = force ? 1 : 0;
  14924. var el = this.container;
  14925. if (!height)
  14926. height = el.clientHeight || el.scrollHeight;
  14927. if (!width)
  14928. width = el.clientWidth || el.scrollWidth;
  14929. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  14930. if (!this.$size.scrollerHeight || (!width && !height))
  14931. return this.resizing = 0;
  14932. if (force)
  14933. this.$gutterLayer.$padding = null;
  14934. if (force)
  14935. this.$renderChanges(changes | this.$changes, true);
  14936. else
  14937. this.$loop.schedule(changes | this.$changes);
  14938. if (this.resizing)
  14939. this.resizing = 0;
  14940. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  14941. };
  14942. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  14943. height -= (this.$extraHeight || 0);
  14944. var changes = 0;
  14945. var size = this.$size;
  14946. var oldSize = {
  14947. width: size.width,
  14948. height: size.height,
  14949. scrollerHeight: size.scrollerHeight,
  14950. scrollerWidth: size.scrollerWidth
  14951. };
  14952. if (height && (force || size.height != height)) {
  14953. size.height = height;
  14954. changes |= this.CHANGE_SIZE;
  14955. size.scrollerHeight = size.height;
  14956. if (this.$horizScroll)
  14957. size.scrollerHeight -= this.scrollBarH.getHeight();
  14958. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  14959. changes = changes | this.CHANGE_SCROLL;
  14960. }
  14961. if (width && (force || size.width != width)) {
  14962. changes |= this.CHANGE_SIZE;
  14963. size.width = width;
  14964. if (gutterWidth == null)
  14965. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  14966. this.gutterWidth = gutterWidth;
  14967. this.scrollBarH.element.style.left =
  14968. this.scroller.style.left = gutterWidth + "px";
  14969. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  14970. this.scrollBarH.element.style.right =
  14971. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  14972. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  14973. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  14974. changes |= this.CHANGE_FULL;
  14975. }
  14976. size.$dirty = !width || !height;
  14977. if (changes)
  14978. this._signal("resize", oldSize);
  14979. return changes;
  14980. };
  14981. this.onGutterResize = function() {
  14982. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  14983. if (gutterWidth != this.gutterWidth)
  14984. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  14985. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  14986. this.$loop.schedule(this.CHANGE_FULL);
  14987. } else if (this.$size.$dirty) {
  14988. this.$loop.schedule(this.CHANGE_FULL);
  14989. } else {
  14990. this.$computeLayerConfig();
  14991. this.$loop.schedule(this.CHANGE_MARKER);
  14992. }
  14993. };
  14994. this.adjustWrapLimit = function() {
  14995. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  14996. var limit = Math.floor(availableWidth / this.characterWidth);
  14997. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  14998. };
  14999. this.setAnimatedScroll = function(shouldAnimate){
  15000. this.setOption("animatedScroll", shouldAnimate);
  15001. };
  15002. this.getAnimatedScroll = function() {
  15003. return this.$animatedScroll;
  15004. };
  15005. this.setShowInvisibles = function(showInvisibles) {
  15006. this.setOption("showInvisibles", showInvisibles);
  15007. this.session.$bidiHandler.setShowInvisibles(showInvisibles);
  15008. };
  15009. this.getShowInvisibles = function() {
  15010. return this.getOption("showInvisibles");
  15011. };
  15012. this.getDisplayIndentGuides = function() {
  15013. return this.getOption("displayIndentGuides");
  15014. };
  15015. this.setDisplayIndentGuides = function(display) {
  15016. this.setOption("displayIndentGuides", display);
  15017. };
  15018. this.setShowPrintMargin = function(showPrintMargin) {
  15019. this.setOption("showPrintMargin", showPrintMargin);
  15020. };
  15021. this.getShowPrintMargin = function() {
  15022. return this.getOption("showPrintMargin");
  15023. };
  15024. this.setPrintMarginColumn = function(showPrintMargin) {
  15025. this.setOption("printMarginColumn", showPrintMargin);
  15026. };
  15027. this.getPrintMarginColumn = function() {
  15028. return this.getOption("printMarginColumn");
  15029. };
  15030. this.getShowGutter = function(){
  15031. return this.getOption("showGutter");
  15032. };
  15033. this.setShowGutter = function(show){
  15034. return this.setOption("showGutter", show);
  15035. };
  15036. this.getFadeFoldWidgets = function(){
  15037. return this.getOption("fadeFoldWidgets");
  15038. };
  15039. this.setFadeFoldWidgets = function(show) {
  15040. this.setOption("fadeFoldWidgets", show);
  15041. };
  15042. this.setHighlightGutterLine = function(shouldHighlight) {
  15043. this.setOption("highlightGutterLine", shouldHighlight);
  15044. };
  15045. this.getHighlightGutterLine = function() {
  15046. return this.getOption("highlightGutterLine");
  15047. };
  15048. this.$updateGutterLineHighlight = function() {
  15049. var pos = this.$cursorLayer.$pixelPos;
  15050. var height = this.layerConfig.lineHeight;
  15051. if (this.session.getUseWrapMode()) {
  15052. var cursor = this.session.selection.getCursor();
  15053. cursor.column = 0;
  15054. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  15055. height *= this.session.getRowLength(cursor.row);
  15056. }
  15057. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  15058. this.$gutterLineHighlight.style.height = height + "px";
  15059. };
  15060. this.$updatePrintMargin = function() {
  15061. if (!this.$showPrintMargin && !this.$printMarginEl)
  15062. return;
  15063. if (!this.$printMarginEl) {
  15064. var containerEl = dom.createElement("div");
  15065. containerEl.className = "ace_layer ace_print-margin-layer";
  15066. this.$printMarginEl = dom.createElement("div");
  15067. this.$printMarginEl.className = "ace_print-margin";
  15068. containerEl.appendChild(this.$printMarginEl);
  15069. this.content.insertBefore(containerEl, this.content.firstChild);
  15070. }
  15071. var style = this.$printMarginEl.style;
  15072. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  15073. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  15074. if (this.session && this.session.$wrap == -1)
  15075. this.adjustWrapLimit();
  15076. };
  15077. this.getContainerElement = function() {
  15078. return this.container;
  15079. };
  15080. this.getMouseEventTarget = function() {
  15081. return this.scroller;
  15082. };
  15083. this.getTextAreaContainer = function() {
  15084. return this.container;
  15085. };
  15086. this.$moveTextAreaToCursor = function() {
  15087. if (!this.$keepTextAreaAtCursor)
  15088. return;
  15089. var config = this.layerConfig;
  15090. var posTop = this.$cursorLayer.$pixelPos.top;
  15091. var posLeft = this.$cursorLayer.$pixelPos.left;
  15092. posTop -= config.offset;
  15093. var style = this.textarea.style;
  15094. var h = this.lineHeight;
  15095. if (posTop < 0 || posTop > config.height - h) {
  15096. style.top = style.left = "0";
  15097. return;
  15098. }
  15099. var w = this.characterWidth;
  15100. if (this.$composition) {
  15101. var val = this.textarea.value.replace(/^\x01+/, "");
  15102. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  15103. h += 2;
  15104. }
  15105. posLeft -= this.scrollLeft;
  15106. if (posLeft > this.$size.scrollerWidth - w)
  15107. posLeft = this.$size.scrollerWidth - w;
  15108. posLeft += this.gutterWidth;
  15109. style.height = h + "px";
  15110. style.width = w + "px";
  15111. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  15112. style.top = Math.min(posTop, this.$size.height - h) + "px";
  15113. };
  15114. this.getFirstVisibleRow = function() {
  15115. return this.layerConfig.firstRow;
  15116. };
  15117. this.getFirstFullyVisibleRow = function() {
  15118. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  15119. };
  15120. this.getLastFullyVisibleRow = function() {
  15121. var config = this.layerConfig;
  15122. var lastRow = config.lastRow;
  15123. var top = this.session.documentToScreenRow(lastRow, 0) * config.lineHeight;
  15124. if (top - this.session.getScrollTop() > config.height - config.lineHeight)
  15125. return lastRow - 1;
  15126. return lastRow;
  15127. };
  15128. this.getLastVisibleRow = function() {
  15129. return this.layerConfig.lastRow;
  15130. };
  15131. this.$padding = null;
  15132. this.setPadding = function(padding) {
  15133. this.$padding = padding;
  15134. this.$textLayer.setPadding(padding);
  15135. this.$cursorLayer.setPadding(padding);
  15136. this.$markerFront.setPadding(padding);
  15137. this.$markerBack.setPadding(padding);
  15138. this.$loop.schedule(this.CHANGE_FULL);
  15139. this.$updatePrintMargin();
  15140. };
  15141. this.setScrollMargin = function(top, bottom, left, right) {
  15142. var sm = this.scrollMargin;
  15143. sm.top = top|0;
  15144. sm.bottom = bottom|0;
  15145. sm.right = right|0;
  15146. sm.left = left|0;
  15147. sm.v = sm.top + sm.bottom;
  15148. sm.h = sm.left + sm.right;
  15149. if (sm.top && this.scrollTop <= 0 && this.session)
  15150. this.session.setScrollTop(-sm.top);
  15151. this.updateFull();
  15152. };
  15153. this.getHScrollBarAlwaysVisible = function() {
  15154. return this.$hScrollBarAlwaysVisible;
  15155. };
  15156. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  15157. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  15158. };
  15159. this.getVScrollBarAlwaysVisible = function() {
  15160. return this.$vScrollBarAlwaysVisible;
  15161. };
  15162. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  15163. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  15164. };
  15165. this.$updateScrollBarV = function() {
  15166. var scrollHeight = this.layerConfig.maxHeight;
  15167. var scrollerHeight = this.$size.scrollerHeight;
  15168. if (!this.$maxLines && this.$scrollPastEnd) {
  15169. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  15170. if (this.scrollTop > scrollHeight - scrollerHeight) {
  15171. scrollHeight = this.scrollTop + scrollerHeight;
  15172. this.scrollBarV.scrollTop = null;
  15173. }
  15174. }
  15175. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  15176. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  15177. };
  15178. this.$updateScrollBarH = function() {
  15179. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  15180. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  15181. };
  15182. this.$frozen = false;
  15183. this.freeze = function() {
  15184. this.$frozen = true;
  15185. };
  15186. this.unfreeze = function() {
  15187. this.$frozen = false;
  15188. };
  15189. this.$renderChanges = function(changes, force) {
  15190. if (this.$changes) {
  15191. changes |= this.$changes;
  15192. this.$changes = 0;
  15193. }
  15194. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  15195. this.$changes |= changes;
  15196. return;
  15197. }
  15198. if (this.$size.$dirty) {
  15199. this.$changes |= changes;
  15200. return this.onResize(true);
  15201. }
  15202. if (!this.lineHeight) {
  15203. this.$textLayer.checkForSizeChanges();
  15204. }
  15205. this._signal("beforeRender");
  15206. if (this.session && this.session.$bidiHandler)
  15207. this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);
  15208. var config = this.layerConfig;
  15209. if (changes & this.CHANGE_FULL ||
  15210. changes & this.CHANGE_SIZE ||
  15211. changes & this.CHANGE_TEXT ||
  15212. changes & this.CHANGE_LINES ||
  15213. changes & this.CHANGE_SCROLL ||
  15214. changes & this.CHANGE_H_SCROLL
  15215. ) {
  15216. changes |= this.$computeLayerConfig();
  15217. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  15218. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  15219. if (st > 0) {
  15220. this.scrollTop = st;
  15221. changes = changes | this.CHANGE_SCROLL;
  15222. changes |= this.$computeLayerConfig();
  15223. }
  15224. }
  15225. config = this.layerConfig;
  15226. this.$updateScrollBarV();
  15227. if (changes & this.CHANGE_H_SCROLL)
  15228. this.$updateScrollBarH();
  15229. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  15230. this.content.style.marginTop = (-config.offset) + "px";
  15231. this.content.style.width = config.width + 2 * this.$padding + "px";
  15232. this.content.style.height = config.minHeight + "px";
  15233. }
  15234. if (changes & this.CHANGE_H_SCROLL) {
  15235. this.content.style.marginLeft = -this.scrollLeft + "px";
  15236. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  15237. }
  15238. if (changes & this.CHANGE_FULL) {
  15239. this.$textLayer.update(config);
  15240. if (this.$showGutter)
  15241. this.$gutterLayer.update(config);
  15242. this.$markerBack.update(config);
  15243. this.$markerFront.update(config);
  15244. this.$cursorLayer.update(config);
  15245. this.$moveTextAreaToCursor();
  15246. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  15247. this._signal("afterRender");
  15248. return;
  15249. }
  15250. if (changes & this.CHANGE_SCROLL) {
  15251. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  15252. this.$textLayer.update(config);
  15253. else
  15254. this.$textLayer.scrollLines(config);
  15255. if (this.$showGutter)
  15256. this.$gutterLayer.update(config);
  15257. this.$markerBack.update(config);
  15258. this.$markerFront.update(config);
  15259. this.$cursorLayer.update(config);
  15260. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  15261. this.$moveTextAreaToCursor();
  15262. this._signal("afterRender");
  15263. return;
  15264. }
  15265. if (changes & this.CHANGE_TEXT) {
  15266. this.$textLayer.update(config);
  15267. if (this.$showGutter)
  15268. this.$gutterLayer.update(config);
  15269. }
  15270. else if (changes & this.CHANGE_LINES) {
  15271. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  15272. this.$gutterLayer.update(config);
  15273. }
  15274. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  15275. if (this.$showGutter)
  15276. this.$gutterLayer.update(config);
  15277. }
  15278. if (changes & this.CHANGE_CURSOR) {
  15279. this.$cursorLayer.update(config);
  15280. this.$moveTextAreaToCursor();
  15281. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  15282. }
  15283. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  15284. this.$markerFront.update(config);
  15285. }
  15286. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  15287. this.$markerBack.update(config);
  15288. }
  15289. this._signal("afterRender");
  15290. };
  15291. this.$autosize = function() {
  15292. var height = this.session.getScreenLength() * this.lineHeight;
  15293. var maxHeight = this.$maxLines * this.lineHeight;
  15294. var desiredHeight = Math.min(maxHeight,
  15295. Math.max((this.$minLines || 1) * this.lineHeight, height)
  15296. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  15297. if (this.$horizScroll)
  15298. desiredHeight += this.scrollBarH.getHeight();
  15299. if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight)
  15300. desiredHeight = this.$maxPixelHeight;
  15301. var vScroll = height > maxHeight;
  15302. if (desiredHeight != this.desiredHeight ||
  15303. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  15304. if (vScroll != this.$vScroll) {
  15305. this.$vScroll = vScroll;
  15306. this.scrollBarV.setVisible(vScroll);
  15307. }
  15308. var w = this.container.clientWidth;
  15309. this.container.style.height = desiredHeight + "px";
  15310. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  15311. this.desiredHeight = desiredHeight;
  15312. this._signal("autosize");
  15313. }
  15314. };
  15315. this.$computeLayerConfig = function() {
  15316. var session = this.session;
  15317. var size = this.$size;
  15318. var hideScrollbars = size.height <= 2 * this.lineHeight;
  15319. var screenLines = this.session.getScreenLength();
  15320. var maxHeight = screenLines * this.lineHeight;
  15321. var longestLine = this.$getLongestLine();
  15322. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  15323. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  15324. var hScrollChanged = this.$horizScroll !== horizScroll;
  15325. if (hScrollChanged) {
  15326. this.$horizScroll = horizScroll;
  15327. this.scrollBarH.setVisible(horizScroll);
  15328. }
  15329. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  15330. if (this.$maxLines && this.lineHeight > 1)
  15331. this.$autosize();
  15332. var offset = this.scrollTop % this.lineHeight;
  15333. var minHeight = size.scrollerHeight + this.lineHeight;
  15334. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  15335. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  15336. : 0;
  15337. maxHeight += scrollPastEnd;
  15338. var sm = this.scrollMargin;
  15339. this.session.setScrollTop(Math.max(-sm.top,
  15340. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  15341. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  15342. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  15343. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  15344. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  15345. var vScrollChanged = vScrollBefore !== vScroll;
  15346. if (vScrollChanged) {
  15347. this.$vScroll = vScroll;
  15348. this.scrollBarV.setVisible(vScroll);
  15349. }
  15350. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  15351. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  15352. var lastRow = firstRow + lineCount;
  15353. var firstRowScreen, firstRowHeight;
  15354. var lineHeight = this.lineHeight;
  15355. firstRow = session.screenToDocumentRow(firstRow, 0);
  15356. var foldLine = session.getFoldLine(firstRow);
  15357. if (foldLine) {
  15358. firstRow = foldLine.start.row;
  15359. }
  15360. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  15361. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  15362. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  15363. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  15364. firstRowHeight;
  15365. offset = this.scrollTop - firstRowScreen * lineHeight;
  15366. var changes = 0;
  15367. if (this.layerConfig.width != longestLine)
  15368. changes = this.CHANGE_H_SCROLL;
  15369. if (hScrollChanged || vScrollChanged) {
  15370. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  15371. this._signal("scrollbarVisibilityChanged");
  15372. if (vScrollChanged)
  15373. longestLine = this.$getLongestLine();
  15374. }
  15375. this.layerConfig = {
  15376. width : longestLine,
  15377. padding : this.$padding,
  15378. firstRow : firstRow,
  15379. firstRowScreen: firstRowScreen,
  15380. lastRow : lastRow,
  15381. lineHeight : lineHeight,
  15382. characterWidth : this.characterWidth,
  15383. minHeight : minHeight,
  15384. maxHeight : maxHeight,
  15385. offset : offset,
  15386. gutterOffset : lineHeight ? Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)) : 0,
  15387. height : this.$size.scrollerHeight
  15388. };
  15389. return changes;
  15390. };
  15391. this.$updateLines = function() {
  15392. if (!this.$changedLines) return;
  15393. var firstRow = this.$changedLines.firstRow;
  15394. var lastRow = this.$changedLines.lastRow;
  15395. this.$changedLines = null;
  15396. var layerConfig = this.layerConfig;
  15397. if (firstRow > layerConfig.lastRow + 1) { return; }
  15398. if (lastRow < layerConfig.firstRow) { return; }
  15399. if (lastRow === Infinity) {
  15400. if (this.$showGutter)
  15401. this.$gutterLayer.update(layerConfig);
  15402. this.$textLayer.update(layerConfig);
  15403. return;
  15404. }
  15405. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  15406. return true;
  15407. };
  15408. this.$getLongestLine = function() {
  15409. var charCount = this.session.getScreenWidth();
  15410. if (this.showInvisibles && !this.session.$useWrapMode)
  15411. charCount += 1;
  15412. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  15413. };
  15414. this.updateFrontMarkers = function() {
  15415. this.$markerFront.setMarkers(this.session.getMarkers(true));
  15416. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  15417. };
  15418. this.updateBackMarkers = function() {
  15419. this.$markerBack.setMarkers(this.session.getMarkers());
  15420. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  15421. };
  15422. this.addGutterDecoration = function(row, className){
  15423. this.$gutterLayer.addGutterDecoration(row, className);
  15424. };
  15425. this.removeGutterDecoration = function(row, className){
  15426. this.$gutterLayer.removeGutterDecoration(row, className);
  15427. };
  15428. this.updateBreakpoints = function(rows) {
  15429. this.$loop.schedule(this.CHANGE_GUTTER);
  15430. };
  15431. this.setAnnotations = function(annotations) {
  15432. this.$gutterLayer.setAnnotations(annotations);
  15433. this.$loop.schedule(this.CHANGE_GUTTER);
  15434. };
  15435. this.updateCursor = function() {
  15436. this.$loop.schedule(this.CHANGE_CURSOR);
  15437. };
  15438. this.hideCursor = function() {
  15439. this.$cursorLayer.hideCursor();
  15440. };
  15441. this.showCursor = function() {
  15442. this.$cursorLayer.showCursor();
  15443. };
  15444. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  15445. this.scrollCursorIntoView(anchor, offset);
  15446. this.scrollCursorIntoView(lead, offset);
  15447. };
  15448. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  15449. if (this.$size.scrollerHeight === 0)
  15450. return;
  15451. var pos = this.$cursorLayer.getPixelPosition(cursor);
  15452. var left = pos.left;
  15453. var top = pos.top;
  15454. var topMargin = $viewMargin && $viewMargin.top || 0;
  15455. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  15456. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  15457. if (scrollTop + topMargin > top) {
  15458. if (offset && scrollTop + topMargin > top + this.lineHeight)
  15459. top -= offset * this.$size.scrollerHeight;
  15460. if (top === 0)
  15461. top = -this.scrollMargin.top;
  15462. this.session.setScrollTop(top);
  15463. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  15464. if (offset && scrollTop + this.$size.scrollerHeight - bottomMargin < top - this.lineHeight)
  15465. top += offset * this.$size.scrollerHeight;
  15466. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  15467. }
  15468. var scrollLeft = this.scrollLeft;
  15469. if (scrollLeft > left) {
  15470. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  15471. left = -this.scrollMargin.left;
  15472. this.session.setScrollLeft(left);
  15473. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  15474. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  15475. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  15476. this.session.setScrollLeft(0);
  15477. }
  15478. };
  15479. this.getScrollTop = function() {
  15480. return this.session.getScrollTop();
  15481. };
  15482. this.getScrollLeft = function() {
  15483. return this.session.getScrollLeft();
  15484. };
  15485. this.getScrollTopRow = function() {
  15486. return this.scrollTop / this.lineHeight;
  15487. };
  15488. this.getScrollBottomRow = function() {
  15489. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  15490. };
  15491. this.scrollToRow = function(row) {
  15492. this.session.setScrollTop(row * this.lineHeight);
  15493. };
  15494. this.alignCursor = function(cursor, alignment) {
  15495. if (typeof cursor == "number")
  15496. cursor = {row: cursor, column: 0};
  15497. var pos = this.$cursorLayer.getPixelPosition(cursor);
  15498. var h = this.$size.scrollerHeight - this.lineHeight;
  15499. var offset = pos.top - h * (alignment || 0);
  15500. this.session.setScrollTop(offset);
  15501. return offset;
  15502. };
  15503. this.STEPS = 8;
  15504. this.$calcSteps = function(fromValue, toValue){
  15505. var i = 0;
  15506. var l = this.STEPS;
  15507. var steps = [];
  15508. var func = function(t, x_min, dx) {
  15509. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  15510. };
  15511. for (i = 0; i < l; ++i)
  15512. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  15513. return steps;
  15514. };
  15515. this.scrollToLine = function(line, center, animate, callback) {
  15516. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  15517. var offset = pos.top;
  15518. if (center)
  15519. offset -= this.$size.scrollerHeight / 2;
  15520. var initialScroll = this.scrollTop;
  15521. this.session.setScrollTop(offset);
  15522. if (animate !== false)
  15523. this.animateScrolling(initialScroll, callback);
  15524. };
  15525. this.animateScrolling = function(fromValue, callback) {
  15526. var toValue = this.scrollTop;
  15527. if (!this.$animatedScroll)
  15528. return;
  15529. var _self = this;
  15530. if (fromValue == toValue)
  15531. return;
  15532. if (this.$scrollAnimation) {
  15533. var oldSteps = this.$scrollAnimation.steps;
  15534. if (oldSteps.length) {
  15535. fromValue = oldSteps[0];
  15536. if (fromValue == toValue)
  15537. return;
  15538. }
  15539. }
  15540. var steps = _self.$calcSteps(fromValue, toValue);
  15541. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  15542. clearInterval(this.$timer);
  15543. _self.session.setScrollTop(steps.shift());
  15544. _self.session.$scrollTop = toValue;
  15545. this.$timer = setInterval(function() {
  15546. if (steps.length) {
  15547. _self.session.setScrollTop(steps.shift());
  15548. _self.session.$scrollTop = toValue;
  15549. } else if (toValue != null) {
  15550. _self.session.$scrollTop = -1;
  15551. _self.session.setScrollTop(toValue);
  15552. toValue = null;
  15553. } else {
  15554. _self.$timer = clearInterval(_self.$timer);
  15555. _self.$scrollAnimation = null;
  15556. callback && callback();
  15557. }
  15558. }, 10);
  15559. };
  15560. this.scrollToY = function(scrollTop) {
  15561. if (this.scrollTop !== scrollTop) {
  15562. this.$loop.schedule(this.CHANGE_SCROLL);
  15563. this.scrollTop = scrollTop;
  15564. }
  15565. };
  15566. this.scrollToX = function(scrollLeft) {
  15567. if (this.scrollLeft !== scrollLeft)
  15568. this.scrollLeft = scrollLeft;
  15569. this.$loop.schedule(this.CHANGE_H_SCROLL);
  15570. };
  15571. this.scrollTo = function(x, y) {
  15572. this.session.setScrollTop(y);
  15573. this.session.setScrollLeft(y);
  15574. };
  15575. this.scrollBy = function(deltaX, deltaY) {
  15576. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  15577. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  15578. };
  15579. this.isScrollableBy = function(deltaX, deltaY) {
  15580. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  15581. return true;
  15582. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  15583. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  15584. return true;
  15585. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  15586. return true;
  15587. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  15588. - this.layerConfig.width < -1 + this.scrollMargin.right)
  15589. return true;
  15590. };
  15591. this.pixelToScreenCoordinates = function(x, y) {
  15592. var canvasPos = this.scroller.getBoundingClientRect();
  15593. var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
  15594. var offset = offsetX / this.characterWidth;
  15595. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  15596. var col = Math.round(offset);
  15597. return {row: row, column: col, side: offset - col > 0 ? 1 : -1, offsetX: offsetX};
  15598. };
  15599. this.screenToTextCoordinates = function(x, y) {
  15600. var canvasPos = this.scroller.getBoundingClientRect();
  15601. var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
  15602. var col = Math.round(offsetX / this.characterWidth);
  15603. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  15604. return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX);
  15605. };
  15606. this.textToScreenCoordinates = function(row, column) {
  15607. var canvasPos = this.scroller.getBoundingClientRect();
  15608. var pos = this.session.documentToScreenPosition(row, column);
  15609. var x = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, row)
  15610. ? this.session.$bidiHandler.getPosLeft(pos.column)
  15611. : Math.round(pos.column * this.characterWidth));
  15612. var y = pos.row * this.lineHeight;
  15613. return {
  15614. pageX: canvasPos.left + x - this.scrollLeft,
  15615. pageY: canvasPos.top + y - this.scrollTop
  15616. };
  15617. };
  15618. this.visualizeFocus = function() {
  15619. dom.addCssClass(this.container, "ace_focus");
  15620. };
  15621. this.visualizeBlur = function() {
  15622. dom.removeCssClass(this.container, "ace_focus");
  15623. };
  15624. this.showComposition = function(position) {
  15625. if (!this.$composition)
  15626. this.$composition = {
  15627. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  15628. cssText: this.textarea.style.cssText
  15629. };
  15630. this.$keepTextAreaAtCursor = true;
  15631. dom.addCssClass(this.textarea, "ace_composition");
  15632. this.textarea.style.cssText = "";
  15633. this.$moveTextAreaToCursor();
  15634. };
  15635. this.setCompositionText = function(text) {
  15636. this.$moveTextAreaToCursor();
  15637. };
  15638. this.hideComposition = function() {
  15639. if (!this.$composition)
  15640. return;
  15641. dom.removeCssClass(this.textarea, "ace_composition");
  15642. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  15643. this.textarea.style.cssText = this.$composition.cssText;
  15644. this.$composition = null;
  15645. };
  15646. this.setTheme = function(theme, cb) {
  15647. var _self = this;
  15648. this.$themeId = theme;
  15649. _self._dispatchEvent('themeChange',{theme:theme});
  15650. if (!theme || typeof theme == "string") {
  15651. var moduleName = theme || this.$options.theme.initialValue;
  15652. config.loadModule(["theme", moduleName], afterLoad);
  15653. } else {
  15654. afterLoad(theme);
  15655. }
  15656. function afterLoad(module) {
  15657. if (_self.$themeId != theme)
  15658. return cb && cb();
  15659. if (!module || !module.cssClass)
  15660. throw new Error("couldn't load module " + theme + " or it didn't call define");
  15661. dom.importCssString(
  15662. module.cssText,
  15663. module.cssClass,
  15664. _self.container.ownerDocument
  15665. );
  15666. if (_self.theme)
  15667. dom.removeCssClass(_self.container, _self.theme.cssClass);
  15668. var padding = "padding" in module ? module.padding
  15669. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  15670. if (_self.$padding && padding != _self.$padding)
  15671. _self.setPadding(padding);
  15672. _self.$theme = module.cssClass;
  15673. _self.theme = module;
  15674. dom.addCssClass(_self.container, module.cssClass);
  15675. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  15676. if (_self.$size) {
  15677. _self.$size.width = 0;
  15678. _self.$updateSizeAsync();
  15679. }
  15680. _self._dispatchEvent('themeLoaded', {theme:module});
  15681. cb && cb();
  15682. }
  15683. };
  15684. this.getTheme = function() {
  15685. return this.$themeId;
  15686. };
  15687. this.setStyle = function(style, include) {
  15688. dom.setCssClass(this.container, style, include !== false);
  15689. };
  15690. this.unsetStyle = function(style) {
  15691. dom.removeCssClass(this.container, style);
  15692. };
  15693. this.setCursorStyle = function(style) {
  15694. if (this.scroller.style.cursor != style)
  15695. this.scroller.style.cursor = style;
  15696. };
  15697. this.setMouseCursor = function(cursorStyle) {
  15698. this.scroller.style.cursor = cursorStyle;
  15699. };
  15700. this.destroy = function() {
  15701. this.$textLayer.destroy();
  15702. this.$cursorLayer.destroy();
  15703. };
  15704. }).call(VirtualRenderer.prototype);
  15705. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  15706. animatedScroll: {initialValue: false},
  15707. showInvisibles: {
  15708. set: function(value) {
  15709. if (this.$textLayer.setShowInvisibles(value))
  15710. this.$loop.schedule(this.CHANGE_TEXT);
  15711. },
  15712. initialValue: false
  15713. },
  15714. showPrintMargin: {
  15715. set: function() { this.$updatePrintMargin(); },
  15716. initialValue: true
  15717. },
  15718. printMarginColumn: {
  15719. set: function() { this.$updatePrintMargin(); },
  15720. initialValue: 80
  15721. },
  15722. printMargin: {
  15723. set: function(val) {
  15724. if (typeof val == "number")
  15725. this.$printMarginColumn = val;
  15726. this.$showPrintMargin = !!val;
  15727. this.$updatePrintMargin();
  15728. },
  15729. get: function() {
  15730. return this.$showPrintMargin && this.$printMarginColumn;
  15731. }
  15732. },
  15733. showGutter: {
  15734. set: function(show){
  15735. this.$gutter.style.display = show ? "block" : "none";
  15736. this.$loop.schedule(this.CHANGE_FULL);
  15737. this.onGutterResize();
  15738. },
  15739. initialValue: true
  15740. },
  15741. fadeFoldWidgets: {
  15742. set: function(show) {
  15743. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  15744. },
  15745. initialValue: false
  15746. },
  15747. showFoldWidgets: {
  15748. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);},
  15749. initialValue: true
  15750. },
  15751. showLineNumbers: {
  15752. set: function(show) {
  15753. this.$gutterLayer.setShowLineNumbers(show);
  15754. this.$loop.schedule(this.CHANGE_GUTTER);
  15755. },
  15756. initialValue: true
  15757. },
  15758. displayIndentGuides: {
  15759. set: function(show) {
  15760. if (this.$textLayer.setDisplayIndentGuides(show))
  15761. this.$loop.schedule(this.CHANGE_TEXT);
  15762. },
  15763. initialValue: true
  15764. },
  15765. highlightGutterLine: {
  15766. set: function(shouldHighlight) {
  15767. if (!this.$gutterLineHighlight) {
  15768. this.$gutterLineHighlight = dom.createElement("div");
  15769. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  15770. this.$gutter.appendChild(this.$gutterLineHighlight);
  15771. return;
  15772. }
  15773. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  15774. if (this.$cursorLayer.$pixelPos)
  15775. this.$updateGutterLineHighlight();
  15776. },
  15777. initialValue: false,
  15778. value: true
  15779. },
  15780. hScrollBarAlwaysVisible: {
  15781. set: function(val) {
  15782. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  15783. this.$loop.schedule(this.CHANGE_SCROLL);
  15784. },
  15785. initialValue: false
  15786. },
  15787. vScrollBarAlwaysVisible: {
  15788. set: function(val) {
  15789. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  15790. this.$loop.schedule(this.CHANGE_SCROLL);
  15791. },
  15792. initialValue: false
  15793. },
  15794. fontSize: {
  15795. set: function(size) {
  15796. if (typeof size == "number")
  15797. size = size + "px";
  15798. this.container.style.fontSize = size;
  15799. this.updateFontSize();
  15800. },
  15801. initialValue: 12
  15802. },
  15803. fontFamily: {
  15804. set: function(name) {
  15805. this.container.style.fontFamily = name;
  15806. this.updateFontSize();
  15807. }
  15808. },
  15809. maxLines: {
  15810. set: function(val) {
  15811. this.updateFull();
  15812. }
  15813. },
  15814. minLines: {
  15815. set: function(val) {
  15816. this.updateFull();
  15817. }
  15818. },
  15819. maxPixelHeight: {
  15820. set: function(val) {
  15821. this.updateFull();
  15822. },
  15823. initialValue: 0
  15824. },
  15825. scrollPastEnd: {
  15826. set: function(val) {
  15827. val = +val || 0;
  15828. if (this.$scrollPastEnd == val)
  15829. return;
  15830. this.$scrollPastEnd = val;
  15831. this.$loop.schedule(this.CHANGE_SCROLL);
  15832. },
  15833. initialValue: 0,
  15834. handlesSet: true
  15835. },
  15836. fixedWidthGutter: {
  15837. set: function(val) {
  15838. this.$gutterLayer.$fixedWidth = !!val;
  15839. this.$loop.schedule(this.CHANGE_GUTTER);
  15840. }
  15841. },
  15842. theme: {
  15843. set: function(val) { this.setTheme(val); },
  15844. get: function() { return this.$themeId || this.theme; },
  15845. initialValue: "./theme/textmate",
  15846. handlesSet: true
  15847. }
  15848. });
  15849. exports.VirtualRenderer = VirtualRenderer;
  15850. });
  15851. define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
  15852. "use strict";
  15853. var oop = require("../lib/oop");
  15854. var net = require("../lib/net");
  15855. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  15856. var config = require("../config");
  15857. function $workerBlob(workerUrl) {
  15858. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  15859. try {
  15860. return new Blob([script], {"type": "application/javascript"});
  15861. } catch (e) { // Backwards-compatibility
  15862. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  15863. var blobBuilder = new BlobBuilder();
  15864. blobBuilder.append(script);
  15865. return blobBuilder.getBlob("application/javascript");
  15866. }
  15867. }
  15868. function createWorker(workerUrl) {
  15869. var blob = $workerBlob(workerUrl);
  15870. var URL = window.URL || window.webkitURL;
  15871. var blobURL = URL.createObjectURL(blob);
  15872. return new Worker(blobURL);
  15873. }
  15874. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl, importScripts) {
  15875. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  15876. this.changeListener = this.changeListener.bind(this);
  15877. this.onMessage = this.onMessage.bind(this);
  15878. if (require.nameToUrl && !require.toUrl)
  15879. require.toUrl = require.nameToUrl;
  15880. if (config.get("packaged") || !require.toUrl) {
  15881. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  15882. } else {
  15883. var normalizePath = this.$normalizePath;
  15884. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  15885. var tlns = {};
  15886. topLevelNamespaces.forEach(function(ns) {
  15887. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  15888. });
  15889. }
  15890. this.$worker = createWorker(workerUrl);
  15891. if (importScripts) {
  15892. this.send("importScripts", importScripts);
  15893. }
  15894. this.$worker.postMessage({
  15895. init : true,
  15896. tlns : tlns,
  15897. module : mod,
  15898. classname : classname
  15899. });
  15900. this.callbackId = 1;
  15901. this.callbacks = {};
  15902. this.$worker.onmessage = this.onMessage;
  15903. };
  15904. (function(){
  15905. oop.implement(this, EventEmitter);
  15906. this.onMessage = function(e) {
  15907. var msg = e.data;
  15908. switch (msg.type) {
  15909. case "event":
  15910. this._signal(msg.name, {data: msg.data});
  15911. break;
  15912. case "call":
  15913. var callback = this.callbacks[msg.id];
  15914. if (callback) {
  15915. callback(msg.data);
  15916. delete this.callbacks[msg.id];
  15917. }
  15918. break;
  15919. case "error":
  15920. this.reportError(msg.data);
  15921. break;
  15922. case "log":
  15923. window.console && console.log && console.log.apply(console, msg.data);
  15924. break;
  15925. }
  15926. };
  15927. this.reportError = function(err) {
  15928. window.console && console.error && console.error(err);
  15929. };
  15930. this.$normalizePath = function(path) {
  15931. return net.qualifyURL(path);
  15932. };
  15933. this.terminate = function() {
  15934. this._signal("terminate", {});
  15935. this.deltaQueue = null;
  15936. this.$worker.terminate();
  15937. this.$worker = null;
  15938. if (this.$doc)
  15939. this.$doc.off("change", this.changeListener);
  15940. this.$doc = null;
  15941. };
  15942. this.send = function(cmd, args) {
  15943. this.$worker.postMessage({command: cmd, args: args});
  15944. };
  15945. this.call = function(cmd, args, callback) {
  15946. if (callback) {
  15947. var id = this.callbackId++;
  15948. this.callbacks[id] = callback;
  15949. args.push(id);
  15950. }
  15951. this.send(cmd, args);
  15952. };
  15953. this.emit = function(event, data) {
  15954. try {
  15955. this.$worker.postMessage({event: event, data: {data: data.data}});
  15956. }
  15957. catch(ex) {
  15958. console.error(ex.stack);
  15959. }
  15960. };
  15961. this.attachToDocument = function(doc) {
  15962. if (this.$doc)
  15963. this.terminate();
  15964. this.$doc = doc;
  15965. this.call("setValue", [doc.getValue()]);
  15966. doc.on("change", this.changeListener);
  15967. };
  15968. this.changeListener = function(delta) {
  15969. if (!this.deltaQueue) {
  15970. this.deltaQueue = [];
  15971. setTimeout(this.$sendDeltaQueue, 0);
  15972. }
  15973. if (delta.action == "insert")
  15974. this.deltaQueue.push(delta.start, delta.lines);
  15975. else
  15976. this.deltaQueue.push(delta.start, delta.end);
  15977. };
  15978. this.$sendDeltaQueue = function() {
  15979. var q = this.deltaQueue;
  15980. if (!q) return;
  15981. this.deltaQueue = null;
  15982. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  15983. this.call("setValue", [this.$doc.getValue()]);
  15984. } else
  15985. this.emit("change", {data: q});
  15986. };
  15987. }).call(WorkerClient.prototype);
  15988. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  15989. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  15990. this.changeListener = this.changeListener.bind(this);
  15991. this.callbackId = 1;
  15992. this.callbacks = {};
  15993. this.messageBuffer = [];
  15994. var main = null;
  15995. var emitSync = false;
  15996. var sender = Object.create(EventEmitter);
  15997. var _self = this;
  15998. this.$worker = {};
  15999. this.$worker.terminate = function() {};
  16000. this.$worker.postMessage = function(e) {
  16001. _self.messageBuffer.push(e);
  16002. if (main) {
  16003. if (emitSync)
  16004. setTimeout(processNext);
  16005. else
  16006. processNext();
  16007. }
  16008. };
  16009. this.setEmitSync = function(val) { emitSync = val; };
  16010. var processNext = function() {
  16011. var msg = _self.messageBuffer.shift();
  16012. if (msg.command)
  16013. main[msg.command].apply(main, msg.args);
  16014. else if (msg.event)
  16015. sender._signal(msg.event, msg.data);
  16016. };
  16017. sender.postMessage = function(msg) {
  16018. _self.onMessage({data: msg});
  16019. };
  16020. sender.callback = function(data, callbackId) {
  16021. this.postMessage({type: "call", id: callbackId, data: data});
  16022. };
  16023. sender.emit = function(name, data) {
  16024. this.postMessage({type: "event", name: name, data: data});
  16025. };
  16026. config.loadModule(["worker", mod], function(Main) {
  16027. main = new Main[classname](sender);
  16028. while (_self.messageBuffer.length)
  16029. processNext();
  16030. });
  16031. };
  16032. UIWorkerClient.prototype = WorkerClient.prototype;
  16033. exports.UIWorkerClient = UIWorkerClient;
  16034. exports.WorkerClient = WorkerClient;
  16035. exports.createWorker = createWorker;
  16036. });
  16037. define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  16038. "use strict";
  16039. var Range = require("./range").Range;
  16040. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  16041. var oop = require("./lib/oop");
  16042. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  16043. var _self = this;
  16044. this.length = length;
  16045. this.session = session;
  16046. this.doc = session.getDocument();
  16047. this.mainClass = mainClass;
  16048. this.othersClass = othersClass;
  16049. this.$onUpdate = this.onUpdate.bind(this);
  16050. this.doc.on("change", this.$onUpdate);
  16051. this.$others = others;
  16052. this.$onCursorChange = function() {
  16053. setTimeout(function() {
  16054. _self.onCursorChange();
  16055. });
  16056. };
  16057. this.$pos = pos;
  16058. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  16059. this.$undoStackDepth = undoStack.length;
  16060. this.setup();
  16061. session.selection.on("changeCursor", this.$onCursorChange);
  16062. };
  16063. (function() {
  16064. oop.implement(this, EventEmitter);
  16065. this.setup = function() {
  16066. var _self = this;
  16067. var doc = this.doc;
  16068. var session = this.session;
  16069. this.selectionBefore = session.selection.toJSON();
  16070. if (session.selection.inMultiSelectMode)
  16071. session.selection.toSingleRange();
  16072. this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
  16073. var pos = this.pos;
  16074. pos.$insertRight = true;
  16075. pos.detach();
  16076. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  16077. this.others = [];
  16078. this.$others.forEach(function(other) {
  16079. var anchor = doc.createAnchor(other.row, other.column);
  16080. anchor.$insertRight = true;
  16081. anchor.detach();
  16082. _self.others.push(anchor);
  16083. });
  16084. session.setUndoSelect(false);
  16085. };
  16086. this.showOtherMarkers = function() {
  16087. if (this.othersActive) return;
  16088. var session = this.session;
  16089. var _self = this;
  16090. this.othersActive = true;
  16091. this.others.forEach(function(anchor) {
  16092. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  16093. });
  16094. };
  16095. this.hideOtherMarkers = function() {
  16096. if (!this.othersActive) return;
  16097. this.othersActive = false;
  16098. for (var i = 0; i < this.others.length; i++) {
  16099. this.session.removeMarker(this.others[i].markerId);
  16100. }
  16101. };
  16102. this.onUpdate = function(delta) {
  16103. if (this.$updating)
  16104. return this.updateAnchors(delta);
  16105. var range = delta;
  16106. if (range.start.row !== range.end.row) return;
  16107. if (range.start.row !== this.pos.row) return;
  16108. this.$updating = true;
  16109. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  16110. var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
  16111. var distanceFromStart = range.start.column - this.pos.column;
  16112. this.updateAnchors(delta);
  16113. if (inMainRange)
  16114. this.length += lengthDiff;
  16115. if (inMainRange && !this.session.$fromUndo) {
  16116. if (delta.action === 'insert') {
  16117. for (var i = this.others.length - 1; i >= 0; i--) {
  16118. var otherPos = this.others[i];
  16119. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  16120. this.doc.insertMergedLines(newPos, delta.lines);
  16121. }
  16122. } else if (delta.action === 'remove') {
  16123. for (var i = this.others.length - 1; i >= 0; i--) {
  16124. var otherPos = this.others[i];
  16125. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  16126. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  16127. }
  16128. }
  16129. }
  16130. this.$updating = false;
  16131. this.updateMarkers();
  16132. };
  16133. this.updateAnchors = function(delta) {
  16134. this.pos.onChange(delta);
  16135. for (var i = this.others.length; i--;)
  16136. this.others[i].onChange(delta);
  16137. this.updateMarkers();
  16138. };
  16139. this.updateMarkers = function() {
  16140. if (this.$updating)
  16141. return;
  16142. var _self = this;
  16143. var session = this.session;
  16144. var updateMarker = function(pos, className) {
  16145. session.removeMarker(pos.markerId);
  16146. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
  16147. };
  16148. updateMarker(this.pos, this.mainClass);
  16149. for (var i = this.others.length; i--;)
  16150. updateMarker(this.others[i], this.othersClass);
  16151. };
  16152. this.onCursorChange = function(event) {
  16153. if (this.$updating || !this.session) return;
  16154. var pos = this.session.selection.getCursor();
  16155. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  16156. this.showOtherMarkers();
  16157. this._emit("cursorEnter", event);
  16158. } else {
  16159. this.hideOtherMarkers();
  16160. this._emit("cursorLeave", event);
  16161. }
  16162. };
  16163. this.detach = function() {
  16164. this.session.removeMarker(this.pos && this.pos.markerId);
  16165. this.hideOtherMarkers();
  16166. this.doc.removeEventListener("change", this.$onUpdate);
  16167. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  16168. this.session.setUndoSelect(true);
  16169. this.session = null;
  16170. };
  16171. this.cancel = function() {
  16172. if (this.$undoStackDepth === -1)
  16173. return;
  16174. var undoManager = this.session.getUndoManager();
  16175. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  16176. for (var i = 0; i < undosRequired; i++) {
  16177. undoManager.undo(true);
  16178. }
  16179. if (this.selectionBefore)
  16180. this.session.selection.fromJSON(this.selectionBefore);
  16181. };
  16182. }).call(PlaceHolder.prototype);
  16183. exports.PlaceHolder = PlaceHolder;
  16184. });
  16185. define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  16186. var event = require("../lib/event");
  16187. var useragent = require("../lib/useragent");
  16188. function isSamePoint(p1, p2) {
  16189. return p1.row == p2.row && p1.column == p2.column;
  16190. }
  16191. function onMouseDown(e) {
  16192. var ev = e.domEvent;
  16193. var alt = ev.altKey;
  16194. var shift = ev.shiftKey;
  16195. var ctrl = ev.ctrlKey;
  16196. var accel = e.getAccelKey();
  16197. var button = e.getButton();
  16198. if (ctrl && useragent.isMac)
  16199. button = ev.button;
  16200. if (e.editor.inMultiSelectMode && button == 2) {
  16201. e.editor.textInput.onContextMenu(e.domEvent);
  16202. return;
  16203. }
  16204. if (!ctrl && !alt && !accel) {
  16205. if (button === 0 && e.editor.inMultiSelectMode)
  16206. e.editor.exitMultiSelectMode();
  16207. return;
  16208. }
  16209. if (button !== 0)
  16210. return;
  16211. var editor = e.editor;
  16212. var selection = editor.selection;
  16213. var isMultiSelect = editor.inMultiSelectMode;
  16214. var pos = e.getDocumentPosition();
  16215. var cursor = selection.getCursor();
  16216. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  16217. var mouseX = e.x, mouseY = e.y;
  16218. var onMouseSelection = function(e) {
  16219. mouseX = e.clientX;
  16220. mouseY = e.clientY;
  16221. };
  16222. var session = editor.session;
  16223. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  16224. var screenCursor = screenAnchor;
  16225. var selectionMode;
  16226. if (editor.$mouseHandler.$enableJumpToDef) {
  16227. if (ctrl && alt || accel && alt)
  16228. selectionMode = shift ? "block" : "add";
  16229. else if (alt && editor.$blockSelectEnabled)
  16230. selectionMode = "block";
  16231. } else {
  16232. if (accel && !alt) {
  16233. selectionMode = "add";
  16234. if (!isMultiSelect && shift)
  16235. return;
  16236. } else if (alt && editor.$blockSelectEnabled) {
  16237. selectionMode = "block";
  16238. }
  16239. }
  16240. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  16241. editor.$mouseHandler.cancelContextMenu();
  16242. }
  16243. if (selectionMode == "add") {
  16244. if (!isMultiSelect && inSelection)
  16245. return; // dragging
  16246. if (!isMultiSelect) {
  16247. var range = selection.toOrientedRange();
  16248. editor.addSelectionMarker(range);
  16249. }
  16250. var oldRange = selection.rangeList.rangeAtPoint(pos);
  16251. editor.$blockScrolling++;
  16252. editor.inVirtualSelectionMode = true;
  16253. if (shift) {
  16254. oldRange = null;
  16255. range = selection.ranges[0] || range;
  16256. editor.removeSelectionMarker(range);
  16257. }
  16258. editor.once("mouseup", function() {
  16259. var tmpSel = selection.toOrientedRange();
  16260. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  16261. selection.substractPoint(tmpSel.cursor);
  16262. else {
  16263. if (shift) {
  16264. selection.substractPoint(range.cursor);
  16265. } else if (range) {
  16266. editor.removeSelectionMarker(range);
  16267. selection.addRange(range);
  16268. }
  16269. selection.addRange(tmpSel);
  16270. }
  16271. editor.$blockScrolling--;
  16272. editor.inVirtualSelectionMode = false;
  16273. });
  16274. } else if (selectionMode == "block") {
  16275. e.stop();
  16276. editor.inVirtualSelectionMode = true;
  16277. var initialRange;
  16278. var rectSel = [];
  16279. var blockSelect = function() {
  16280. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  16281. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column, newCursor.offsetX);
  16282. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  16283. return;
  16284. screenCursor = newCursor;
  16285. editor.$blockScrolling++;
  16286. editor.selection.moveToPosition(cursor);
  16287. editor.renderer.scrollCursorIntoView();
  16288. editor.removeSelectionMarkers(rectSel);
  16289. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  16290. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  16291. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  16292. rectSel.forEach(editor.addSelectionMarker, editor);
  16293. editor.updateSelectionMarkers();
  16294. editor.$blockScrolling--;
  16295. };
  16296. editor.$blockScrolling++;
  16297. if (isMultiSelect && !accel) {
  16298. selection.toSingleRange();
  16299. } else if (!isMultiSelect && accel) {
  16300. initialRange = selection.toOrientedRange();
  16301. editor.addSelectionMarker(initialRange);
  16302. }
  16303. if (shift)
  16304. screenAnchor = session.documentToScreenPosition(selection.lead);
  16305. else
  16306. selection.moveToPosition(pos);
  16307. editor.$blockScrolling--;
  16308. screenCursor = {row: -1, column: -1};
  16309. var onMouseSelectionEnd = function(e) {
  16310. clearInterval(timerId);
  16311. editor.removeSelectionMarkers(rectSel);
  16312. if (!rectSel.length)
  16313. rectSel = [selection.toOrientedRange()];
  16314. editor.$blockScrolling++;
  16315. if (initialRange) {
  16316. editor.removeSelectionMarker(initialRange);
  16317. selection.toSingleRange(initialRange);
  16318. }
  16319. for (var i = 0; i < rectSel.length; i++)
  16320. selection.addRange(rectSel[i]);
  16321. editor.inVirtualSelectionMode = false;
  16322. editor.$mouseHandler.$clickSelection = null;
  16323. editor.$blockScrolling--;
  16324. };
  16325. var onSelectionInterval = blockSelect;
  16326. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  16327. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  16328. return e.preventDefault();
  16329. }
  16330. }
  16331. exports.onMouseDown = onMouseDown;
  16332. });
  16333. define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  16334. exports.defaultCommands = [{
  16335. name: "addCursorAbove",
  16336. exec: function(editor) { editor.selectMoreLines(-1); },
  16337. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  16338. scrollIntoView: "cursor",
  16339. readOnly: true
  16340. }, {
  16341. name: "addCursorBelow",
  16342. exec: function(editor) { editor.selectMoreLines(1); },
  16343. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  16344. scrollIntoView: "cursor",
  16345. readOnly: true
  16346. }, {
  16347. name: "addCursorAboveSkipCurrent",
  16348. exec: function(editor) { editor.selectMoreLines(-1, true); },
  16349. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  16350. scrollIntoView: "cursor",
  16351. readOnly: true
  16352. }, {
  16353. name: "addCursorBelowSkipCurrent",
  16354. exec: function(editor) { editor.selectMoreLines(1, true); },
  16355. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  16356. scrollIntoView: "cursor",
  16357. readOnly: true
  16358. }, {
  16359. name: "selectMoreBefore",
  16360. exec: function(editor) { editor.selectMore(-1); },
  16361. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  16362. scrollIntoView: "cursor",
  16363. readOnly: true
  16364. }, {
  16365. name: "selectMoreAfter",
  16366. exec: function(editor) { editor.selectMore(1); },
  16367. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  16368. scrollIntoView: "cursor",
  16369. readOnly: true
  16370. }, {
  16371. name: "selectNextBefore",
  16372. exec: function(editor) { editor.selectMore(-1, true); },
  16373. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  16374. scrollIntoView: "cursor",
  16375. readOnly: true
  16376. }, {
  16377. name: "selectNextAfter",
  16378. exec: function(editor) { editor.selectMore(1, true); },
  16379. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  16380. scrollIntoView: "cursor",
  16381. readOnly: true
  16382. }, {
  16383. name: "splitIntoLines",
  16384. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  16385. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  16386. readOnly: true
  16387. }, {
  16388. name: "alignCursors",
  16389. exec: function(editor) { editor.alignCursors(); },
  16390. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  16391. scrollIntoView: "cursor"
  16392. }, {
  16393. name: "findAll",
  16394. exec: function(editor) { editor.findAll(); },
  16395. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  16396. scrollIntoView: "cursor",
  16397. readOnly: true
  16398. }];
  16399. exports.multiSelectCommands = [{
  16400. name: "singleSelection",
  16401. bindKey: "esc",
  16402. exec: function(editor) { editor.exitMultiSelectMode(); },
  16403. scrollIntoView: "cursor",
  16404. readOnly: true,
  16405. isAvailable: function(editor) {return editor && editor.inMultiSelectMode;}
  16406. }];
  16407. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  16408. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  16409. });
  16410. 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) {
  16411. var RangeList = require("./range_list").RangeList;
  16412. var Range = require("./range").Range;
  16413. var Selection = require("./selection").Selection;
  16414. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  16415. var event = require("./lib/event");
  16416. var lang = require("./lib/lang");
  16417. var commands = require("./commands/multi_select_commands");
  16418. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  16419. var Search = require("./search").Search;
  16420. var search = new Search();
  16421. function find(session, needle, dir) {
  16422. search.$options.wrap = true;
  16423. search.$options.needle = needle;
  16424. search.$options.backwards = dir == -1;
  16425. return search.find(session);
  16426. }
  16427. var EditSession = require("./edit_session").EditSession;
  16428. (function() {
  16429. this.getSelectionMarkers = function() {
  16430. return this.$selectionMarkers;
  16431. };
  16432. }).call(EditSession.prototype);
  16433. (function() {
  16434. this.ranges = null;
  16435. this.rangeList = null;
  16436. this.addRange = function(range, $blockChangeEvents) {
  16437. if (!range)
  16438. return;
  16439. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  16440. var oldRange = this.toOrientedRange();
  16441. this.rangeList.add(oldRange);
  16442. this.rangeList.add(range);
  16443. if (this.rangeList.ranges.length != 2) {
  16444. this.rangeList.removeAll();
  16445. return $blockChangeEvents || this.fromOrientedRange(range);
  16446. }
  16447. this.rangeList.removeAll();
  16448. this.rangeList.add(oldRange);
  16449. this.$onAddRange(oldRange);
  16450. }
  16451. if (!range.cursor)
  16452. range.cursor = range.end;
  16453. var removed = this.rangeList.add(range);
  16454. this.$onAddRange(range);
  16455. if (removed.length)
  16456. this.$onRemoveRange(removed);
  16457. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  16458. this._signal("multiSelect");
  16459. this.inMultiSelectMode = true;
  16460. this.session.$undoSelect = false;
  16461. this.rangeList.attach(this.session);
  16462. }
  16463. return $blockChangeEvents || this.fromOrientedRange(range);
  16464. };
  16465. this.toSingleRange = function(range) {
  16466. range = range || this.ranges[0];
  16467. var removed = this.rangeList.removeAll();
  16468. if (removed.length)
  16469. this.$onRemoveRange(removed);
  16470. range && this.fromOrientedRange(range);
  16471. };
  16472. this.substractPoint = function(pos) {
  16473. var removed = this.rangeList.substractPoint(pos);
  16474. if (removed) {
  16475. this.$onRemoveRange(removed);
  16476. return removed[0];
  16477. }
  16478. };
  16479. this.mergeOverlappingRanges = function() {
  16480. var removed = this.rangeList.merge();
  16481. if (removed.length)
  16482. this.$onRemoveRange(removed);
  16483. else if(this.ranges[0])
  16484. this.fromOrientedRange(this.ranges[0]);
  16485. };
  16486. this.$onAddRange = function(range) {
  16487. this.rangeCount = this.rangeList.ranges.length;
  16488. this.ranges.unshift(range);
  16489. this._signal("addRange", {range: range});
  16490. };
  16491. this.$onRemoveRange = function(removed) {
  16492. this.rangeCount = this.rangeList.ranges.length;
  16493. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  16494. var lastRange = this.rangeList.ranges.pop();
  16495. removed.push(lastRange);
  16496. this.rangeCount = 0;
  16497. }
  16498. for (var i = removed.length; i--; ) {
  16499. var index = this.ranges.indexOf(removed[i]);
  16500. this.ranges.splice(index, 1);
  16501. }
  16502. this._signal("removeRange", {ranges: removed});
  16503. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  16504. this.inMultiSelectMode = false;
  16505. this._signal("singleSelect");
  16506. this.session.$undoSelect = true;
  16507. this.rangeList.detach(this.session);
  16508. }
  16509. lastRange = lastRange || this.ranges[0];
  16510. if (lastRange && !lastRange.isEqual(this.getRange()))
  16511. this.fromOrientedRange(lastRange);
  16512. };
  16513. this.$initRangeList = function() {
  16514. if (this.rangeList)
  16515. return;
  16516. this.rangeList = new RangeList();
  16517. this.ranges = [];
  16518. this.rangeCount = 0;
  16519. };
  16520. this.getAllRanges = function() {
  16521. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  16522. };
  16523. this.splitIntoLines = function () {
  16524. if (this.rangeCount > 1) {
  16525. var ranges = this.rangeList.ranges;
  16526. var lastRange = ranges[ranges.length - 1];
  16527. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  16528. this.toSingleRange();
  16529. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  16530. } else {
  16531. var range = this.getRange();
  16532. var isBackwards = this.isBackwards();
  16533. var startRow = range.start.row;
  16534. var endRow = range.end.row;
  16535. if (startRow == endRow) {
  16536. if (isBackwards)
  16537. var start = range.end, end = range.start;
  16538. else
  16539. var start = range.start, end = range.end;
  16540. this.addRange(Range.fromPoints(end, end));
  16541. this.addRange(Range.fromPoints(start, start));
  16542. return;
  16543. }
  16544. var rectSel = [];
  16545. var r = this.getLineRange(startRow, true);
  16546. r.start.column = range.start.column;
  16547. rectSel.push(r);
  16548. for (var i = startRow + 1; i < endRow; i++)
  16549. rectSel.push(this.getLineRange(i, true));
  16550. r = this.getLineRange(endRow, true);
  16551. r.end.column = range.end.column;
  16552. rectSel.push(r);
  16553. rectSel.forEach(this.addRange, this);
  16554. }
  16555. };
  16556. this.toggleBlockSelection = function () {
  16557. if (this.rangeCount > 1) {
  16558. var ranges = this.rangeList.ranges;
  16559. var lastRange = ranges[ranges.length - 1];
  16560. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  16561. this.toSingleRange();
  16562. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  16563. } else {
  16564. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  16565. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  16566. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  16567. rectSel.forEach(this.addRange, this);
  16568. }
  16569. };
  16570. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  16571. var rectSel = [];
  16572. var xBackwards = screenCursor.column < screenAnchor.column;
  16573. if (xBackwards) {
  16574. var startColumn = screenCursor.column;
  16575. var endColumn = screenAnchor.column;
  16576. var startOffsetX = screenCursor.offsetX;
  16577. var endOffsetX = screenAnchor.offsetX;
  16578. } else {
  16579. var startColumn = screenAnchor.column;
  16580. var endColumn = screenCursor.column;
  16581. var startOffsetX = screenAnchor.offsetX;
  16582. var endOffsetX = screenCursor.offsetX;
  16583. }
  16584. var yBackwards = screenCursor.row < screenAnchor.row;
  16585. if (yBackwards) {
  16586. var startRow = screenCursor.row;
  16587. var endRow = screenAnchor.row;
  16588. } else {
  16589. var startRow = screenAnchor.row;
  16590. var endRow = screenCursor.row;
  16591. }
  16592. if (startColumn < 0)
  16593. startColumn = 0;
  16594. if (startRow < 0)
  16595. startRow = 0;
  16596. if (startRow == endRow)
  16597. includeEmptyLines = true;
  16598. for (var row = startRow; row <= endRow; row++) {
  16599. var range = Range.fromPoints(
  16600. this.session.screenToDocumentPosition(row, startColumn, startOffsetX),
  16601. this.session.screenToDocumentPosition(row, endColumn, endOffsetX)
  16602. );
  16603. if (range.isEmpty()) {
  16604. if (docEnd && isSamePoint(range.end, docEnd))
  16605. break;
  16606. var docEnd = range.end;
  16607. }
  16608. range.cursor = xBackwards ? range.start : range.end;
  16609. rectSel.push(range);
  16610. }
  16611. if (yBackwards)
  16612. rectSel.reverse();
  16613. if (!includeEmptyLines) {
  16614. var end = rectSel.length - 1;
  16615. while (rectSel[end].isEmpty() && end > 0)
  16616. end--;
  16617. if (end > 0) {
  16618. var start = 0;
  16619. while (rectSel[start].isEmpty())
  16620. start++;
  16621. }
  16622. for (var i = end; i >= start; i--) {
  16623. if (rectSel[i].isEmpty())
  16624. rectSel.splice(i, 1);
  16625. }
  16626. }
  16627. return rectSel;
  16628. };
  16629. }).call(Selection.prototype);
  16630. var Editor = require("./editor").Editor;
  16631. (function() {
  16632. this.updateSelectionMarkers = function() {
  16633. this.renderer.updateCursor();
  16634. this.renderer.updateBackMarkers();
  16635. };
  16636. this.addSelectionMarker = function(orientedRange) {
  16637. if (!orientedRange.cursor)
  16638. orientedRange.cursor = orientedRange.end;
  16639. var style = this.getSelectionStyle();
  16640. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  16641. this.session.$selectionMarkers.push(orientedRange);
  16642. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  16643. return orientedRange;
  16644. };
  16645. this.removeSelectionMarker = function(range) {
  16646. if (!range.marker)
  16647. return;
  16648. this.session.removeMarker(range.marker);
  16649. var index = this.session.$selectionMarkers.indexOf(range);
  16650. if (index != -1)
  16651. this.session.$selectionMarkers.splice(index, 1);
  16652. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  16653. };
  16654. this.removeSelectionMarkers = function(ranges) {
  16655. var markerList = this.session.$selectionMarkers;
  16656. for (var i = ranges.length; i--; ) {
  16657. var range = ranges[i];
  16658. if (!range.marker)
  16659. continue;
  16660. this.session.removeMarker(range.marker);
  16661. var index = markerList.indexOf(range);
  16662. if (index != -1)
  16663. markerList.splice(index, 1);
  16664. }
  16665. this.session.selectionMarkerCount = markerList.length;
  16666. };
  16667. this.$onAddRange = function(e) {
  16668. this.addSelectionMarker(e.range);
  16669. this.renderer.updateCursor();
  16670. this.renderer.updateBackMarkers();
  16671. };
  16672. this.$onRemoveRange = function(e) {
  16673. this.removeSelectionMarkers(e.ranges);
  16674. this.renderer.updateCursor();
  16675. this.renderer.updateBackMarkers();
  16676. };
  16677. this.$onMultiSelect = function(e) {
  16678. if (this.inMultiSelectMode)
  16679. return;
  16680. this.inMultiSelectMode = true;
  16681. this.setStyle("ace_multiselect");
  16682. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  16683. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  16684. this.renderer.updateCursor();
  16685. this.renderer.updateBackMarkers();
  16686. };
  16687. this.$onSingleSelect = function(e) {
  16688. if (this.session.multiSelect.inVirtualMode)
  16689. return;
  16690. this.inMultiSelectMode = false;
  16691. this.unsetStyle("ace_multiselect");
  16692. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  16693. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  16694. this.renderer.updateCursor();
  16695. this.renderer.updateBackMarkers();
  16696. this._emit("changeSelection");
  16697. };
  16698. this.$onMultiSelectExec = function(e) {
  16699. var command = e.command;
  16700. var editor = e.editor;
  16701. if (!editor.multiSelect)
  16702. return;
  16703. if (!command.multiSelectAction) {
  16704. var result = command.exec(editor, e.args || {});
  16705. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  16706. editor.multiSelect.mergeOverlappingRanges();
  16707. } else if (command.multiSelectAction == "forEach") {
  16708. result = editor.forEachSelection(command, e.args);
  16709. } else if (command.multiSelectAction == "forEachLine") {
  16710. result = editor.forEachSelection(command, e.args, true);
  16711. } else if (command.multiSelectAction == "single") {
  16712. editor.exitMultiSelectMode();
  16713. result = command.exec(editor, e.args || {});
  16714. } else {
  16715. result = command.multiSelectAction(editor, e.args || {});
  16716. }
  16717. return result;
  16718. };
  16719. this.forEachSelection = function(cmd, args, options) {
  16720. if (this.inVirtualSelectionMode)
  16721. return;
  16722. var keepOrder = options && options.keepOrder;
  16723. var $byLines = options == true || options && options.$byLines;
  16724. var session = this.session;
  16725. var selection = this.selection;
  16726. var rangeList = selection.rangeList;
  16727. var ranges = (keepOrder ? selection : rangeList).ranges;
  16728. var result;
  16729. if (!ranges.length)
  16730. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  16731. var reg = selection._eventRegistry;
  16732. selection._eventRegistry = {};
  16733. var tmpSel = new Selection(session);
  16734. this.inVirtualSelectionMode = true;
  16735. for (var i = ranges.length; i--;) {
  16736. if ($byLines) {
  16737. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  16738. i--;
  16739. }
  16740. tmpSel.fromOrientedRange(ranges[i]);
  16741. tmpSel.index = i;
  16742. this.selection = session.selection = tmpSel;
  16743. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  16744. if (!result && cmdResult !== undefined)
  16745. result = cmdResult;
  16746. tmpSel.toOrientedRange(ranges[i]);
  16747. }
  16748. tmpSel.detach();
  16749. this.selection = session.selection = selection;
  16750. this.inVirtualSelectionMode = false;
  16751. selection._eventRegistry = reg;
  16752. selection.mergeOverlappingRanges();
  16753. var anim = this.renderer.$scrollAnimation;
  16754. this.onCursorChange();
  16755. this.onSelectionChange();
  16756. if (anim && anim.from == anim.to)
  16757. this.renderer.animateScrolling(anim.from);
  16758. return result;
  16759. };
  16760. this.exitMultiSelectMode = function() {
  16761. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  16762. return;
  16763. this.multiSelect.toSingleRange();
  16764. };
  16765. this.getSelectedText = function() {
  16766. var text = "";
  16767. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  16768. var ranges = this.multiSelect.rangeList.ranges;
  16769. var buf = [];
  16770. for (var i = 0; i < ranges.length; i++) {
  16771. buf.push(this.session.getTextRange(ranges[i]));
  16772. }
  16773. var nl = this.session.getDocument().getNewLineCharacter();
  16774. text = buf.join(nl);
  16775. if (text.length == (buf.length - 1) * nl.length)
  16776. text = "";
  16777. } else if (!this.selection.isEmpty()) {
  16778. text = this.session.getTextRange(this.getSelectionRange());
  16779. }
  16780. return text;
  16781. };
  16782. this.$checkMultiselectChange = function(e, anchor) {
  16783. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  16784. var range = this.multiSelect.ranges[0];
  16785. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  16786. return;
  16787. var pos = anchor == this.multiSelect.anchor
  16788. ? range.cursor == range.start ? range.end : range.start
  16789. : range.cursor;
  16790. if (pos.row != anchor.row
  16791. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  16792. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  16793. }
  16794. };
  16795. this.findAll = function(needle, options, additive) {
  16796. options = options || {};
  16797. options.needle = needle || options.needle;
  16798. if (options.needle == undefined) {
  16799. var range = this.selection.isEmpty()
  16800. ? this.selection.getWordRange()
  16801. : this.selection.getRange();
  16802. options.needle = this.session.getTextRange(range);
  16803. }
  16804. this.$search.set(options);
  16805. var ranges = this.$search.findAll(this.session);
  16806. if (!ranges.length)
  16807. return 0;
  16808. this.$blockScrolling += 1;
  16809. var selection = this.multiSelect;
  16810. if (!additive)
  16811. selection.toSingleRange(ranges[0]);
  16812. for (var i = ranges.length; i--; )
  16813. selection.addRange(ranges[i], true);
  16814. if (range && selection.rangeList.rangeAtPoint(range.start))
  16815. selection.addRange(range, true);
  16816. this.$blockScrolling -= 1;
  16817. return ranges.length;
  16818. };
  16819. this.selectMoreLines = function(dir, skip) {
  16820. var range = this.selection.toOrientedRange();
  16821. var isBackwards = range.cursor == range.end;
  16822. var screenLead = this.session.documentToScreenPosition(range.cursor);
  16823. if (this.selection.$desiredColumn)
  16824. screenLead.column = this.selection.$desiredColumn;
  16825. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  16826. if (!range.isEmpty()) {
  16827. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  16828. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  16829. } else {
  16830. var anchor = lead;
  16831. }
  16832. if (isBackwards) {
  16833. var newRange = Range.fromPoints(lead, anchor);
  16834. newRange.cursor = newRange.start;
  16835. } else {
  16836. var newRange = Range.fromPoints(anchor, lead);
  16837. newRange.cursor = newRange.end;
  16838. }
  16839. newRange.desiredColumn = screenLead.column;
  16840. if (!this.selection.inMultiSelectMode) {
  16841. this.selection.addRange(range);
  16842. } else {
  16843. if (skip)
  16844. var toRemove = range.cursor;
  16845. }
  16846. this.selection.addRange(newRange);
  16847. if (toRemove)
  16848. this.selection.substractPoint(toRemove);
  16849. };
  16850. this.transposeSelections = function(dir) {
  16851. var session = this.session;
  16852. var sel = session.multiSelect;
  16853. var all = sel.ranges;
  16854. for (var i = all.length; i--; ) {
  16855. var range = all[i];
  16856. if (range.isEmpty()) {
  16857. var tmp = session.getWordRange(range.start.row, range.start.column);
  16858. range.start.row = tmp.start.row;
  16859. range.start.column = tmp.start.column;
  16860. range.end.row = tmp.end.row;
  16861. range.end.column = tmp.end.column;
  16862. }
  16863. }
  16864. sel.mergeOverlappingRanges();
  16865. var words = [];
  16866. for (var i = all.length; i--; ) {
  16867. var range = all[i];
  16868. words.unshift(session.getTextRange(range));
  16869. }
  16870. if (dir < 0)
  16871. words.unshift(words.pop());
  16872. else
  16873. words.push(words.shift());
  16874. for (var i = all.length; i--; ) {
  16875. var range = all[i];
  16876. var tmp = range.clone();
  16877. session.replace(range, words[i]);
  16878. range.start.row = tmp.start.row;
  16879. range.start.column = tmp.start.column;
  16880. }
  16881. };
  16882. this.selectMore = function(dir, skip, stopAtFirst) {
  16883. var session = this.session;
  16884. var sel = session.multiSelect;
  16885. var range = sel.toOrientedRange();
  16886. if (range.isEmpty()) {
  16887. range = session.getWordRange(range.start.row, range.start.column);
  16888. range.cursor = dir == -1 ? range.start : range.end;
  16889. this.multiSelect.addRange(range);
  16890. if (stopAtFirst)
  16891. return;
  16892. }
  16893. var needle = session.getTextRange(range);
  16894. var newRange = find(session, needle, dir);
  16895. if (newRange) {
  16896. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  16897. this.$blockScrolling += 1;
  16898. this.session.unfold(newRange);
  16899. this.multiSelect.addRange(newRange);
  16900. this.$blockScrolling -= 1;
  16901. this.renderer.scrollCursorIntoView(null, 0.5);
  16902. }
  16903. if (skip)
  16904. this.multiSelect.substractPoint(range.cursor);
  16905. };
  16906. this.alignCursors = function() {
  16907. var session = this.session;
  16908. var sel = session.multiSelect;
  16909. var ranges = sel.ranges;
  16910. var row = -1;
  16911. var sameRowRanges = ranges.filter(function(r) {
  16912. if (r.cursor.row == row)
  16913. return true;
  16914. row = r.cursor.row;
  16915. });
  16916. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  16917. var range = this.selection.getRange();
  16918. var fr = range.start.row, lr = range.end.row;
  16919. var guessRange = fr == lr;
  16920. if (guessRange) {
  16921. var max = this.session.getLength();
  16922. var line;
  16923. do {
  16924. line = this.session.getLine(lr);
  16925. } while (/[=:]/.test(line) && ++lr < max);
  16926. do {
  16927. line = this.session.getLine(fr);
  16928. } while (/[=:]/.test(line) && --fr > 0);
  16929. if (fr < 0) fr = 0;
  16930. if (lr >= max) lr = max - 1;
  16931. }
  16932. var lines = this.session.removeFullLines(fr, lr);
  16933. lines = this.$reAlignText(lines, guessRange);
  16934. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  16935. if (!guessRange) {
  16936. range.start.column = 0;
  16937. range.end.column = lines[lines.length - 1].length;
  16938. }
  16939. this.selection.setRange(range);
  16940. } else {
  16941. sameRowRanges.forEach(function(r) {
  16942. sel.substractPoint(r.cursor);
  16943. });
  16944. var maxCol = 0;
  16945. var minSpace = Infinity;
  16946. var spaceOffsets = ranges.map(function(r) {
  16947. var p = r.cursor;
  16948. var line = session.getLine(p.row);
  16949. var spaceOffset = line.substr(p.column).search(/\S/g);
  16950. if (spaceOffset == -1)
  16951. spaceOffset = 0;
  16952. if (p.column > maxCol)
  16953. maxCol = p.column;
  16954. if (spaceOffset < minSpace)
  16955. minSpace = spaceOffset;
  16956. return spaceOffset;
  16957. });
  16958. ranges.forEach(function(r, i) {
  16959. var p = r.cursor;
  16960. var l = maxCol - p.column;
  16961. var d = spaceOffsets[i] - minSpace;
  16962. if (l > d)
  16963. session.insert(p, lang.stringRepeat(" ", l - d));
  16964. else
  16965. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  16966. r.start.column = r.end.column = maxCol;
  16967. r.start.row = r.end.row = p.row;
  16968. r.cursor = r.end;
  16969. });
  16970. sel.fromOrientedRange(ranges[0]);
  16971. this.renderer.updateCursor();
  16972. this.renderer.updateBackMarkers();
  16973. }
  16974. };
  16975. this.$reAlignText = function(lines, forceLeft) {
  16976. var isLeftAligned = true, isRightAligned = true;
  16977. var startW, textW, endW;
  16978. return lines.map(function(line) {
  16979. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  16980. if (!m)
  16981. return [line];
  16982. if (startW == null) {
  16983. startW = m[1].length;
  16984. textW = m[2].length;
  16985. endW = m[3].length;
  16986. return m;
  16987. }
  16988. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  16989. isRightAligned = false;
  16990. if (startW != m[1].length)
  16991. isLeftAligned = false;
  16992. if (startW > m[1].length)
  16993. startW = m[1].length;
  16994. if (textW < m[2].length)
  16995. textW = m[2].length;
  16996. if (endW > m[3].length)
  16997. endW = m[3].length;
  16998. return m;
  16999. }).map(forceLeft ? alignLeft :
  17000. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  17001. function spaces(n) {
  17002. return lang.stringRepeat(" ", n);
  17003. }
  17004. function alignLeft(m) {
  17005. return !m[2] ? m[0] : spaces(startW) + m[2]
  17006. + spaces(textW - m[2].length + endW)
  17007. + m[4].replace(/^([=:])\s+/, "$1 ");
  17008. }
  17009. function alignRight(m) {
  17010. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  17011. + spaces(endW)
  17012. + m[4].replace(/^([=:])\s+/, "$1 ");
  17013. }
  17014. function unAlign(m) {
  17015. return !m[2] ? m[0] : spaces(startW) + m[2]
  17016. + spaces(endW)
  17017. + m[4].replace(/^([=:])\s+/, "$1 ");
  17018. }
  17019. };
  17020. }).call(Editor.prototype);
  17021. function isSamePoint(p1, p2) {
  17022. return p1.row == p2.row && p1.column == p2.column;
  17023. }
  17024. exports.onSessionChange = function(e) {
  17025. var session = e.session;
  17026. if (session && !session.multiSelect) {
  17027. session.$selectionMarkers = [];
  17028. session.selection.$initRangeList();
  17029. session.multiSelect = session.selection;
  17030. }
  17031. this.multiSelect = session && session.multiSelect;
  17032. var oldSession = e.oldSession;
  17033. if (oldSession) {
  17034. oldSession.multiSelect.off("addRange", this.$onAddRange);
  17035. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  17036. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  17037. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  17038. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  17039. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  17040. }
  17041. if (session) {
  17042. session.multiSelect.on("addRange", this.$onAddRange);
  17043. session.multiSelect.on("removeRange", this.$onRemoveRange);
  17044. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  17045. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  17046. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  17047. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  17048. }
  17049. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  17050. if (session.selection.inMultiSelectMode)
  17051. this.$onMultiSelect();
  17052. else
  17053. this.$onSingleSelect();
  17054. }
  17055. };
  17056. function MultiSelect(editor) {
  17057. if (editor.$multiselectOnSessionChange)
  17058. return;
  17059. editor.$onAddRange = editor.$onAddRange.bind(editor);
  17060. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  17061. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  17062. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  17063. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  17064. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  17065. editor.$multiselectOnSessionChange(editor);
  17066. editor.on("changeSession", editor.$multiselectOnSessionChange);
  17067. editor.on("mousedown", onMouseDown);
  17068. editor.commands.addCommands(commands.defaultCommands);
  17069. addAltCursorListeners(editor);
  17070. }
  17071. function addAltCursorListeners(editor){
  17072. var el = editor.textInput.getElement();
  17073. var altCursor = false;
  17074. event.addListener(el, "keydown", function(e) {
  17075. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  17076. if (editor.$blockSelectEnabled && altDown) {
  17077. if (!altCursor) {
  17078. editor.renderer.setMouseCursor("crosshair");
  17079. altCursor = true;
  17080. }
  17081. } else if (altCursor) {
  17082. reset();
  17083. }
  17084. });
  17085. event.addListener(el, "keyup", reset);
  17086. event.addListener(el, "blur", reset);
  17087. function reset(e) {
  17088. if (altCursor) {
  17089. editor.renderer.setMouseCursor("");
  17090. altCursor = false;
  17091. }
  17092. }
  17093. }
  17094. exports.MultiSelect = MultiSelect;
  17095. require("./config").defineOptions(Editor.prototype, "editor", {
  17096. enableMultiselect: {
  17097. set: function(val) {
  17098. MultiSelect(this);
  17099. if (val) {
  17100. this.on("changeSession", this.$multiselectOnSessionChange);
  17101. this.on("mousedown", onMouseDown);
  17102. } else {
  17103. this.off("changeSession", this.$multiselectOnSessionChange);
  17104. this.off("mousedown", onMouseDown);
  17105. }
  17106. },
  17107. value: true
  17108. },
  17109. enableBlockSelect: {
  17110. set: function(val) {
  17111. this.$blockSelectEnabled = val;
  17112. },
  17113. value: true
  17114. }
  17115. });
  17116. });
  17117. define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  17118. "use strict";
  17119. var Range = require("../../range").Range;
  17120. var FoldMode = exports.FoldMode = function() {};
  17121. (function() {
  17122. this.foldingStartMarker = null;
  17123. this.foldingStopMarker = null;
  17124. this.getFoldWidget = function(session, foldStyle, row) {
  17125. var line = session.getLine(row);
  17126. if (this.foldingStartMarker.test(line))
  17127. return "start";
  17128. if (foldStyle == "markbeginend"
  17129. && this.foldingStopMarker
  17130. && this.foldingStopMarker.test(line))
  17131. return "end";
  17132. return "";
  17133. };
  17134. this.getFoldWidgetRange = function(session, foldStyle, row) {
  17135. return null;
  17136. };
  17137. this.indentationBlock = function(session, row, column) {
  17138. var re = /\S/;
  17139. var line = session.getLine(row);
  17140. var startLevel = line.search(re);
  17141. if (startLevel == -1)
  17142. return;
  17143. var startColumn = column || line.length;
  17144. var maxRow = session.getLength();
  17145. var startRow = row;
  17146. var endRow = row;
  17147. while (++row < maxRow) {
  17148. var level = session.getLine(row).search(re);
  17149. if (level == -1)
  17150. continue;
  17151. if (level <= startLevel)
  17152. break;
  17153. endRow = row;
  17154. }
  17155. if (endRow > startRow) {
  17156. var endColumn = session.getLine(endRow).length;
  17157. return new Range(startRow, startColumn, endRow, endColumn);
  17158. }
  17159. };
  17160. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  17161. var start = {row: row, column: column + 1};
  17162. var end = session.$findClosingBracket(bracket, start, typeRe);
  17163. if (!end)
  17164. return;
  17165. var fw = session.foldWidgets[end.row];
  17166. if (fw == null)
  17167. fw = session.getFoldWidget(end.row);
  17168. if (fw == "start" && end.row > start.row) {
  17169. end.row --;
  17170. end.column = session.getLine(end.row).length;
  17171. }
  17172. return Range.fromPoints(start, end);
  17173. };
  17174. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  17175. var end = {row: row, column: column};
  17176. var start = session.$findOpeningBracket(bracket, end);
  17177. if (!start)
  17178. return;
  17179. start.column++;
  17180. end.column--;
  17181. return Range.fromPoints(start, end);
  17182. };
  17183. }).call(FoldMode.prototype);
  17184. });
  17185. define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  17186. "use strict";
  17187. exports.isDark = false;
  17188. exports.cssClass = "ace-tm";
  17189. exports.cssText = ".ace-tm .ace_gutter {\
  17190. background: #f0f0f0;\
  17191. color: #333;\
  17192. }\
  17193. .ace-tm .ace_print-margin {\
  17194. width: 1px;\
  17195. background: #e8e8e8;\
  17196. }\
  17197. .ace-tm .ace_fold {\
  17198. background-color: #6B72E6;\
  17199. }\
  17200. .ace-tm {\
  17201. background-color: #FFFFFF;\
  17202. color: black;\
  17203. }\
  17204. .ace-tm .ace_cursor {\
  17205. color: black;\
  17206. }\
  17207. .ace-tm .ace_invisible {\
  17208. color: rgb(191, 191, 191);\
  17209. }\
  17210. .ace-tm .ace_storage,\
  17211. .ace-tm .ace_keyword {\
  17212. color: blue;\
  17213. }\
  17214. .ace-tm .ace_constant {\
  17215. color: rgb(197, 6, 11);\
  17216. }\
  17217. .ace-tm .ace_constant.ace_buildin {\
  17218. color: rgb(88, 72, 246);\
  17219. }\
  17220. .ace-tm .ace_constant.ace_language {\
  17221. color: rgb(88, 92, 246);\
  17222. }\
  17223. .ace-tm .ace_constant.ace_library {\
  17224. color: rgb(6, 150, 14);\
  17225. }\
  17226. .ace-tm .ace_invalid {\
  17227. background-color: rgba(255, 0, 0, 0.1);\
  17228. color: red;\
  17229. }\
  17230. .ace-tm .ace_support.ace_function {\
  17231. color: rgb(60, 76, 114);\
  17232. }\
  17233. .ace-tm .ace_support.ace_constant {\
  17234. color: rgb(6, 150, 14);\
  17235. }\
  17236. .ace-tm .ace_support.ace_type,\
  17237. .ace-tm .ace_support.ace_class {\
  17238. color: rgb(109, 121, 222);\
  17239. }\
  17240. .ace-tm .ace_keyword.ace_operator {\
  17241. color: rgb(104, 118, 135);\
  17242. }\
  17243. .ace-tm .ace_string {\
  17244. color: rgb(3, 106, 7);\
  17245. }\
  17246. .ace-tm .ace_comment {\
  17247. color: rgb(76, 136, 107);\
  17248. }\
  17249. .ace-tm .ace_comment.ace_doc {\
  17250. color: rgb(0, 102, 255);\
  17251. }\
  17252. .ace-tm .ace_comment.ace_doc.ace_tag {\
  17253. color: rgb(128, 159, 191);\
  17254. }\
  17255. .ace-tm .ace_constant.ace_numeric {\
  17256. color: rgb(0, 0, 205);\
  17257. }\
  17258. .ace-tm .ace_variable {\
  17259. color: rgb(49, 132, 149);\
  17260. }\
  17261. .ace-tm .ace_xml-pe {\
  17262. color: rgb(104, 104, 91);\
  17263. }\
  17264. .ace-tm .ace_entity.ace_name.ace_function {\
  17265. color: #0000A2;\
  17266. }\
  17267. .ace-tm .ace_heading {\
  17268. color: rgb(12, 7, 255);\
  17269. }\
  17270. .ace-tm .ace_list {\
  17271. color:rgb(185, 6, 144);\
  17272. }\
  17273. .ace-tm .ace_meta.ace_tag {\
  17274. color:rgb(0, 22, 142);\
  17275. }\
  17276. .ace-tm .ace_string.ace_regex {\
  17277. color: rgb(255, 0, 0)\
  17278. }\
  17279. .ace-tm .ace_marker-layer .ace_selection {\
  17280. background: rgb(181, 213, 255);\
  17281. }\
  17282. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  17283. box-shadow: 0 0 3px 0px white;\
  17284. }\
  17285. .ace-tm .ace_marker-layer .ace_step {\
  17286. background: rgb(252, 255, 0);\
  17287. }\
  17288. .ace-tm .ace_marker-layer .ace_stack {\
  17289. background: rgb(164, 229, 101);\
  17290. }\
  17291. .ace-tm .ace_marker-layer .ace_bracket {\
  17292. margin: -1px 0 0 -1px;\
  17293. border: 1px solid rgb(192, 192, 192);\
  17294. }\
  17295. .ace-tm .ace_marker-layer .ace_active-line {\
  17296. background: rgba(0, 0, 0, 0.07);\
  17297. }\
  17298. .ace-tm .ace_gutter-active-line {\
  17299. background-color : #dcdcdc;\
  17300. }\
  17301. .ace-tm .ace_marker-layer .ace_selected-word {\
  17302. background: rgb(250, 250, 255);\
  17303. border: 1px solid rgb(200, 200, 250);\
  17304. }\
  17305. .ace-tm .ace_indent-guide {\
  17306. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  17307. }\
  17308. ";
  17309. var dom = require("../lib/dom");
  17310. dom.importCssString(exports.cssText, exports.cssClass);
  17311. });
  17312. define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  17313. "use strict";
  17314. var oop = require("./lib/oop");
  17315. var dom = require("./lib/dom");
  17316. var Range = require("./range").Range;
  17317. function LineWidgets(session) {
  17318. this.session = session;
  17319. this.session.widgetManager = this;
  17320. this.session.getRowLength = this.getRowLength;
  17321. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  17322. this.updateOnChange = this.updateOnChange.bind(this);
  17323. this.renderWidgets = this.renderWidgets.bind(this);
  17324. this.measureWidgets = this.measureWidgets.bind(this);
  17325. this.session._changedWidgets = [];
  17326. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  17327. this.session.on("change", this.updateOnChange);
  17328. this.session.on("changeFold", this.updateOnFold);
  17329. this.session.on("changeEditor", this.$onChangeEditor);
  17330. }
  17331. (function() {
  17332. this.getRowLength = function(row) {
  17333. var h;
  17334. if (this.lineWidgets)
  17335. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  17336. else
  17337. h = 0;
  17338. if (!this.$useWrapMode || !this.$wrapData[row]) {
  17339. return 1 + h;
  17340. } else {
  17341. return this.$wrapData[row].length + 1 + h;
  17342. }
  17343. };
  17344. this.$getWidgetScreenLength = function() {
  17345. var screenRows = 0;
  17346. this.lineWidgets.forEach(function(w){
  17347. if (w && w.rowCount && !w.hidden)
  17348. screenRows += w.rowCount;
  17349. });
  17350. return screenRows;
  17351. };
  17352. this.$onChangeEditor = function(e) {
  17353. this.attach(e.editor);
  17354. };
  17355. this.attach = function(editor) {
  17356. if (editor && editor.widgetManager && editor.widgetManager != this)
  17357. editor.widgetManager.detach();
  17358. if (this.editor == editor)
  17359. return;
  17360. this.detach();
  17361. this.editor = editor;
  17362. if (editor) {
  17363. editor.widgetManager = this;
  17364. editor.renderer.on("beforeRender", this.measureWidgets);
  17365. editor.renderer.on("afterRender", this.renderWidgets);
  17366. }
  17367. };
  17368. this.detach = function(e) {
  17369. var editor = this.editor;
  17370. if (!editor)
  17371. return;
  17372. this.editor = null;
  17373. editor.widgetManager = null;
  17374. editor.renderer.off("beforeRender", this.measureWidgets);
  17375. editor.renderer.off("afterRender", this.renderWidgets);
  17376. var lineWidgets = this.session.lineWidgets;
  17377. lineWidgets && lineWidgets.forEach(function(w) {
  17378. if (w && w.el && w.el.parentNode) {
  17379. w._inDocument = false;
  17380. w.el.parentNode.removeChild(w.el);
  17381. }
  17382. });
  17383. };
  17384. this.updateOnFold = function(e, session) {
  17385. var lineWidgets = session.lineWidgets;
  17386. if (!lineWidgets || !e.action)
  17387. return;
  17388. var fold = e.data;
  17389. var start = fold.start.row;
  17390. var end = fold.end.row;
  17391. var hide = e.action == "add";
  17392. for (var i = start + 1; i < end; i++) {
  17393. if (lineWidgets[i])
  17394. lineWidgets[i].hidden = hide;
  17395. }
  17396. if (lineWidgets[end]) {
  17397. if (hide) {
  17398. if (!lineWidgets[start])
  17399. lineWidgets[start] = lineWidgets[end];
  17400. else
  17401. lineWidgets[end].hidden = hide;
  17402. } else {
  17403. if (lineWidgets[start] == lineWidgets[end])
  17404. lineWidgets[start] = undefined;
  17405. lineWidgets[end].hidden = hide;
  17406. }
  17407. }
  17408. };
  17409. this.updateOnChange = function(delta) {
  17410. var lineWidgets = this.session.lineWidgets;
  17411. if (!lineWidgets) return;
  17412. var startRow = delta.start.row;
  17413. var len = delta.end.row - startRow;
  17414. if (len === 0) {
  17415. } else if (delta.action == 'remove') {
  17416. var removed = lineWidgets.splice(startRow + 1, len);
  17417. removed.forEach(function(w) {
  17418. w && this.removeLineWidget(w);
  17419. }, this);
  17420. this.$updateRows();
  17421. } else {
  17422. var args = new Array(len);
  17423. args.unshift(startRow, 0);
  17424. lineWidgets.splice.apply(lineWidgets, args);
  17425. this.$updateRows();
  17426. }
  17427. };
  17428. this.$updateRows = function() {
  17429. var lineWidgets = this.session.lineWidgets;
  17430. if (!lineWidgets) return;
  17431. var noWidgets = true;
  17432. lineWidgets.forEach(function(w, i) {
  17433. if (w) {
  17434. noWidgets = false;
  17435. w.row = i;
  17436. while (w.$oldWidget) {
  17437. w.$oldWidget.row = i;
  17438. w = w.$oldWidget;
  17439. }
  17440. }
  17441. });
  17442. if (noWidgets)
  17443. this.session.lineWidgets = null;
  17444. };
  17445. this.addLineWidget = function(w) {
  17446. if (!this.session.lineWidgets)
  17447. this.session.lineWidgets = new Array(this.session.getLength());
  17448. var old = this.session.lineWidgets[w.row];
  17449. if (old) {
  17450. w.$oldWidget = old;
  17451. if (old.el && old.el.parentNode) {
  17452. old.el.parentNode.removeChild(old.el);
  17453. old._inDocument = false;
  17454. }
  17455. }
  17456. this.session.lineWidgets[w.row] = w;
  17457. w.session = this.session;
  17458. var renderer = this.editor.renderer;
  17459. if (w.html && !w.el) {
  17460. w.el = dom.createElement("div");
  17461. w.el.innerHTML = w.html;
  17462. }
  17463. if (w.el) {
  17464. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  17465. w.el.style.position = "absolute";
  17466. w.el.style.zIndex = 5;
  17467. renderer.container.appendChild(w.el);
  17468. w._inDocument = true;
  17469. }
  17470. if (!w.coverGutter) {
  17471. w.el.style.zIndex = 3;
  17472. }
  17473. if (w.pixelHeight == null) {
  17474. w.pixelHeight = w.el.offsetHeight;
  17475. }
  17476. if (w.rowCount == null) {
  17477. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  17478. }
  17479. var fold = this.session.getFoldAt(w.row, 0);
  17480. w.$fold = fold;
  17481. if (fold) {
  17482. var lineWidgets = this.session.lineWidgets;
  17483. if (w.row == fold.end.row && !lineWidgets[fold.start.row])
  17484. lineWidgets[fold.start.row] = w;
  17485. else
  17486. w.hidden = true;
  17487. }
  17488. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  17489. this.$updateRows();
  17490. this.renderWidgets(null, renderer);
  17491. this.onWidgetChanged(w);
  17492. return w;
  17493. };
  17494. this.removeLineWidget = function(w) {
  17495. w._inDocument = false;
  17496. w.session = null;
  17497. if (w.el && w.el.parentNode)
  17498. w.el.parentNode.removeChild(w.el);
  17499. if (w.editor && w.editor.destroy) try {
  17500. w.editor.destroy();
  17501. } catch(e){}
  17502. if (this.session.lineWidgets) {
  17503. var w1 = this.session.lineWidgets[w.row];
  17504. if (w1 == w) {
  17505. this.session.lineWidgets[w.row] = w.$oldWidget;
  17506. if (w.$oldWidget)
  17507. this.onWidgetChanged(w.$oldWidget);
  17508. } else {
  17509. while (w1) {
  17510. if (w1.$oldWidget == w) {
  17511. w1.$oldWidget = w.$oldWidget;
  17512. break;
  17513. }
  17514. w1 = w1.$oldWidget;
  17515. }
  17516. }
  17517. }
  17518. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  17519. this.$updateRows();
  17520. };
  17521. this.getWidgetsAtRow = function(row) {
  17522. var lineWidgets = this.session.lineWidgets;
  17523. var w = lineWidgets && lineWidgets[row];
  17524. var list = [];
  17525. while (w) {
  17526. list.push(w);
  17527. w = w.$oldWidget;
  17528. }
  17529. return list;
  17530. };
  17531. this.onWidgetChanged = function(w) {
  17532. this.session._changedWidgets.push(w);
  17533. this.editor && this.editor.renderer.updateFull();
  17534. };
  17535. this.measureWidgets = function(e, renderer) {
  17536. var changedWidgets = this.session._changedWidgets;
  17537. var config = renderer.layerConfig;
  17538. if (!changedWidgets || !changedWidgets.length) return;
  17539. var min = Infinity;
  17540. for (var i = 0; i < changedWidgets.length; i++) {
  17541. var w = changedWidgets[i];
  17542. if (!w || !w.el) continue;
  17543. if (w.session != this.session) continue;
  17544. if (!w._inDocument) {
  17545. if (this.session.lineWidgets[w.row] != w)
  17546. continue;
  17547. w._inDocument = true;
  17548. renderer.container.appendChild(w.el);
  17549. }
  17550. w.h = w.el.offsetHeight;
  17551. if (!w.fixedWidth) {
  17552. w.w = w.el.offsetWidth;
  17553. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  17554. }
  17555. var rowCount = w.h / config.lineHeight;
  17556. if (w.coverLine) {
  17557. rowCount -= this.session.getRowLineCount(w.row);
  17558. if (rowCount < 0)
  17559. rowCount = 0;
  17560. }
  17561. if (w.rowCount != rowCount) {
  17562. w.rowCount = rowCount;
  17563. if (w.row < min)
  17564. min = w.row;
  17565. }
  17566. }
  17567. if (min != Infinity) {
  17568. this.session._emit("changeFold", {data:{start:{row: min}}});
  17569. this.session.lineWidgetWidth = null;
  17570. }
  17571. this.session._changedWidgets = [];
  17572. };
  17573. this.renderWidgets = function(e, renderer) {
  17574. var config = renderer.layerConfig;
  17575. var lineWidgets = this.session.lineWidgets;
  17576. if (!lineWidgets)
  17577. return;
  17578. var first = Math.min(this.firstRow, config.firstRow);
  17579. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  17580. while (first > 0 && !lineWidgets[first])
  17581. first--;
  17582. this.firstRow = config.firstRow;
  17583. this.lastRow = config.lastRow;
  17584. renderer.$cursorLayer.config = config;
  17585. for (var i = first; i <= last; i++) {
  17586. var w = lineWidgets[i];
  17587. if (!w || !w.el) continue;
  17588. if (w.hidden) {
  17589. w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
  17590. continue;
  17591. }
  17592. if (!w._inDocument) {
  17593. w._inDocument = true;
  17594. renderer.container.appendChild(w.el);
  17595. }
  17596. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  17597. if (!w.coverLine)
  17598. top += config.lineHeight * this.session.getRowLineCount(w.row);
  17599. w.el.style.top = top - config.offset + "px";
  17600. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  17601. if (!w.fixedWidth)
  17602. left -= renderer.scrollLeft;
  17603. w.el.style.left = left + "px";
  17604. if (w.fullWidth && w.screenWidth) {
  17605. w.el.style.minWidth = config.width + 2 * config.padding + "px";
  17606. }
  17607. if (w.fixedWidth) {
  17608. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  17609. } else {
  17610. w.el.style.right = "";
  17611. }
  17612. }
  17613. };
  17614. }).call(LineWidgets.prototype);
  17615. exports.LineWidgets = LineWidgets;
  17616. });
  17617. define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  17618. "use strict";
  17619. var LineWidgets = require("../line_widgets").LineWidgets;
  17620. var dom = require("../lib/dom");
  17621. var Range = require("../range").Range;
  17622. function binarySearch(array, needle, comparator) {
  17623. var first = 0;
  17624. var last = array.length - 1;
  17625. while (first <= last) {
  17626. var mid = (first + last) >> 1;
  17627. var c = comparator(needle, array[mid]);
  17628. if (c > 0)
  17629. first = mid + 1;
  17630. else if (c < 0)
  17631. last = mid - 1;
  17632. else
  17633. return mid;
  17634. }
  17635. return -(first + 1);
  17636. }
  17637. function findAnnotations(session, row, dir) {
  17638. var annotations = session.getAnnotations().sort(Range.comparePoints);
  17639. if (!annotations.length)
  17640. return;
  17641. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  17642. if (i < 0)
  17643. i = -i - 1;
  17644. if (i >= annotations.length)
  17645. i = dir > 0 ? 0 : annotations.length - 1;
  17646. else if (i === 0 && dir < 0)
  17647. i = annotations.length - 1;
  17648. var annotation = annotations[i];
  17649. if (!annotation || !dir)
  17650. return;
  17651. if (annotation.row === row) {
  17652. do {
  17653. annotation = annotations[i += dir];
  17654. } while (annotation && annotation.row === row);
  17655. if (!annotation)
  17656. return annotations.slice();
  17657. }
  17658. var matched = [];
  17659. row = annotation.row;
  17660. do {
  17661. matched[dir < 0 ? "unshift" : "push"](annotation);
  17662. annotation = annotations[i += dir];
  17663. } while (annotation && annotation.row == row);
  17664. return matched.length && matched;
  17665. }
  17666. exports.showErrorMarker = function(editor, dir) {
  17667. var session = editor.session;
  17668. if (!session.widgetManager) {
  17669. session.widgetManager = new LineWidgets(session);
  17670. session.widgetManager.attach(editor);
  17671. }
  17672. var pos = editor.getCursorPosition();
  17673. var row = pos.row;
  17674. var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
  17675. return w.type == "errorMarker";
  17676. })[0];
  17677. if (oldWidget) {
  17678. oldWidget.destroy();
  17679. } else {
  17680. row -= dir;
  17681. }
  17682. var annotations = findAnnotations(session, row, dir);
  17683. var gutterAnno;
  17684. if (annotations) {
  17685. var annotation = annotations[0];
  17686. pos.column = (annotation.pos && typeof annotation.column != "number"
  17687. ? annotation.pos.sc
  17688. : annotation.column) || 0;
  17689. pos.row = annotation.row;
  17690. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  17691. } else if (oldWidget) {
  17692. return;
  17693. } else {
  17694. gutterAnno = {
  17695. text: ["Looks good!"],
  17696. className: "ace_ok"
  17697. };
  17698. }
  17699. editor.session.unfold(pos.row);
  17700. editor.selection.moveToPosition(pos);
  17701. var w = {
  17702. row: pos.row,
  17703. fixedWidth: true,
  17704. coverGutter: true,
  17705. el: dom.createElement("div"),
  17706. type: "errorMarker"
  17707. };
  17708. var el = w.el.appendChild(dom.createElement("div"));
  17709. var arrow = w.el.appendChild(dom.createElement("div"));
  17710. arrow.className = "error_widget_arrow " + gutterAnno.className;
  17711. var left = editor.renderer.$cursorLayer
  17712. .getPixelPosition(pos).left;
  17713. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  17714. w.el.className = "error_widget_wrapper";
  17715. el.className = "error_widget " + gutterAnno.className;
  17716. el.innerHTML = gutterAnno.text.join("<br>");
  17717. el.appendChild(dom.createElement("div"));
  17718. var kb = function(_, hashId, keyString) {
  17719. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  17720. w.destroy();
  17721. return {command: "null"};
  17722. }
  17723. };
  17724. w.destroy = function() {
  17725. if (editor.$mouseHandler.isMousePressed)
  17726. return;
  17727. editor.keyBinding.removeKeyboardHandler(kb);
  17728. session.widgetManager.removeLineWidget(w);
  17729. editor.off("changeSelection", w.destroy);
  17730. editor.off("changeSession", w.destroy);
  17731. editor.off("mouseup", w.destroy);
  17732. editor.off("change", w.destroy);
  17733. };
  17734. editor.keyBinding.addKeyboardHandler(kb);
  17735. editor.on("changeSelection", w.destroy);
  17736. editor.on("changeSession", w.destroy);
  17737. editor.on("mouseup", w.destroy);
  17738. editor.on("change", w.destroy);
  17739. editor.session.widgetManager.addLineWidget(w);
  17740. w.el.onmousedown = editor.focus.bind(editor);
  17741. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  17742. };
  17743. dom.importCssString("\
  17744. .error_widget_wrapper {\
  17745. background: inherit;\
  17746. color: inherit;\
  17747. border:none\
  17748. }\
  17749. .error_widget {\
  17750. border-top: solid 2px;\
  17751. border-bottom: solid 2px;\
  17752. margin: 5px 0;\
  17753. padding: 10px 40px;\
  17754. white-space: pre-wrap;\
  17755. }\
  17756. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  17757. border-color: #ff5a5a\
  17758. }\
  17759. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  17760. border-color: #F1D817\
  17761. }\
  17762. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  17763. border-color: #5a5a5a\
  17764. }\
  17765. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  17766. border-color: #5aaa5a\
  17767. }\
  17768. .error_widget_arrow {\
  17769. position: absolute;\
  17770. border: solid 5px;\
  17771. border-top-color: transparent!important;\
  17772. border-right-color: transparent!important;\
  17773. border-left-color: transparent!important;\
  17774. top: -5px;\
  17775. }\
  17776. ", "");
  17777. });
  17778. 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) {
  17779. "use strict";
  17780. require("./lib/fixoldbrowsers");
  17781. var dom = require("./lib/dom");
  17782. var event = require("./lib/event");
  17783. var Editor = require("./editor").Editor;
  17784. var EditSession = require("./edit_session").EditSession;
  17785. var UndoManager = require("./undomanager").UndoManager;
  17786. var Renderer = require("./virtual_renderer").VirtualRenderer;
  17787. require("./worker/worker_client");
  17788. require("./keyboard/hash_handler");
  17789. require("./placeholder");
  17790. require("./multi_select");
  17791. require("./mode/folding/fold_mode");
  17792. require("./theme/textmate");
  17793. require("./ext/error_marker");
  17794. exports.config = require("./config");
  17795. exports.require = require;
  17796. if (typeof define === "function")
  17797. exports.define = define;
  17798. exports.edit = function(el) {
  17799. if (typeof el == "string") {
  17800. var _id = el;
  17801. el = document.getElementById(_id);
  17802. if (!el)
  17803. throw new Error("ace.edit can't find div #" + _id);
  17804. }
  17805. if (el && el.env && el.env.editor instanceof Editor)
  17806. return el.env.editor;
  17807. var value = "";
  17808. if (el && /input|textarea/i.test(el.tagName)) {
  17809. var oldNode = el;
  17810. value = oldNode.value;
  17811. el = dom.createElement("pre");
  17812. oldNode.parentNode.replaceChild(el, oldNode);
  17813. } else if (el) {
  17814. value = dom.getInnerText(el);
  17815. el.innerHTML = "";
  17816. }
  17817. var doc = exports.createEditSession(value);
  17818. var editor = new Editor(new Renderer(el));
  17819. editor.setSession(doc);
  17820. var env = {
  17821. document: doc,
  17822. editor: editor,
  17823. onResize: editor.resize.bind(editor, null)
  17824. };
  17825. if (oldNode) env.textarea = oldNode;
  17826. event.addListener(window, "resize", env.onResize);
  17827. editor.on("destroy", function() {
  17828. event.removeListener(window, "resize", env.onResize);
  17829. env.editor.container.env = null; // prevent memory leak on old ie
  17830. });
  17831. editor.container.env = editor.env = env;
  17832. return editor;
  17833. };
  17834. exports.createEditSession = function(text, mode) {
  17835. var doc = new EditSession(text, mode);
  17836. doc.setUndoManager(new UndoManager());
  17837. return doc;
  17838. };
  17839. exports.EditSession = EditSession;
  17840. exports.UndoManager = UndoManager;
  17841. exports.version = "1.2.9";
  17842. });
  17843. (function() {
  17844. window.require(["ace/ace"], function(a) {
  17845. if (a) {
  17846. a.config.init(true);
  17847. a.define = window.define;
  17848. }
  17849. if (!window.ace)
  17850. window.ace = a;
  17851. for (var key in a) if (a.hasOwnProperty(key))
  17852. window.ace[key] = a[key];
  17853. });
  17854. })();