maxide.bmx 201 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521
  1. ' maxide.bmx
  2. ' BlitzMax native integrated development environment
  3. ' Copyright (c) 2005-2014 Simon Armstrong, Blitz Research Limited
  4. ' Permission is hereby granted, free of charge, to any person obtaining a copy
  5. ' of this software and associated documentation files (the "Software"), to deal
  6. ' in the Software without restriction, including without limitation the rights
  7. ' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. ' copies of the Software, and to permit persons to whom the Software is
  9. ' furnished to do so, subject to the following conditions:
  10. '
  11. ' The above copyright notice and this permission notice shall be included in
  12. ' all copies or substantial portions of the Software.
  13. '
  14. ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. ' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. ' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. ' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. ' THE SOFTWARE.
  21. Strict
  22. Framework brl.standardio
  23. ?macos
  24. Import MaxGUI.CocoaMaxGui
  25. ?win32
  26. Import MaxGUI.Win32MaxGUIEx
  27. ?linux
  28. Import gtk.gtk3maxgui
  29. Import gtk.gtk3webkitgtk
  30. Import gtk.maxguitextareascintilla
  31. ?
  32. Import MaxGUI.ProxyGadgets
  33. '?Win32x86
  34. 'Import "maxicons.o"
  35. '?Win32x64
  36. 'Import "maxicons64.o"
  37. '?
  38. Import brl.eventqueue
  39. Import brl.filesystem
  40. Import brl.system
  41. Import brl.ramstream
  42. Import pub.freeprocess
  43. Import brl.pngloader
  44. Import brl.timer
  45. ?bmxng
  46. Import brl.timerdefault
  47. ?
  48. Import brl.maxutil
  49. Incbin "bmxlogo.png"
  50. Incbin "toolbar.png"
  51. Incbin "toolbar_48.png"
  52. Incbin "toolbar_64.png"
  53. Incbin "splash.png"
  54. Incbin "default.language.ini"
  55. Const DEFAULT_LANGUAGEPATH$ = "incbin::default.language.ini"
  56. ?Linux
  57. Incbin "window_icon.png"
  58. ?
  59. Const IDE_VERSION$="1.44 beta [ng]"
  60. Const TIMER_FREQUENCY=15
  61. AppTitle = "MaxIDE "+IDE_VERSION
  62. ?Win32
  63. Extern
  64. Global _bbusew 'secret 'NT' flag
  65. End Extern
  66. If Not _bbusew
  67. Notify..
  68. "This program is not compatible with Windows 95/98/ME.~n~n"+..
  69. "Please visit www.blitzbasic.com to download a compatible version.",True
  70. End
  71. EndIf
  72. ?
  73. Global BCC_VERSION$="{unknown}" 'not valid until codeplay opened
  74. Const EOL$="~n"
  75. Const ABOUT$=..
  76. "{bcc_version} - Copyright Blitz Research Ltd.~n~n"+..
  77. "Please visit www.blitzbasic.com for all your Blitz related needs!"
  78. Const ABOUTDEMO$=..
  79. "This demo features both the core BlitzMax package and optional MaxGUI module.~n~n"+..
  80. "Please note that the MaxGUI module must be purchased separately."
  81. Const FileTypes$="bmx,bbdoc,txt,ini,doc,plist,bb,cpp,c,cc,m,cxx,s,glsl,hlsl,lua,py,h,hpp,html,htm,css,js,bat,sh,mm,as,java,bbx,cx"
  82. Const FileTypeFilters$="Code Files:"+FileTypes$+";All Files:*"
  83. Const HOMEPAGE$="/docs/html/index.html"
  84. ?MacOS
  85. Global SVNCMD$="/usr/local/bin/svn"
  86. Const LABELOFFSET=2
  87. ?Win32
  88. Global SVNCMD$="svn"
  89. Const LABELOFFSET=4
  90. ?Linux
  91. Global SVNCMD$="/usr/bin/svn"
  92. Const LABELOFFSET=0
  93. ?
  94. Const MENUNEW=1
  95. Const MENUOPEN=2
  96. Const MENUCLOSE=3
  97. Const MENUSAVE=4
  98. Const MENUSAVEAS=5
  99. Const MENUSAVEALL=6
  100. Const MENUPRINT=7
  101. Const MENUQUIT=8
  102. Const MENUUNDO=9
  103. Const MENUREDO=10
  104. Const MENUCUT=11
  105. Const MENUCOPY=12
  106. Const MENUPASTE=13
  107. Const MENUSELECTALL=14
  108. Const MENUGOTO=15
  109. Const MENUINDENT=16
  110. Const MENUOUTDENT=17
  111. Const MENUFIND=18
  112. Const MENUFINDNEXT=19
  113. Const MENUREPLACE=20
  114. Const MENUNEXT=21
  115. Const MENUPREV=22
  116. Const MENUBUILD=23
  117. Const MENURUN=24
  118. Const MENUSTEP=25
  119. Const MENUSTEPIN=26
  120. Const MENUSTEPOUT=27
  121. Const MENUSTOP=28
  122. Const MENULOCKBUILD=29
  123. Const MENUUNLOCKBUILD=30
  124. Const MENUBUILDMODULES=31
  125. Const MENUBUILDALLMODULES=32
  126. Const MENUQUICKENABLED=33
  127. Const MENUDEBUGENABLED=34
  128. 'Const MENUGUIENABLED=35
  129. Const MENUCOMMANDLINE=36
  130. 'Const MENUSYNCMODS=37
  131. Const MENUIMPORTBB=38
  132. Const MENUFINDINFILES=39
  133. Const MENUPROJECTMANAGER=40
  134. Const MENUSHOWCONSOLE=41
  135. Const MENUOPTIONS=42
  136. Const MENUHOME=43
  137. Const MENUBACK=44
  138. Const MENUFORWARD=45
  139. Const MENUQUICKHELP=46
  140. Const MENUABOUT=47
  141. Const MENUNEWVIEW=48
  142. Const MENUDOCMODS=49
  143. Const MENUTRIGGERDOCMODS=50
  144. Const MENUTRIGGERSYNCDOCS=51
  145. Const MENUCLOSEALL=53
  146. Const MENUREFRESH=54
  147. Const MENUBROWSE=55
  148. Const MENUSHELL=56
  149. Const MENUPROPS=57
  150. Const MENUUPDATE=58
  151. Const MENUCOMMIT=59
  152. Const MENUCLOSEOTHERS=60
  153. Const MENUTHREADEDENABLED=61
  154. Const MENUVERBOSEENABLED=62
  155. Const MENUQUICKSCANENABLED=63
  156. Const MENUUNIVERSALENABLED=64
  157. Const MENUWARNOVERENABLED=65
  158. Const MENUGDBDEBUGENABLED=66
  159. Const MENUAPPOPTIONS=70
  160. Const MENUCONSOLEENABLED=71
  161. Const MENUGUIENABLED=72
  162. Const MENUMAKELIBENABLED=73
  163. Const MENUPLATFORM=80
  164. Const MENUWIN32ENABLED=81
  165. Const MENULINUXENABLED=82
  166. Const MENUMACOSXENABLED=83
  167. Const MENURASPBERRYPIENABLED=84
  168. Const MENUANDROIDENABLED=85
  169. Const MENUEMSCRIPTENENABLED=86
  170. Const MENUIOSENABLED=87
  171. Const MENUNXENABLED=88
  172. Const MENUARCHITECTURE=90
  173. Const MENUX86ENABLED=91
  174. Const MENUX64ENABLED=92
  175. Const MENUPPCENABLED=93
  176. Const MENUARMENABLED=94
  177. Const MENUARMEABIV5ENABLED=95
  178. Const MENUARMEABIV7AENABLED=96
  179. Const MENUARM64V8AENABLED=97
  180. Const MENUJSENABLED=98
  181. Const MENUARMV7ENABLED=99
  182. Const MENUARM64ENABLED=100
  183. Const MENUAPPSTUB=160
  184. Const MENURECENT=256
  185. Const TB_NEW=0
  186. Const TB_OPEN=1
  187. Const TB_CLOSE=2
  188. Const TB_SAVE=3
  189. Const TB_CUT=5
  190. Const TB_COPY=6
  191. Const TB_PASTE=7
  192. Const TB_FIND=8
  193. Const TB_BUILD=10
  194. Const TB_BUILDRUN=11
  195. Const TB_STEP=12
  196. Const TB_STEPIN=13
  197. Const TB_STEPOUT=14
  198. Const TB_STOP=15
  199. Const TB_HOME=17
  200. Const TB_BACK=18
  201. Const TB_FORWARDS=19
  202. Const TB_CONTINUE=20
  203. Const TAB$=Chr(9)
  204. Const QUOTES$=Chr(34)
  205. Global TEMPCOUNT
  206. Global is_demo
  207. Global codeplay:TCodePlay
  208. Function CheckDemo()
  209. If Not is_demo Return 1
  210. Notify LocalizeString("{{notify_demo_featureunavailable}}")
  211. Return 0
  212. End Function
  213. Global defaultLanguage:TMaxGUILanguage = LoadLanguage( DEFAULT_LANGUAGEPATH )
  214. SetLocalizationLanguage( defaultLanguage )
  215. SetLocalizationMode( LOCALIZATION_ON|LOCALIZATION_OVERRIDE )
  216. codeplay=New TCodePlay
  217. codeplay.Initialize
  218. While codeplay.running
  219. codeplay.poll
  220. Wend
  221. End
  222. Function Quote$(a$) 'add quotes to arg if spaces found
  223. Local p
  224. If Not a.length Return
  225. If a[0]=34 Return a 'already quoted
  226. p=a.find(" ")
  227. If p=-1 Return a 'no spaces
  228. Return Chr(34)+a+Chr(34)
  229. End Function
  230. Type TToken
  231. Field token$
  232. Field help$
  233. Field ref$
  234. Method Create:TToken(t$,h$,r$)
  235. token=t
  236. help=h
  237. ref=r
  238. Return Self
  239. End Method
  240. End Type
  241. Type TQuickHelp
  242. Field map:TMap=New TMap 'key=lower(token) value=token:TToken
  243. Method AddCommand:TQuickHelp(t$,l$,a$)
  244. map.Insert t.ToLower(),New TToken.Create(t$,l$,a$)
  245. End Method
  246. Method Token$(cmd$)
  247. Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
  248. If t Return t.token
  249. End Method
  250. Method Help$(cmd$)
  251. Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
  252. If t Return t.help
  253. End Method
  254. Method Link$(cmd$)
  255. Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
  256. If t Return t.ref
  257. End Method
  258. Function LoadCommandsTxt:TQuickHelp(bmxpath$)
  259. Local Text$
  260. Local qh:TQuickHelp
  261. Local i:Int,c,p,q
  262. Local token$,help$,anchor$
  263. Try
  264. Text=CacheAndLoadText(bmxpath+"/docs/html/Modules/commands.txt")
  265. Catch exception:Object
  266. Return Null
  267. EndTry
  268. If Not Text Return Null
  269. qh=New TQuickHelp
  270. For Local l$ = EachIn Text.Split("~n")
  271. For i=0 Until l.length
  272. c=l[i]
  273. If c=Asc("_") Continue
  274. If c>=Asc("0") And c<=Asc("9") Continue
  275. If c>=Asc("a") And c<=Asc("z") Continue
  276. If c>=Asc("A") And c<=Asc("Z") Continue
  277. Exit
  278. Next
  279. token$=l[..i]
  280. help$=""
  281. anchor$=""
  282. q=l.findlast("|")
  283. If q>=0
  284. help=l[..q]
  285. anchor=l[q+1..]
  286. EndIf
  287. qh.AddCommand token,help,anchor
  288. Next
  289. Return qh
  290. End Function
  291. End Type
  292. Const TOOLSHOW=1
  293. Const TOOLREFRESH=2
  294. Const TOOLNEW=3
  295. Const TOOLOPEN=4
  296. Const TOOLCLOSE=5
  297. Const TOOLSAVE=6
  298. Const TOOLHELP=7
  299. Const TOOLUNDO=8
  300. Const TOOLREDO=9
  301. Const TOOLCUT=10
  302. Const TOOLCOPY=11
  303. Const TOOLPASTE=12
  304. Const TOOLQUICKSAVE=13
  305. Const TOOLSAVEAS=14
  306. Const TOOLGOTO=15
  307. Const TOOLFIND=16
  308. Const TOOLFINDNEXT=17
  309. Const TOOLREPLACE=18
  310. Const TOOLBUILD=19
  311. Const TOOLRUN=20
  312. Const TOOLLOCK=21
  313. Const TOOLUNLOCK=22
  314. Const TOOLSELECT=23
  315. Const TOOLSELECTALL=24
  316. Const TOOLINDENT=25
  317. Const TOOLOUTDENT=26
  318. Const TOOLACTIVATE=27
  319. Const TOOLNAVIGATE=28
  320. Const TOOLNEWVIEW=29
  321. Const TOOLMENU=30
  322. Const TOOLPRINT=31
  323. Const TOOLERROR=32
  324. Const TOOLOUTPUT=32
  325. Type TTool
  326. Method Invoke(command,argument:Object=Null)
  327. End Method
  328. End Type
  329. Type TRequester
  330. Const STYLE_OK% = 1, STYLE_CANCEL% = 2
  331. Const STYLE_DIVIDER% = 4, STYLE_STATUS% = 8
  332. Const STYLE_RESIZABLE% = 16, STYLE_STDBORDER% = 32
  333. Const STYLE_MODAL% = 64
  334. Field host:TCodePlay
  335. Field window:TGadget,ok:TGadget,cancel:TGadget,divider:TGadget
  336. Field centered, modal
  337. Method initrequester(owner:TCodeplay,label$,w=260,h=60,flags=STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER,oktext$="{{btn_ok}}")
  338. host=owner
  339. If (flags&STYLE_MODAL) Then flags:|STYLE_STDBORDER
  340. If (flags & (STYLE_CANCEL|STYLE_OK)) Then h:+ScaledSize(32);If (flags&STYLE_DIVIDER) Then h:+ScaledSize(12)
  341. Local windowflags% = WINDOW_TITLEBAR|WINDOW_HIDDEN|WINDOW_CLIENTCOORDS
  342. If (flags & STYLE_STATUS) Then windowflags:|WINDOW_STATUS
  343. If (flags & STYLE_RESIZABLE) Then windowflags:|WINDOW_RESIZABLE
  344. If Not (flags & STYLE_STDBORDER) Then windowflags:|WINDOW_TOOL
  345. window=CreateWindow(label,0,0,w,h,host.window,windowflags)
  346. If (flags & STYLE_RESIZABLE) Then
  347. If (flags & STYLE_STDBORDER) Then SetMaxWindowSize(window,ClientWidth(Desktop()),ClientHeight(Desktop()))
  348. SetMinWindowSize(window,w,h)
  349. EndIf
  350. If (flags & STYLE_OK) Then
  351. ok=CreateButton(oktext,ClientWidth(window)-ScaledSize(101),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_OK)
  352. SetGadgetLayout(ok,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
  353. If (flags & STYLE_CANCEL) Then
  354. cancel=CreateButton("{{btn_cancel}}",ScaledSize(6),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_CANCEL)
  355. SetGadgetLayout(cancel,EDGE_ALIGNED,EDGE_CENTERED,EDGE_CENTERED,EDGE_ALIGNED)
  356. EndIf
  357. Else
  358. If (flags & STYLE_CANCEL) Then
  359. cancel=CreateButton("{{btn_close}}",ClientWidth(window)-ScaledSize(101),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_CANCEL)
  360. SetGadgetLayout(cancel,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
  361. EndIf
  362. EndIf
  363. If (flags & STYLE_DIVIDER) And (flags & (STYLE_OK|STYLE_CANCEL)) Then
  364. divider = CreateLabel( "", ScaledSize(6), ClientHeight(window)-ScaledSize(42), ClientWidth(window)-ScaledSize(12), ScaledSize(4), window, LABEL_SEPARATOR )
  365. SetGadgetLayout(divider,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
  366. EndIf
  367. If (flags & STYLE_MODAL) Then modal = True Else modal = False
  368. End Method
  369. Method Show()
  370. Local x,y,w,h,win:TGadget
  371. If Not centered
  372. win=host.window
  373. w=GadgetWidth(window)
  374. h=GadgetHeight(window)
  375. x=GadgetX(win)+(GadgetWidth(win)-w)/2
  376. y=GadgetY(win)+(GadgetHeight(win)-h)/2
  377. SetGadgetShape window,x,y,w,h
  378. centered=True
  379. EndIf
  380. host.HookRequester Self
  381. ShowGadget window
  382. ActivateGadget window
  383. PollSystem
  384. End Method
  385. Method Hide()
  386. EnableGadget host.window
  387. HideGadget window
  388. host.UnhookRequester Self
  389. host.SelectPanel host.currentpanel
  390. End Method
  391. Method IsModal()
  392. Return modal
  393. EndMethod
  394. Method Poll()
  395. End Method
  396. End Type
  397. Rem
  398. Type TProgressRequester Extends TRequester
  399. Field message$,value
  400. Field showing
  401. Field label:TGadget
  402. Field progbar:TGadget
  403. Method Show() 'returns false if cancelled
  404. showing=True
  405. Super.Show
  406. End Method
  407. Method Hide()
  408. showing=False
  409. Super.Hide()
  410. End Method
  411. Method Open(title$)
  412. SetGadgetText window,title
  413. Show
  414. End Method
  415. Method Update(msg$,val)
  416. If msg$<>message
  417. message=msg
  418. If label FreeGadget label
  419. label=CreateLabel(message,8,8,260,20,window)
  420. EndIf
  421. If showing And (val&$fc)<>(value&$fc) 'only update every 4 percent
  422. UpdateProgBar( progbar,val/100.0 )
  423. PollSystem
  424. EndIf
  425. value=val
  426. End Method
  427. Function Create:TProgressRequester(host:TCodePlay)
  428. Local progress:TProgressRequester
  429. progress=New TProgressRequester
  430. progress.initrequester(host,"{{progress_window_title}}",280,128,STYLE_CANCEL)
  431. progress.progbar=CreateProgBar( 8,32,260,20,progress.window )
  432. Return progress
  433. End Function
  434. End Type
  435. EndRem
  436. Type TPanelRequester Extends TRequester
  437. Field tabber:TGadget
  438. Field panels:TGadget[]
  439. Field index
  440. Method InitPanelRequester(owner:TCodeplay,label$,w=280,h=128)
  441. InitRequester owner,label,w,h,STYLE_OK|STYLE_CANCEL|STYLE_STDBORDER|STYLE_MODAL
  442. tabber=CreateTabber(ScaledSize(6),ScaledSize(6),w-ScaledSize(12),h-ScaledSize(12),window)
  443. SetGadgetLayout tabber,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  444. End Method
  445. Method SetPanelIndex(i)
  446. HideGadget panels[index]
  447. index=i
  448. ShowGadget panels[index]
  449. SelectGadgetItem tabber,index
  450. End Method
  451. Method SetPanel(panel:TGadget)
  452. Local i
  453. For Local p:TGadget = EachIn panels
  454. If p=panel SetPanelIndex i;Exit
  455. i:+1
  456. Next
  457. End Method
  458. Method AddPanel:TGadget(name$)
  459. Local panel:TGadget
  460. panel=CreatePanel(0,0,ClientWidth(tabber),ClientHeight(tabber),tabber)
  461. SetGadgetLayout panel,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  462. HideGadget panel
  463. AddGadgetItem tabber,name,GADGETITEM_LOCALIZED
  464. panels=panels[..panels.length+1]
  465. panels[panels.length-1]=panel
  466. Return panel
  467. End Method
  468. Method RemovePanel(panel)
  469. End Method
  470. End Type
  471. Type TAboutRequester Extends TRequester
  472. Global pixLogo:TPixmap
  473. Field pnlLogo:TGadget, lblTitle:TGadget, lblSubtitle:TGadget
  474. Field lblLeftAligned:TGadget[], lblRightAligned:TGadget[]
  475. Field hypBlitz:TGadget
  476. Method PopulateText()
  477. Local strHeadings$[], strValues$[]
  478. strHeadings:+["{{about_label_bccver}}:"]
  479. strValues:+[BCC_VERSION]
  480. strHeadings:+["{{about_label_bmkver}}:"]
  481. strValues:+[GetBMK()]
  482. strHeadings:+[""]
  483. strValues:+[""]
  484. strHeadings:+["{{about_label_bmxpath}}:"]
  485. ?Win32
  486. strValues:+[BlitzMaxPath().Replace("/","\")]
  487. ?Not Win32
  488. strValues:+[BlitzMaxPath()]
  489. ?
  490. ?Win32
  491. strHeadings:+["{{about_label_mingwpath}}:"]
  492. ' check For Local mingw32 dir First
  493. If FileType(BlitzMaxPath() + "/MinGW32") = FILETYPE_DIR Then
  494. strValues:+[(BlitzMaxPath() + "/MinGW32").Replace("/","\")]
  495. Else If getenv_("MINGW") Then
  496. strValues:+[getenv_("MINGW")]
  497. Else
  498. strValues:+[LocalizeString("{{about_error_unavailable}}")]
  499. EndIf
  500. ?
  501. strHeadings:+[""]
  502. strValues:+[""]
  503. ?Not MacOS
  504. strHeadings:+["{{about_label_fasmver}}:"]
  505. strValues:+[GetFASM()]
  506. ?
  507. strHeadings:+["{{about_label_gccver}}:"]
  508. strValues:+[GetGCC()]
  509. strHeadings:+["{{about_label_gplusplusver}}:"]
  510. strValues:+[GetGpp()]
  511. PopulateColumns( strHeadings, strValues )
  512. EndMethod
  513. Function GetProcessOutput$(cmd$, flags$ = "")
  514. Local version$
  515. ?Win32
  516. cmd:+".exe"
  517. ?
  518. cmd=Quote(cmd)
  519. If flags Then cmd:+" "+flags
  520. Local process:TProcess = CreateProcess(cmd,HIDECONSOLE)
  521. If process
  522. Local bytes:Byte[]
  523. Local tmpTimeout:Int = MilliSecs() + 500
  524. Repeat
  525. Delay 10
  526. bytes=process.pipe.ReadPipe()
  527. If bytes
  528. version:+String.FromBytes(bytes,bytes.length)
  529. EndIf
  530. Until (Not process.status()) Or (MilliSecs() > tmpTimeout)
  531. process.Close()
  532. Return version.Trim().Replace("~r","")
  533. EndIf
  534. Return LocalizeString("{{about_error_unavailable}}")
  535. EndFunction
  536. Method GetFASM$()
  537. ?Not MacOS
  538. Local tmpSections$[] = GetProcessOutput(BlitzMaxPath()+"/bin/fasm").Split("~n")[0].Split(" ")
  539. Return tmpSections[tmpSections.length-1]
  540. ?
  541. EndMethod
  542. Method GetBMK$()
  543. Local tmpSections$[] = GetProcessOutput(BlitzMaxPath()+"/bin/bmk", "-v").Split("~n")
  544. Return tmpSections[tmpSections.length-1]
  545. EndMethod
  546. Method GetGCC$()
  547. ?Win32
  548. Local gccPath:String = BlitzMaxPath() + "/MinGW32"
  549. If Not FileType(gccPath) Then
  550. gccPath = getenv_("MinGW")
  551. If Not gccPath Then Return LocalizeString("{{about_error_notapplicable}}")
  552. End If
  553. gccPath :+ "/bin/gcc"
  554. gccPath = gccPath.Replace("/", "\")
  555. ? Not win32
  556. Local gccPath:String = "gcc"
  557. ?
  558. Return GetProcessOutput(gccPath, "-dumpversion").Split("~n")[0]
  559. EndMethod
  560. Method GetGpp$()
  561. ?Win32
  562. Local gppPath:String = BlitzMaxPath() + "/MinGW32"
  563. If Not FileType(gppPath) Then
  564. gppPath = getenv_("MinGW")
  565. If Not gppPath Then Return LocalizeString("{{about_error_notapplicable}}")
  566. End If
  567. gppPath:+ "/bin/g++"
  568. gppPath = gppPath.Replace("/", "\")
  569. ? Not win32
  570. Local gppPath:String = "g++"
  571. ?
  572. Return GetProcessOutput(gppPath, "-dumpversion").Split("~n")[0]
  573. EndMethod
  574. Method PopulateColumns( strHeadings$[], strValues$[] )
  575. strHeadings = strHeadings[..lblLeftAligned.length]
  576. strValues = strValues[..lblRightAligned.length]
  577. For Local i:Int = 0 Until lblLeftAligned.length
  578. LocalizeGadget( lblLeftAligned[i], strHeadings[i] )
  579. Next
  580. For Local i:Int = 0 Until lblRightAligned.length
  581. SetGadgetText( lblRightAligned[i], strValues[i] )
  582. SetGadgetToolTip( lblRightAligned[i], strValues[i] )
  583. Next
  584. EndMethod
  585. Method Show()
  586. PopulateText()
  587. Super.Show()
  588. EndMethod
  589. Method Poll()
  590. Select EventSource()
  591. Case window
  592. If EventID()=EVENT_WINDOWCLOSE
  593. Hide()
  594. EndIf
  595. Case cancel
  596. If EventID()=EVENT_GADGETACTION
  597. Hide()
  598. EndIf
  599. Default
  600. Return 0
  601. End Select
  602. Return 1
  603. End Method
  604. Function Create:TAboutRequester(host:TCodePlay)
  605. Local abt:TAboutRequester = New TAboutRequester
  606. abt.initrequester(host,"{{about_window_title}}",ScaledSize(420),ScaledSize(277),STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
  607. Local win:TGadget = abt.window, w = ClientWidth(abt.window)-ScaledSize(12), h = ClientHeight(abt.window)
  608. abt.pnlLogo = CreatePanel(w-ScaledSize(64-6),0,ScaledSize(64),ScaledSize(64),win)
  609. SetGadgetLayout abt.pnlLogo, EDGE_CENTERED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
  610. 'abt.pnlLogo = CreatePanel(0,0,64,64,win)
  611. 'SetGadgetLayout abt.pnlLogo, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED
  612. If Not pixLogo Then pixLogo = LoadPixmapPNG("incbin::bmxlogo.png")
  613. SetGadgetPixmap abt.pnlLogo, pixLogo, PANELPIXMAP_CENTER
  614. Local y = 12
  615. Local arch:String
  616. ?x86
  617. arch = "x86"
  618. ?x64
  619. arch = "x64"
  620. ?arm
  621. arch = "ARM"
  622. ?
  623. abt.lblTitle = CreateLabel("MaxIDE "+IDE_VERSION + " (" + arch + ")",ScaledSize(6),ScaledSize(y),w,ScaledSize(20),win,LABEL_LEFT)
  624. SetGadgetFont abt.lblTitle, LookupGuiFont( GUIFONT_SYSTEM, 12, FONT_BOLD )
  625. SetGadgetLayout abt.lblTitle, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
  626. y:+21
  627. abt.lblSubtitle = CreateLabel("Copyright Blitz Research Ltd.",ScaledSize(6),ScaledSize(y),w,ScaledSize(22),win,LABEL_LEFT)
  628. SetGadgetFont abt.lblSubtitle, LookupGuiFont( GUIFONT_SYSTEM, 10, FONT_ITALIC )
  629. SetGadgetLayout abt.lblSubtitle, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
  630. y = 64
  631. SetGadgetLayout( CreateLabel("",ScaledSize(6),ScaledSize(y),w,ScaledSize(4),win,LABEL_SEPARATOR), EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED )
  632. y:+(4+6)
  633. Local tmpGadget:TGadget
  634. For y = y Until (277-21) Step 22
  635. tmpGadget = CreateLabel("",ScaledSize(6),ScaledSize(y),ScaledSize(135),ScaledSize(22),win,LABEL_LEFT)
  636. SetGadgetLayout( tmpGadget, EDGE_ALIGNED, EDGE_RELATIVE, EDGE_ALIGNED, EDGE_CENTERED )
  637. abt.lblLeftAligned:+[tmpGadget]
  638. tmpGadget = CreateLabel("",ScaledSize(135+6),ScaledSize(y),w-ScaledSize(135),ScaledSize(22),win,LABEL_LEFT)
  639. SetGadgetLayout( tmpGadget, EDGE_RELATIVE, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED )
  640. DelocalizeGadget tmpGadget
  641. abt.lblRightAligned:+[tmpGadget]
  642. Next
  643. abt.hypBlitz = CreateHyperlink("http://www.blitzbasic.com/",ScaledSize(6),(h-ScaledSize(28)),ScaledSize(200),ScaledSize(26),win,LABEL_LEFT)
  644. SetGadgetLayout abt.hypBlitz, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED
  645. Return abt
  646. EndFunction
  647. Function Spacer( height:Int, inpout:Int Var )
  648. inpout:+height+ScaledSize(6)
  649. Return height
  650. EndFunction
  651. EndType
  652. Type TCmdLineRequester Extends TRequester
  653. Field label:TGadget,textfield:TGadget
  654. Method Poll()
  655. Select EventSource()
  656. Case window
  657. If EventID()=EVENT_WINDOWCLOSE
  658. Hide
  659. EndIf
  660. Case ok
  661. If EventID()=EVENT_GADGETACTION
  662. host.SetCommandLine TextFieldText(textfield)
  663. Hide
  664. EndIf
  665. Case cancel
  666. If EventID()=EVENT_GADGETACTION
  667. SetGadgetText textfield,host.GetCommandLine()
  668. Hide
  669. EndIf
  670. Default
  671. Return 0
  672. End Select
  673. Return 1
  674. End Method
  675. Method Show()
  676. SetGadgetText textfield,host.GetCommandLine()
  677. Super.Show()
  678. ActivateGadget textfield
  679. End Method
  680. Function Create:TCmdLineRequester(host:TCodePlay)
  681. Local cmd:TCmdLineRequester = New TCmdLineRequester
  682. cmd.initrequester(host,"{{cmdline_window_title}}",ScaledSize(260),ScaledSize(60),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
  683. cmd.label=CreateLabel("{{cmdline_label_cmdline}}:",ScaledSize(6),ScaledSize(8),ScaledSize(260),ScaledSize(20),cmd.window)
  684. cmd.textfield=CreateTextField(ScaledSize(6),ScaledSize(30),ClientWidth(cmd.window)-ScaledSize(12),ScaledSize(21),cmd.window)
  685. Return cmd
  686. End Function
  687. End Type
  688. Type TGotoRequester Extends TRequester
  689. Field linenumber:TGadget
  690. Method Show()
  691. Super.Show()
  692. ActivateGadget linenumber
  693. End Method
  694. Method Poll()
  695. Local line,data,Text$
  696. Select EventSource()
  697. Case linenumber
  698. If EventID() = EVENT_GADGETACTION
  699. Text = GadgetText(linenumber)
  700. If Text And (Int(Text) <> Text) Then SetGadgetText linenumber, Int(Text)
  701. EndIf
  702. Case window
  703. If EventID()=EVENT_WINDOWCLOSE
  704. Hide
  705. EndIf
  706. Case ok
  707. line=Int(GadgetText(linenumber))
  708. Hide
  709. host.activepanel.Invoke TOOLGOTO,String(line)
  710. Case cancel
  711. Hide
  712. Default
  713. Return 0
  714. End Select
  715. Return 1
  716. End Method
  717. Function Create:TGotoRequester(host:TCodePlay)
  718. Local seek:TGotoRequester = New TGotoRequester
  719. seek.initrequester(host,"{{goto_window_title}}",ScaledSize(260),ScaledSize(66),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL,"{{goto_btn_goto}}")
  720. CreateLabel("{{goto_label_linenum}}:",ScaledSize(6),ScaledSize(8+4),ScaledSize(114),ScaledSize(20),seek.window)
  721. seek.linenumber=CreateTextField(ScaledSize(150),ScaledSize(8),ClientWidth(seek.window)-ScaledSize(150+6),ScaledSize(21),seek.window)
  722. SetGadgetFilter( seek.linenumber, IntegerFilter )
  723. Return seek
  724. End Function
  725. Function IntegerFilter:Int( event:TEvent, context:Object )
  726. Select event.id
  727. Case EVENT_KEYCHAR
  728. If event.data >= Asc("0") And event.data <= Asc("9") Return True
  729. If event.data = 8 Or event.data = 127 Or event.data = 13 Return True
  730. Return False
  731. Case EVENT_KEYDOWN
  732. Return True
  733. EndSelect
  734. EndFunction
  735. End Type
  736. Type TColor
  737. Field red,green,blue
  738. Method Set(rgb)
  739. red=(rgb Shr 16)&$FF
  740. green=(rgb Shr 8)&$FF
  741. blue=rgb&$FF
  742. End Method
  743. Method ToString$()
  744. Return ""+red+","+green+","+blue
  745. End Method
  746. Method FromString(s$)
  747. Local p=s.Find(",")+1
  748. If Not p Return
  749. Local q=s.Find(",",p)+1
  750. If Not q Return
  751. red=Int(s[..p-1])
  752. green=Int(s[p..q-1])
  753. blue=Int(s[q..])
  754. End Method
  755. Method Request()
  756. If RequestColor(red,green,blue)
  757. red=RequestedRed()
  758. green=RequestedGreen()
  759. blue=RequestedBlue()
  760. Return True
  761. EndIf
  762. End Method
  763. End Type
  764. Type TTextStyle
  765. Field label:TGadget,panel:TGadget,combo:TGadget
  766. Field underline:TGadget, color:TColor
  767. Field flags
  768. Method Set(rgb,bolditalic)
  769. color.set(rgb)
  770. flags=bolditalic
  771. End Method
  772. Method Format(textarea:TGadget,pos,length,emphasise:Int = False)
  773. Local tmpFlags:Int = flags
  774. If emphasise Then tmpFlags:|TEXTFORMAT_BOLD
  775. FormatTextAreaText textarea,color.red,color.green,color.blue,tmpFlags,pos,length
  776. End Method
  777. Method ToString$()
  778. Return ""+color.red+","+color.green+","+color.blue+","+flags
  779. End Method
  780. Method FromString(s$)
  781. Local p,q,r
  782. p=s.Find(",")+1;If Not p Return
  783. q=s.Find(",",p)+1;If Not q Return
  784. r=s.Find(",",q)+1;If Not r Return
  785. color.red=Int(s[..p-1])
  786. color.green=Int(s[p..q-1])
  787. color.blue=Int(s[q..r-1])
  788. flags=Int(s[r..])
  789. End Method
  790. Method Poll()
  791. Select EventSource()
  792. Case panel
  793. If EventID()=EVENT_MOUSEDOWN
  794. Return color.Request()
  795. EndIf
  796. Case combo
  797. flags=(flags&~3)|SelectedGadgetItem(combo)
  798. Return True
  799. Case underline
  800. If EventData() Then flags:|TEXTFORMAT_UNDERLINE Else flags:&~TEXTFORMAT_UNDERLINE
  801. Return True
  802. End Select
  803. End Method
  804. Method Refresh()
  805. SetPanelColor panel,color.red,color.green,color.blue
  806. SelectGadgetItem combo,flags&3
  807. SetButtonState(underline,(flags&TEXTFORMAT_UNDERLINE <> 0))
  808. End Method
  809. Function Create:TTextStyle(name$,xpos,ypos,window:TGadget)
  810. Local s:TTextStyle
  811. s=New TTextStyle
  812. s.color=New TColor
  813. s.label=CreateLabel(name,xpos,ypos+ScaledSize(4),ScaledSize(90),ScaledSize(24),window)
  814. s.panel=CreatePanel(xpos+ScaledSize(94),ypos,ScaledSize(24),ScaledSize(24),window,PANEL_BORDER|PANEL_ACTIVE)
  815. SetPanelColor s.panel,255,255,0
  816. s.combo=CreateComboBox(xpos+ScaledSize(122),ypos,ScaledSize(96),ScaledSize(24),window)
  817. s.underline=CreateButton("{{txtstyle_underline}}",xpos+ScaledSize(226),ypos,ClientWidth(window)-(xpos+ScaledSize(220)),ScaledSize(24),window,BUTTON_CHECKBOX)
  818. AddGadgetItem s.combo,"{{txtstyle_normal}}",GADGETITEM_LOCALIZED
  819. AddGadgetItem s.combo,"{{txtstyle_bold}}",GADGETITEM_LOCALIZED
  820. AddGadgetItem s.combo,"{{txtstyle_italic}}",GADGETITEM_LOCALIZED
  821. AddGadgetItem s.combo,"{{txtstyle_bolditalic}}",GADGETITEM_LOCALIZED
  822. Return s
  823. End Function
  824. End Type
  825. Type TCaretStyle
  826. Field label:TGadget,panel:TGadget,combo:TGadget
  827. Field color:TColor
  828. Field width:Int = 1
  829. Method Set(rgb,width)
  830. color.set(rgb)
  831. Self.width=width
  832. End Method
  833. Method ToString$()
  834. Return ""+color.red+","+color.green+","+color.blue+","+width
  835. End Method
  836. Method FromString(s$)
  837. Local p,q,r
  838. p=s.Find(",")+1;If Not p Return
  839. q=s.Find(",",p)+1;If Not q Return
  840. r=s.Find(",",q)+1;If Not r Return
  841. color.red=Int(s[..p-1])
  842. color.green=Int(s[p..q-1])
  843. color.blue=Int(s[q..r-1])
  844. width=Min(3,Max(1,Int(s[r..])))
  845. End Method
  846. Method Poll()
  847. Select EventSource()
  848. Case panel
  849. If EventID()=EVENT_MOUSEDOWN
  850. Return color.Request()
  851. EndIf
  852. Case combo
  853. width=SelectedGadgetItem(combo) + 1
  854. Return True
  855. 'Case underline
  856. ' If EventData() Then flags:|TEXTFORMAT_UNDERLINE Else flags:&~TEXTFORMAT_UNDERLINE
  857. ' Return True
  858. End Select
  859. End Method
  860. Method Refresh()
  861. SetPanelColor panel,color.red,color.green,color.blue
  862. SelectGadgetItem combo,width - 1
  863. End Method
  864. Function Create:TCaretStyle(name$,xpos,ypos,window:TGadget)
  865. Local s:TCaretStyle
  866. s=New TCaretStyle
  867. s.color=New TColor
  868. s.label=CreateLabel(name,xpos,ypos+ScaledSize(4),ScaledSize(90),ScaledSize(24),window)
  869. s.panel=CreatePanel(xpos+ScaledSize(94),ypos,ScaledSize(24),ScaledSize(24),window,PANEL_BORDER|PANEL_ACTIVE)
  870. SetPanelColor s.panel,255,255,0
  871. s.combo=CreateComboBox(xpos+ScaledSize(122),ypos,ScaledSize(96),ScaledSize(24),window)
  872. AddGadgetItem s.combo,"{{caretstyle_width_1}}",GADGETITEM_LOCALIZED
  873. AddGadgetItem s.combo,"{{caretstyle_width_2}}",GADGETITEM_LOCALIZED
  874. AddGadgetItem s.combo,"{{caretstyle_width_3}}",GADGETITEM_LOCALIZED
  875. Return s
  876. End Function
  877. End Type
  878. Type TGadgetStyle
  879. Global fntLibrary:TGUIFont[] = [TGuiFont(Null), LookupGuiFont(GUIFONT_SYSTEM), LookupGuiFont(GUIFONT_MONOSPACED), ..
  880. LookupGuiFont(GUIFONT_SANSSERIF), LookupGuiFont(GUIFONT_SERIF), ..
  881. LookupGuiFont(GUIFONT_SCRIPT) ]
  882. Field label:TGadget,fpanel:TGadget,bpanel:TGadget,fcombo:TGadget,fbutton:TGadget
  883. Field font_name$, font_size:Double
  884. Field fg:TColor, bg:TColor
  885. Field font_type = GUIFONT_SYSTEM, font:TGUIFont = fntLibrary[font_type]
  886. Method Apply(gadget:TGadget)
  887. SetGadgetFont gadget,font
  888. SetGadgetColor gadget,bg.red,bg.green,bg.blue,True
  889. SetGadgetColor gadget,fg.red,fg.green,fg.blue,False
  890. End Method
  891. Method Set(fg_rgb,bg_rgb,ftype,fname$="",fsize=0)
  892. fg.set(fg_rgb)
  893. bg.set(bg_rgb)
  894. If Not fntLibrary[ftype] Then
  895. font_name=fname
  896. font_size=fsize
  897. Else
  898. font_name=FontName(fntLibrary[ftype])
  899. font_size=FontSize(fntLibrary[ftype])
  900. EndIf
  901. font_type=ftype
  902. End Method
  903. Method ToString$()
  904. Return font_name+","+String(font_size).Replace(",",".")+","+fg.ToString()+","+bg.ToString()+","+font_type
  905. End Method
  906. Function GetArg$(a$ Var)
  907. Local p = a.Find(",")
  908. If p=-1 Then p=a.length
  909. Local r$ = a$[..p]
  910. a$=a$[p+1..]
  911. Return r$
  912. End Function
  913. Method FromString(s$)
  914. font_name=GetArg(s$)
  915. font_size=Double(GetArg(s$))
  916. fg.red=Int(GetArg(s$))
  917. fg.green=Int(GetArg(s$))
  918. fg.blue=Int(GetArg(s$))
  919. bg.red=Int(GetArg(s$))
  920. bg.green=Int(GetArg(s$))
  921. bg.blue=Int(GetArg(s$))
  922. font_type=Int(GetArg(s$))
  923. If fntLibrary[font_type] Then
  924. font_name=FontName(fntLibrary[font_type])
  925. font_size=FontSize(fntLibrary[font_type])
  926. EndIf
  927. End Method
  928. Method Poll()
  929. Local f:TGUIFont
  930. Select EventSource()
  931. Case fpanel
  932. If EventID()=EVENT_MOUSEDOWN
  933. Return fg.Request()
  934. EndIf
  935. Case bpanel
  936. If EventID()=EVENT_MOUSEDOWN
  937. Return bg.Request()
  938. EndIf
  939. Case fcombo, fbutton
  940. If EventSource() = fcombo Then
  941. If Not (EventData() < 0) Then
  942. font_type = EventData()
  943. f = fntLibrary[font_type]
  944. EndIf
  945. Else
  946. font_type = 0
  947. SelectGadgetItem fcombo, font_type
  948. EndIf
  949. If Not f Then f=RequestFont(font)
  950. If f
  951. font_name=FontName(f)
  952. font_size=FontSize(f)
  953. Return True
  954. EndIf
  955. End Select
  956. End Method
  957. Method Refresh()
  958. font=fntLibrary[font_type]
  959. If Not font Then font=LoadGuiFont(font_name,font_size)
  960. SetPanelColor fpanel,fg.red,fg.green,fg.blue
  961. SetPanelColor bpanel,bg.red,bg.green,bg.blue
  962. SelectGadgetItem fcombo, font_type
  963. Local tmpFloatText$[] = String(font_size).Split(".")
  964. If tmpFloatText.length > 1 Then tmpFloatText[1] = tmpFloatText[1][..Min(2,tmpFloatText[1].length)]
  965. SetGadgetText fbutton,font_name+" : "+".".Join(tmpFloatText)+"pt"
  966. End Method
  967. Function Create:TGadgetStyle(name$,xpos,ypos,window:TGadget)
  968. Local s:TGadgetStyle
  969. s=New TGadgetStyle
  970. s.fg=New TColor
  971. s.bg=New TColor
  972. s.label=CreateLabel(name,xpos,ypos+ScaledSize(LABELOFFSET),ScaledSize(66),ScaledSize(50),window)
  973. s.fpanel=CreatePanel(xpos+ScaledSize(68),ypos,ScaledSize(24),ScaledSize(24),window,PANEL_BORDER|PANEL_ACTIVE)
  974. s.bpanel=CreatePanel(xpos+ScaledSize(96),ypos,ScaledSize(24),ScaledSize(24),window,PANEL_BORDER|PANEL_ACTIVE)
  975. s.fbutton=CreateButton("..",xpos+ScaledSize(122),ypos+ScaledSize(30),ClientWidth(window)-(xpos+ScaledSize(128)),ScaledSize(24),window)
  976. s.fcombo=CreateComboBox(xpos+ScaledSize(122),ypos,ClientWidth(window)-(xpos+ScaledSize(128)),ScaledSize(24),window)
  977. AddGadgetItem s.fcombo, "{{options_font_desc_user}}", GADGETITEM_DEFAULT|GADGETITEM_LOCALIZED
  978. AddGadgetItem s.fcombo, "{{options_font_desc_guidefault}}", GADGETITEM_LOCALIZED
  979. AddGadgetItem s.fcombo, "{{options_font_desc_monospaced}}", GADGETITEM_LOCALIZED
  980. AddGadgetItem s.fcombo, "{{options_font_desc_sansserif}}", GADGETITEM_LOCALIZED
  981. AddGadgetItem s.fcombo, "{{options_font_desc_serif}}", GADGETITEM_LOCALIZED
  982. AddGadgetItem s.fcombo, "{{options_font_desc_script}}", GADGETITEM_LOCALIZED
  983. Return s
  984. End Function
  985. End Type
  986. Const NORMAL=0
  987. Const COMMENT=1
  988. Const QUOTED=2
  989. Const KEYWORD=3
  990. Const NUMBER=4
  991. Const MATCHING=5
  992. Type TOptionsRequester Extends TPanelRequester
  993. ' panels
  994. Field optionspanel:TGadget,editorpanel:TGadget,toolpanel:TGadget,appstubpanel:TGadget
  995. ' settings
  996. Field showtoolbar,restoreopenfiles,autocapitalize,syntaxhighlight,autobackup,autoindent,hideoutput
  997. Field bracketmatching, externalhelp,systemkeys,sortcode
  998. Field tabsize,language$
  999. Field editfontname$,editfontsize,editcolor:TColor
  1000. Field outputfontname$,outputfontsize,outputcolor:TColor
  1001. ' states
  1002. Field editfont:TGUIFont
  1003. ' gadgets
  1004. Field languages:TGadget
  1005. Field tabbutton:TGadget
  1006. Field editpanel:TGadget,editbutton:TGadget
  1007. Field buttons:TGadget[11]
  1008. Field styles:TTextStyle[]
  1009. Field textarea:TGadget
  1010. Field outputstyle:TGadgetStyle
  1011. Field navstyle:TGadgetStyle
  1012. Field dirty
  1013. Field undo:TBank
  1014. Field appstublist:TGadget
  1015. Field appstubs:String[]
  1016. Field appstubedit:TGadget
  1017. Field addappstub:TGadget
  1018. Field delappstub:TGadget
  1019. Field caretStyle:TCaretStyle
  1020. Method Show()
  1021. RefreshGadgets()
  1022. Super.Show()
  1023. EndMethod
  1024. Method Snapshot()
  1025. If Not undo undo=CreateBank(8192)
  1026. Local stream:TStream=CreateBankStream(undo)
  1027. write stream
  1028. stream.close
  1029. End Method
  1030. Method Restore()
  1031. If Not undo Return
  1032. Local stream:TStream=CreateBankStream(undo)
  1033. Read stream
  1034. stream.close
  1035. End Method
  1036. Method SetDefaults()
  1037. language=DEFAULT_LANGUAGEPATH
  1038. bracketmatching=True
  1039. showtoolbar=True
  1040. restoreopenfiles=True
  1041. autocapitalize=True
  1042. syntaxhighlight=True
  1043. autobackup=True
  1044. autoindent=True
  1045. tabsize=4
  1046. editfontname$=FontName(TGadgetStyle.fntLibrary[GUIFONT_MONOSPACED])
  1047. editfontsize=FontSize(TGadgetStyle.fntLibrary[GUIFONT_MONOSPACED])
  1048. editcolor.set( $334455 )
  1049. styles[NORMAL].set( $ffffff,0 )
  1050. styles[COMMENT].set( $bbeeff,0 )
  1051. styles[QUOTED].set( $00ff66,0 )
  1052. styles[KEYWORD].set( $ffff00,0 )
  1053. styles[NUMBER].set( $40ffff,0 )
  1054. styles[MATCHING].set( $ff4040,TEXTFORMAT_BOLD )
  1055. outputstyle.set(0,-1,GUIFONT_MONOSPACED)
  1056. navstyle.set(0,-1,GUIFONT_SYSTEM)
  1057. appstubs = ["brl.appstub"]
  1058. caretStyle.set($ffffff,1)
  1059. RefreshGadgets
  1060. End Method
  1061. Method Write(stream:TStream)
  1062. stream.WriteLine "[Options]"
  1063. stream.WriteLine "language="+language
  1064. stream.WriteLine "showtoolbar="+showtoolbar
  1065. stream.WriteLine "restoreopenfiles="+restoreopenfiles
  1066. stream.WriteLine "autocapitalize="+autocapitalize
  1067. stream.WriteLine "syntaxhighlight="+syntaxhighlight
  1068. stream.WriteLine "bracketmatching="+bracketmatching
  1069. stream.WriteLine "autobackup="+autobackup
  1070. stream.WriteLine "autoindent="+autoindent
  1071. stream.WriteLine "tabsize="+tabsize
  1072. stream.WriteLine "editfontname="+editfontname
  1073. stream.WriteLine "editfontsize="+editfontsize
  1074. stream.WriteLine "editcolor="+editcolor.ToString()
  1075. stream.WriteLine "normal_style="+styles[NORMAL].ToString()
  1076. stream.WriteLine "comment_style="+styles[COMMENT].ToString()
  1077. stream.WriteLine "quote_style="+styles[QUOTED].ToString()
  1078. stream.WriteLine "keyword_style="+styles[KEYWORD].ToString()
  1079. stream.WriteLine "number_style="+styles[NUMBER].ToString()
  1080. stream.WriteLine "matched_style="+styles[MATCHING].ToString()
  1081. stream.WriteLine "console_style="+outputstyle.ToString() 'Renamed from 'output_style' to bump users to default monospace font.
  1082. stream.WriteLine "navi_style="+navstyle.ToString() 'Renamed from 'nav_style' to bump users to default treeview font.
  1083. stream.WriteLine "hide_output="+hideoutput
  1084. stream.WriteLine "external_help="+externalhelp
  1085. stream.WriteLine "system_keys="+systemkeys
  1086. stream.WriteLine "sort_code="+sortcode
  1087. For Local i:Int = 1 Until appstubs.length
  1088. stream.WriteLine "appstub_" + i + "="+appstubs[i]
  1089. Next
  1090. stream.WriteLine "caret_style="+caretstyle.ToString()
  1091. End Method
  1092. Method Read(stream:TStream)
  1093. Local f$,p,a$,b$,t
  1094. appstubs = ["brl.appstub"]
  1095. While Not stream.Eof()
  1096. f$=stream.ReadLine()
  1097. If f$="" Or (f$[..1]="[" And f$<>"[Options]") Exit
  1098. p=f.find("=")
  1099. a$=f[..p]
  1100. b$=f[p+1..]
  1101. t=Int(b)
  1102. Select a$
  1103. Case "showtoolbar" showtoolbar=t
  1104. Case "restoreopenfiles" restoreopenfiles=t
  1105. Case "autocapitalize" autocapitalize=t
  1106. Case "syntaxhighlight" syntaxhighlight=t
  1107. Case "bracketmatching" bracketmatching=t
  1108. Case "autobackup" autobackup=t
  1109. Case "autoindent" autoindent=t
  1110. Case "tabsize" tabsize=t
  1111. Case "editfontname" editfontname=b
  1112. Case "editfontsize" editfontsize=t
  1113. Case "editcolor" editcolor.FromString(b)
  1114. Case "normal_style" styles[NORMAL].FromString(b)
  1115. Case "comment_style" styles[COMMENT].FromString(b)
  1116. Case "quote_style" styles[QUOTED].FromString(b)
  1117. Case "keyword_style" styles[KEYWORD].FromString(b)
  1118. Case "number_style" styles[NUMBER].FromString(b)
  1119. Case "matched_style" styles[MATCHING].FromString(b)
  1120. Case "console_style" outputstyle.FromString(b) 'Renamed from 'output_style' to bump users to default monospace font.
  1121. Case "navi_style" navstyle.FromString(b) 'Renamed from 'nav_style' to bump users to default treeview font.
  1122. Case "hide_output" hideoutput=t
  1123. Case "external_help" externalhelp=t
  1124. Case "system_keys" systemkeys=t
  1125. Case "sort_code" sortcode=t
  1126. Case "caret_style" caretstyle.FromString(b)
  1127. Case "language"
  1128. Try
  1129. Local tmpLanguage:TMaxGUILanguage = LoadLanguage(host.FullPath(b))
  1130. If tmpLanguage Then
  1131. language = b
  1132. SetLocalizationLanguage tmpLanguage
  1133. host.RefreshMenu()
  1134. EndIf
  1135. Catch excn:Object
  1136. EndTry
  1137. End Select
  1138. If a.StartsWith("appstub_") Then
  1139. appstubs :+ [b]
  1140. End If
  1141. Wend
  1142. RefreshGadgets
  1143. End Method
  1144. Method RefreshGadgets()
  1145. Local rgb:TColor,flags
  1146. editfont=LoadGuiFont(editfontname,editfontsize)
  1147. 'Language Loading / Enumeration
  1148. ClearGadgetItems languages
  1149. AddGadgetItem languages, "English (English) [Embedded]", GADGETITEM_DEFAULT,-1,"",DEFAULT_LANGUAGEPATH
  1150. For Local tmpFile$ = EachIn LoadDir( host.bmxpath+"/cfg", True )
  1151. Local tmpPath$ = host.bmxpath+"/cfg/"+tmpFile
  1152. If FileType(tmpPath) = FILETYPE_FILE And tmpFile.ToLower().EndsWith(".language.ini") Then
  1153. If tmpPath = host.FullPath(language) Then flags = GADGETITEM_DEFAULT Else flags = 0
  1154. AddGadgetItem languages, tmpFile.Split(".")[0], flags, -1, "", "$BMXPATH/cfg/"+tmpFile
  1155. EndIf
  1156. Next
  1157. SetButtonState buttons[0],showtoolbar
  1158. SetButtonState buttons[1],restoreopenfiles
  1159. SetButtonState buttons[2],autocapitalize
  1160. SetButtonState buttons[3],syntaxhighlight
  1161. SetButtonState buttons[4],bracketmatching
  1162. SetButtonState buttons[5],autobackup
  1163. SetButtonState buttons[6],autoindent
  1164. SetButtonState buttons[7],hideoutput
  1165. SetButtonState buttons[8],externalhelp
  1166. SetButtonState buttons[9],systemkeys
  1167. SetButtonState buttons[10],sortcode
  1168. SelectGadgetItem tabbutton,Min(Max(tabsize/2-1,0),7)
  1169. SetPanelColor editpanel,editcolor.red,editcolor.green,editcolor.blue
  1170. SetGadgetText editbutton,editfontname+" : "+editfontsize + "pt"
  1171. For Local i:Int = 0 Until styles.length
  1172. styles[i].Refresh
  1173. Next
  1174. caretstyle.Refresh
  1175. LockTextArea textarea
  1176. SetTextAreaColor textarea,editcolor.red,editcolor.green,editcolor.blue,True
  1177. SetGadgetFont textarea,editfont
  1178. styles[NORMAL].format(textarea,0,TEXTAREA_ALL)
  1179. styles[COMMENT].format(textarea,0,12)
  1180. styles[MATCHING].format(textarea,24,1)
  1181. styles[NUMBER].format(textarea,25,3)
  1182. styles[NUMBER].format(textarea,31,1)
  1183. styles[MATCHING].format(textarea,32,1)
  1184. styles[NUMBER].format(textarea,36,1)
  1185. styles[KEYWORD].format(textarea,39,5)
  1186. styles[QUOTED].format(textarea,46,10)
  1187. UnlockTextArea textarea
  1188. outputstyle.Refresh
  1189. navstyle.Refresh
  1190. dirty=True
  1191. ClearGadgetItems appstublist
  1192. For Local appstub:String = EachIn appstubs
  1193. AddGadgetItem appstublist,appstub
  1194. Next
  1195. DisableGadget addappstub
  1196. DisableGadget delappstub
  1197. End Method
  1198. Method Poll()
  1199. Local font:TGUIFont,refresh,processed = 1
  1200. For Local i:Int = 0 Until styles.length
  1201. refresh:|styles[i].Poll()
  1202. Next
  1203. refresh:|caretstyle.Poll()
  1204. refresh:|outputstyle.Poll()
  1205. refresh:|navstyle.Poll()
  1206. Select EventID()
  1207. Case EVENT_GADGETACTION, EVENT_WINDOWCLOSE
  1208. Select EventSource()
  1209. Case buttons[0];showtoolbar=ButtonState(buttons[0]);dirty=True
  1210. Case buttons[1];restoreopenfiles=ButtonState(buttons[1])
  1211. Case buttons[2];autocapitalize=ButtonState(buttons[2]);dirty=True
  1212. Case buttons[3];syntaxhighlight=ButtonState(buttons[3]);dirty=True
  1213. Case buttons[4];bracketmatching=ButtonState(buttons[4])
  1214. Case buttons[5];autobackup=ButtonState(buttons[5])
  1215. Case buttons[6];autoindent=ButtonState(buttons[6])
  1216. Case buttons[7];hideoutput=ButtonState(buttons[7])
  1217. Case buttons[8];externalhelp=ButtonState(buttons[8])
  1218. Case buttons[9];systemkeys=ButtonState(buttons[9]);dirty=2
  1219. Case buttons[10];sortcode=ButtonState(buttons[10]);dirty=3
  1220. Case tabber;SetPanelIndex SelectedGadgetItem(tabber)
  1221. Case ok
  1222. Hide()
  1223. Select dirty
  1224. Case 1
  1225. host.RefreshAll
  1226. Case 2
  1227. host.Restart
  1228. Case 3
  1229. host.RefreshAppStubs
  1230. End Select
  1231. dirty=False
  1232. SnapShot()
  1233. Case window
  1234. If EventID()=EVENT_WINDOWCLOSE
  1235. Restore()
  1236. dirty=False
  1237. Hide()
  1238. EndIf
  1239. Case cancel
  1240. Restore()
  1241. dirty=False
  1242. Hide()
  1243. Case tabbutton
  1244. tabsize=(SelectedGadgetItem(tabbutton)+1)*2
  1245. refresh=True
  1246. Case editpanel
  1247. If EventID()=EVENT_MOUSEDOWN
  1248. refresh=editcolor.Request()
  1249. EndIf
  1250. Case editbutton
  1251. font=RequestFont(editfont)
  1252. If font
  1253. editfontname=FontName(font)
  1254. editfontsize=FontSize(font)
  1255. refresh=True
  1256. EndIf
  1257. Case languages
  1258. If EventData() > 0 Then
  1259. language = String(GadgetItemExtra(languages,EventData()))
  1260. SetLocalizationLanguage TMaxGUILanguage(LoadLanguage(host.FullPath(language)))
  1261. Else
  1262. language = DEFAULT_LANGUAGEPATH
  1263. SetLocalizationLanguage defaultLanguage
  1264. EndIf
  1265. host.RefreshMenu()
  1266. Case addappstub
  1267. If GadgetText(appstubedit) Then
  1268. appstubs :+ [GadgetText(appstubedit).ToLower()]
  1269. SetGadgetText appstubedit, ""
  1270. End If
  1271. refresh=True
  1272. dirty=3
  1273. Case delappstub
  1274. Local index:Int = SelectedGadgetItem(appstublist)
  1275. If index > 0 Then
  1276. If index < appstubs.length
  1277. appstubs = appstubs[..index] + appstubs[index+1..]
  1278. Else
  1279. appstubs = appstubs[..index]
  1280. End If
  1281. refresh=True
  1282. dirty=3
  1283. End If
  1284. Case appstubedit
  1285. If GadgetText(appstubedit) Then
  1286. EnableGadget addappstub
  1287. Else
  1288. DisableGadget addappstub
  1289. End If
  1290. Default
  1291. processed = 0
  1292. EndSelect
  1293. Case EVENT_GADGETSELECT
  1294. Select EventSource()
  1295. Case appstublist
  1296. If SelectedGadgetItem(appstublist) > 0 Then
  1297. EnableGadget delappstub
  1298. Else
  1299. DisableGadget delappstub
  1300. End If
  1301. End Select
  1302. Case EVENT_MOUSEDOWN
  1303. Select EventSource()
  1304. Case editpanel
  1305. If EventID()=EVENT_MOUSEDOWN
  1306. editcolor.Request()
  1307. refresh=True
  1308. EndIf
  1309. Default
  1310. processed = 0
  1311. EndSelect
  1312. EndSelect
  1313. If refresh Then RefreshGadgets()
  1314. Return processed
  1315. End Method
  1316. Method InitOptionsRequester(host:TCodePlay)
  1317. Local w:TGadget
  1318. InitPanelRequester(host,"{{options_window_title}}", ScaledSize(380), ScaledSize(460))
  1319. ' init values
  1320. editcolor=New TColor
  1321. ' init gadgets
  1322. optionspanel=AddPanel("{{options_optionstab}}")
  1323. editorpanel=AddPanel("{{options_editortab}}")
  1324. toolpanel=AddPanel("{{options_toolstab}}")
  1325. appstubpanel=AddPanel("{{options_appstubtab}}")
  1326. SetGadgetShape( tabber, GadgetX(tabber), GadgetY(tabber)+ScaledSize(32), GadgetWidth(tabber), GadgetHeight(tabber)-ScaledSize(32) )
  1327. w=window
  1328. CreateLabel("{{options_options_label_language}}:",ScaledSize(6),ScaledSize(6+4),ScaledSize(80),ScaledSize(24),w)
  1329. languages = CreateComboBox(ScaledSize(90),ScaledSize(6),ClientWidth(w)-ScaledSize(96),ScaledSize(26),w)
  1330. w=optionspanel
  1331. buttons[0]=CreateButton("{{options_options_btn_showtoolbar}}",ScaledSize(6),ScaledSize(6),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1332. buttons[1]=CreateButton("{{options_options_btn_autorestore}}",ScaledSize(6),ScaledSize(34),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1333. buttons[2]=CreateButton("{{options_options_btn_autocaps}}",ScaledSize(6),ScaledSize(60),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1334. buttons[3]=CreateButton("{{options_options_btn_syntaxhighlight}}",ScaledSize(6),ScaledSize(86),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1335. buttons[4]=CreateButton("{{options_options_btn_bracketmatching}}",ScaledSize(6),ScaledSize(112),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1336. buttons[5]=CreateButton("{{options_options_btn_autobackup}}",ScaledSize(6),ScaledSize(138),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1337. buttons[6]=CreateButton("{{options_options_btn_autoindent}}",ScaledSize(6),ScaledSize(164),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1338. buttons[7]=CreateButton("{{options_options_btn_autohideoutput}}",ScaledSize(6),ScaledSize(190),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1339. buttons[8]=CreateButton("{{options_options_btn_useexternalbrowser}}",ScaledSize(6),ScaledSize(216),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1340. buttons[9]=CreateButton("{{options_options_btn_osshortcuts}}",ScaledSize(6),ScaledSize(242),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1341. buttons[10]=CreateButton("{{options_options_btn_sortcodeviewnodes}}",ScaledSize(6),ScaledSize(268),ClientWidth(w)-ScaledSize(12),ScaledSize(26),w,BUTTON_CHECKBOX)
  1342. w=editorpanel
  1343. CreateLabel("{{options_editor_label_background}}:",ScaledSize(6),ScaledSize(6+4),ScaledSize(90),ScaledSize(24),w)
  1344. editpanel=CreatePanel(ScaledSize(100),ScaledSize(6),ScaledSize(24),ScaledSize(24),w,PANEL_BORDER|PANEL_ACTIVE)
  1345. editbutton=CreateButton("..",ScaledSize(128),ScaledSize(6),ClientWidth(w)-ScaledSize(134),ScaledSize(24),w)
  1346. tabbutton=CreateComboBox(ScaledSize(128),ScaledSize(36),ClientWidth(w)-ScaledSize(134),ScaledSize(24),w)
  1347. For Local i=1 To 8
  1348. AddGadgetItem tabbutton,"{{options_editor_itemlabel_tabsize}} "+(i*2),GADGETITEM_LOCALIZED
  1349. Next
  1350. styles=New TTextStyle[6]
  1351. styles[NORMAL]=TTextStyle.Create("{{options_editor_label_plaintext}}:",ScaledSize(6),ScaledSize(66),w)
  1352. styles[COMMENT]=TTextStyle.Create("{{options_editor_label_remarks}}:",ScaledSize(6),ScaledSize(96),w)
  1353. styles[QUOTED]=TTextStyle.Create("{{options_editor_label_strings}}:",ScaledSize(6),ScaledSize(126),w)
  1354. styles[KEYWORD]=TTextStyle.Create("{{options_editor_label_keywords}}:",ScaledSize(6),ScaledSize(156),w)
  1355. styles[NUMBER]=TTextStyle.Create("{{options_editor_label_numbers}}:",ScaledSize(6),ScaledSize(186),w)
  1356. styles[MATCHING]=TTextStyle.Create("{{options_editor_label_matchings}}:",ScaledSize(6),ScaledSize(216),w)
  1357. caretstyle = TCaretStyle.Create("{{options_editor_label_caret}}:",ScaledSize(6),ScaledSize(250),w)
  1358. textarea=CreateTextArea(ScaledSize(6),ScaledSize(280),ClientWidth(w)-ScaledSize(12),ClientHeight(w)-ScaledSize(256),w,TEXTAREA_READONLY)
  1359. SetGadgetText textarea,"'Sample Code~n~nresult = ((2.0 * 4) + 1)~nPrint( ~qResult: ~q + result )~n"
  1360. w=toolpanel
  1361. outputstyle=TGadgetStyle.Create("{{options_tools_label_output}}: ",ScaledSize(6),ScaledSize(6),w)
  1362. navstyle=TGadgetStyle.Create("{{options_tools_label_navbar}}: ",ScaledSize(6),ScaledSize(66),w)
  1363. w=appstubpanel
  1364. appstublist=CreateListBox(ScaledSize(6),ScaledSize(6),ClientWidth(w)-ScaledSize(12),ClientHeight(w)-ScaledSize(80),w)
  1365. appstubedit=CreateTextField(ScaledSize(6),ClientHeight(w)-ScaledSize(66),ClientWidth(w)-ScaledSize(12),ScaledSize(21),w)
  1366. addappstub=CreateButton("{{options_appstub_btn_add}}",ScaledSize(6),ClientHeight(w)-ScaledSize(40),ScaledSize(140),ScaledSize(26),w,BUTTON_PUSH)
  1367. delappstub=CreateButton("{{options_appstub_btn_del}}",ClientWidth(w)-ScaledSize(146),ClientHeight(w)-ScaledSize(40),ScaledSize(140),ScaledSize(26),w,BUTTON_PUSH)
  1368. appstubs = ["brl.appstub"]
  1369. AddGadgetItem appstublist,appstubs[0]
  1370. DisableGadget addappstub
  1371. DisableGadget delappstub
  1372. SetDefaults()
  1373. SetPanel optionspanel
  1374. SnapShot
  1375. End Method
  1376. Function Create:TOptionsRequester(host:TCodePlay)
  1377. Local o:TOptionsRequester
  1378. o=New TOptionsRequester
  1379. o.InitOptionsRequester host
  1380. Return o
  1381. End Function
  1382. End Type
  1383. Type TFindRequester Extends TRequester
  1384. Field findterm:TGadget
  1385. Method ShowFind(term$="")
  1386. If term SetGadgetText(findterm,term)
  1387. Super.Show()
  1388. ActivateGadget findterm
  1389. End Method
  1390. Method Poll()
  1391. Local find$,data
  1392. Select EventSource()
  1393. Case window
  1394. If EventID()=EVENT_WINDOWCLOSE
  1395. Hide()
  1396. EndIf
  1397. Case ok
  1398. If EventID() = EVENT_GADGETACTION
  1399. If TextFieldText(findterm)
  1400. find=TextFieldText(findterm)
  1401. Hide()
  1402. host.activepanel.Invoke TOOLFINDNEXT,find
  1403. Else
  1404. Notify LocalizeString("{{search_error_nosearchstring}}"), True
  1405. ActivateGadget findterm
  1406. EndIf
  1407. EndIf
  1408. Case cancel
  1409. If EventID() = EVENT_GADGETACTION Then Hide()
  1410. Default
  1411. Return 0
  1412. End Select
  1413. Return 1
  1414. End Method
  1415. Function Create:TFindRequester(host:TCodePlay)
  1416. Local seek:TFindRequester
  1417. seek=New TFindRequester
  1418. seek.initrequester(host,"{{find_window_title}}",ScaledSize(280),ScaledSize(66),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL,"{{find_btn_find}}")
  1419. CreateLabel("{{find_label_find}}:",ScaledSize(6),ScaledSize(12),ScaledSize(82),ScaledSize(24),seek.window)
  1420. seek.findterm=CreateTextField(ScaledSize(88),ScaledSize(8),ClientWidth(seek.window)-ScaledSize(88+6),ScaledSize(21),seek.window)
  1421. Return seek
  1422. End Function
  1423. End Type
  1424. Type TReplaceRequester Extends TRequester
  1425. Field findterm:TGadget,replaceterm:TGadget
  1426. Field findnext:TGadget,replaceit:TGadget,replaceall:TGadget
  1427. Method Show()
  1428. Super.Show()
  1429. ActivateGadget findterm
  1430. End Method
  1431. Method Poll()
  1432. Local find$,Replace$
  1433. Select EventSource()
  1434. Case window
  1435. If EventID()=EVENT_WINDOWCLOSE
  1436. Hide()
  1437. EndIf
  1438. Case cancel
  1439. If EventID() = EVENT_GADGETACTION Then Hide
  1440. Case ok
  1441. If EventID() = EVENT_GADGETACTION Then
  1442. If TextFieldText(findterm) Then
  1443. find=TextFieldText(findterm)
  1444. host.activepanel.Invoke TOOLFINDNEXT,find
  1445. Else
  1446. Notify LocalizeString("{{search_error_nosearchstring}}"), True
  1447. ActivateGadget findterm
  1448. EndIf
  1449. EndIf
  1450. Case replaceit
  1451. If EventID() = EVENT_GADGETACTION Then
  1452. Replace=TextFieldText(replaceterm)
  1453. If host.activepanel.Invoke(TOOLREPLACE,Replace)
  1454. host.activepanel.Invoke TOOLFINDNEXT,find
  1455. EndIf
  1456. EndIf
  1457. Case replaceall
  1458. If EventID() = EVENT_GADGETACTION Then
  1459. find=TextFieldText(findterm)
  1460. Replace=TextFieldText(replaceterm)
  1461. host.activepanel.Invoke TOOLREPLACE,find+Chr(0)+Replace
  1462. EndIf
  1463. Default
  1464. Return 0
  1465. End Select
  1466. Return 1
  1467. End Method
  1468. Function Create:TReplaceRequester(host:TCodePlay)
  1469. Local x,y
  1470. Local seek:TReplaceRequester
  1471. seek=New TReplaceRequester
  1472. seek.initrequester(host,"{{replace_window_title}}",ScaledSize(380),ScaledSize(80),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER,"{{replace_btn_findnext}}")
  1473. y=11
  1474. CreateLabel( "{{replace_label_find}}:",ScaledSize(6),ScaledSize(y+4),ScaledSize(88),ScaledSize(24),seek.window )
  1475. seek.findterm=CreateTextField( ScaledSize(96),ScaledSize(y),ScaledSize(168),ScaledSize(21),seek.window )
  1476. y:+32
  1477. CreateLabel( "{{replace_label_replacewith}}:",ScaledSize(6),ScaledSize(y+4),ScaledSize(88),ScaledSize(24),seek.window )
  1478. seek.replaceterm=CreateTextField( ScaledSize(96),ScaledSize(y),ScaledSize(168),ScaledSize(21),seek.window )
  1479. x=ClientWidth(seek.window)-ScaledSize(102)
  1480. y=8
  1481. seek.replaceit=CreateButton("{{replace_btn_replace}}",x,ScaledSize(y),ScaledSize(96),ScaledSize(26),seek.window)
  1482. seek.replaceall=CreateButton("{{replace_btn_replaceall}}",x,ScaledSize(y+32),ScaledSize(96),ScaledSize(26),seek.window)
  1483. Return seek
  1484. End Function
  1485. End Type
  1486. Type TEventHandler Extends TTool
  1487. Method OnEvent() Abstract
  1488. End Type
  1489. Type TToolPanel Extends TEventHandler
  1490. Field name$,path$
  1491. Field panel:TGadget
  1492. Field index
  1493. Field active
  1494. Method Show()
  1495. End Method
  1496. End Type
  1497. Type TView
  1498. Field node:TGadget
  1499. Field state
  1500. End Type
  1501. Type TNode Extends TTool
  1502. Const HIDESTATE=0
  1503. Const CLOSEDSTATE=1
  1504. Const OPENSTATE=2
  1505. Field name$,sortname$
  1506. Field parent:TNode
  1507. Field kids:TList=New TList
  1508. Field views:TView[]
  1509. ' activate program
  1510. Field target:TTool
  1511. Field action
  1512. Field argument:Object
  1513. Method SortKids( ascending=True )
  1514. Local term:TLink=kids._head
  1515. Repeat
  1516. Local link:TLink=kids._head._succ
  1517. Local sorted=True
  1518. Repeat
  1519. Local succ:TLink=link._succ
  1520. If succ=term Exit
  1521. Local cc=TNode(link._value).sortname.Compare( TNode(succ._value).sortname )
  1522. If (cc>0 And ascending) Or (cc<0 And Not ascending)
  1523. Local link_pred:TLink=link._pred
  1524. Local succ_succ:TLink=succ._succ
  1525. link_pred._succ=succ
  1526. succ._succ=link
  1527. succ._pred=link_pred
  1528. link._succ=succ_succ
  1529. link._pred=succ
  1530. succ_succ._pred=link
  1531. sorted=False
  1532. Else
  1533. link=succ
  1534. EndIf
  1535. Forever
  1536. If sorted Return
  1537. term=link
  1538. Forever
  1539. End Method
  1540. Method FindArgument:TNode(arg:Object)
  1541. Local n:TNode,r:TNode,a$
  1542. If arg.Compare(argument)=0 Return Self
  1543. a$=(String(arg)).ToLower()
  1544. If a And a=(String(argument)).toLower() Return Self
  1545. For n=EachIn kids
  1546. r=n.FindArgument(arg)
  1547. If r Return r
  1548. Next
  1549. End Method
  1550. ?Debug
  1551. Method Dump(indent$="")
  1552. Local n:TNode
  1553. Print indent+name
  1554. indent:+"~t"
  1555. For n=EachIn kids
  1556. n.Dump indent
  1557. Next
  1558. End Method
  1559. ?
  1560. Method IsHidden()
  1561. Local v:TView
  1562. If Not parent Return False
  1563. For v=EachIn parent.views
  1564. If v.state=OPENSTATE Return False
  1565. Next
  1566. Return True
  1567. End Method
  1568. Method SetAction(tool:TTool,cmd,arg:Object=Null)
  1569. target=tool
  1570. action=cmd
  1571. argument=arg
  1572. End Method
  1573. Method Hide(v:TView=Null) 'null means hide in all views
  1574. For Local n:TNode = EachIn kids
  1575. n.hide v
  1576. Next
  1577. If v
  1578. If v.node FreeTreeViewNode v.node;v.node=Null
  1579. Else
  1580. For v=EachIn views
  1581. If v.node FreeTreeViewNode v.node;v.node=Null
  1582. Next
  1583. EndIf
  1584. End Method
  1585. Method Detach()
  1586. Hide()
  1587. If parent parent.kids.remove Self;parent=Null
  1588. End Method
  1589. Method FreeKids()
  1590. For Local n:TNode = EachIn kids
  1591. n.free
  1592. Next
  1593. End Method
  1594. Method Free()
  1595. FreeKids()
  1596. Detach()
  1597. target=Null;argument=Null;views=Null
  1598. End Method
  1599. Method Invoke(command,arg:Object=Null)
  1600. Select command
  1601. Case TOOLACTIVATE
  1602. If target Return target.Invoke(action,argument)
  1603. End Select
  1604. End Method
  1605. Method Find:TNode(treeviewnode:TGadget,view=0)
  1606. Local n:TNode,r:TNode
  1607. Local v:TView
  1608. v=getview(view)
  1609. If v And v.node=treeviewnode Return Self
  1610. For n=EachIn kids
  1611. r=n.Find(treeviewnode,view)
  1612. If r Return r
  1613. Next
  1614. End Method
  1615. Method SetNode(treeviewnode:TGadget,view=0)
  1616. Local v:TView = getview(view)
  1617. v.node=treeviewnode
  1618. open view
  1619. End Method
  1620. Method HighLight(view=-1)
  1621. Local v:TView
  1622. If view=-1
  1623. For view=0 Until views.length
  1624. HighLight view
  1625. Next
  1626. Return
  1627. EndIf
  1628. v=GetView(view)
  1629. If v.node SelectTreeViewNode v.node
  1630. End Method
  1631. Method Open(view=-1)
  1632. Local v:TView
  1633. If view=-1
  1634. For view=0 Until views.length
  1635. Open view
  1636. Next
  1637. Return
  1638. EndIf
  1639. v=GetView(view)
  1640. If v.state<>OPENSTATE
  1641. v.state=OPENSTATE
  1642. RefreshView view
  1643. ' If v.node ExpandTreeViewNode v.node
  1644. EndIf
  1645. End Method
  1646. Method Close(view=0)
  1647. Local v:TView = GetView(view)
  1648. If v.state<>CLOSEDSTATE
  1649. v.state=CLOSEDSTATE
  1650. ' If v.node CollapseTreeViewNode v.node
  1651. EndIf
  1652. End Method
  1653. Method GetState(view=0)
  1654. Return GetView(view).state
  1655. End Method
  1656. Method GetView:TView(view=0)
  1657. If view>=views.length
  1658. views=views[..view+1]
  1659. EndIf
  1660. If Not views[view] views[view] = New TView
  1661. Return views[view]
  1662. End Method
  1663. Method GetIndex()
  1664. Local node:TNode
  1665. Local i
  1666. If parent
  1667. For node=EachIn parent.kids
  1668. If node=Self Return i
  1669. i:+1
  1670. Next
  1671. EndIf
  1672. End Method
  1673. Method Refresh()
  1674. For Local i:Int = 0 Until views.length
  1675. RefreshView i
  1676. Next
  1677. End Method
  1678. Method RefreshView(view=0)
  1679. Local n:TNode,quick,nodeToOpen:TGadget
  1680. Local v:TView,vv:TView
  1681. Local node
  1682. If parent And parent.getstate(view)=CLOSEDSTATE quick=True
  1683. v=getview(view)
  1684. If v.node And parent
  1685. If GadgetText(v.node) <> name Then
  1686. ModifyTreeViewNode v.node,name
  1687. LocalizeGadget(v.node,name,"")
  1688. EndIf
  1689. If v.state=OPENSTATE nodeToOpen = v.node;quick = False
  1690. Else
  1691. If parent And name
  1692. vv=parent.getview(view)
  1693. If vv.node
  1694. v.node=InsertTreeViewNode(GetIndex(),name,vv.node)
  1695. If v.state=HIDESTATE v.state=CLOSEDSTATE
  1696. If vv.state=OPENSTATE nodeToOpen = vv.node
  1697. quick=False
  1698. EndIf
  1699. EndIf
  1700. EndIf
  1701. If quick Return
  1702. If Not kids Return
  1703. For n=EachIn kids
  1704. n.RefreshView view
  1705. Next
  1706. If nodeToOpen Then ExpandTreeViewNode nodeToOpen
  1707. End Method
  1708. Method NodeAfter:TNode(node:TNode)
  1709. Local link:TLink
  1710. If node link=kids.FindLink(node)
  1711. If link link=link.NextLink()
  1712. If link Return TNode(link.Value())
  1713. End Method
  1714. Method Sync(snap:TNode)
  1715. Local snapkid:TNode
  1716. Local currentkid:TNode
  1717. Local kid:TNode
  1718. Local t:TNode
  1719. Local link:TLink
  1720. If snap.name<>name Return
  1721. If kids.Count() currentkid=TNode(kids.First())
  1722. For snapkid=EachIn snap.kids
  1723. ' if same name in list
  1724. kid=currentkid
  1725. While kid
  1726. If kid.name=snapkid.name Exit
  1727. kid=NodeAfter(kid)
  1728. Wend
  1729. ' then remove entries in front
  1730. If kid
  1731. While currentkid<>kid
  1732. t=currentkid
  1733. currentkid=NodeAfter(currentkid)
  1734. t.free()
  1735. Wend
  1736. EndIf
  1737. ' if same name sync else insert
  1738. If currentkid And currentkid.name=snapkid.name 'merge values if same name
  1739. currentkid.Sync snapkid
  1740. currentkid=NodeAfter(currentkid)
  1741. Else
  1742. snapkid.detach
  1743. If currentkid
  1744. link=kids.FindLink(currentkid)
  1745. kids.InsertBeforeLink snapkid,link
  1746. Else
  1747. kids.AddLast snapkid
  1748. EndIf
  1749. snapkid.parent=Self
  1750. EndIf
  1751. Next
  1752. ' remove any entries at end
  1753. While currentkid
  1754. t=currentkid
  1755. currentkid=NodeAfter(currentkid)
  1756. t.free()
  1757. Wend
  1758. Refresh()
  1759. End Method
  1760. Method SetName(n$)
  1761. name=n
  1762. End Method
  1763. Method AddNode:TNode(name$)
  1764. Local v:TNode
  1765. v=New TNode
  1766. v.setname name
  1767. Append v
  1768. Return v
  1769. End Method
  1770. Method Append(v:TNode)
  1771. v.parent=Self
  1772. kids.AddLast v
  1773. End Method
  1774. Function CreateNode:TNode(name$)
  1775. Local node:TNode
  1776. node=New TNode
  1777. node.setname name
  1778. Return node
  1779. End Function
  1780. End Type
  1781. Type THelpPanel Extends TToolPanel
  1782. Field host:TCodePlay
  1783. Field htmlview:TGadget
  1784. Method AddLink:TNode(parent:TNode,name$,href$)
  1785. Local n:TNode
  1786. If parent
  1787. n=parent.AddNode(name)
  1788. Else
  1789. n=host.helproot
  1790. EndIf
  1791. If href href=RealPath(href)
  1792. n.SetAction(Self,TOOLNAVIGATE,href)
  1793. Return n
  1794. End Method
  1795. Method ImportLinks( node:TNode,path$ )
  1796. Local t$=path+"/index.html"
  1797. If FileType( t )<>FILETYPE_FILE Return
  1798. node=AddLink( node,StripDir( path ),t )
  1799. Local map:TMap=New TMap
  1800. 'scan for html files
  1801. For Local e$=EachIn LoadDir( path )
  1802. If e="index.html" Continue
  1803. Local p$=path+"/"+e
  1804. Select FileType( p )
  1805. Case FILETYPE_DIR
  1806. ImportLinks node,p
  1807. Case FILETYPE_FILE
  1808. If Not e.StartsWith( "_" ) And ExtractExt( e ).Tolower()="html"
  1809. map.Insert StripExt( e ),p
  1810. EndIf
  1811. End Select
  1812. Next
  1813. 'scan for anchors in index.html...
  1814. '
  1815. 'note: anchors must be quote enclosed and of simple form <a name="blah">
  1816. Local c$=CacheAndLoadText( t ),i
  1817. Repeat
  1818. i=c.Find( "<a name=~q",i )
  1819. If i=-1 Exit
  1820. i:+9
  1821. Local i2=c.Find( "~q>",i )
  1822. If i2=-1 Exit
  1823. Local q$=c[i..i2]
  1824. If q.StartsWith( "_" ) Continue
  1825. map.Insert q,t+"#"+q
  1826. i=i2+1
  1827. Forever
  1828. For Local kv:TKeyValue=EachIn map
  1829. AddLink node,String( kv.Key() ),String( kv.Value() )
  1830. Next
  1831. End Method
  1832. Method SyncDocs()
  1833. host.helproot.FreeKids
  1834. ImportLinks Null,host.bmxpath+"/docs/html"
  1835. Local link:TNode
  1836. For Local m$=EachIn EnumModules()
  1837. If m.StartsWith( "brl." ) Or m.StartsWith( "pub." ) Or m.StartsWith("maxgui.") Continue
  1838. Local p$=ModulePath( m )+"/doc/commands.html"
  1839. If FileType( p )<>FILETYPE_FILE Continue
  1840. If Not link link=AddLink( host.helproot,"{{navnode_thirdpartymods}}","" )
  1841. AddLink link,m,p
  1842. Next
  1843. link=AddLink( host.helproot,"{{navnode_moduleindex}}","" )
  1844. If FileType( host.bmxpath+"/docs/html/Modules/commands.txt" )=FILETYPE_FILE
  1845. Local comm$=CacheAndLoadText( host.bmxpath+"/docs/html/Modules/commands.txt" )
  1846. For Local line$=EachIn comm.Split( "~n" )
  1847. Local bits$[]=line.Split( "|" )
  1848. If bits.length<>2 Continue
  1849. Local i=bits[0].Find( " : " )
  1850. If i<>-1 bits[0]=bits[0][..i]
  1851. AddLink link,bits[0],host.bmxpath+bits[1]
  1852. Next
  1853. EndIf
  1854. host.helproot.Refresh
  1855. End Method
  1856. Method Invoke(command,argument:Object=Null)
  1857. Local href$
  1858. If Not htmlview Return
  1859. Select command
  1860. Case TOOLCUT
  1861. GadgetCut htmlview
  1862. Case TOOLCOPY
  1863. GadgetCopy htmlview
  1864. Case TOOLPASTE
  1865. GadgetPaste htmlview
  1866. Case TOOLSHOW
  1867. ActivateGadget htmlview
  1868. host.SetTitle
  1869. Case TOOLNAVIGATE
  1870. href$=String(argument)
  1871. If href Go href
  1872. Case TOOLPRINT
  1873. GadgetPrint htmlview
  1874. End Select
  1875. End Method
  1876. Method OnEvent()
  1877. Local url$,p,t$
  1878. If EventSource()=htmlview
  1879. Select EventID()
  1880. Case EVENT_GADGETACTION 'NAVIGATEREQUEST
  1881. url$=String( EventExtra() )
  1882. If url[..5]="http:"
  1883. OpenURL url
  1884. Else
  1885. p=url.findlast(".")
  1886. If p>-1
  1887. t$=url[p..].tolower()
  1888. If t$=".bmx"
  1889. If url.Find( "file://" )=0
  1890. url=url[7..]
  1891. ?Win32
  1892. url=url[1..]
  1893. ?
  1894. EndIf
  1895. url=url.Replace("%20"," ")
  1896. Local source:TOpenCode=host.OpenSource(url)
  1897. If source source.MakePathTemp
  1898. Else
  1899. url=url.Replace("\","/")
  1900. url=url.Replace("user/index","user/welcome")
  1901. url=url.Replace("lang/index","lang/welcome")
  1902. url=url.Replace("mods/index","mods/welcome")
  1903. Go url$
  1904. EndIf
  1905. EndIf
  1906. EndIf
  1907. End Select
  1908. EndIf
  1909. End Method
  1910. Method Go(url$,internal=False)
  1911. Local node:TNode
  1912. If host.options.externalhelp And Not internal
  1913. PollSystem
  1914. OpenURL url
  1915. MinimizeWindow host.window
  1916. PollSystem
  1917. Return
  1918. EndIf
  1919. HtmlViewGo htmlview,url
  1920. host.SelectPanel Self
  1921. node=host.helproot.FindArgument(RealPath(url))
  1922. If node
  1923. node.Highlight
  1924. ' Else
  1925. ' print "node not found"
  1926. EndIf
  1927. ActivateGadget htmlview
  1928. End Method
  1929. Method Home()
  1930. Go host.bmxpath+HOMEPAGE,True
  1931. End Method
  1932. Method Forward()
  1933. HtmlViewForward htmlview
  1934. End Method
  1935. Method Back()
  1936. HtmlViewBack htmlview
  1937. End Method
  1938. Function Create:THelpPanel(host:TCodePlay)
  1939. Local root,style
  1940. Local p:THelpPanel = New THelpPanel
  1941. p.host=host
  1942. p.name="{{tab_help}}"
  1943. codeplay.addpanel(p)
  1944. style=HTMLVIEW_NONAVIGATE 'HTMLVIEW_NOCONTEXTMENU
  1945. p.htmlview=CreateHTMLView(0,0,ClientWidth(p.panel),ClientHeight(p.panel),p.panel,style)
  1946. SetGadgetLayout p.htmlview,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  1947. ' p.Home
  1948. p.SyncDocs
  1949. Return p
  1950. End Function
  1951. End Type
  1952. Type TSearchResult
  1953. Field filepath$
  1954. Field char%, line%
  1955. Field linestring$
  1956. Method AddToListbox( pGadget:TGadget )
  1957. AddGadgetItem pGadget, "[" + line + ", " + char + "] " + filepath, 0, -1, StripWhitespace(linestring,char), Self
  1958. EndMethod
  1959. Method Set:TSearchResult(pFilePath$,pChar%,pLine%,pLineString$)
  1960. filepath = pFilePath
  1961. char = pChar
  1962. line = pLine
  1963. linestring = pLineString
  1964. Return Self
  1965. EndMethod
  1966. Function StripWhitespace$(pString$,pChar%)
  1967. If pString.length < pChar Then Return pString
  1968. Local outString$
  1969. For Local i:Int = 0 Until pString.length
  1970. Select pString[i]
  1971. Case Asc(" "), Asc("~t"), Asc("~n"), Asc("~r")
  1972. If outString And Not outString.EndsWith(" ") Then outString:+" "
  1973. Default
  1974. outString:+pString[i..i+1]
  1975. EndSelect
  1976. Next
  1977. Return outString
  1978. EndFunction
  1979. EndType
  1980. Type TSearchRequester Extends TRequester
  1981. Const strSearchText$ = "{{search_btn_startsearch}}", strStopSearchText$ = "{{search_btn_stopsearch}}"
  1982. Global strFileExts$[][] = [["bmx"],filetypes.Split(","),String[](Null)]
  1983. Field findbox:TGadget,typebox:TGadget,pathbox:TGadget,pathbutton:TGadget,pathsubdir:TGadget,results:TGadget
  1984. Field lstSearchResults:TList = New TList
  1985. Field safetyCount% = -1, safetyThreshold = 500, safetyResetCount% = 0
  1986. Method Poll()
  1987. Local id:Int = EventID()
  1988. Local data:Int = EventData()
  1989. Select EventSource()
  1990. Case results
  1991. Select id
  1992. Case EVENT_GADGETACTION
  1993. Local tmpSearchResult:TSearchResult = TSearchResult(EventExtra())
  1994. If tmpSearchResult Then
  1995. host.DebugSource( tmpSearchResult.filepath, tmpSearchResult.line, tmpSearchResult.char )
  1996. 'Hide()
  1997. EndIf
  1998. EndSelect
  1999. Case pathbutton
  2000. If EventID()=EVENT_GADGETACTION
  2001. Local tmpString$ = RequestDir( LocalizeString("{{search_requestfolder_title}}"),GadgetText(pathbox))
  2002. If tmpString Then SetGadgetText(pathbox,tmpString)
  2003. EndIf
  2004. Case window
  2005. If EventID()=EVENT_WINDOWCLOSE Then Hide()
  2006. Case findbox
  2007. If EventID() = EVENT_GADGETACTION Then
  2008. If GadgetText(findbox) Then EnableGadget(ok) Else DisableGadget(ok)
  2009. EndIf
  2010. Case ok
  2011. If EventID()=EVENT_GADGETACTION
  2012. If safetyCount < 0 Then StartSearch() Else safetyCount = -2
  2013. EndIf
  2014. Case cancel
  2015. If EventID()=EVENT_GADGETACTION Then Hide()
  2016. End Select
  2017. End Method
  2018. Method Hide()
  2019. safetyCount = -2
  2020. Super.Hide()
  2021. EndMethod
  2022. Method ShowWithPath( pPath$ )
  2023. If pPath Then SetGadgetText( pathbox, pPath )
  2024. Show()
  2025. ActivateGadget( findbox )
  2026. EndMethod
  2027. Method StartSearch()
  2028. PollSystem()
  2029. Select FileType(RealPath(GadgetText(pathbox)))
  2030. Case FILETYPE_NONE
  2031. Notify LocalizeString("{{search_error_pathnotfound}}"),True
  2032. ActivateGadget(pathbox)
  2033. Return
  2034. Case FILETYPE_FILE
  2035. Notify LocalizeString("{{search_error_pathisfile}}"),True
  2036. ActivateGadget(pathbox)
  2037. Return
  2038. EndSelect
  2039. If Not GadgetText(findbox) Then
  2040. Notify LocalizeString("{{search_error_nosearchstring}}"),True
  2041. ActivateGadget(findbox);Return
  2042. EndIf
  2043. safetyResetCount = 0;safetyCount = 0
  2044. LocalizeGadget ok, strStopSearchText;ClearGadgetItems results
  2045. SearchPath( GadgetText(pathbox), strFileExts[SelectedGadgetItem(typebox)], GadgetText(findbox).ToLower(), ButtonState(pathsubdir) )
  2046. LocalizeGadget ok, strSearchText;safetyCount = -1
  2047. SetStatusText window, LocalizeString("{{search_msg_complete}}").Replace("%1",CountGadgetItems(results))
  2048. EndMethod
  2049. Method SearchPath(pPath$,pFileType$[],pString$,pRecurse% = True)
  2050. pPath$ = RealPath(pPath) 'Make sure we are using a real path
  2051. Local tmpSearchDir$[] = LoadDir(pPath,True) 'Load directors contents into string array
  2052. If Not tmpSearchDir Then Return 'Return if the directory is invalid
  2053. tmpSearchDir.Sort() 'Sort the contents alphabetically
  2054. SetStatusText window, LocalizeString("{{search_msg_searchingdir}}").Replace("%1", pPath) 'And let user know which directory is being searched
  2055. Local tmpFullPath$
  2056. For Local tmpItem$ = EachIn tmpSearchDir
  2057. tmpFullPath = pPath + "/" + tmpItem
  2058. Select FileType(tmpFullPath)
  2059. Case FILETYPE_NONE;Continue 'Skip item if, for whatever reason, it doesn't exist
  2060. Case FILETYPE_FILE 'If file, then check extension and search if valid
  2061. If Not pFileType
  2062. SearchFile(tmpFullPath,pString)
  2063. Else
  2064. Local tmpExt$ = ExtractExt(tmpFullPath).ToLower$()
  2065. For Local tmpValidExt$ = EachIn pFileType
  2066. If tmpExt = tmpValidExt Then SearchFile(tmpFullPath,pString)
  2067. Next
  2068. EndIf
  2069. Case FILETYPE_DIR 'If folder, then we might have to search recursively
  2070. If pRecurse Then SearchPath(tmpFullPath,pFileType,pString,pRecurse)
  2071. EndSelect
  2072. If Not ShouldContinue() Then Return
  2073. Next
  2074. PollSystem();If PeekEvent() Then host.Poll() 'Let the system update as we could be searching a while
  2075. EndMethod
  2076. Method SearchFile(pPath$,pString$)
  2077. Local tmpText$ = CacheAndLoadText( pPath ), tmpLines$[], tmpFindPos%, tmpCharCount%, tmpLineNo%
  2078. Local tmpStringLength% = pString.length, tmpChunkLines$[], tmpPrevLines$
  2079. If tmpText Then
  2080. tmpLines = tmpText.Split("~n")
  2081. tmpText = tmpText.ToLower()
  2082. tmpFindPos = tmpText.Find(pString)
  2083. While ShouldContinue() And tmpFindPos > -1
  2084. tmpChunkLines = tmpText[..tmpFindPos].Split("~n")
  2085. tmpPrevLines = "~n".Join(tmpChunkLines[..tmpChunkLines.length-1])
  2086. tmpLineNo:+(tmpChunkLines.length)-1
  2087. Local tmpSearchResult:TSearchResult = New TSearchResult.Set(pPath,tmpFindPos-tmpPrevLines.length,tmpLineNo+1,tmpLines[tmpLineNo])
  2088. tmpSearchResult.AddToListbox(results);safetyCount:+1
  2089. tmpCharCount:+tmpFindPos+tmpStringLength
  2090. tmpText = tmpText[tmpFindPos+tmpStringLength..]
  2091. tmpFindPos = tmpText.Find(pString)
  2092. Wend
  2093. EndIf
  2094. EndMethod
  2095. Method ShouldContinue()
  2096. If safetyCount < 0 Then Return False
  2097. If safetyCount >= safetyThreshold Then
  2098. If Confirm( LocalizeString("{{search_safetynotification}}").Replace("%1",(safetyResetCount*safetyThreshold)+safetyCount) ) Then
  2099. safetyCount = 0
  2100. safetyResetCount:+1
  2101. Else
  2102. safetyCount = -1
  2103. Return False
  2104. EndIf
  2105. EndIf
  2106. Return True
  2107. EndMethod
  2108. Function Create:TSearchRequester(host:TCodePlay)
  2109. Local search:TSearchRequester = New TSearchRequester
  2110. search.initrequester(host,"{{search_window_title}}",ScaledSize(440),ScaledSize(280),STYLE_CANCEL|STYLE_DIVIDER|STYLE_OK|STYLE_STATUS|STYLE_RESIZABLE,strSearchText)
  2111. DisableGadget(search.ok)
  2112. SetGadgetLayout(CreateLabel("{{search_label_find}}:",ScaledSize(6),ScaledSize(8+4),ScaledSize(95),ScaledSize(24),search.window),EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED)
  2113. search.findbox=CreateTextField(ScaledSize(103),ScaledSize(8),ClientWidth(search.window)-ScaledSize(103+6),ScaledSize(21),search.window);SetGadgetLayout(search.findbox,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)
  2114. SetGadgetLayout(CreateLabel("{{search_label_filetypes}}:",ScaledSize(6),ScaledSize(42),ScaledSize(95),ScaledSize(24),search.window),EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED)
  2115. search.typebox=CreateComboBox(ScaledSize(103),ScaledSize(38),ClientWidth(search.window)-ScaledSize(103+6),ScaledSize(24),search.window);SetGadgetLayout(search.typebox,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)
  2116. AddGadgetItem( search.typebox, "{{search_type_bmaxfiles}}",GADGETITEM_DEFAULT|GADGETITEM_LOCALIZED,-1,"*.bmx" )
  2117. AddGadgetItem( search.typebox, "{{search_type_codefiles}}",GADGETITEM_LOCALIZED,-1,fileTypes )
  2118. AddGadgetItem( search.typebox, "{{search_type_allfiles}}",GADGETITEM_LOCALIZED,-1,"*")
  2119. SetGadgetLayout(CreateLabel("{{search_label_searchpath}}:",ScaledSize(6),ScaledSize(72),ScaledSize(95),ScaledSize(48),search.window),1,0,1,0)
  2120. search.pathbox=CreateTextField(ScaledSize(103),ScaledSize(68),ClientWidth(search.window)-ScaledSize(103+6+30+6),ScaledSize(21),search.window);SetGadgetLayout(search.pathbox,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)
  2121. search.pathbutton=CreateButton("..",ClientWidth(search.window)-ScaledSize(34+6),ScaledSize(65),ScaledSize(34),ScaledSize(26),search.window);SetGadgetLayout(search.pathbutton,EDGE_CENTERED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)
  2122. SetGadgetText(search.pathbox, CurrentDir())
  2123. search.pathsubdir=CreateButton("{{search_btn_searchsubfolders}}",ScaledSize(103),ScaledSize(98),ClientWidth(search.window)-ScaledSize(103+6),ScaledSize(20),search.window,BUTTON_CHECKBOX);SetGadgetLayout(search.pathsubdir,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)
  2124. SetButtonState(search.pathsubdir,True)
  2125. search.results=CreateListBox(ScaledSize(6),ScaledSize(128),ClientWidth(search.window)-ScaledSize(12),ScaledSize(280-(128+6)),search.window);SetGadgetLayout(search.results,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED)
  2126. Return search
  2127. End Function
  2128. End Type
  2129. Type TProjectRequester Extends TRequester
  2130. Field projects:TProjects
  2131. Field listbox:TGadget
  2132. Field add:TGadget
  2133. Field remove:TGadget
  2134. Field props:TGadget
  2135. Field moveup:TGadget
  2136. Field movedown:TGadget
  2137. Field Current:TProjectFolderNode
  2138. Method Invoke(command,arg:Object=Null)
  2139. Select command
  2140. Case TOOLACTIVATE
  2141. Refresh
  2142. End Select
  2143. End Method
  2144. Method SetCurrent(i)
  2145. If i=-1
  2146. DisableGadget remove
  2147. DisableGadget moveup
  2148. DisableGadget movedown
  2149. DisableGadget props
  2150. Current=Null
  2151. Else
  2152. Current=TProjectFolderNode(GadgetItemExtra(listbox,i))
  2153. If Current
  2154. EnableGadget remove
  2155. EnableGadget props
  2156. EnableGadget moveup
  2157. EnableGadget movedown
  2158. EndIf
  2159. EndIf
  2160. End Method
  2161. Method Poll()
  2162. Local index
  2163. Select EventSource()
  2164. Case window
  2165. If EventID()=EVENT_WINDOWCLOSE Then Hide()
  2166. Case add
  2167. If EventID() = EVENT_GADGETACTION Then
  2168. projects.NewProject
  2169. Refresh
  2170. EndIf
  2171. Case remove
  2172. If EventID() = EVENT_GADGETACTION Then
  2173. projects.RemoveProject SelectedGadgetItem(listbox)
  2174. Refresh
  2175. EndIf
  2176. Case cancel
  2177. If EventID() = EVENT_GADGETACTION Then Hide
  2178. Case props
  2179. If EventID() = EVENT_GADGETACTION And Current
  2180. host.projectprops.Open(Current)
  2181. EndIf
  2182. Case listbox
  2183. If EventID()=EVENT_GADGETSELECT
  2184. SetCurrent SelectedGadgetItem(listbox) 'EventData()
  2185. ElseIf EventID()=EVENT_GADGETACTION
  2186. SetCurrent SelectedGadgetItem(listbox)
  2187. host.projectprops.Open(Current)
  2188. EndIf
  2189. Case moveup
  2190. If EventID()=EVENT_GADGETACTION Then
  2191. index=projects.MoveProject(SelectedGadgetItem(listbox),-1)
  2192. Refresh
  2193. SelectGadgetItem listbox,index
  2194. SetCurrent(index)
  2195. EndIf
  2196. Case movedown
  2197. If EventID()=EVENT_GADGETACTION Then
  2198. index=projects.MoveProject(SelectedGadgetItem(listbox),1)
  2199. Refresh
  2200. SelectGadgetItem listbox,index
  2201. SetCurrent(index)
  2202. EndIf
  2203. End Select
  2204. End Method
  2205. Method Refresh()
  2206. ClearGadgetItems listbox
  2207. For Local node:TNode = EachIn projects.kids
  2208. If TFolderNode(node)'node.argument
  2209. AddGadgetItem listbox,node.name,0,-1,"",node
  2210. EndIf
  2211. Next
  2212. SetCurrent -1
  2213. End Method
  2214. Method Open(projnode:TProjects)
  2215. projects=projnode
  2216. Refresh
  2217. Show
  2218. End Method
  2219. Function Create:TProjectRequester(host:TCodePlay)
  2220. Local x,y
  2221. Local proj:TProjectRequester = New TProjectRequester
  2222. proj.initrequester(host,"{{projman_window_title}}",ScaledSize(400),ScaledSize(168),STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
  2223. proj.listbox=CreateListBox( ScaledSize(6),ScaledSize(8),ScaledSize(244),ScaledSize(154),proj.window )
  2224. x=ClientWidth(proj.window)-ScaledSize(144)
  2225. proj.add=CreateButton("{{projman_btn_addproj}}",x,ScaledSize(8),ScaledSize(138),ScaledSize(26),proj.window)
  2226. proj.remove=CreateButton("{{projman_btn_delproj}}",x,ScaledSize(40),ScaledSize(138),ScaledSize(26),proj.window)
  2227. proj.moveup=CreateButton("{{projman_btn_moveup}}",x,ScaledSize(72),ScaledSize(138),ScaledSize(26),proj.window)
  2228. proj.movedown=CreateButton("{{projman_btn_movedn}}",x,ScaledSize(104),ScaledSize(138),ScaledSize(26),proj.window)
  2229. proj.props=CreateButton("{{projman_btn_properties}}",x,ScaledSize(136),ScaledSize(138),ScaledSize(26),proj.window)
  2230. DisableGadget proj.remove
  2231. DisableGadget proj.moveup
  2232. DisableGadget proj.movedown
  2233. DisableGadget proj.props
  2234. Return proj
  2235. End Function
  2236. End Type
  2237. Type TProjectProperties Extends TRequester
  2238. Field proj:TProjectFolderNode
  2239. Field newproj:Int = False 'If 'True' then cancel/close deletes project.
  2240. Field localname:TGadget
  2241. Field localpath:TGadget
  2242. Field pathbutton:TGadget
  2243. Field path:TGadget
  2244. Field user:TGadget
  2245. Field password:TGadget
  2246. Field checkout:TGadget
  2247. ' Field update:TGadget
  2248. ' Field commit:TGadget
  2249. Field poprequester:TRequester 'hack for restoring to projectmanager requester
  2250. Field dirty
  2251. Method Invoke(command,arg:Object=Null)
  2252. Select command
  2253. Case TOOLACTIVATE
  2254. Refresh
  2255. End Select
  2256. End Method
  2257. Method Tidy()
  2258. newproj = False
  2259. If dirty
  2260. proj.Set GadgetText(localname),GadgetText(localpath),GadgetText(path),GadgetText(user),GadgetText(password)
  2261. dirty=False
  2262. EndIf
  2263. End Method
  2264. Method Poll()
  2265. If (EventID() <> EVENT_GADGETACTION) And (EventID() <> EVENT_WINDOWCLOSE) Then Return
  2266. Select EventSource()
  2267. Case localname,localpath,path,user,password
  2268. dirty=True
  2269. Case pathbutton
  2270. Local dir$=RequestDir(LocalizeString("{{project_requestfolder_title}}"))
  2271. If dir
  2272. If dir[dir.length-1..]="/" 'fltk hack
  2273. dir=dir[..dir.length-1]
  2274. EndIf
  2275. SetGadgetText localpath,dir
  2276. If GadgetText(localname)=""
  2277. SetGadgetText localname,StripDir(dir)
  2278. EndIf
  2279. dirty=True
  2280. EndIf
  2281. Case checkout
  2282. Tidy()
  2283. Hide()
  2284. proj.CheckoutVersion()
  2285. Rem
  2286. Case commit
  2287. Tidy
  2288. Hide
  2289. proj.CommitVersion
  2290. Case update
  2291. Tidy
  2292. Hide
  2293. proj.UpdateVersion
  2294. EndRem
  2295. Case ok
  2296. Tidy()
  2297. Hide()
  2298. Case cancel
  2299. Hide()
  2300. Case window
  2301. If EventID()=EVENT_WINDOWCLOSE
  2302. Hide()
  2303. EndIf
  2304. End Select
  2305. End Method
  2306. Method Hide()
  2307. If proj And newproj Then proj.Free()
  2308. EnableGadget host.window
  2309. HideGadget window
  2310. host.UnhookRequester Self'poprequester
  2311. If poprequester poprequester.Show
  2312. End Method
  2313. Method Refresh()
  2314. SetGadgetText localname,proj.name
  2315. SetGadgetText localpath,proj.path
  2316. SetGadgetText path,proj.svnpath
  2317. SetGadgetText user,proj.svnuser
  2318. SetGadgetText password,proj.svnpass
  2319. End Method
  2320. Method Open(projnode:TProjectFolderNode, newproject:Int = False)
  2321. newproj=newproject
  2322. proj=projnode
  2323. Refresh()
  2324. Show()
  2325. End Method
  2326. Function Create:TProjectProperties(host:TCodePlay)
  2327. Local proj:TProjectProperties = New TProjectProperties
  2328. proj.initrequester(host,"{{project_window_title}}",ScaledSize(480),ScaledSize(250),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
  2329. proj.modal = True
  2330. Local projectdetails:TGadget = CreatePanel(ScaledSize(6),ScaledSize(8),ClientWidth(proj.window)-ScaledSize(12),ScaledSize(85),proj.window,PANEL_GROUP,"{{project_group_details}}")
  2331. Local i,n,y
  2332. y=4
  2333. CreateLabel("{{project_label_name}}:",ScaledSize(6),ScaledSize(y+4),ScaledSize(72),ScaledSize(24),projectdetails)
  2334. proj.localname=CreateTextField(ScaledSize(88),ScaledSize(y),ClientWidth(projectdetails)-ScaledSize(88+6),ScaledSize(21),projectdetails)
  2335. ' proj.pathbutton=CreateButton("..",434,y,34,28,projectdetails)
  2336. y:+30
  2337. CreateLabel("{{project_label_path}}:",ScaledSize(8),ScaledSize(y+4),ScaledSize(72),ScaledSize(24),projectdetails)
  2338. proj.localpath=CreateTextField(ScaledSize(88),ScaledSize(y),ClientWidth(projectdetails)-ScaledSize(88+34+6+6),ScaledSize(21),projectdetails)
  2339. proj.pathbutton=CreateButton("..",ClientWidth(projectdetails)-ScaledSize(34+6),ScaledSize(y-3),ScaledSize(34),ScaledSize(26),projectdetails)
  2340. y:+30
  2341. Local svnbox:TGadget = CreatePanel(ScaledSize(6),ScaledSize(101),ClientWidth(proj.window)-ScaledSize(12),ScaledSize(144),proj.window,PANEL_GROUP,"{{project_group_svn}}")
  2342. y=4
  2343. CreateLabel("{{project_label_url}}:",ScaledSize(8),ScaledSize(y+LABELOFFSET),ScaledSize(72),ScaledSize(24),svnbox)
  2344. proj.path=CreateTextField(ScaledSize(88),ScaledSize(y),ClientWidth(svnbox)-ScaledSize(92),ScaledSize(21),svnbox)
  2345. y:+30
  2346. CreateLabel("{{project_label_username}}:",ScaledSize(8),ScaledSize(y+LABELOFFSET),ScaledSize(72),ScaledSize(24),svnbox)
  2347. proj.user=CreateTextField(ScaledSize(88),ScaledSize(y),ClientWidth(svnbox)-ScaledSize(92),ScaledSize(21),svnbox)
  2348. y:+30
  2349. CreateLabel("{{project_label_password}}:",ScaledSize(8),ScaledSize(y+LABELOFFSET),ScaledSize(72),ScaledSize(24),svnbox)
  2350. proj.password=CreateTextField(ScaledSize(88),ScaledSize(y),ClientWidth(svnbox)-ScaledSize(92),ScaledSize(21),svnbox,TEXTFIELD_PASSWORD)
  2351. y:+30
  2352. proj.checkout=CreateButton("{{project_btn_checkout}}",ClientWidth(svnbox)-ScaledSize(154),ClientHeight(svnbox)-ScaledSize(32),ScaledSize(150),ScaledSize(28),svnbox)
  2353. ' proj.update=CreateButton("{{project_btn_update}}",180,y+10,150,28,svnbox)
  2354. ' proj.commit=CreateButton("{{project_btn_commit}}",340,y+10,150,28,svnbox)
  2355. y:+40
  2356. Return proj
  2357. End Function
  2358. End Type
  2359. Function GetInfo$(a$ Var)
  2360. Local p,r$
  2361. p=a.Find("|")+1
  2362. If p=0 p=a.length+1
  2363. r$=a$[..p-1]
  2364. a$=a$[p..]
  2365. Return r$
  2366. End Function
  2367. Type TFolderNode Extends TNode
  2368. Field owner:TNode
  2369. Field path$
  2370. Field scanned
  2371. Field version
  2372. Field foldertype
  2373. Const PROJECTFOLDER=0
  2374. Const DIRECTORYFOLDER=1
  2375. Const FILEFOLDER=2
  2376. Method FindFolderFromPath:TFolderNode(dir$)
  2377. Local result:TFolderNode
  2378. If path=dir Return Self
  2379. For Local folder:TFolderNode = EachIn kids
  2380. result=folder.FindFolderFromPath(dir)
  2381. If result Return result
  2382. Next
  2383. End Method
  2384. Method SetName(n$)
  2385. If version Then n:+"("+version+")"
  2386. Super.SetName( n )
  2387. Refresh
  2388. End Method
  2389. Method SetVersion(ver)
  2390. version=ver
  2391. SetName StripDir(path)
  2392. End Method
  2393. Method Write(stream:TStream)
  2394. Local isopen
  2395. If GetState()=OPENSTATE isopen=True
  2396. If version Or isopen
  2397. stream.WriteLine "proj_data="+path+"|"+isopen+"|"+version+"|"
  2398. EndIf
  2399. For Local folder:TFolderNode = EachIn kids
  2400. folder.Write(stream)
  2401. Next
  2402. End Method
  2403. Method ProjectHost:TCodePlay()
  2404. Local n:TNode = Self
  2405. While n
  2406. If TProjects(n) Return TProjects(n).host
  2407. n=n.parent
  2408. Wend
  2409. End Method
  2410. Method ProjectNode:TProjectFolderNode()
  2411. Local n:TNode = Self
  2412. While n
  2413. If TProjectFolderNode(n) Return TProjectFolderNode(n)
  2414. n=n.parent
  2415. Wend
  2416. End Method
  2417. Method RunSVN(cmd$,about$,refresh)
  2418. Local host:TCodePlay = ProjectHost()
  2419. If Not host Notify LocalizeString("{{svn_notification_nodehostnotfound}}");Return
  2420. Local project:TProjectFolderNode = ProjectNode()
  2421. If Not project Notify LocalizeString("{{svn_notification_nodeprojectnotfound}}");Return
  2422. If project.svnuser
  2423. cmd:+" --username "+project.svnuser
  2424. If project.svnpass cmd:+" --password "+project.svnpass
  2425. EndIf
  2426. If refresh
  2427. host.execute cmd,about,MENUREFRESH,True,Self
  2428. Else
  2429. host.execute cmd,about,0,0,Self
  2430. EndIf
  2431. End Method
  2432. Method UpdateVersion()
  2433. Local cmd$=svncmd+" update"
  2434. cmd:+" "+quote(path)
  2435. RunSVN cmd,LocalizeString("{{svn_msg_updating}}").Replace("%1",path),True
  2436. End Method
  2437. Method CommitVersion()
  2438. Local cmd$=svncmd+" commit"
  2439. cmd:+" -m ~qmy comment~q"
  2440. cmd:+" "+quote(path)
  2441. RunSVN cmd,LocalizeString("{{svn_msg_committing}}").Replace("%1",path),False
  2442. End Method
  2443. Method Open(view=-1)
  2444. Update(True)
  2445. Super.Open view
  2446. End Method
  2447. Method AddFileNode:TNode(file$)
  2448. Local n:TNode
  2449. Local ext$
  2450. If (","+FileTypes+",").Contains(","+ExtractExt(file).toLower()+",") Then
  2451. n=AddNode(StripDir(file))
  2452. n.SetAction(owner,TOOLOPEN,file)
  2453. ext=ExtractExt(file$).ToLower()
  2454. n.sortname=ext+n.name
  2455. Return n
  2456. EndIf
  2457. End Method
  2458. Method AddFolderNode:TNode(path$)
  2459. Local n:TFolderNode = TFolderNode.CreateFolderNode(path,DIRECTORYFOLDER)
  2460. n.owner = owner
  2461. n.sortname=" "+n.name
  2462. Append n
  2463. Return n
  2464. End Method
  2465. Method Scan(o:TNode)
  2466. Local p$
  2467. Local flist:TList = New TList
  2468. owner=o
  2469. For Local f$ = EachIn LoadDir(path,True)
  2470. If f[..1] = "." Then Continue
  2471. p$=path+"/"+f
  2472. Select FileType(p$)
  2473. Case FILETYPE_FILE
  2474. AddFileNode p$
  2475. Case FILETYPE_DIR
  2476. AddFolderNode p$
  2477. End Select
  2478. Next
  2479. SortKids
  2480. scanned = True
  2481. End Method
  2482. Method ScanKids()
  2483. For Local f:TFolderNode = EachIn kids
  2484. f.owner = owner
  2485. f.Update(False)
  2486. Next
  2487. End Method
  2488. Method Rescan()
  2489. scanned = False
  2490. Update()
  2491. EndMethod
  2492. Method Update( alwaysScanKids:Int = False )
  2493. If Not scanned Then
  2494. FreeKids()
  2495. Scan owner
  2496. EndIf
  2497. If alwaysScanKids Or Not IsHidden() Then ScanKids()
  2498. Refresh()
  2499. End Method
  2500. Method Invoke(command,argument:Object=Null)
  2501. Local host:TCodePlay
  2502. Local cmd,p
  2503. Local line$
  2504. host=ProjectHost()
  2505. If Not host Notify LocalizeString("{{svn_notification_nodehostnotfound}}");Return
  2506. Select command
  2507. Case TOOLOUTPUT
  2508. line$=String(argument)
  2509. p=line.find(" revision ")
  2510. If p>-1
  2511. SetVersion Int(line[p+10..])
  2512. EndIf
  2513. ' If line[..12]="At revision "
  2514. ' DebugLog "TOOLOUTPUT:"+line
  2515. Return
  2516. Case TOOLERROR
  2517. line$=String(argument)
  2518. ' DebugLog "TOOLERROR:"+line
  2519. Return
  2520. Case TOOLMENU
  2521. cmd=Int(String(argument))
  2522. Select cmd
  2523. Case 0 'special toolmenu-command=0 fired by rightbutton node context
  2524. Highlight
  2525. Local menu:TGadget
  2526. menu=host.projects.projmenu
  2527. PopupWindowMenu host.window,menu,Self
  2528. Case MENUREFRESH
  2529. Rescan()
  2530. Case MENUBROWSE
  2531. OpenURL RealPath(path)
  2532. Case MENUSHELL
  2533. Local cd$=CurrentDir()
  2534. ChangeDir RealPath(path)
  2535. ?MacOS
  2536. host.execute "/bin/bash","Shell Terminal"
  2537. ?Linux
  2538. host.execute "/bin/bash","Shell Terminal"
  2539. ?Win32
  2540. host.execute "cmd","Shell Terminal - Type Exit To End"
  2541. ?
  2542. ChangeDir cd
  2543. Case MENUUPDATE
  2544. UpdateVersion
  2545. Case MENUCOMMIT
  2546. CommitVersion
  2547. ' Case MENUPROPS
  2548. ' host.projectprops.Open(Self)
  2549. Case MENUFINDINFILES
  2550. host.searchreq.ShowWithPath( RealPath(path) )
  2551. End Select
  2552. End Select
  2553. End Method
  2554. Function CreateFolderNode:TFolderNode(path$,foldertype)
  2555. Local n:TFolderNode = New TFolderNode
  2556. ' n.host=host
  2557. n.SetName( StripDir(path) )
  2558. n.path = path
  2559. n.foldertype = foldertype
  2560. Return n
  2561. End Function
  2562. End Type
  2563. Type TProjectFolderNode Extends TFolderNode
  2564. Field owner:TProjects
  2565. Field svnpath$,svnuser$,svnpass$,svnversion
  2566. Field svnerr$
  2567. Method CheckoutVersion() 'to do - needs to move old version to temp?
  2568. Local cmd$ = svncmd+" checkout"
  2569. cmd:+" "+quote(svnpath)
  2570. cmd:+" "+quote(path)
  2571. RunSVN cmd,LocalizeString("{{svn_msg_checkingout}}").Replace("%1",svnpath).Replace("%2",path),True
  2572. End Method
  2573. Function Crypt$(a$)
  2574. Local b$,c
  2575. For Local i:Int = 0 Until a.length
  2576. c=a[i]
  2577. If c>31 c:~((i*-5)&31)
  2578. b:+Chr(c&255)
  2579. Next
  2580. Return b
  2581. End Function
  2582. Method ToString$()
  2583. Local prj$
  2584. Local isopen
  2585. If GetState()&OPENSTATE isopen=True
  2586. prj=name+"|"+path+"|"+svnpath+"|"+svnuser+"|"+crypt(svnpass)+"|"+isopen+"|"+version
  2587. Return prj
  2588. End Method
  2589. Method Write(stream:TStream)
  2590. stream.WriteLine "proj_node="+ToString()
  2591. For Local folder:TFolderNode = EachIn kids
  2592. folder.Write(stream)
  2593. Next
  2594. End Method
  2595. Method FromString(info$)
  2596. Local n$ = GetInfo(info)
  2597. If Not n Then n = "Unknown"
  2598. SetName( n )
  2599. path=GetInfo(info)
  2600. If path path=owner.host.FullPath(path)
  2601. svnpath=GetInfo(info)
  2602. svnuser=GetInfo(info)
  2603. svnpass=GetInfo(info)
  2604. Scan(owner)
  2605. Local isopen,vers
  2606. isopen=Int(GetInfo(info))
  2607. If isopen
  2608. Open
  2609. EndIf
  2610. vers=Int(GetInfo(info))
  2611. If vers
  2612. SetVersion vers
  2613. EndIf
  2614. End Method
  2615. Method Invoke(command,argument:Object=Null)
  2616. Local cmd
  2617. Select command
  2618. Case TOOLMENU
  2619. cmd=Int(String(argument))
  2620. Select cmd
  2621. Case MENUPROPS
  2622. Return owner.host.projectprops.Open(Self)
  2623. End Select
  2624. End Select
  2625. Return Super.Invoke(command,argument)
  2626. End Method
  2627. Method Set(n$,p$,s$,user$,pass$)
  2628. path=owner.host.FullPath(p)
  2629. setname n
  2630. svnpath=s
  2631. svnuser=user
  2632. svnpass=pass
  2633. Rescan()
  2634. owner.host.projectreq.Refresh()
  2635. End Method
  2636. Function CreateProjectNode:TProjectFolderNode(projects:TProjects,info$)
  2637. Local n:TProjectFolderNode = New TProjectFolderNode
  2638. n.owner=projects
  2639. n.FromString(info)
  2640. n.foldertype=PROJECTFOLDER
  2641. Return n
  2642. End Function
  2643. End Type
  2644. Type TProjects Extends TNode
  2645. Field host:TCodePlay
  2646. Field addproj:TNode
  2647. Field projmenu:TGadget
  2648. Field projmenuprops:TGadget
  2649. Method RemoveProject(index)
  2650. Local node:TNode
  2651. If index<0 Or index>=kids.Count() Return
  2652. node=TNode(kids.ValueAtIndex(index))
  2653. If node node.Free
  2654. Refresh
  2655. End Method
  2656. Method MoveProject(index,dir)
  2657. Local node:TNode
  2658. Local link:TLink
  2659. If index<0 Or index>=kids.Count() Return index
  2660. node=TNode(kids.ValueAtIndex(index))
  2661. If node
  2662. addproj.Detach
  2663. node.Hide
  2664. link=kids.FindLink(node)
  2665. If dir>0
  2666. If link link=link._succ
  2667. If link
  2668. kids.Remove node
  2669. kids.InsertAfterLink node,link
  2670. index:+1
  2671. EndIf
  2672. Else
  2673. If link link=link._pred
  2674. If link
  2675. kids.Remove node
  2676. kids.InsertBeforeLink node,link
  2677. index:-1
  2678. EndIf
  2679. EndIf
  2680. Append addproj
  2681. Refresh
  2682. EndIf
  2683. Return index
  2684. End Method
  2685. Method NewProject()
  2686. addproj.Detach
  2687. Local proj:TProjectFolderNode = TProjectFolderNode.CreateProjectNode(Self,LocalizeString("{{project_defaultname}}"))
  2688. ' proj.scan(Self)
  2689. Append proj
  2690. Append addproj
  2691. host.projectprops.Open(proj, True)
  2692. Refresh
  2693. End Method
  2694. Method AddProject(data:TList)
  2695. Local project:TProjectFolderNode
  2696. Local folder:TFolderNode
  2697. For Local info$ = EachIn data
  2698. If Not project
  2699. addproj.Detach
  2700. project=TProjectFolderNode.CreateProjectNode(Self,info)
  2701. Append project
  2702. Append addproj
  2703. Refresh
  2704. Else
  2705. Local path$
  2706. Local popen
  2707. Local pversion
  2708. path=GetInfo(info)
  2709. popen=Int(GetInfo(info))
  2710. pversion=Int(GetInfo(info))
  2711. folder=project.FindFolderFromPath(path)
  2712. If folder
  2713. folder.SetVersion pversion
  2714. folder.ReScan()
  2715. If popen Then folder.Open()
  2716. EndIf
  2717. EndIf
  2718. Next
  2719. End Method
  2720. Method Write(stream:TStream)
  2721. For Local project:TProjectFolderNode = EachIn kids
  2722. project.Write(stream)
  2723. Next
  2724. End Method
  2725. Method Invoke(command,argument:Object=Null)
  2726. Select command
  2727. Case TOOLNEW
  2728. NewProject
  2729. Case TOOLOPEN
  2730. host.OpenSource String(argument)
  2731. End Select
  2732. End Method
  2733. Function CreateProjects:TProjects(host:TCodePlay)
  2734. Local p:TProjects = New TProjects
  2735. p.SetName("{{navnode_projects}}")
  2736. p.host=host
  2737. p.addproj=p.AddNode("{{navnode_addproject}}")
  2738. p.addproj.SetAction p,TOOLNEW
  2739. p.projmenu=CreateMenu("{{popup_nav_proj}}",0,Null)
  2740. CreateMenu "{{popup_nav_proj_refresh}}",MENUREFRESH,p.projmenu
  2741. CreateMenu "{{popup_nav_proj_findinfiles}}",MENUFINDINFILES,p.projmenu
  2742. CreateMenu "{{popup_nav_proj_explore}}",MENUBROWSE,p.projmenu
  2743. CreateMenu "{{popup_nav_proj_shell}}",MENUSHELL,p.projmenu
  2744. CreateMenu "",0,p.projmenu
  2745. CreateMenu "{{popup_nav_proj_svnupdate}}",MENUUPDATE,p.projmenu
  2746. CreateMenu "{{popup_nav_proj_svncommit}}",MENUCOMMIT,p.projmenu
  2747. CreateMenu "",0,p.projmenu
  2748. p.projmenuprops=CreateMenu("{{popup_nav_proj_properties}}",MENUPROPS,p.projmenu)
  2749. host.projectreq.projects=p
  2750. Return p
  2751. End Function
  2752. End Type
  2753. ?Not bmxng
  2754. Type TByteBuffer Extends TStream
  2755. Field bytes:Byte[]
  2756. Field readpointer
  2757. Method Read( buf:Byte Ptr,count )
  2758. If count>readpointer count=readpointer
  2759. If Not count Return
  2760. MemCopy buf,bytes,count
  2761. readpointer:-count
  2762. If readpointer MemMove bytes,Varptr bytes[count],readpointer
  2763. Return count
  2764. End Method
  2765. Method ReadLine$()
  2766. For Local i:Int = 0 Until readpointer
  2767. If bytes[i]=10 Or bytes[i] = 0 Then
  2768. Local tmpBytes:Byte[] = New Byte[i+1]
  2769. If i And bytes[i-1] = 13 Then i:-1
  2770. Read(tmpBytes,tmpBytes.length)
  2771. Return String.FromBytes(tmpBytes, i)
  2772. EndIf
  2773. Next
  2774. EndMethod
  2775. Method WriteFromPipe( pipe:TPipeStream )
  2776. Local n,m,count = pipe.ReadAvail()
  2777. n=readpointer+count
  2778. If n>bytes.length
  2779. m=Max(bytes.length*1.5,n)
  2780. bytes=bytes[..m]
  2781. EndIf
  2782. pipe.Read( Varptr bytes[readpointer], count )
  2783. readpointer=n
  2784. Return count
  2785. EndMethod
  2786. Method Write( buf:Byte Ptr,count )
  2787. Local n,m
  2788. n=readpointer+count
  2789. If n>bytes.length
  2790. m=Max(bytes.length*1.5,n)
  2791. bytes=bytes[..m]
  2792. EndIf
  2793. MemCopy Varptr bytes[readpointer],buf,count
  2794. readpointer=n
  2795. Return count
  2796. End Method
  2797. Method LineAvail()
  2798. For Local i:Int = 0 Until readpointer
  2799. If bytes[i]=10 Return True
  2800. Next
  2801. End Method
  2802. Method FlushBytes:Byte[]()
  2803. Local res:Byte[] = bytes[..readpointer]
  2804. readpointer = 0
  2805. Return res
  2806. End Method
  2807. End Type
  2808. ?bmxng
  2809. Type TByteBuffer Extends TStream
  2810. Field bytes:Byte[]
  2811. Field readpointer:Long
  2812. Method Read:Long( buf:Byte Ptr,count:Long )
  2813. If count>readpointer count=readpointer
  2814. If Not count Return
  2815. MemCopy buf,bytes,Size_T(count)
  2816. readpointer:-count
  2817. If readpointer MemMove bytes,Varptr bytes[count],Size_T(readpointer)
  2818. Return count
  2819. End Method
  2820. Method ReadLine$()
  2821. For Local i:Int = 0 Until readpointer
  2822. If bytes[i]=10 Or bytes[i] = 0 Then
  2823. Local tmpBytes:Byte[] = New Byte[i+1]
  2824. If i And bytes[i-1] = 13 Then i:-1
  2825. Read(tmpBytes,tmpBytes.length)
  2826. Return String.FromBytes(tmpBytes, i)
  2827. EndIf
  2828. Next
  2829. EndMethod
  2830. Method WriteFromPipe( pipe:TPipeStream )
  2831. Local n,m,count = pipe.ReadAvail()
  2832. n=readpointer+count
  2833. If n>bytes.length
  2834. m=Max(bytes.length*1.5,n)
  2835. bytes=bytes[..m]
  2836. EndIf
  2837. pipe.Read( Varptr bytes[readpointer], count )
  2838. readpointer=n
  2839. Return count
  2840. EndMethod
  2841. Method Write:Long( buf:Byte Ptr,count:Long )
  2842. Local n:Long,m:Long
  2843. n=readpointer+count
  2844. If n>bytes.length
  2845. m=Max(bytes.length*1.5,n)
  2846. bytes=bytes[..m]
  2847. EndIf
  2848. MemCopy Varptr bytes[readpointer],buf,Size_T(count)
  2849. readpointer=n
  2850. Return count
  2851. End Method
  2852. Method LineAvail()
  2853. For Local i:Int = 0 Until readpointer
  2854. If bytes[i]=10 Return True
  2855. Next
  2856. End Method
  2857. Method FlushBytes:Byte[]()
  2858. Local res:Byte[] = bytes[..readpointer]
  2859. readpointer = 0
  2860. Return res
  2861. End Method
  2862. End Type
  2863. ?
  2864. Type TObj
  2865. Field addr$,sync,refs,syncnext
  2866. Method ShouldSync( pDebugTree:TDebugTree )
  2867. If sync < pDebugTree.sync Then pDebugTree.QueueSync( Self )
  2868. EndMethod
  2869. Method HasSynced( pSync% )
  2870. sync = pSync;syncnext = False
  2871. EndMethod
  2872. End Type
  2873. Type TVar Extends TNode
  2874. Field owner:TDebugTree
  2875. Field obj:Object
  2876. Method Free()
  2877. If TObj(obj) owner.RemoveObj TObj(obj)
  2878. obj=Null
  2879. Super.Free()
  2880. End Method
  2881. Method SetVarName(n$)
  2882. Local p
  2883. name=n
  2884. ' if object ref set addr$ field
  2885. If name.find("$=")=-1 And name.find( ":String=" )=-1 And name.find(")=$")=-1
  2886. p=name.find("=$")
  2887. If p<>-1
  2888. If TObj(obj) Then
  2889. If TObj(obj).addr <> name[p+2..] Then
  2890. TDebugTree.RemoveObj TObj(obj)
  2891. Else
  2892. TObj(obj).refs:-1
  2893. EndIf
  2894. EndIf
  2895. obj=TDebugTree.AddObj(name[p+2..])
  2896. 'Request object dump if we are visible now that
  2897. 'we have updated our own object pointer.
  2898. If Not IsHidden() Then Request()
  2899. Return
  2900. EndIf
  2901. p=name.find("=Null")
  2902. If p<>-1
  2903. FreeKids
  2904. TDebugTree.RemoveObj TObj(obj)
  2905. obj=Null
  2906. EndIf
  2907. EndIf
  2908. End Method
  2909. Method AddVar(name$)
  2910. Local v:TVar=New TVar
  2911. v.owner=owner
  2912. Append v
  2913. v.setvarname name
  2914. End Method
  2915. Method SetValue(val:TVar)
  2916. Local v:TVar,w:TVar,i,kidsarray:Object[]
  2917. ' if this is a reference to same object refresh values
  2918. If obj And obj=val.obj
  2919. If kids.IsEmpty()
  2920. For v=EachIn val.kids
  2921. AddVar v.name
  2922. Next
  2923. Else
  2924. kidsarray = kids.ToArray()
  2925. For v=EachIn val.kids
  2926. If i<kidsarray.length
  2927. w=TVar(kidsarray[i])
  2928. If w w.SetVarName v.name
  2929. Else
  2930. AddVar v.name
  2931. EndIf
  2932. i:+1
  2933. Next
  2934. kidsarray = Null
  2935. EndIf
  2936. Refresh
  2937. EndIf
  2938. ' recurse so all references are updated
  2939. If IsHidden() Then Return 'parent And parent.state=CLOSEDSTATE Return
  2940. For v=EachIn kids
  2941. v.SetValue val
  2942. Next
  2943. End Method
  2944. Method Open(open=-1)
  2945. For Local kid:TVar = EachIn kids
  2946. kid.Request()
  2947. Next
  2948. Super.Open(open)
  2949. EndMethod
  2950. Method Request()
  2951. If TObj(obj) Then TObj(obj).ShouldSync(owner)
  2952. EndMethod
  2953. End Type
  2954. Type TScope Extends TVar
  2955. Field tree:TDebugTree
  2956. Field file$,line,column
  2957. Method Invoke(command,argument:Object=Null)
  2958. Select command
  2959. Case TOOLACTIVATE
  2960. tree.SelectScope Self,True
  2961. End Select
  2962. End Method
  2963. Method SetScope(s:TScope)
  2964. Local v:TVar
  2965. file=s.file
  2966. line=s.line
  2967. column=s.column
  2968. s.obj=Self
  2969. SetValue s
  2970. End Method
  2971. Method SetFile(debugtree:TDebugTree,f$)
  2972. tree=debugtree
  2973. Local p=f.Find("<")+1
  2974. Local q=f.Find(">")+1
  2975. Local r=f.Find(",")+1
  2976. If p And q And r
  2977. file=f[..p-1]
  2978. line=Int(f[p..r-1])
  2979. column=Int(f[r..q-1])
  2980. EndIf
  2981. obj=Self
  2982. End Method
  2983. Method Request()
  2984. For Local kid:TVar = EachIn kids
  2985. kid.Request()
  2986. Next
  2987. EndMethod
  2988. End Type
  2989. Type TDebugTree Extends TVar
  2990. Global sync
  2991. Global objmap:TMap = CreateMap()
  2992. Field host:TCodePlay
  2993. Field instack:TList
  2994. Field inscope:TScope
  2995. Field invar:TVar
  2996. Field infile$
  2997. Field inexception$
  2998. Field firststop
  2999. Field cancontinue
  3000. Method Reset()
  3001. ' host.SetMode host.DEBUGMODE
  3002. SetStack( New TList )
  3003. ClearMap objmap
  3004. instack=Null
  3005. inscope=Null
  3006. invar=Null
  3007. infile=""
  3008. inexception=""
  3009. sync=0
  3010. firststop=True
  3011. cancontinue=False
  3012. End Method
  3013. Function AddObj:TObj(addr$)
  3014. Local o:TObj = TObj(MapValueForKey( objmap, addr ))
  3015. If o Then
  3016. o.refs:+1
  3017. Else
  3018. o=New TObj
  3019. o.addr=addr
  3020. o.refs=1
  3021. MapInsert objmap, addr, o
  3022. EndIf
  3023. Return o
  3024. End Function
  3025. Function FindObj:TObj(addr$)
  3026. Return TObj(MapValueForKey( objmap, addr ))
  3027. End Function
  3028. Function RemoveObj(obj:TObj) ':TObj
  3029. If obj Then
  3030. obj.refs:-1
  3031. If Not obj.refs Then MapRemove objmap, obj.addr
  3032. EndIf
  3033. End Function
  3034. Method SyncVars()
  3035. sync:+1
  3036. For Local tmpVar:TVar = EachIn kids
  3037. tmpVar.Request()
  3038. Next
  3039. End Method
  3040. Method QueueSync( pObj:TObj )
  3041. If Not pObj Then Return
  3042. 'Sync as soon as the debug pipe is clear
  3043. '(see TOuputPanel.SendDumpRequests()).
  3044. pObj.syncnext = True
  3045. EndMethod
  3046. Method SetStack(list:TList)
  3047. Local openscope:TScope
  3048. Local s:TScope
  3049. Local count,i
  3050. count=kids.count() 'root.varlist.count()
  3051. For Local scope:TScope = EachIn list
  3052. If i>=count
  3053. Append scope 'root.Append scope
  3054. s=scope
  3055. Else
  3056. s=TScope(kids.ValueAtIndex(i))
  3057. ' simon was here
  3058. If s.name=scope.name
  3059. s.SetScope scope
  3060. scope.Free
  3061. Else
  3062. While kids.count()>i
  3063. s=TScope(kids.Last())
  3064. s.free
  3065. Wend
  3066. Append scope
  3067. s=scope
  3068. count=i+1
  3069. EndIf
  3070. EndIf
  3071. If firststop
  3072. If host.IsSourceOpen(s.file) openscope=s
  3073. Else
  3074. openscope=s
  3075. EndIf
  3076. i:+1
  3077. Next
  3078. While kids.count()>i
  3079. s=TScope(kids.Last())
  3080. s.free
  3081. Wend
  3082. If list.IsEmpty() Return
  3083. If Not openscope openscope=TScope(list.First())
  3084. If openscope SelectScope openscope,True
  3085. Refresh
  3086. firststop=False
  3087. End Method
  3088. Method SelectScope(scope:TScope,open)
  3089. If Not scope Return
  3090. host.SetMode host.DEBUGMODE ' simon was here, smoved from reset
  3091. If scope.file host.DebugSource scope.file,scope.line,scope.column
  3092. scope.Open()
  3093. ' If open
  3094. ' SelectTreeViewNode scope.node
  3095. ' scope.open
  3096. ' EndIf
  3097. End Method
  3098. Method ProcessError$(line$)
  3099. Local p
  3100. While p < line.length
  3101. If line[p]=$3E Then p:+1 Else Exit '">"
  3102. Wend
  3103. If p = line.length Return
  3104. If p Then line = line[p..]
  3105. If Not line.StartsWith("~~>") Return line
  3106. line=line[2..]
  3107. If invar
  3108. If line="}"
  3109. SetValue invar 'root
  3110. invar.Free
  3111. invar=Null
  3112. Else
  3113. ' If Not invar.name
  3114. ' invar.name=line
  3115. ' Else
  3116. invar.AddVar line
  3117. ' EndIf
  3118. EndIf
  3119. Return
  3120. EndIf
  3121. If instack
  3122. If line="}"
  3123. SetStack instack
  3124. instack=Null
  3125. inscope=Null
  3126. 'Request first object dumps, and bump sync count
  3127. SyncVars
  3128. If inexception
  3129. Notify inexception
  3130. inexception=""
  3131. EndIf
  3132. Return
  3133. EndIf
  3134. If infile
  3135. If line="Local <local>"
  3136. Else
  3137. inscope=New TScope
  3138. ' Print "inscope.line="+line
  3139. inscope.name=line
  3140. inscope.owner=Self
  3141. instack.AddLast inscope
  3142. EndIf
  3143. If inscope inscope.setfile Self,infile
  3144. infile=""
  3145. Return
  3146. EndIf
  3147. If line.StartsWith("@") And line.Contains("<")
  3148. infile=line[1..]
  3149. Else
  3150. If inscope inscope.AddVar line
  3151. EndIf
  3152. Return
  3153. EndIf
  3154. If line.StartsWith("Unhandled Exception:")
  3155. inexception=line
  3156. host.output.WritePipe "t"
  3157. cancontinue=False
  3158. Return
  3159. EndIf
  3160. If line="StackTrace{"
  3161. instack=New TList
  3162. Return
  3163. EndIf
  3164. If line="Debug:" Or line="DebugStop:"
  3165. host.output.WritePipe "t"
  3166. If Not cancontinue Then
  3167. cancontinue=True
  3168. host.RefreshToolbar()
  3169. EndIf
  3170. Return
  3171. EndIf
  3172. If line.StartsWith("ObjectDump@")
  3173. p=line.find("{",11)
  3174. If p=-1 Return line
  3175. line=line[11..p]
  3176. invar=New TVar
  3177. invar.obj=FindObj(line)
  3178. invar.owner=Self
  3179. Return
  3180. EndIf
  3181. End Method
  3182. Function CreateDebugTree:TDebugTree(host:TCodePlay)
  3183. Local d:TDebugTree = New TDebugTree
  3184. d.owner=d
  3185. d.SetName "{{navtab_debug}}"
  3186. d.host=host
  3187. d.Open
  3188. Return d
  3189. End Function
  3190. End Type
  3191. Type TNodeView
  3192. Field owner:TNavBar
  3193. Field root:TNode
  3194. Field treeview:TGadget
  3195. Field index
  3196. Method NewView()
  3197. Local n:TNode,hnode:TGadget
  3198. hnode=SelectedTreeViewNode(treeview)
  3199. n=root.Find(hnode,index)
  3200. If n And n.parent owner.AddView n
  3201. End Method
  3202. Method OnEvent()
  3203. Local n:TNode = root.Find(TGadget(EventExtra()),index)
  3204. If Not n Return 'probably an eventgadgetselect -1 Notify("could not find in root");Return
  3205. Select EventID()
  3206. Case EVENT_GADGETSELECT
  3207. n.invoke(TOOLSELECT)
  3208. Case EVENT_GADGETACTION
  3209. n.invoke(TOOLACTIVATE)
  3210. Case EVENT_GADGETMENU
  3211. n.invoke(TOOLMENU,Self)
  3212. Case EVENT_GADGETOPEN
  3213. n.open index
  3214. Case EVENT_GADGETCLOSE
  3215. n.close index
  3216. End Select
  3217. End Method
  3218. End Type
  3219. Type TNavBar Extends TEventHandler
  3220. Field host:TCodePlay
  3221. Field tabber:TGadget
  3222. Field viewlist:TList=New TList
  3223. Field selected:TNodeView
  3224. Field navmenu:TGadget
  3225. Method SelectedView()
  3226. If selected Return selected.index
  3227. End Method
  3228. Method SelectView(index)
  3229. Local n:TNodeView
  3230. If index>=viewlist.count() Return
  3231. n=TNodeView(viewlist.ValueAtIndex(index))
  3232. If Not n Print "selectview failed";Return
  3233. If n<>selected
  3234. If selected HideGadget selected.treeview
  3235. selected=n
  3236. EndIf
  3237. ShowGadget n.treeview
  3238. SelectGadgetItem tabber,index
  3239. End Method
  3240. Method AddView(node:TNode)
  3241. Local n:TNodeView
  3242. Local index,root:TGadget
  3243. For n=EachIn viewlist
  3244. If n.root=node SelectView n.index;Return
  3245. Next
  3246. n=New TNodeView
  3247. n.owner=Self
  3248. n.root=node
  3249. n.treeview=CreateTreeView(0,0,ClientWidth(tabber),ClientHeight(tabber),tabber)
  3250. host.options.navstyle.Apply n.treeview
  3251. SetGadgetLayout n.treeview,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  3252. HideGadget n.treeview
  3253. n.index=viewlist.Count()
  3254. viewlist.AddLast n
  3255. AddGadgetItem tabber,node.name,GADGETITEM_LOCALIZED
  3256. root=TreeViewRoot(n.treeview)
  3257. node.setnode root,n.index
  3258. SelectView n.index
  3259. Return n.index
  3260. End Method
  3261. Method OnEvent()
  3262. If EventSource()=tabber
  3263. SelectView SelectedGadgetItem(tabber)
  3264. End If
  3265. If selected And EventSource()=selected.treeview
  3266. selected.OnEvent
  3267. EndIf
  3268. End Method
  3269. Method Refresh()
  3270. For Local view:TNodeView = EachIn viewlist
  3271. host.options.navstyle.Apply view.treeview
  3272. Next
  3273. End Method
  3274. Method Invoke(command,argument:Object=Null)
  3275. If command=TOOLREFRESH Refresh()
  3276. If command=TOOLNEWVIEW And selected selected.NewView
  3277. End Method
  3278. Function CreateNavMenu:TGadget()
  3279. Local edit:TGadget = CreateMenu("&Nav",0,Null)
  3280. CreateMenu "&New View",MENUNEWVIEW,edit
  3281. Return edit
  3282. End Function
  3283. Function Create:TNavBar(host:TCodePlay, parent:TGadget) ',root:TNode)
  3284. Local n:TNavBar = New TNavBar
  3285. n.host=host
  3286. n.tabber=CreateTabber(0,0,ClientWidth(parent),ClientHeight(parent),parent)
  3287. SetGadgetLayout(n.tabber,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED)
  3288. ' n.AddView root
  3289. n.navmenu=CreateNavMenu()
  3290. Return n
  3291. End Function
  3292. End Type
  3293. Type TOutputPanel Extends TToolPanel 'used build and run
  3294. Field host:TCodePlay
  3295. Field output:TGadget
  3296. Field process:TProcess
  3297. Field pipe:TStream
  3298. Field wpipe:TTextStream
  3299. Field user$,cmdline$,err$,post$
  3300. Field errbuffer:TByteBuffer
  3301. Field outputmenu:TGadget
  3302. Field posttool:TTool
  3303. Method ClearDumpRequests()
  3304. For Local o:TObj = EachIn MapValues(host.debugtree.objmap)
  3305. o.HasSynced(o.sync)
  3306. Next
  3307. EndMethod
  3308. Method SendDumpRequests()
  3309. For Local o:TObj = EachIn MapValues(host.debugtree.objmap)
  3310. If o.syncnext Then
  3311. If o.addr <> "00000000" Then WritePipe "d"+o.addr
  3312. o.HasSynced( host.debugtree.sync )
  3313. EndIf
  3314. Next
  3315. EndMethod
  3316. Method Clear()
  3317. If Not output Open()
  3318. SetGadgetText output,""
  3319. End Method
  3320. Method WriteAscii(mess$)
  3321. If Not output Open()
  3322. AddTextAreaText output,mess.Replace("~0","")
  3323. End Method
  3324. Method Write(mess$)
  3325. If Not output Open()
  3326. AddTextAreaText output,mess.Replace("~0","")
  3327. End Method
  3328. Method Execute(cmd$,mess$="",exe$="",home=True,owner:TTool=Null)
  3329. If Not output Open()
  3330. If Not mess$ mess$=cmd$
  3331. err$=""
  3332. post$=exe
  3333. posttool=owner
  3334. host.SelectPanel Self
  3335. host.debugtree.Reset
  3336. If process And ProcessStatus(process)
  3337. Delay 500
  3338. If ProcessStatus(process)
  3339. Notify LocalizeString("{{output_notification_stillbusy}}").Replace("%1",cmdline)
  3340. Return
  3341. EndIf
  3342. EndIf
  3343. cmd=cmd.Trim()
  3344. process=CreateProcess(cmd$,HIDECONSOLE)
  3345. If Not process Then Notify LocalizeString("{{output_notification_processfailure}}").Replace("%1",cmd);Return
  3346. If Not process.status() Then Notify LocalizeString("{{output_notification_failedstart}}").Replace("%1",cmd);process=Null;Return
  3347. pipe=Process.pipe
  3348. wpipe=TTextStream.Create(pipe,TTextStream.UTF8)
  3349. cmdline=cmd
  3350. If home Clear
  3351. Write( mess+"~n" )
  3352. errbuffer = New TByteBuffer
  3353. host.RefreshToolbar
  3354. End Method
  3355. Method WritePipe(l$)
  3356. Try
  3357. If pipe pipe.WriteLine(l)
  3358. Catch ex:TStreamWriteException
  3359. Write LocalizeString("{{output_msg_debugfailure}}~n").Replace("%1",l)
  3360. Stop
  3361. EndTry
  3362. End Method
  3363. Method Go()
  3364. WritePipe "r"
  3365. host.debugtree.cancontinue = False
  3366. host.SelectPanel Self
  3367. host.RefreshToolbar()
  3368. End Method
  3369. Method StepOver()
  3370. ClearDumpRequests()
  3371. WritePipe "s"
  3372. End Method
  3373. Method StepIn()
  3374. ClearDumpRequests()
  3375. WritePipe "e"
  3376. End Method
  3377. Method StepOut()
  3378. ClearDumpRequests()
  3379. WritePipe "l"
  3380. End Method
  3381. Method Stop()
  3382. If Not process Return
  3383. process.Terminate()
  3384. FlushPipes process.pipe,process.err
  3385. process.Close()
  3386. process=Null
  3387. Write LocalizeString("~n{{output_msg_processterminated}}~n")
  3388. host.DebugExit()
  3389. Close()
  3390. End Method
  3391. Method Wait()
  3392. While process And process.status()
  3393. PollSystem
  3394. Wend
  3395. End Method
  3396. Method Invoke(command,argument:Object=Null)
  3397. Select command
  3398. Case TOOLSHOW
  3399. host.SetTitle()
  3400. If output ActivateGadget output
  3401. Case TOOLCLOSE
  3402. host.RemovePanel Self
  3403. output=Null
  3404. Case TOOLCUT
  3405. GadgetCut output
  3406. Case TOOLCOPY
  3407. GadgetCopy output
  3408. Case TOOLPASTE
  3409. GadgetPaste output
  3410. Case TOOLSELECTALL
  3411. If output SelectTextAreaText output
  3412. Case TOOLREFRESH
  3413. host.options.outputstyle.apply output
  3414. End Select
  3415. End Method
  3416. Method Close()
  3417. host.SelectPanel host.activepanel
  3418. End Method
  3419. Method Escape()
  3420. Stop
  3421. Close
  3422. End Method
  3423. Function outputfilter(event:TEvent,context:Object)
  3424. Local out:TOutputPanel=TOutputPanel(context)
  3425. If Not out Return
  3426. Select event.id
  3427. Case EVENT_KEYDOWN
  3428. If event.data=27
  3429. out.Escape()
  3430. Return 0
  3431. EndIf
  3432. Case EVENT_KEYCHAR
  3433. ' Print "output_keychar "+event.data
  3434. out.writechar(event.data)
  3435. End Select
  3436. Return 1
  3437. End Function
  3438. Method OnEvent()
  3439. If EventSource()=output
  3440. If EventID()=EVENT_GADGETMENU
  3441. PopupWindowMenu host.window,outputmenu
  3442. EndIf
  3443. EndIf
  3444. ' Case EVENT_TIMERTICK
  3445. If Not process Return
  3446. ReadPipes process.pipe,process.err
  3447. If Not process.status()
  3448. process.terminate
  3449. FlushPipes process.pipe,process.err
  3450. process.close()
  3451. process = Null
  3452. Write LocalizeString("~n{{output_msg_processcomplete}}~n")
  3453. host.DebugExit
  3454. host.SelectPanel Self
  3455. If err
  3456. host.ParseError err
  3457. Else
  3458. If post$
  3459. Local menuaction=Int(post)
  3460. If menuaction
  3461. host.OnMenu menuaction,posttool
  3462. ' Else
  3463. ' Execute post$,"","",False,0
  3464. EndIf
  3465. Else
  3466. If host.options.hideoutput Close()
  3467. EndIf
  3468. EndIf
  3469. EndIf
  3470. End Method
  3471. Method FlushPipes(pipe:TPipeStream,errpipe:TPipeStream)
  3472. ReadPipes(pipe,errpipe)
  3473. Local bytes:Byte[] = errbuffer.flushbytes()
  3474. If bytes
  3475. Local line$=String.FromBytes(bytes,Len bytes)
  3476. line=line.Replace(Chr(13),"")
  3477. If line<>">" Write line
  3478. EndIf
  3479. End Method
  3480. Method ReadPipes(pipe:TPipeStream,errpipe:TPipeStream)
  3481. Local status
  3482. Local bytes:Byte[],line$
  3483. bytes=pipe.ReadPipe()
  3484. If bytes
  3485. line$=String.FromBytes(bytes,Len bytes)
  3486. line=line.Replace(Chr(13),"")
  3487. Write line
  3488. EndIf
  3489. If errpipe.ReadAvail() Then
  3490. errbuffer.WriteFromPipe(errpipe)
  3491. Else
  3492. SendDumpRequests()
  3493. EndIf
  3494. ' If bytes Write String.FromBytes(bytes,bytes.length)
  3495. While errbuffer.LineAvail()
  3496. line$=errbuffer.ReadLine()
  3497. line=host.debugtree.ProcessError(line)
  3498. If line
  3499. Write line+"~n"
  3500. err:+line+"~n"
  3501. EndIf
  3502. Wend
  3503. End Method
  3504. Method WriteChar(char)
  3505. Local pipe:TPipeStream
  3506. If Not process Return
  3507. pipe=process.pipe
  3508. If char=3 'CTRL-C
  3509. Stop()
  3510. EndIf
  3511. If char=13 'ENTER
  3512. ' Write Chr(10)
  3513. pipe.WriteLine user$
  3514. user=""
  3515. EndIf
  3516. If char=8 And user.length 'DELETE
  3517. ' Local pos=TextAreaLen(output)
  3518. ' If pos SetTextAreaText output,"",pos-1,1,TEXTAREA_CHARS
  3519. user=user[..user.length-1]
  3520. EndIf
  3521. If char>31
  3522. ' Write Chr(char)
  3523. user:+Chr(char)
  3524. EndIf
  3525. End Method
  3526. Method Open()
  3527. If output Then
  3528. codeplay.SelectPanel Self
  3529. Return
  3530. EndIf
  3531. codeplay.addpanel(Self)
  3532. output=CreateTextArea(0,0,ClientWidth(panel),ClientHeight(panel),panel,TEXTAREA_WORDWRAP)
  3533. DelocalizeGadget output
  3534. SetGadgetLayout output,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  3535. SetGadgetFilter output,outputfilter,Self
  3536. SetGadgetText output," " 'simon was here
  3537. host.options.outputstyle.apply output
  3538. End Method
  3539. Function CreateOutputMenu:TGadget()
  3540. Local edit:TGadget = CreateMenu("{{popup_output}}",0,Null)
  3541. CreateMenu "{{popup_output_cut}}",MENUCUT,edit
  3542. CreateMenu "{{popup_output_copy}}",MENUCOPY,edit
  3543. CreateMenu "{{popup_output_paste}}",MENUPASTE,edit
  3544. CreateMenu "",0,edit
  3545. CreateMenu "{{popup_output_stop}}",MENUSTOP,edit
  3546. Return edit
  3547. End Function
  3548. Function Create:TOutputPanel(host:TCodePlay)
  3549. Local o:TOutputPanel = New TOutputPanel
  3550. o.host=host
  3551. o.name="{{tab_output}}"
  3552. o.outputmenu=CreateOutputMenu()
  3553. ' o.Open
  3554. Return o
  3555. End Function
  3556. End Type
  3557. Type TCodeNode Extends TNode
  3558. Field owner:TOpenCode
  3559. Field pos,count
  3560. 'Field groups:TMap=New TMap
  3561. Method Invoke(command,argument:Object=Null)
  3562. Select command
  3563. Case TOOLACTIVATE
  3564. owner.ShowPos(pos)
  3565. End Select
  3566. End Method
  3567. Method Sync(snap:TNode)
  3568. If snap.name<>name SetName(snap.name)
  3569. Local n:TCodeNode = TCodeNode(snap)
  3570. If n pos=n.pos;count=n.count
  3571. Super.Sync(snap)
  3572. End Method
  3573. Method SetName(n$)
  3574. Local p = n.find("'")
  3575. If p<>-1 n=n[..p]
  3576. name=n.Trim()
  3577. ' If owner.host.options.sortcode
  3578. sortname=n
  3579. End Method
  3580. Method Free()
  3581. owner = Null
  3582. Super.Free()
  3583. End Method
  3584. Method AddCodeNode:TCodeNode(n$,p0,p1)
  3585. Local t$
  3586. Local i:Int = n.find(" ") 'if space then group
  3587. If i>0
  3588. t=n[..i]
  3589. n=n[i+1..]
  3590. Rem
  3591. p=TNode(groups.ValueForKey(t))
  3592. If Not p
  3593. p=AddNode(t+"s")
  3594. p.Open
  3595. groups.insert t,p
  3596. EndIf
  3597. EndRem
  3598. EndIf
  3599. Local c:TCodeNode = New TCodeNode
  3600. c.owner=owner
  3601. c.setname n$
  3602. c.pos=p0
  3603. c.count=p1-p0
  3604. Append(c)
  3605. Return c
  3606. End Method
  3607. End Type
  3608. Type TDiff
  3609. Field pos,count,del$,add$,pos0,count0,pos1,textchange = True
  3610. End Type
  3611. Type TOpenCode Extends TToolPanel
  3612. Global msgHighlightingStatus$ = "Highlighting"
  3613. Field host:TCodePlay
  3614. Field textarea:TGadget
  3615. Field dirty=True
  3616. Field filesrc$,cleansrc$,cleansrcl$
  3617. Field Current:TDiff
  3618. Field undolist:TList=New TList
  3619. Field redolist:TList=New TList
  3620. Field helpcmd$,helpstring$
  3621. Field seek$
  3622. Field cursorpos,cursorlen,cursorline
  3623. Field oldpos,oldlen
  3624. Field isbmx,isc,iscpp,ishtml
  3625. Field deferpos = -1
  3626. Field tidyqueue1 = -1, tidyqueue2 = -1
  3627. Field editmenu:TGadget
  3628. Field codenode:TCodeNode
  3629. Field dirtynode,uc
  3630. Function RefreshHighlightingMsg()
  3631. msgHighlightingStatus = LocalizeString("{{msg_highlightingcode}}")
  3632. EndFunction
  3633. Function IsNotAlpha(c)
  3634. If c<48 Return True
  3635. If c>=58 And c<65 Return True
  3636. If c>=91 And c<95 Return True
  3637. If c>=96 And c<97 Return True
  3638. If c>=123 Return True
  3639. End Function
  3640. Function WordAtPos$(a$,p)
  3641. Local c,q,r,n
  3642. ' string literal
  3643. q=a.findlast(EOL$,a.length-p)
  3644. If q=-1 q=0
  3645. For q=q To p-1
  3646. If a[q]=34 Then
  3647. n=Not n
  3648. r=q
  3649. EndIf
  3650. Next
  3651. If n
  3652. q=a.Find("~q",r+1)+1
  3653. If q=0 q=a.length
  3654. Return a[r..q]
  3655. EndIf
  3656. ' alphanumeric
  3657. p=Min(p,a.length-1) 'simon was here - crash when checking at last char
  3658. For p=p Until 0 Step -1 'simon was here unto->to
  3659. If IsNotAlpha(a$[p]) Continue
  3660. Exit
  3661. Next
  3662. For q=p-1 To 0 Step -1
  3663. If IsNotAlpha(a$[q]) Exit
  3664. Next
  3665. For r=p To a.length-1
  3666. If IsNotAlpha(a$[r]) Exit
  3667. Next
  3668. Return a[q+1..r]
  3669. End Function
  3670. Function FirstDiff(s0$,s1$)
  3671. Local n = Min(s0.length,s1.length)
  3672. For Local i:Int = 0 Until n
  3673. If s0[i]<>s1[i] Return i
  3674. Next
  3675. Return n
  3676. End Function
  3677. Function LastDiff(s0$,s1$)
  3678. Local n = Min(s0.length,s1.length)
  3679. Local i = s0.length-1
  3680. Local j = s1.length-1
  3681. While n>0
  3682. If s0[i]<>s1[j] Exit
  3683. i:-1;j:-1;n:-1
  3684. Wend
  3685. Return i+1
  3686. End Function
  3687. Method parsebmx(n:TCodeNode)
  3688. Local src$,line,col
  3689. Local p,p1,r,t,m,f,l,e
  3690. src=cleansrcl
  3691. p1=src.length
  3692. p=-1;r=-1;t=-1;m=-1;f=-1;l=-1
  3693. While p<p1 'update rem,type,method,function,label pointers
  3694. While r<=p
  3695. r=FindToken("rem",src,r+1)
  3696. Wend
  3697. While t<=p
  3698. t=FindToken("type",src,t+1)
  3699. Wend
  3700. While m<=p
  3701. m=FindToken("method",src,m+1)
  3702. Wend
  3703. While f<=p
  3704. f=FindToken("function",src,f+1)
  3705. Wend
  3706. While l<=p
  3707. l=FindLabel(src,l+1)
  3708. Wend
  3709. If r<t And r<m And r<f And r<l
  3710. p=FindEndToken("rem",src,r+1,True)
  3711. Continue
  3712. EndIf
  3713. p=Min(t,Min(m,Min(f,l)))
  3714. If p=src.length Exit
  3715. While (n And n.parent And p>n.pos+n.count)
  3716. If Not TCodeNode(n.parent)
  3717. If n.parent.parent
  3718. n = TCodeNode(n.parent.parent)
  3719. Else
  3720. n = Null
  3721. EndIf
  3722. Else
  3723. n=TCodeNode(n.parent)
  3724. EndIf
  3725. Wend
  3726. If t<m And t<f And t<l
  3727. e=src.find(EOL,t)
  3728. n=n.AddCodeNode(cleansrc[t..e],t,FindEndToken("type",src,t,True))
  3729. p=t+1
  3730. Continue
  3731. EndIf
  3732. If m<f And m<l
  3733. e=src.find(EOL,m)
  3734. n.AddCodeNode(cleansrc[m..e],m,e)
  3735. p=m+1
  3736. Continue
  3737. EndIf
  3738. If f<l
  3739. e=src.find(EOL,f)
  3740. n.AddCodeNode(cleansrc[f..e],f,e)
  3741. p=f+1
  3742. Continue
  3743. Else
  3744. e=src.find(EOL,l)
  3745. n.AddCodeNode(cleansrc[l..e],l,e)
  3746. p=l+1
  3747. Continue
  3748. EndIf
  3749. Wend
  3750. End Method
  3751. Method GetNode:TNode()
  3752. Local root:TCodeNode = New TCodeNode
  3753. root.name = StripDir(path)
  3754. root.owner = Self
  3755. root.count = cleansrc.length
  3756. If isbmx parsebmx(root) ' stopped code view parse on non bmx files
  3757. If codenode
  3758. If host.options.sortcode root.sortkids
  3759. codenode.Sync(root)
  3760. root.Free()
  3761. Else
  3762. codenode=root
  3763. EndIf
  3764. Return codenode
  3765. End Method
  3766. Method HighlightLine(line,column = 0)
  3767. Local i:Int, tmpCharLineStart% = TextAreaChar(textarea,line)
  3768. Local tmpLine$ = TextAreaText( textarea, line, 1, TEXTAREA_LINES ).Replace("~r","").Replace("~n","")
  3769. For i = column Until tmpLine.length
  3770. If IsNotAlpha(tmpLine[i]) Then tmpCharLineStart:+1 Else Exit
  3771. Next
  3772. SelectTextAreaText textarea,line-1,0,TEXTAREA_LINES
  3773. SelectTextAreaText textarea,line+1,0,TEXTAREA_LINES
  3774. If i = tmpLine.length Or ..
  3775. ( TextAreaCharX( textarea, tmpCharLineStart + tmpLine.length-i ) - TextAreaCharX( textarea, tmpCharLineStart ) >= ClientWidth(textarea) ) Then
  3776. SelectTextAreaText textarea,line,1,TEXTAREA_LINES
  3777. Else
  3778. SelectTextAreaText textarea,tmpCharLineStart,tmpLine.length-i,TEXTAREA_CHARS
  3779. EndIf
  3780. EndMethod
  3781. Method ShowPos(pos)
  3782. host.SelectPanel( Self )
  3783. HighlightLine( TextAreaLine(textarea,pos) )
  3784. UpdateCursor()
  3785. ActivateGadget( textarea )
  3786. End Method
  3787. Method Debug(line,column)
  3788. HighlightLine( line-1 )
  3789. UpdateCursor()
  3790. End Method
  3791. Method Edit()
  3792. SelectTextAreaText( textarea,cursorpos,0,TEXTAREA_CHARS )
  3793. ActivateGadget( textarea )
  3794. UpdateStatus()
  3795. End Method
  3796. Method UpdateStatus()
  3797. Local c = cursorpos+cursorlen
  3798. If cursorline Then c:-TextAreaChar(textarea,cursorline-1)
  3799. host.SetStatus helpstring+"~t~t"+LocalizeString("{{status_line_char}}").Replace("%1",cursorline).Replace("%2",(c+1))
  3800. End Method
  3801. Method UpdateCursor()
  3802. oldpos=cursorpos
  3803. oldlen=cursorlen
  3804. cursorpos=TextAreaCursor(textarea,TEXTAREA_CHARS)
  3805. cursorlen=TextAreaSelLen(textarea,TEXTAREA_CHARS)
  3806. If cursorpos<>oldpos Or cursorlen<>oldlen
  3807. Local l = TextAreaLine(textarea,cursorpos)+1
  3808. If l<>cursorline And dirtynode
  3809. GetNode().Refresh
  3810. dirtynode=False
  3811. If (deferpos>=0) UpdateCode 'SetCode cleansrc
  3812. EndIf
  3813. cursorline=l
  3814. UpdateStatus()
  3815. BracketMatching(cleansrcl)
  3816. If (tidyqueue1 >= 0 Or tidyqueue2 >= 0) Then UpdateCode()
  3817. PollSystem
  3818. EndIf
  3819. End Method
  3820. ' tdiff - pos del$ add$
  3821. Method CalcDiff:TDiff(src$)
  3822. Local d:TDiff
  3823. If src.length<>cleansrc.length
  3824. d=New TDiff
  3825. d.pos0=cursorpos
  3826. d.count0=cursorlen
  3827. d.pos=oldpos
  3828. d.count=oldlen
  3829. If cursorlen And oldlen 'block modified
  3830. d.del=cleansrc[oldpos..oldpos+oldlen]
  3831. d.add=src[oldpos..cursorpos+cursorlen]
  3832. d.pos1=oldpos
  3833. Else
  3834. If cursorpos<=oldpos And cursorlen<=oldlen 'backspace
  3835. d.del=cleansrc[cursorpos..cursorpos+cleansrc.length-src.length]
  3836. d.pos1=cursorpos
  3837. Else 'insert
  3838. d.del=cleansrc[oldpos..oldpos+oldlen]
  3839. d.add=src[oldpos..cursorpos+cursorlen]
  3840. d.pos1=oldpos
  3841. EndIf
  3842. EndIf
  3843. Else
  3844. If cursorpos>oldpos 'overwrite
  3845. d=New TDiff
  3846. d.pos0=cursorpos
  3847. d.count0=cursorlen
  3848. d.pos=oldpos
  3849. d.count=oldlen
  3850. d.del=cleansrc[oldpos..cursorpos]
  3851. d.add=src[oldpos..cursorpos]
  3852. d.pos1=oldpos
  3853. If d.del = d.add Then d.textchange=False
  3854. EndIf
  3855. EndIf
  3856. Return d
  3857. End Method
  3858. Method UpdateCode(makeundo=True)
  3859. Local cpos
  3860. Local src$ = TextAreaText(textarea)
  3861. Local d:TDiff = CalcDiff(src)
  3862. If d
  3863. If makeundo And d.textchange
  3864. undolist.AddLast d
  3865. redolist.Clear
  3866. EndIf
  3867. SetCode src,d
  3868. If d.textchange Then dirtynode=True
  3869. EndIf
  3870. If (deferpos >= 0) Or (tidyqueue1 >= 0) Or (tidyqueue2 >= 0) Then SetCode src
  3871. End Method
  3872. Method Undo()
  3873. Local d:TDiff
  3874. If undolist.IsEmpty() Return
  3875. d=TDiff(undolist.RemoveLast())
  3876. redolist.AddLast d
  3877. SetTextAreaText textarea,d.del,d.pos1,d.add.length
  3878. SelectTextAreaText(textarea,d.pos,d.count)
  3879. SetCode TextAreaText(textarea),d
  3880. UpdateCursor
  3881. End Method
  3882. Method Redo()
  3883. Local d:TDiff
  3884. If redolist.IsEmpty() Return
  3885. d=TDiff(redolist.RemoveLast())
  3886. undolist.AddLast d
  3887. SetTextAreaText textarea,d.add,d.pos,d.del.length
  3888. SelectTextAreaText(textarea,d.pos0,d.count0)
  3889. UpdateCursor
  3890. SetCode TextAreaText(textarea),d
  3891. End Method
  3892. Method RefreshStyle()
  3893. Local rgb:TColor
  3894. Local src$
  3895. Local charwidth
  3896. charwidth=host.options.editfont.CharWidth(32)
  3897. SetTextAreaTabs textarea,host.options.tabsize*charwidth
  3898. SetMargins textarea,4
  3899. SetTextAreaFont textarea,host.options.editfont
  3900. rgb=host.options.editcolor
  3901. SetTextAreaColor textarea,rgb.red,rgb.green,rgb.blue,True
  3902. rgb=host.options.styles[0].color
  3903. SetTextAreaColor textarea,rgb.red,rgb.green,rgb.blue,False
  3904. SetTextAreaCaretWidth textarea,host.options.caretstyle.width
  3905. rgb=host.options.caretstyle.color
  3906. SetTextAreaCaretColor textarea,rgb.red,rgb.green,rgb.blue
  3907. src=cleansrc
  3908. cleansrc=""
  3909. cleansrcl=""
  3910. cursorpos=0
  3911. SetCode(src)
  3912. End Method
  3913. Function IsntAlphaNumeric(c) 'lowercase test only
  3914. If c<48 Return True
  3915. If c>=58 And c<95 Return True
  3916. If c=96 Return True
  3917. If c>=123 Return True
  3918. End Function
  3919. Function IsntAlphaNumericOrQuote(c) 'lowercase test only
  3920. If c=34 Return False
  3921. If c<48 Return True
  3922. If c>=58 And c<95 Return True
  3923. If c=96 Return True
  3924. If c>=123 Return True
  3925. End Function
  3926. Function IsCode(src$,p)
  3927. Local n
  3928. Local l = src.FindLast(EOL$,src.length-p)
  3929. If l=-1 l=0
  3930. Local q = src.Find("'",l)
  3931. If q<>-1 And q<p Return
  3932. q=l
  3933. While q<p
  3934. q=src.Find(QUOTES$,q)+1
  3935. If q=0 Exit
  3936. If q<=p n:+1
  3937. Wend
  3938. Return Not(n&1)
  3939. End Function
  3940. Function FindLabel(src$,pos)
  3941. Local p,q,c
  3942. While pos>=0
  3943. p=src.Find("#",pos)
  3944. If p=-1 Exit
  3945. q=p
  3946. While q>0
  3947. q:-1
  3948. c=src[q]
  3949. If c=13 Return p
  3950. If c=10 Return p
  3951. If c=32 Or c=9 Continue
  3952. Exit
  3953. Wend
  3954. If q<0 Return p
  3955. pos=p+1
  3956. Wend
  3957. Return src.length
  3958. End Function
  3959. Function FindToken(token$,src$,pos) 'lowercase src only!
  3960. Local p,c
  3961. Local n=token.length
  3962. While pos>=0
  3963. p=src.Find(token,pos)
  3964. If p=-1 Exit
  3965. c=10 If p>0 c=src[p-1]
  3966. If isntalphanumeric(c)
  3967. If p+n<src.length c=src[p+n]
  3968. If isntalphanumeric(c)
  3969. If iscode(src,p)
  3970. If p<4 Or src[p-4..p]<>"end " Return p
  3971. EndIf
  3972. EndIf
  3973. EndIf
  3974. pos=p+1
  3975. Wend
  3976. Return src.length
  3977. End Function
  3978. Function FindEndToken(token$,src$,pos,returnlast=False) 'if true returns first character after endtoken
  3979. Local p,q,e$,n
  3980. p=pos
  3981. e$="end"+token
  3982. n=e.length
  3983. While p<src.length
  3984. p=src.Find(e$,p)
  3985. If p=-1 Exit
  3986. If p+n=src.length Or isntalphanumeric(src[p+n])
  3987. If iscode(src,p)
  3988. If p=0 Or isntalphanumeric(src[p-1]) Exit
  3989. EndIf
  3990. EndIf
  3991. p=p+n
  3992. Wend
  3993. If p=-1 p=src.length Else If returnlast p:+n
  3994. q=pos
  3995. e$="end "+token
  3996. n=e.length
  3997. While q<src.length
  3998. q=src.Find(e$,q)
  3999. If q=-1 Exit
  4000. If q+n=src.length Or isntalphanumeric(src[q+n])
  4001. If iscode(src,q)
  4002. If q=0 Or isntalphanumeric(src[q-1]) Exit
  4003. EndIf
  4004. EndIf
  4005. q=q+n
  4006. Wend
  4007. If q=-1 q=src.length Else If returnlast q:+n
  4008. Return Min(p,q)
  4009. End Function
  4010. Function IsFirstCharOnLine(src$,pos)
  4011. Local c
  4012. For Local i:Int = 1 To pos
  4013. c=src[pos-i]
  4014. If c=10 Or c=13 Return True
  4015. If c>32 Return False
  4016. Next
  4017. Return True
  4018. End Function
  4019. ' rem and endrem must be first nonwhitespace on line - following funcs are for lowercase src only
  4020. Function FindRem(src$,pos)
  4021. While pos<src.length
  4022. pos=FindToken("rem",src,pos)
  4023. If pos=src.length Exit
  4024. If IsFirstCharOnLine(src,pos) Return pos
  4025. pos:+1
  4026. Wend
  4027. Return pos
  4028. End Function
  4029. Function FindEndRem(src$,pos,returnlast=False)
  4030. Local i,c
  4031. While pos<src.length
  4032. pos=FindEndToken("rem",src,pos)
  4033. If pos=src.length Exit
  4034. If IsFirstCharOnLine(src,pos)
  4035. If returnlast
  4036. If src[pos+5]=Asc("e") Or src[pos+5]=Asc("E") pos:+1
  4037. pos:+6
  4038. EndIf
  4039. Return pos
  4040. EndIf
  4041. pos:+1
  4042. Wend
  4043. Return src.length
  4044. End Function
  4045. Function FindPrevRem(src$,pos) 'lowercase src only!
  4046. Local p,c
  4047. While pos>0
  4048. If pos>src.length Exit 'fixed endrem on lastline overrun
  4049. p=src.FindLast("rem",src.length-pos)
  4050. If p=-1 Exit
  4051. If ( p>=src.length-3 Or isntalphanumeric(src[p+3]) ) And IsFirstCharOnLine(src,p) Return p
  4052. pos=p-1
  4053. Wend
  4054. Return -1
  4055. End Function
  4056. Method IsRemmed(pos,src$)
  4057. Local p = FindPrevRem(src$,Min(pos+3,src.length))
  4058. If p<0 Return
  4059. p=FindEndRem(src$,p)
  4060. If p<0 Or pos<p Return True
  4061. EndMethod
  4062. Method WasRemmed(pos,src$)
  4063. Local s$ = cleansrcl
  4064. Local p = (src.length-s.length)
  4065. If p<0 pos:-p
  4066. p=FindPrevRem(s$,Min(pos+3,s.length))
  4067. If p<0 Return
  4068. p=FindEndRem(s$,p)
  4069. If pos<p Return True
  4070. End Method
  4071. Method CheckDirty(src$)
  4072. SetDirty (Not (src=filesrc And undolist.IsEmpty()))
  4073. End Method
  4074. Method HasTidyQueue()
  4075. Return ((deferpos >= 0) Or (tidyqueue1 >= 0) Or (tidyqueue2 >= 0))
  4076. EndMethod
  4077. Method ClearTidyQueue(start,endpos)
  4078. If start<=deferpos And deferpos < endpos Then deferpos = -1
  4079. If start<=tidyqueue1 And tidyqueue1 < endpos Then tidyqueue1 = -1
  4080. If start<=tidyqueue2 And tidyqueue2 < endpos Then tidyqueue2 = -1
  4081. EndMethod
  4082. Method SetCode(src$,diff:TDiff=Null)
  4083. Local same,i,p,startp,p1,q,r,a,t$,h$,lsrc$,r0,r1,cpos,autocap
  4084. Local style:TTextStyle[5],s:TTextStyle
  4085. ' update dirty flag
  4086. CheckDirty src
  4087. same = Not ((diff) Or (src<>cleansrc))
  4088. If same And Not (diff Or HasTidyQueue()) Then Return
  4089. If Not isbmx Or Not host.quickhelp Or Not host.options.syntaxhighlight
  4090. If Not same Then
  4091. cleansrc=src
  4092. cleansrcl=src.ToLower()
  4093. EndIf
  4094. Return
  4095. EndIf
  4096. ' doit
  4097. autocap=host.options.autocapitalize
  4098. If same Then lsrc = cleansrcl Else lsrc=src.ToLower()
  4099. cpos=TextAreaCursor(textarea,TEXTAREA_CHARS)
  4100. LockTextArea textarea
  4101. style=host.options.styles
  4102. ' calculate highlight region
  4103. If diff
  4104. p=diff.pos
  4105. p1=p+diff.add.length
  4106. If Not diff.add.length Then
  4107. p:-diff.del.length
  4108. EndIf
  4109. ElseIf HasTidyQueue()
  4110. p=src.length
  4111. If (deferpos>=0) Then
  4112. p = Min(p,deferpos)
  4113. p1 = Max(p1,deferpos+1)
  4114. EndIf
  4115. If (tidyqueue1>=0) Then
  4116. p = Min(p,tidyqueue1)
  4117. p1 = Max(p1, tidyqueue1+1)
  4118. EndIf
  4119. If (tidyqueue2>=0) Then
  4120. p = Min(p,tidyqueue2)
  4121. p1 = Max(p1, tidyqueue2+1)
  4122. EndIf
  4123. Else
  4124. p=firstdiff(src,cleansrc)
  4125. p1=lastdiff(src,cleansrc)
  4126. EndIf
  4127. q=src.length-cleansrc.length
  4128. If p1-p<q p1=p+q
  4129. If p1<p p1=p
  4130. ' round region to line breaks
  4131. 'Print "p="+p+" p1="+p1
  4132. If p>src.length p=src.length
  4133. p=src.findlast(EOL,src.length-(p-1))+1
  4134. p1=src.find(EOL,p1)+1
  4135. If p1=0 p1=src.length
  4136. ' if endrem between p0,p1 and next rem after p1 move p1 forwards
  4137. r1=FindEndRem(lsrc,p)
  4138. If r1<p1 And wasremmed(r1+6,lsrc)
  4139. r0=FindRem(lsrc,r1+6)
  4140. If r0>p1 p1=r0
  4141. EndIf
  4142. ' if rem between p0,p1 and matching endrem after p1 move p1 forewards
  4143. r0=FindPrevRem(lsrc,p1)
  4144. If r0>=p And r0+3<>cpos 'defer fix
  4145. r1=FindEndRem(lsrc,r0,True)
  4146. If r1>p1 p1=r1
  4147. EndIf
  4148. ' if rem before p0 and matching endrem after p0 highlight to endrem and move p0 forwards
  4149. r0=FindPrevRem(lsrc,p)
  4150. If r0<>-1 And r0<p
  4151. r1=FindEndRem(lsrc,r0,True)
  4152. If r1>p
  4153. s=style[COMMENT]
  4154. If r1>p s.Format(textarea,p,r1-p)
  4155. If autocap And r1<src.length
  4156. If lsrc[r1-6..r1]="endrem" And src[r1-6..r1]<>"EndRem" SetTextAreaText textarea,"EndRem",r1-6,6
  4157. If lsrc[r1-7..r1]="end rem" And src[r1-7..r1]<>"End Rem" SetTextAreaText textarea,"End Rem",r1-7,7
  4158. EndIf
  4159. ClearTidyQueue(p,r1)
  4160. p=r1
  4161. EndIf
  4162. EndIf
  4163. ' if was remmed and now isn't move p1 down to nearest rem or endrem
  4164. If WasRemmed(p,lsrc)
  4165. r0=FindRem(lsrc,p)
  4166. r1=FindEndRem(lsrc,r0,True)
  4167. p1=Max(p1,Min(r0,r1))
  4168. EndIf
  4169. ' highlight code
  4170. ClearTidyQueue(p,p1)
  4171. s=style[NORMAL]
  4172. If p1>p s.format(textarea,p,p1-p)
  4173. startp = p
  4174. While p<p1
  4175. host.UpdateProgress(msgHighlightingStatus,(p*100)/p1)
  4176. a=src[p]
  4177. ' quoted strings
  4178. If a=34
  4179. q=p1
  4180. r=src.Find(Chr(34),p+1)
  4181. If r>-1 And r<q q=r+1
  4182. r=src.Find(EOL,p+1)
  4183. If r>-1 And r<q q=r
  4184. s=style[QUOTED]
  4185. s.format(textarea,p,q-p)
  4186. p=q
  4187. Continue
  4188. EndIf
  4189. ' single line comments
  4190. If a=39
  4191. q=p1
  4192. r=src.Find(EOL,p+1)
  4193. If r>-1 And r<q q=r
  4194. s=style[COMMENT]
  4195. s.format(textarea,p,q-p)
  4196. p=q
  4197. Continue
  4198. EndIf
  4199. ' tokens
  4200. If (a>=65 And a<91) Or (a>=97 And a<123) Or (a=95)
  4201. q=p+1
  4202. While q<p1
  4203. a=src[q]
  4204. If a<48 Exit 'changed to include dot (chr 47)
  4205. If a>=58 And a<65 Exit
  4206. If a>=91 And a<95 Exit
  4207. If a=96 Exit
  4208. If a>122 Exit
  4209. q:+1
  4210. Wend
  4211. t$=src[p..q]
  4212. h$=host.quickhelp.token(t$)
  4213. If h$
  4214. If h$<>t$ And autocap
  4215. If cpos<p Or cpos>q
  4216. SetTextAreaText textarea,h,p,h.length
  4217. Else
  4218. deferpos=q
  4219. EndIf
  4220. EndIf
  4221. s=style[KEYWORD]
  4222. If h$="Rem" And IsFirstCharOnLine(lsrc,p) ' Not (p>4 And lsrc[p-4..p]="end ")
  4223. If q<>cpos
  4224. q=FindEndRem(lsrc,p,True)
  4225. s=style[COMMENT]
  4226. Else
  4227. deferpos=q
  4228. EndIf
  4229. EndIf
  4230. s.format(textarea,p,q-p)
  4231. EndIf
  4232. p=q
  4233. Continue
  4234. EndIf
  4235. ' numbers
  4236. If (p=0 Or IsntAlphaNumeric(lsrc[p-1])) And ((a>=$30 And a<$3A) Or (a=$24) Or (a=$25) Or (a=$2E)) '0-9, $, %, .
  4237. q=p+1
  4238. Local hexed:Int = (a=$24), binaried:Int = (a=$25), dots:Int = (a=$2E)
  4239. Local valid:Int = Not(hexed Or binaried Or dots)
  4240. While q<(p1)
  4241. a=lsrc[q]
  4242. q:+1
  4243. If (a>=$30 And a<$3A) Then
  4244. valid = True
  4245. Continue '0-9
  4246. EndIf
  4247. If hexed
  4248. If (a>=$61 And a<$67) Then 'a-f (only test lower as 'a' var is from lsrc)
  4249. valid = True
  4250. Continue
  4251. EndIf
  4252. EndIf
  4253. If (a=$2E) Then
  4254. 'Hex or Binary literals don't support decimal points
  4255. If Not (hexed Or binaried) Then
  4256. dots:+1
  4257. 'Fix for slicing '..' syntax
  4258. If src[q-2] = $2E Then
  4259. dots:-2
  4260. q:-2
  4261. Exit
  4262. EndIf
  4263. 'End Fix
  4264. Continue
  4265. EndIf
  4266. EndIf
  4267. If Not IsntAlphaNumeric(a) Then valid = False
  4268. q:-1
  4269. Exit
  4270. Wend
  4271. If valid And dots < 2 Then style[NUMBER].format(textarea,p,(q-p))
  4272. 'Fix for slicing '..' syntax
  4273. If q<src.length And (src[q]=Asc(".")) Then q:+1
  4274. If q<src.length And (src[q]=Asc(".")) Then q:+1
  4275. 'End Fix
  4276. p=q
  4277. Continue
  4278. EndIf
  4279. p:+1
  4280. Wend
  4281. BracketMatching(lsrc,startp,p1,True)
  4282. UnlockTextArea textarea
  4283. If Not same
  4284. cleansrc=src
  4285. cleansrcl=lsrc
  4286. EndIf
  4287. ' CheckDirty src simon was here
  4288. End Method
  4289. Field currentbrackets:Int[]
  4290. Method BracketMatching(lsrc$,cln1=-1,cln2=-1,alwaysfind:Int = False)
  4291. Local check:Int, depth:Int, style:TTextStyle[] = host.options.styles
  4292. Local otherchar:Int = 0, absotherchar:Int = 0, othercharpos:Int = 0, limit:Int
  4293. Local currentchar:Int = 0, currentcharpos:Int = Max(cursorpos-1,0)
  4294. If cursorlen Then Return
  4295. If currentbrackets Then
  4296. If Not(cln2 > currentbrackets[0] And cln1 <= currentbrackets[0]) Then
  4297. If currentbrackets[0]>-1 Then tidyqueue1 = currentbrackets[0]
  4298. EndIf
  4299. If Not(cln2 > currentbrackets[1] And cln1 <= currentbrackets[1]) Then
  4300. If currentbrackets[1]>-1 Then tidyqueue2 = currentbrackets[1]
  4301. EndIf
  4302. currentbrackets = Null
  4303. If Not alwaysfind Then Return
  4304. EndIf
  4305. If host.options.bracketmatching And isbmx And Not IsRemmed(currentcharpos,lsrc) Then
  4306. limit = Min(lsrc.length,currentcharpos+2)
  4307. While currentcharpos >= 0 And currentcharpos < limit
  4308. If IsCode(lsrc,currentcharpos) Then
  4309. Select lsrc[currentcharpos]
  4310. Case Asc("(");otherchar = Asc(")");Exit
  4311. Case Asc("{");otherchar = Asc("}");Exit
  4312. Case Asc("[");otherchar = Asc("]");Exit
  4313. ' Negate char code to search backwards
  4314. Case Asc(")");otherchar = -Asc("(");Exit
  4315. Case Asc("}");otherchar = -Asc("{");Exit
  4316. Case Asc("]");otherchar = -Asc("[");Exit
  4317. EndSelect
  4318. EndIf
  4319. currentcharpos:+1
  4320. Wend
  4321. If otherchar Then
  4322. absotherchar = (Abs otherchar)
  4323. currentchar = lsrc[currentcharpos]
  4324. LockTextArea textarea
  4325. style[MATCHING].format(textarea, currentcharpos, 1)
  4326. currentbrackets = [currentcharpos,-1]
  4327. othercharpos = currentcharpos+(otherchar/absotherchar)
  4328. While othercharpos < lsrc.length And othercharpos >= 0
  4329. If IsCode(lsrc,othercharpos) Then
  4330. Select lsrc[othercharpos]
  4331. Case Asc(" "), Asc("~t")
  4332. 'Do nothing
  4333. Case Asc("'")
  4334. Exit
  4335. Case absotherchar
  4336. If check < 0 Then Exit Else check = 0
  4337. If depth Then
  4338. depth:-1
  4339. Else
  4340. style[MATCHING].format(textarea, othercharpos, 1)
  4341. currentbrackets[1] = othercharpos
  4342. UnlockTextArea textarea
  4343. Return
  4344. EndIf
  4345. Case Asc("~n")
  4346. If (otherchar/absotherchar) > 0 Then
  4347. If check = 2 Then check = 0 Else Exit
  4348. Else
  4349. If check < 0 Then Exit Else check = -2
  4350. EndIf
  4351. Case Asc(".")
  4352. check:+1
  4353. Default
  4354. If check < 0 Then Exit Else check = 0
  4355. If lsrc[othercharpos] = lsrc[currentcharpos] Then depth:+1
  4356. EndSelect
  4357. EndIf
  4358. othercharpos:+(otherchar/absotherchar)
  4359. Wend
  4360. UnlockTextArea textarea
  4361. EndIf
  4362. EndIf
  4363. EndMethod
  4364. Method AutoIndent()
  4365. Local p,q
  4366. Local c = TextAreaCursor(textarea,TEXTAREA_CHARS)
  4367. Local n = TextAreaSelLen(textarea,TEXTAREA_CHARS)
  4368. If c<cleansrc.length
  4369. p=cleansrc.FindLast(EOL,cleansrc.length-(c-1))+1
  4370. q=p
  4371. While cleansrc[q]=9 And q<c
  4372. q:+1
  4373. Wend
  4374. If q>c q=c
  4375. EndIf
  4376. SetTextAreaText textarea,EOL$+cleansrc[p..q],c,n
  4377. SelectTextAreaText textarea,c+1+q-p,0
  4378. UpdateCursor
  4379. UpdateCode
  4380. End Method
  4381. Method IndentCode()
  4382. Local a$
  4383. ' blockindent
  4384. Local p0 = TextAreaCursor(textarea,TEXTAREA_LINES)
  4385. Local p1 = TextAreaSelLen(textarea,TEXTAREA_LINES)
  4386. ' v122: make sure the entire block is selected (start cursor pos may in the middle of the line)
  4387. SelectTextAreaText textarea , p0 , p1 , TEXTAREA_LINES
  4388. UpdateCursor
  4389. For Local i:Int = 0 Until p1
  4390. a$="~t"+TextAreaText(textarea,p0+i,1,TEXTAREA_LINES)
  4391. SetTextAreaText textarea,a$,p0+i,1,TEXTAREA_LINES
  4392. Next
  4393. SelectTextAreaText textarea,p0,p1,TEXTAREA_LINES
  4394. UpdateCursor
  4395. UpdateCode
  4396. End Method
  4397. Method OutdentCode()
  4398. Local a$,modified
  4399. ' blockoutdent
  4400. Local p0 = TextAreaCursor(textarea,TEXTAREA_LINES)
  4401. Local p1 = TextAreaSelLen(textarea,TEXTAREA_LINES)
  4402. ' v122: make sure the entire block is selected (start cursor pos may in the middle of the line)
  4403. SelectTextAreaText textarea , p0 , p1 , TEXTAREA_LINES
  4404. UpdateCursor
  4405. For Local i:Int = 0 Until p1
  4406. a$=TextAreaText(textarea,p0+i,1,TEXTAREA_LINES)
  4407. If a[0]=9 a$=a$[1..];modified=True
  4408. SetTextAreaText textarea,a$,p0+i,1,TEXTAREA_LINES
  4409. Next
  4410. If Not modified
  4411. For Local i:Int = 0 Until p1
  4412. a$=TextAreaText(textarea,p0+i,1,TEXTAREA_LINES)
  4413. If a[0]=32 a$=a$[1..]
  4414. SetTextAreaText textarea,a$,p0+i,1,TEXTAREA_LINES
  4415. Next
  4416. EndIf
  4417. SelectTextAreaText textarea,p0,p1,TEXTAREA_LINES
  4418. UpdateCursor
  4419. UpdateCode
  4420. End Method
  4421. Function FilterKey(event:TEvent,context:Object)
  4422. ' If event.id<>EVENT_KEYCHAR Return 1
  4423. Local id=event.id
  4424. Local key=event.data
  4425. Local mods=event.mods
  4426. Local this:TOpenCode=TOpenCode(context)
  4427. ?MacOS
  4428. If key=25 And mods=MODIFIER_SHIFT key=KEY_TAB
  4429. ?
  4430. If id=EVENT_KEYCHAR And this And key=KEY_TAB And TextAreaSelLen( this.textarea,TEXTAREA_CHARS )
  4431. Select mods
  4432. Case MODIFIER_NONE
  4433. this.IndentCode
  4434. Case MODIFIER_SHIFT
  4435. this.OutdentCode
  4436. End Select
  4437. Return 0
  4438. EndIf
  4439. If id=EVENT_KEYDOWN And key=KEY_ENTER And this And this.host.options.autoindent
  4440. this.AutoIndent()
  4441. Return 0
  4442. EndIf
  4443. Return 1
  4444. End Function
  4445. Method OnEvent()
  4446. Select EventSource()
  4447. Case textarea
  4448. Select EventID()
  4449. Case EVENT_GADGETMENU
  4450. PopupWindowMenu host.window,editmenu
  4451. Case EVENT_GADGETACTION
  4452. UpdateCode
  4453. Case EVENT_GADGETSELECT
  4454. UpdateCursor
  4455. End Select
  4456. End Select
  4457. End Method
  4458. Method SetDirty( bool )
  4459. If dirty=bool Return
  4460. dirty=bool
  4461. name=StripDir(path)
  4462. If (dirty) name:+"*"
  4463. If (host.lockedpanel=Self) name=LocalizeString("{{tab_locked:%1}}").Replace("%1",name)
  4464. host.RefreshPanel Self
  4465. PollSystem
  4466. End Method
  4467. Method SetLocked( bool )
  4468. Local locked:TOpenCode = TOpenCode(host.lockedpanel)
  4469. If locked And locked<>Self locked.SetLocked False
  4470. name=StripDir(path)
  4471. If (dirty) name:+"*"
  4472. If (bool)
  4473. name=LocalizeString("{{tab_locked:%1}}").Replace("%1",name)
  4474. host.lockedpanel=Self
  4475. Else
  4476. host.lockedpanel=Null
  4477. EndIf
  4478. host.RefreshPanel Self
  4479. End Method
  4480. Method Help()
  4481. If Not host.quickhelp Return
  4482. Local p = TextAreaCursor(textarea,TEXTAREA_CHARS)
  4483. Local a$ = WordAtPos(cleansrc,p)
  4484. If a=helpcmd
  4485. Local l$ = host.quickhelp.link(a$)
  4486. If l
  4487. host.helppanel.go host.bmxpath+l$
  4488. EndIf
  4489. Else
  4490. helpcmd=a$
  4491. helpstring$=host.quickhelp.help(a$)
  4492. UpdateStatus 'host.setstatus helpstring$
  4493. EndIf
  4494. End Method
  4495. Method Find()
  4496. host.findreq.ShowFind WordAtPos(cleansrc,TextAreaCursor(textarea,TEXTAREA_CHARS))
  4497. End Method
  4498. Method FindNext(s$)
  4499. If s seek=s Else s=seek
  4500. Local p = TextAreaCursor(textarea,TEXTAREA_CHARS)
  4501. p:+TextAreaSelLen(textarea,TEXTAREA_CHARS)
  4502. ' case insensitive
  4503. Local l$ = s.toLower()
  4504. p=cleansrcl.Find(l$,p)
  4505. If p=-1 p=cleansrcl.Find(l$)
  4506. ' case sensitive
  4507. ' p=cleansrc.Find(s$,p+1)
  4508. ' if p=-1 p=cleansrc.Find(s$)
  4509. If p=-1
  4510. Notify LocalizeString("{{find_notification_cannotfind}}").Replace("%1",s)
  4511. Return False
  4512. Else
  4513. SelectTextAreaText textarea,p,Len s,TEXTAREA_CHARS
  4514. UpdateCursor
  4515. Return True
  4516. EndIf
  4517. End Method
  4518. Method ReplaceAll(s$,r$)
  4519. Local t$ = TextAreaText( textarea ).ToLower()
  4520. Local c = TextAreaCursor(textarea,TEXTAREA_CHARS),i,p
  4521. s = s.ToLower()
  4522. Repeat
  4523. Local i2=t.Find( s,i )
  4524. If i2=-1 Exit
  4525. p:+i2-i
  4526. i=i2+s.length
  4527. SelectTextAreaText textarea,p,s.length
  4528. UpdateCursor
  4529. UpdateCode
  4530. SetTextAreaText textarea,r,p,s.length
  4531. If p<c c=c+r.length-s.length
  4532. p:+r.length
  4533. SelectTextAreaText textarea,p,0
  4534. UpdateCursor
  4535. UpdateCode
  4536. Forever
  4537. SelectTextAreaText textarea,c,0
  4538. UpdateCursor
  4539. End Method
  4540. Method FindReplace(r$)
  4541. Local n, f$, x$
  4542. Local p = r.Find("~0")
  4543. If p>0
  4544. f$=r[..p]
  4545. r$=r[p+1..]
  4546. ReplaceAll f$,r$
  4547. Else
  4548. p=TextAreaCursor(textarea,TEXTAREA_CHARS)
  4549. n=TextAreaSelLen(textarea,TEXTAREA_CHARS)
  4550. If Not n Return
  4551. SetTextAreaText textarea,r$,p,n
  4552. SelectTextAreaText textarea,p+r.length,0
  4553. UpdateCursor
  4554. UpdateCode
  4555. EndIf
  4556. Return True
  4557. End Method
  4558. Method ReadSource(path$)
  4559. Local src$
  4560. src=CacheAndLoadText(path)
  4561. src=src.Replace(Chr(13),"")
  4562. src=src.Replace(Chr(11),"")
  4563. LockTextArea textarea
  4564. SetTextAreaText textarea,src
  4565. UnlockTextArea textarea
  4566. filesrc=TextAreaText(textarea)
  4567. cleansrc=""
  4568. cleansrcl=""
  4569. ActivateGadget textarea
  4570. End Method
  4571. Method SaveSource(file$)
  4572. If host.options.autobackup
  4573. DeleteFile file+".bak"
  4574. RenameFile file,file+".bak"
  4575. EndIf
  4576. Local src$ = TextAreaText(textarea)
  4577. filesrc=src
  4578. src=src.Replace(Chr(13),Chr(10))
  4579. src=src.Replace(Chr(11),"")
  4580. Local txt$ = src.Replace$(Chr(10),Chr(13)+Chr(10))
  4581. Try
  4582. SaveText txt,file
  4583. Catch exception:Object
  4584. Local err$=String(exception)
  4585. Notify "Save Error~n"+err
  4586. Return False
  4587. EndTry
  4588. path=host.FullPath$(file)
  4589. dirty=True
  4590. SetDirty False
  4591. host.AddRecent(path$)
  4592. Return True
  4593. End Method
  4594. Method BuildSource(quick,debug,threaded,consoleBuild,guiBuild,makelibBuild,run, verbose, quickscan, universal, warnover, gdbdebug, platform:String = Null, architecture:String = Null, appstub:String = Null)
  4595. Local cmd$,out$,arg$
  4596. If isbmx Or isc Or iscpp
  4597. cmd$=quote(host.bmkpath)
  4598. If guiBuild Or consoleBuild Then
  4599. cmd$:+" makeapp"
  4600. Else
  4601. cmd:+" makelib"
  4602. End If
  4603. If run cmd$:+" -x"
  4604. If debug cmd$:+" -d" Else cmd$:+" -r" '-v
  4605. If threaded cmd$:+" -h"
  4606. If guiBuild cmd$:+" -t gui"
  4607. If Not quick cmd$:+" -a"
  4608. If verbose cmd :+ " -v"
  4609. If quickscan cmd :+ " -quick"
  4610. If universal cmd :+ " -i"
  4611. If warnover cmd :+ " -w"
  4612. If gdbdebug cmd :+ " -gdb"
  4613. If appstub And appstub <> "brl.appstub" cmd :+ " -b " + appstub
  4614. If platform cmd :+ " -l " + platform
  4615. If architecture cmd :+ " -g " + architecture
  4616. If debug Or threaded
  4617. out=StripExt(host.FullPath(path))
  4618. If debug out:+".debug"
  4619. If threaded out:+".mt"
  4620. cmd:+" -o "+quote(out$)+" "
  4621. EndIf
  4622. cmd$:+" "+quote(host.FullPath(path))
  4623. If run
  4624. arg$=host.GetCommandLine()
  4625. If arg cmd$:+" "+arg
  4626. EndIf
  4627. host.execute cmd,"Building "+StripExt(StripDir(path)) ',exe$
  4628. Else
  4629. If ishtml
  4630. host.helppanel.Go "file://"+path
  4631. Else
  4632. 'see what the system shell thinks of the file
  4633. Local cd$=CurrentDir()
  4634. ChangeDir ExtractDir(path)
  4635. cmd=StripDir(path)
  4636. host.execute cmd,"Building "+cmd
  4637. ChangeDir cd
  4638. EndIf
  4639. EndIf
  4640. ' print cmd
  4641. End Method
  4642. Method Save()
  4643. Local file$ = path
  4644. If host.IsTempPath(path)
  4645. file=RequestFile(LocalizeString("{{request_saveas_title}}"),FileTypeFilters,True,"")
  4646. If file="" Return False
  4647. If ExtractExt(file)="" file=file+".bmx"
  4648. dirty=True
  4649. EndIf
  4650. If dirty SaveSource(file)
  4651. Return True
  4652. End Method
  4653. ' common command interface
  4654. Method Invoke(command,argument:Object=Null)
  4655. Local file$,ex$
  4656. Local p,res
  4657. Select command
  4658. Case TOOLSHOW
  4659. host.SetCodeNode GetNode()
  4660. host.SetTitle path
  4661. ' simon was here If textarea Edit
  4662. If textarea ActivateGadget textarea
  4663. Case TOOLCLOSE
  4664. If dirty 'Or host.IsTempPath(path)
  4665. Invoke(TOOLSHOW)
  4666. p=Proceed(LocalizeString("{{request_savechanges}}").Replace("%1",name)) 'the current file?
  4667. If p=-1 Return True
  4668. If p=1
  4669. If Not Save() Return True
  4670. EndIf
  4671. EndIf
  4672. If codenode Then
  4673. codenode.Free()
  4674. codenode=Null
  4675. EndIf
  4676. 'Added just in case MaxGUI driver doesn't handle properly.
  4677. SetGadgetFilter textarea,Null,Null
  4678. 'Seb gone.
  4679. host.RemovePanel Self
  4680. FreeGadget(editmenu)
  4681. Case TOOLSAVE
  4682. Save
  4683. Case TOOLQUICKSAVE
  4684. file=path
  4685. If dirty SaveSource(file)
  4686. Case TOOLSAVEAS
  4687. file=path
  4688. If host.IsTempPath(path) file$=""
  4689. file=RequestFile(LocalizeString("{{request_saveas_title}}"),FileTypeFilters,True,file)
  4690. If file="" Return
  4691. ex$=ExtractExt(file)
  4692. If ex$=""
  4693. file=file+".bmx"
  4694. isbmx=True
  4695. Else
  4696. isbmx=(ex.ToLower()="bmx")
  4697. ishtml=(ex.ToLower()="html")
  4698. isc=(ex.ToLower()="c")
  4699. iscpp=(ex.ToLower()="cpp" Or ex.ToLower()="cxx")
  4700. EndIf
  4701. SaveSource(file$)
  4702. RefreshStyle()
  4703. GetNode().Refresh
  4704. SetDirty False
  4705. host.SetTitle path
  4706. Case TOOLGOTO
  4707. Local line=Int(String(argument))
  4708. SelectTextAreaText textarea,line-1,0,TEXTAREA_LINES
  4709. UpdateCursor
  4710. ActivateGadget textarea
  4711. Case TOOLFIND
  4712. Find
  4713. Case TOOLFINDNEXT
  4714. Return FindNext(String(argument))
  4715. Case TOOLREPLACE
  4716. Return FindReplace(String(argument))
  4717. Case TOOLBUILD
  4718. BuildSource host.quickenabled,host.debugenabled,host.threadedenabled,host.consoleenabled, host.guienabled, host.makelibenabled,False, host.verboseenabled, host.quickscanenabled, host.universalenabled, host.warnoverenabled, host.gdbdebugenabled, host.GetPlatform(), host.GetArchitecture(), host.selectedappstub
  4719. Case TOOLRUN
  4720. BuildSource host.quickenabled,host.debugenabled,host.threadedenabled,host.consoleenabled, host.guienabled, host.makelibenabled,True, host.verboseenabled, host.quickscanenabled, host.universalenabled, host.warnoverenabled, host.gdbdebugenabled, host.GetPlatform(), host.GetArchitecture(), host.selectedappstub
  4721. Case TOOLLOCK
  4722. SetLocked True
  4723. Case TOOLUNLOCK
  4724. SetLocked False
  4725. Case TOOLHELP
  4726. Help()
  4727. Case TOOLUNDO
  4728. Undo()
  4729. Case TOOLREDO
  4730. Redo()
  4731. Case TOOLREFRESH
  4732. RefreshStyle()
  4733. Case TOOLCUT
  4734. GadgetCut textarea
  4735. UpdateCursor()
  4736. UpdateCode()
  4737. Case TOOLCOPY
  4738. GadgetCopy textarea
  4739. Case TOOLPASTE
  4740. GadgetPaste textarea
  4741. UpdateCursor()
  4742. UpdateCode()
  4743. Case TOOLSELECTALL
  4744. SelectTextAreaText textarea
  4745. UpdateCursor()
  4746. Case TOOLINDENT
  4747. IndentCode()
  4748. Case TOOLOUTDENT
  4749. OutdentCode()
  4750. Case TOOLPRINT
  4751. GadgetPrint textarea
  4752. End Select
  4753. End Method
  4754. Function CreateEditMenu:TGadget()
  4755. Local edit:TGadget = CreateMenu("{{popup_edit}}",0,Null)
  4756. CreateMenu "{{popup_edit_quickhelp}}",MENUQUICKHELP,edit
  4757. CreateMenu "",0,edit
  4758. CreateMenu "{{popup_edit_cut}}",MENUCUT,edit
  4759. CreateMenu "{{popup_edit_copy}}",MENUCOPY,edit
  4760. CreateMenu "{{popup_edit_paste}}",MENUPASTE,edit
  4761. CreateMenu "",0,edit
  4762. CreateMenu "{{popup_edit_selectall}}",MENUSELECTALL,edit
  4763. CreateMenu "",0,edit
  4764. CreateMenu "{{popup_edit_blockindent}}",MENUINDENT,edit
  4765. CreateMenu "{{popup_edit_blockoutdent}}",MENUOUTDENT,edit
  4766. CreateMenu "",0,edit
  4767. CreateMenu "{{popup_edit_find}}",MENUFIND,edit
  4768. CreateMenu "{{popup_edit_findnext}}",MENUFINDNEXT,edit
  4769. CreateMenu "{{popup_edit_replace}}",MENUREPLACE,edit
  4770. CreateMenu "{{popup_edit_goto}}",MENUGOTO,edit
  4771. Return edit
  4772. End Function
  4773. Method MakePathTemp()
  4774. ' prepends "." to file name with code borrowed from SaveAs
  4775. Local file$=ExtractDir(path)+"/."+StripDir(path)
  4776. SaveSource(file$)
  4777. ' Refresh
  4778. GetNode().Refresh
  4779. ' setdirty False
  4780. host.SetTitle path
  4781. End Method
  4782. Function Create:TOpenCode(path$,host:TCodePlay)
  4783. Local code:TOpenCode
  4784. Local stream:TStream
  4785. Local isnew
  4786. If path
  4787. If FileType(path)<>FILETYPE_FILE
  4788. Return Null
  4789. EndIf
  4790. stream=ReadFile(path)
  4791. If Not stream
  4792. ' Notify "Open could not read from "+path
  4793. Return Null
  4794. EndIf
  4795. CloseFile stream
  4796. Else
  4797. TEMPCOUNT:+1
  4798. path=host.bmxpath+"/tmp/untitled"+TEMPCOUNT+".bmx"
  4799. isnew=True
  4800. EndIf
  4801. code=New TOpenCode
  4802. code.host=host
  4803. code.active=True
  4804. code.path=host.FullPath(path)
  4805. code.editmenu=CreateEditMenu()
  4806. codeplay.addpanel(code)
  4807. code.textarea=CreateTextArea(0,0,ClientWidth(code.panel),ClientHeight(code.panel),code.panel,0)
  4808. DelocalizeGadget code.textarea
  4809. SetGadgetFilter code.textarea,code.FilterKey,code
  4810. SetTextAreaText code.textarea,"~n"
  4811. SetGadgetLayout code.textarea,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  4812. code.RefreshStyle()
  4813. If isnew
  4814. code.SaveSource path
  4815. code.filesrc="~n"
  4816. ActivateGadget code.textarea
  4817. Else
  4818. host.UpdateProgress "Reading Stream"
  4819. code.ReadSource(path)
  4820. EndIf
  4821. If ExtractExt(path).toLower()="bmx" code.isbmx=True
  4822. If ExtractExt(path).toLower()="c" code.isc=True
  4823. If ExtractExt(path).toLower()="cpp" code.iscpp=True
  4824. If ExtractExt(path).toLower()="cxx" code.iscpp=True
  4825. If ExtractExt(path).toLower()="html" code.ishtml=True
  4826. If ExtractExt(path).toLower()="htm" code.ishtml=True
  4827. code.UpdateCode False
  4828. code.filesrc=TextAreaText(code.textarea)
  4829. Return code
  4830. End Function
  4831. End Type
  4832. Type TRect
  4833. Field x,y,w,h
  4834. Method Set(xpos,ypos,width,height)
  4835. x=xpos;y=ypos;w=width;h=height
  4836. End Method
  4837. Method ToString$()
  4838. Return ""+x+","+y+","+w+","+h
  4839. End Method
  4840. Method FromString(s$)
  4841. Local p,q,r
  4842. p=s.Find(",")+1;If Not p Return
  4843. q=s.Find(",",p)+1;If Not q Return
  4844. r=s.Find(",",q)+1;If Not r Return
  4845. x=Int(s[..p-1])
  4846. y=Int(s[p..q-1])
  4847. w=Int(s[q..r-1])
  4848. h=Int(s[r..])
  4849. End Method
  4850. Method IsOutside(tx,ty,tw,th)
  4851. If x+w<=tx Or y+h<=ty Return True
  4852. If x>=tx+tw Or y>=ty+th Return True
  4853. End Method
  4854. End Type
  4855. Type TCodePlay
  4856. Const EDITMODE=1
  4857. Const DEBUGMODE=2
  4858. Field bmxpath$,bmkpath$
  4859. Field panels:TToolPanel[]
  4860. Field helppanel:THelpPanel
  4861. Field currentpanel:TToolPanel
  4862. Field output:TOutputPanel
  4863. Field lockedpanel:TToolPanel
  4864. Field activepanel:TToolPanel
  4865. Field cmdlinereq:TCmdLineRequester
  4866. Field cmdline$
  4867. 'Field syncmodsreq:TSyncModsRequester
  4868. Field gotoreq:TGotoRequester
  4869. Field findreq:TFindRequester
  4870. Field replacereq:TReplaceRequester
  4871. Field options:TOptionsRequester
  4872. ' Field progress:TProgressRequester
  4873. Field activerequesters:TList = New TList
  4874. Field projectreq:TProjectRequester
  4875. Field projectprops:TProjectProperties
  4876. Field searchreq:TSearchRequester
  4877. Field aboutreq:TAboutRequester
  4878. Field eventhandlers:TList=New TList
  4879. Field window:TGadget,menubar:TGadget,toolbar:TGadget,client:TGadget,tabbar:TGadget
  4880. Field split:TSplitter
  4881. Field debugtree:TDebugTree
  4882. Field root:TNode
  4883. Field helproot:TNode
  4884. Field projects:TProjects
  4885. Field coderoot:TNode
  4886. Field navbar:TNavBar
  4887. Field Mode
  4888. Field debugcode:TOpenCode
  4889. Field quickenable:TGadget,quickenabled 'menu,state
  4890. Field debugenable:TGadget,debugenabled 'menu,state
  4891. Field threadedenable:TGadget,threadedenabled
  4892. Field consoleenable:TGadget,consoleenabled 'menu,state
  4893. Field guienable:TGadget,guienabled 'menu,state
  4894. Field makelibenable:TGadget,makelibenabled 'menu,state
  4895. Field verboseenable:TGadget,verboseenabled 'menu,state
  4896. Field quickscanenable:TGadget,quickscanenabled 'menu,state
  4897. Field universalenable:TGadget,universalenabled 'menu,state
  4898. Field warnoverenable:TGadget,warnoverenabled 'menu,state
  4899. Field gdbdebugenable:TGadget,gdbdebugenabled 'menu,state
  4900. Field quickhelp:TQuickHelp
  4901. Field running
  4902. Field recentmenu:TGadget
  4903. Field recentfiles:TList=New TList
  4904. Field recentmenus:TGadget[]
  4905. Field openlist:TList=New TList
  4906. Field openlock$
  4907. Field projlist:TList=New TList
  4908. Field winsize:TRect=New TRect
  4909. Field winmax,tooly,splitpos,debugview,navtab
  4910. Field progress,splitorientation
  4911. Field selectedappstub:String
  4912. Field win32enable:TGadget 'menu
  4913. Field linuxenable:TGadget 'menu
  4914. Field macosxenable:TGadget 'menu
  4915. Field iosenable:TGadget 'menu
  4916. Field raspberrypienable:TGadget 'menu
  4917. Field androidenable:TGadget 'menu
  4918. Field emscriptenenable:TGadget 'menu
  4919. Field nxenable:TGadget 'menu
  4920. Field platformenabled:Int[8]
  4921. Const PLATFORMOFFSET:Int = 81
  4922. Field x86enable:TGadget 'menu
  4923. Field x64enable:TGadget 'menu
  4924. Field ppcenable:TGadget 'menu
  4925. Field armenable:TGadget 'menu
  4926. Field armeabiv5enable:TGadget 'menu
  4927. Field armeabiv7aenable:TGadget 'menu
  4928. Field arm64v8aenable:TGadget 'menu
  4929. Field jsenable:TGadget 'menu
  4930. Field armv7enable:TGadget 'menu
  4931. Field arm64enable:TGadget 'menu
  4932. Field architectureenabled:Int[10]
  4933. Const ARCHITECTUREOFFSET:Int = 91
  4934. Const APPSTUBOFFSET:Int = 161
  4935. Field appstubmenus:TGadget[]
  4936. Field appstubmenu:TGadget
  4937. ?MacOS
  4938. Method RanlibMods()
  4939. Local cmd$=Quote( bmxpath+"/bin/bmk" )+" ranlibdir "+Quote( bmxpath+"/mod" )
  4940. system_ cmd
  4941. End Method
  4942. ?
  4943. Method CheckVersion$()
  4944. Local process:TProcess
  4945. Local bytes:Byte[]
  4946. Local cmd$,version$
  4947. cmd$=bmxpath+"/bin/bcc"
  4948. ?win32
  4949. cmd:+".exe"
  4950. ?
  4951. cmd=Quote(cmd)
  4952. process=CreateProcess(cmd$,HIDECONSOLE)
  4953. If process
  4954. Repeat
  4955. Delay 10
  4956. bytes=process.pipe.ReadPipe()
  4957. If bytes
  4958. version:+String.FromBytes(bytes,bytes.length)
  4959. EndIf
  4960. Until Not process.Status()
  4961. EndIf
  4962. If version=""
  4963. Notify "Unable to determine BlitzMax version.~n~nPlease reinstall BlitzMax to repair this problem."
  4964. End
  4965. EndIf
  4966. BCC_VERSION=version.Trim()
  4967. ' print "bcc version="+version
  4968. If version.find("(expired)")>-1 'Demo timed out
  4969. Notify "This demo version of BlitzMax has expired.~n~nPlease visit www.blitzbasic.com to buy the full version."
  4970. End
  4971. EndIf
  4972. If version.find("Demo Version")>-1 'Valid demo version
  4973. is_demo=True
  4974. Notify version+"~nTo purchase the full version please visit www.blitzbasic.com."
  4975. Notify ABOUTDEMO
  4976. EndIf
  4977. End Method
  4978. Method OpenProgress(message$)
  4979. ' progress.Open message
  4980. DisableGadget window
  4981. SetStatus message
  4982. progress=-1
  4983. End Method
  4984. Method CloseProgress()
  4985. ' progress.Hide
  4986. SetStatus ""
  4987. EnableGadget window
  4988. progress=0
  4989. End Method
  4990. Method UpdateProgress(message$,value=0) 'returns false if cancelled
  4991. ' Return progress.Update(message,value)
  4992. If progress
  4993. If progress/5<>value/5
  4994. SetStatus message+" "+value+"%"
  4995. progress=value
  4996. ' Pollsystem
  4997. EndIf
  4998. EndIf
  4999. End Method
  5000. Method FullPath$(path$)
  5001. If path[..8]="$BMXPATH" path=bmxpath+path[8..]
  5002. If Not path.Contains("::") Then path = RealPath(path)
  5003. ?win32
  5004. path=path.Replace("\","/")
  5005. ?
  5006. Return path
  5007. End Method
  5008. Method IsTempPath(path$)
  5009. If path[..bmxpath.length+5]=bmxpath+"/tmp/" Return True
  5010. End Method
  5011. Method AddDefaultProj(p$)
  5012. Local projdata:TList = New TList
  5013. projdata.AddLast p
  5014. projlist.AddLast projdata
  5015. End Method
  5016. Method ReadConfig()
  5017. Local stream:TStream
  5018. Local f$,p,a$,b$
  5019. ' defaults
  5020. Local wh=GadgetHeight(Desktop())-80'32
  5021. Local ww=wh
  5022. Local wx=(GadgetWidth(Desktop())-ww)/2
  5023. Local wy=(GadgetHeight(Desktop())-wh)/2
  5024. winsize.set( wx,wy,ww,wh )
  5025. quickenabled=False
  5026. debugenabled=True
  5027. threadedenabled=False
  5028. consoleenabled=False
  5029. guienabled=True
  5030. makelibenabled=False
  5031. verboseenabled=False
  5032. quickscanenabled=True
  5033. universalenabled=False
  5034. warnoverenabled=True
  5035. gdbdebugenabled=False
  5036. For Local i:Int = 0 Until platformenabled.length
  5037. platformenabled[i] = False
  5038. Next
  5039. ?win32
  5040. platformenabled[MENUWIN32ENABLED - PLATFORMOFFSET] = True
  5041. ?linuxx86
  5042. platformenabled[MENULINUXENABLED - PLATFORMOFFSET] = True
  5043. ?linuxx64
  5044. platformenabled[MENULINUXENABLED - PLATFORMOFFSET] = True
  5045. ?macos
  5046. platformenabled[MENUMACOSXENABLED - PLATFORMOFFSET] = True
  5047. ?raspberrypi
  5048. platformenabled[MENURASPBERRYPIENABLED - PLATFORMOFFSET] = True
  5049. ?emscripten
  5050. platformenabled[MENUEMSCRIPTENENABLED - PLATFORMOFFSET] = True
  5051. ?
  5052. splitpos=200;splitorientation = SPLIT_VERTICAL
  5053. selectedappstub="brl.appstub"
  5054. ' read ini
  5055. stream=ReadFile(bmxpath+"/cfg/ide.ini")
  5056. If Not stream
  5057. AddDefaultProj "Samples|samples"
  5058. If Not is_demo
  5059. AddDefaultProj "Modules Source|mod"
  5060. AddDefaultProj "BlitzMax Source|src"
  5061. EndIf
  5062. Return
  5063. EndIf
  5064. options.Read(stream)
  5065. options.Snapshot
  5066. Local projdata:TList
  5067. While Not stream.Eof()
  5068. f$=stream.ReadLine()
  5069. p=f.find("=")
  5070. If p=-1 Continue
  5071. a$=f[..p]
  5072. b$=f[p+1..]
  5073. Select a$
  5074. Case "ide_version"
  5075. Case "file_recent"
  5076. recentfiles.addlast b$
  5077. Case "file_open"
  5078. openlist.addlast b$
  5079. Case "prg_quick"
  5080. quickenabled=Int(b$)
  5081. Case "prg_debug"
  5082. debugenabled=Int(b$)
  5083. Case "prg_threaded"
  5084. threadedenabled=Int(b$)
  5085. Case "prg_console"
  5086. consoleenabled=Int(b$)
  5087. Case "prg_gui"
  5088. guienabled=Int(b$)
  5089. Case "prg_makelib"
  5090. makelibenabled=Int(b$)
  5091. Case "prg_verbose"
  5092. verboseenabled=Int(b$)
  5093. Case "prg_quickscan"
  5094. quickscanenabled=Int(b$)
  5095. Case "prg_universal"
  5096. universalenabled=Int(b$)
  5097. Case "prg_warnover"
  5098. warnoverenabled=Int(b$)
  5099. Case "prg_gdbdebug"
  5100. gdbdebugenabled=Int(b$)
  5101. Case "prg_platform"
  5102. For Local i:Int = 0 Until platformenabled.length
  5103. platformenabled[i] = False
  5104. If i = Int(b$) Then
  5105. platformenabled[i] = True
  5106. End If
  5107. Next
  5108. Case "prg_architecture"
  5109. For Local i:Int = 0 Until architectureenabled.length
  5110. architectureenabled[i] = False
  5111. If i = Int(b$) Then
  5112. architectureenabled[i] = True
  5113. End If
  5114. Next
  5115. Case "cmd_line"
  5116. cmdline=b$
  5117. Case "prg_locked"
  5118. openlock=b$
  5119. Case "win_size"
  5120. winsize.FromString(b$)
  5121. Case "win_max"
  5122. winmax=Int(b$)
  5123. Case "split_position"
  5124. splitpos=Int(b$)
  5125. Case "split_orientation"
  5126. splitorientation=Int(b$)
  5127. Case "proj_node"
  5128. projdata=New TList
  5129. projdata.AddLast b
  5130. projlist.AddLast projdata
  5131. Case "proj_data"
  5132. If projdata projdata.AddLast b
  5133. Case "appstub"
  5134. selectedappstub = b
  5135. 'Case "sync_state"
  5136. 'syncmodsreq.FromString b$
  5137. End Select
  5138. Wend
  5139. If Not guienabled And Not makelibenabled Then
  5140. consoleenabled = True
  5141. End If
  5142. stream.close()
  5143. End Method
  5144. Method WriteConfig()
  5145. Local panel:TToolPanel
  5146. Local node:TNode
  5147. Local f$
  5148. Local stream:TStream = WriteFile(bmxpath+"/cfg/ide.ini")
  5149. If Not stream Return
  5150. ' options
  5151. options.write(stream)
  5152. ' defaults
  5153. stream.WriteLine "[Defaults]"
  5154. stream.WriteLine "ide_version="+IDE_VERSION$
  5155. stream.WriteLine "prg_quick="+quickenabled
  5156. stream.WriteLine "prg_debug="+debugenabled
  5157. stream.WriteLine "prg_threaded="+threadedenabled
  5158. stream.WriteLine "prg_console="+consoleenabled
  5159. stream.WriteLine "prg_gui="+guienabled
  5160. stream.WriteLine "prg_makelib="+makelibenabled
  5161. stream.WriteLine "prg_verbose="+verboseenabled
  5162. stream.WriteLine "prg_quickscan="+quickscanenabled
  5163. stream.WriteLine "prg_universal="+universalenabled
  5164. stream.WriteLine "prg_warnover="+warnoverenabled
  5165. stream.WriteLine "prg_gdbdebug="+gdbdebugenabled
  5166. For Local i:Int = 0 Until platformenabled.length
  5167. If platformenabled[i] Then
  5168. stream.WriteLine "prg_platform=" + i
  5169. End If
  5170. Next
  5171. For Local i:Int = 0 Until architectureenabled.length
  5172. If architectureenabled[i] Then
  5173. stream.WriteLine "prg_architecture=" + i
  5174. End If
  5175. Next
  5176. stream.WriteLine "win_size="+winsize.ToString()
  5177. stream.WriteLine "win_max="+winmax
  5178. stream.WriteLine "split_position="+SplitterPosition(split)
  5179. stream.WriteLine "split_orientation="+SplitterOrientation(split)
  5180. stream.WriteLine "cmd_line="+cmdline
  5181. If selectedappstub Then
  5182. stream.WriteLine "appstub="+selectedappstub
  5183. End If
  5184. 'stream.WriteLine "sync_state="+syncmodsreq.ToString()
  5185. If lockedpanel stream.WriteLine "prg_locked="+lockedpanel.path
  5186. Local n:Int
  5187. For f$=EachIn recentfiles
  5188. stream.WriteLine "file_recent="+f$
  5189. ' only last 20
  5190. If n=20 Exit
  5191. n:+1
  5192. Next
  5193. For Local panel:TToolPanel = EachIn panels
  5194. f$=panel.path
  5195. If f$ And Not IsTempPath(f$) stream.WriteLine "file_open="+f$
  5196. Next
  5197. projects.write(stream)
  5198. stream.close
  5199. End Method
  5200. Method CloseAll(dontask,inccurrent=True) 'returns true if successful
  5201. Local count, cancel
  5202. For Local panel:TToolPanel = EachIn panels
  5203. If TOpenCode(panel) And (inccurrent Or currentpanel <> panel) count:+1
  5204. Next
  5205. If (Not count) Or dontask Or Confirm(LocalizeString("{{request_closeall}}"))
  5206. For Local panel:TToolPanel = EachIn panels[..] 'Use a copy of the original array for iterating.
  5207. If (inccurrent Or currentpanel <> panel) And panel.invoke(TOOLCLOSE) Then
  5208. cancel=True
  5209. Exit
  5210. EndIf
  5211. Next
  5212. Return Not cancel
  5213. EndIf
  5214. End Method
  5215. Method Quit()
  5216. WriteConfig()
  5217. If CloseAll(True) running=False
  5218. End Method
  5219. Method DebugExit()
  5220. If debugcode
  5221. debugtree.cancontinue = False
  5222. debugcode.Edit 'restore cursor etc.
  5223. debugcode=Null
  5224. EndIf
  5225. SetMode EDITMODE
  5226. RefreshToolbar()
  5227. End Method
  5228. Method DebugSource(path$,line,column)
  5229. Local code:TOpenCode
  5230. path=FullPath(path)
  5231. code=OpenSource(path)
  5232. If Not code Then
  5233. Notify(LocalizeString("{{loaderror_failed}}").Replace("%1",path), True)
  5234. Return
  5235. EndIf
  5236. If debugcode And debugcode<>code Then debugcode.Edit() 'restore cursor etc.
  5237. debugcode=code
  5238. debugcode.debug(line,column)
  5239. ActivateWindow window
  5240. PollSystem
  5241. End Method
  5242. Method SetMode(m)
  5243. If Mode=m Return
  5244. ActivateWindow window
  5245. Select m
  5246. Case DEBUGMODE
  5247. navtab=navbar.SelectedView()
  5248. navbar.SelectView debugview
  5249. Case EDITMODE
  5250. navbar.SelectView navtab
  5251. End Select
  5252. Mode=m
  5253. RefreshToolbar
  5254. End Method
  5255. Method RefreshMenu()
  5256. TOpenCode.RefreshHighlightingMsg()
  5257. UpdateWindowMenu window
  5258. EndMethod
  5259. Method RefreshToolbar()
  5260. Local i
  5261. ' sourceedit buttons
  5262. If THelpPanel(CurrentPanel)
  5263. DisableGadgetItem toolbar,TB_CLOSE
  5264. Else
  5265. EnableGadgetItem toolbar,TB_CLOSE
  5266. EndIf
  5267. If TOpenCode(CurrentPanel)
  5268. EnableGadgetItem toolbar,TB_SAVE
  5269. For i=TB_CUT To TB_FIND
  5270. EnableGadgetItem toolbar,i
  5271. Next
  5272. Else
  5273. DisableGadgetItem toolbar,TB_SAVE
  5274. For i=TB_CUT To TB_FIND
  5275. DisableGadgetItem toolbar,i
  5276. Next
  5277. EndIf
  5278. ' debug buttons
  5279. If Mode = DEBUGMODE And debugtree.cancontinue Then
  5280. If GadgetItemIcon( toolbar, TB_BUILDRUN ) = TB_BUILDRUN Then
  5281. ModifyGadgetItem( toolbar, TB_BUILDRUN, "", GADGETITEM_LOCALIZED, TB_CONTINUE, "{{tb_continue}}" )
  5282. EndIf
  5283. Else
  5284. If GadgetItemIcon( toolbar, TB_BUILDRUN ) <> TB_BUILDRUN Then
  5285. ModifyGadgetItem( toolbar, TB_BUILDRUN, "", GADGETITEM_LOCALIZED, TB_BUILDRUN, "{{tb_buildrun}}" )
  5286. EndIf
  5287. EndIf
  5288. For i=TB_STEP To TB_STEPOUT
  5289. If Mode=DEBUGMODE And debugtree.cancontinue Then
  5290. EnableGadgetItem toolbar,i
  5291. Else
  5292. DisableGadgetItem toolbar,i
  5293. EndIf
  5294. Next
  5295. ' stop button
  5296. If output And output.process
  5297. EnableGadgetItem toolbar,TB_STOP
  5298. Else
  5299. DisableGadgetItem toolbar,TB_STOP
  5300. EndIf
  5301. End Method
  5302. Method IsSourceOpen(path$)
  5303. Local p$ = FullPath(path)
  5304. For Local panel:TToolPanel = EachIn panels
  5305. If panel.path=p Return True
  5306. Next
  5307. End Method
  5308. Method OpenSource:TOpenCode(path$)
  5309. Local code:TOpenCode
  5310. Local ext$,p$
  5311. If path$="."
  5312. path$=RequestFile(LocalizeString("{{request_openfile}}"),FileTypeFilters )
  5313. If path$="" Return
  5314. EndIf
  5315. ' check if already open
  5316. p$=FullPath(path).ToLower()
  5317. For Local panel:TToolPanel = EachIn panels
  5318. If panel.path.ToLower()=p
  5319. SelectPanel panel
  5320. Return TOpenCode(panel)
  5321. EndIf
  5322. Next
  5323. ' open based on extension
  5324. ' Select ExtractExt(Upper(path$))
  5325. ' Case "BMX","TXT","BB","CPP","C","S","I","H","HTML","CSS","BAT","FS","VS","README",""
  5326. OpenProgress LocalizeString("{{msg_loading}}").Replace("%1",StripDir(path))
  5327. code=TOpenCode.Create(path,Self)
  5328. If code
  5329. AddRecent code.path
  5330. EndIf
  5331. CloseProgress
  5332. If code
  5333. ActivateGadget code.textarea
  5334. code.GetNode().Refresh
  5335. EndIf
  5336. Return code
  5337. ' end select
  5338. End Method
  5339. Method AddRecent(path$)
  5340. For Local f$ = EachIn recentfiles
  5341. If f$=path$ recentfiles.Remove(f$);Exit
  5342. Next
  5343. recentfiles.AddFirst(path$)
  5344. RefreshRecentFiles
  5345. UpdateWindowMenu window
  5346. End Method
  5347. Method RefreshRecentFiles()
  5348. Local n
  5349. For Local m:TGadget = EachIn recentmenus
  5350. FreeMenu m
  5351. Next
  5352. n=Min(recentfiles.count(),16)
  5353. recentmenus=New TGadget[n]
  5354. n=0
  5355. For Local f$ = EachIn recentfiles
  5356. recentmenus[n]=CreateMenu(f$,MENURECENT+n,recentmenu)
  5357. n:+1
  5358. If n=16 Exit
  5359. Next
  5360. End Method
  5361. Method RefreshAppStubs()
  5362. For Local m:TGadget = EachIn appstubmenus
  5363. FreeMenu m
  5364. Next
  5365. Local n:Int = options.appstubs.length
  5366. appstubmenus=New TGadget[n]
  5367. n=0
  5368. Local checked:Int
  5369. For Local a:String = EachIn options.appstubs
  5370. appstubmenus[n]=CreateMenu(a,APPSTUBOFFSET+n,appstubmenu)
  5371. If selectedappstub = a Then
  5372. CheckMenu appstubmenus[n]
  5373. checked = True
  5374. Else
  5375. UncheckMenu appstubmenus[n]
  5376. End If
  5377. n:+1
  5378. Next
  5379. ' didn't match any app stubs. choose default (brl.appstub)
  5380. If Not checked Then
  5381. selectedappstub = options.appstubs[0]
  5382. CheckMenu appstubmenus[0]
  5383. End If
  5384. End Method
  5385. Method BuildModules(buildall)
  5386. Local cmd$,out$,exe$
  5387. output.Stop
  5388. SaveAll
  5389. cmd$=quote(bmkpath)
  5390. cmd$:+" makemods "
  5391. If buildall cmd$:+"-a "
  5392. If threadedenabled cmd:+"-h "
  5393. If verboseenabled cmd:+"-v "
  5394. If quickscanenabled cmd:+"-quick "
  5395. If universalenabled cmd:+"-i "
  5396. If warnoverenabled cmd:+"-w "
  5397. If gdbdebugenabled cmd:+"-gdb "
  5398. Local platform:String = GetPlatform()
  5399. Local architecture:String = GetArchitecture()
  5400. If platform cmd :+ "-l " + platform + " "
  5401. If architecture cmd :+ "-g " + architecture + " "
  5402. Execute cmd,LocalizeString("{{output_msg_buildingmods}}")
  5403. End Method
  5404. Method ImportBB()
  5405. Local f$ = RequestFile(LocalizeString("{{request_importbb_title}}"),"bb" )
  5406. If Not f$ Return
  5407. Local cmd$ = Quote(bmkpath$)
  5408. cmd$:+" convertbb "
  5409. cmd$:+quote(FullPath(f$))
  5410. Execute cmd,LocalizeString("{{output_msg_converting}}").Replace("%1",StripExt(StripDir(f$)))
  5411. output.wait
  5412. OpenSource(StripExt(f$)+".bmx")
  5413. End Method
  5414. Method GetCommandLine$()
  5415. Return cmdline
  5416. End Method
  5417. Method SetCommandLine(Text$)
  5418. cmdline=Text
  5419. End Method
  5420. Method SetStatus(Text$)
  5421. SetStatusText window,Text
  5422. End Method
  5423. Method Execute(cmd$,mess$="",post$="",home=True,tool:TTool=Null)
  5424. If Not output output=TOutputPanel.Create(Self)
  5425. output.execute cmd$,mess$,post$,home,tool
  5426. End Method
  5427. Method SelectError(path$,column,line)
  5428. Local panel:TOpenCode,found
  5429. For panel=EachIn panels
  5430. If panel.path=path found=True;Exit
  5431. Next
  5432. If Not found panel=OpenSource(path)
  5433. If panel
  5434. SelectPanel panel
  5435. panel.Debug line,column
  5436. EndIf
  5437. End Method
  5438. Method ParseError(err$)
  5439. Local mess$,file$,p,q
  5440. Local line,column
  5441. ' bcc error
  5442. If err$[..13]="Compile Error"
  5443. err=err[14..]
  5444. p=err.find(EOL$)
  5445. If p=-1 p=err.length
  5446. mess=err[..p]
  5447. err=err[p+1..]
  5448. If err[..1]="["
  5449. p=err.find("]")
  5450. If p=-1 p=err.length
  5451. file$=err[1..p]
  5452. p=file.find(";")+1
  5453. If p=0 p=err.length
  5454. q=file.find(";",p)+1
  5455. If q=0 q=err.length
  5456. line=Int(file[p..q-1])
  5457. column=Int(file[q..])
  5458. file=FullPath(file[..p-1])
  5459. SelectError file,column,line
  5460. EndIf
  5461. Notify LocalizeString("{{output_error_compileerror}}").Replace("%1",mess)
  5462. SetStatus mess
  5463. Return
  5464. EndIf
  5465. ' gcc error
  5466. err=err.Replace(EOL+" "," ")
  5467. While err
  5468. p=err.find(EOL)
  5469. If p=-1 p:+err.length 'equiv. to p=err.length-1 ;-)
  5470. mess=err[..p]
  5471. err=err[p+1..]
  5472. p=0
  5473. Repeat
  5474. p=mess.Find(":",p)+1
  5475. If p=0 Exit
  5476. q=mess.Find(":",p)
  5477. If q<>-1
  5478. file=mess[..p-1]
  5479. line=Int(mess[p..q])
  5480. If line
  5481. mess=mess[q+1..]
  5482. SelectError file,column,line
  5483. Notify LocalizeString("{{output_error_compileerror}}").Replace("%1",mess)
  5484. Return
  5485. EndIf
  5486. p=q+1
  5487. EndIf
  5488. Forever
  5489. Wend
  5490. End Method
  5491. Method AddPanel(tabpanel:TToolPanel)
  5492. Local panel:TGadget,index
  5493. index=CountGadgetItems(tabbar)
  5494. If panels.length<=index panels=panels[..index+1]
  5495. AddGadgetItem(tabbar,tabpanel.name$,GADGETITEM_DEFAULT|GADGETITEM_LOCALIZED)
  5496. panel=CreatePanel(0,0,ClientWidth(tabbar),ClientHeight(tabbar),tabbar,0) 'name
  5497. SetGadgetLayout panel,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
  5498. tabpanel.panel=panel
  5499. tabpanel.index=index
  5500. panels[index]=tabpanel
  5501. SelectPanel tabpanel
  5502. AddHandler tabpanel
  5503. End Method
  5504. Method AddHandler(handler:TEventHandler)
  5505. eventhandlers.addlast handler
  5506. End Method
  5507. Method RemovePanel(tabpanel:TToolPanel)
  5508. Local p:TToolPanel[]
  5509. Local index
  5510. eventhandlers.remove tabpanel
  5511. ' unset debugcode
  5512. If debugcode=tabpanel debugcode=Null
  5513. ' activate next panel
  5514. If tabpanel=activepanel activepanel=helppanel
  5515. If tabpanel=lockedpanel lockedpanel=Null
  5516. If tabpanel=currentpanel
  5517. index=tabpanel.index+1
  5518. If index>=panels.length index=panels.length-2
  5519. SelectPanel panels[index]
  5520. EndIf
  5521. ' remove from array
  5522. p=panels
  5523. panels=panels[..panels.length-1]
  5524. For index=tabpanel.index To panels.length-1
  5525. panels[index]=p[index+1]
  5526. panels[index].index=index
  5527. Next
  5528. ' remove gadget - simon come here, placing before remove needs fix in fltk
  5529. FreeGadget tabpanel.panel
  5530. RemoveGadgetItem tabbar,tabpanel.index
  5531. tabpanel.panel=Null
  5532. End Method
  5533. Method HookRequester(req:TRequester)
  5534. If Not activerequesters.Contains(req) Then
  5535. If req.IsModal() Then
  5536. For Local tmpRequester:TRequester = EachIn activerequesters
  5537. DisableGadget tmpRequester.window
  5538. Next
  5539. DisableGadget window
  5540. EndIf
  5541. activerequesters.AddFirst(req)
  5542. EndIf
  5543. End Method
  5544. Method UnhookRequester(req:TRequester)
  5545. If activerequesters.Contains(req) Then
  5546. activerequesters.Remove(req)
  5547. If req.IsModal() Then
  5548. For Local tmpRequester:TRequester = EachIn activerequesters
  5549. EnableGadget tmpRequester.window
  5550. Next
  5551. EnableGadget window
  5552. EndIf
  5553. EndIf
  5554. EndMethod
  5555. Method SetTitle(title$="")
  5556. If title title=" - "+title
  5557. SetGadgetText window,"MaxIDE"+title
  5558. End Method
  5559. Method SelectPanel(panel:TToolPanel)
  5560. Local curr:TToolPanel = currentpanel
  5561. currentpanel=panel
  5562. If curr And curr<>currentpanel
  5563. SelectGadgetItem tabbar,panel.index
  5564. ShowGadget panel.panel
  5565. If panel.active activepanel=panel
  5566. HideGadget curr.panel
  5567. RefreshToolbar
  5568. EndIf
  5569. currentpanel.Invoke TOOLSHOW
  5570. End Method
  5571. Method RefreshPanel(panel:TToolPanel) 'call after a name change
  5572. ModifyGadgetItem( tabbar,panel.index,panel.name,GADGETITEM_LOCALIZED )
  5573. End Method
  5574. Function OutsideDesktop(winrect:TRect)
  5575. Local x,y,w,h
  5576. Local desk:TGadget = Desktop()
  5577. x=GadgetX(desk)
  5578. y=GadgetY(desk)
  5579. w=GadgetWidth(desk)
  5580. h=GadgetHeight(desk)
  5581. Return winrect.IsOutside(x,y,w,h)
  5582. End Function
  5583. Method SetCodeNode(code:TNode)
  5584. Local node:TNode
  5585. If coderoot.kids.count() node=TNode(coderoot.kids.First())
  5586. If node=code Return
  5587. If node node.Detach
  5588. If code
  5589. coderoot.Append code
  5590. coderoot.Refresh
  5591. coderoot.Open
  5592. code.Open
  5593. EndIf
  5594. End Method
  5595. Method Initialize()
  5596. Local open:TOpenCode, splash:TGadget
  5597. Local dir$,nomods,pname$,p
  5598. Local stream:TStream
  5599. Try
  5600. bmxpath=BlitzMaxPath()
  5601. Catch err$
  5602. Notify "Unable to determine BlitzMax installation directory."
  5603. End
  5604. EndTry
  5605. CreateDir bmxpath+"/tmp"
  5606. If FileType( bmxpath+"/tmp" )<>FILETYPE_DIR
  5607. Notify "Unable to create BlitzMax 'tmp' directory."
  5608. End
  5609. EndIf
  5610. ?Win32
  5611. CreateFile bmxpath+"/tmp/t.exe"
  5612. If FileType( bmxpath+"/tmp/t.exe" ) <> FILETYPE_FILE
  5613. Notify "Unable to write to BlitzMax installation directory.~n"+..
  5614. "Please run MaxIDE as administrator, or reinstall BlitzMax to a different directory."
  5615. End
  5616. EndIf
  5617. DeleteFile bmxpath+"/tmp/t.exe"
  5618. ?
  5619. bmkpath=bmxpath+"/bin/bmk"
  5620. ?Win32
  5621. bmkpath:+".exe"
  5622. ?
  5623. dir$=bmxpath+"/mod"
  5624. If FileType(dir)=FILETYPE_NONE
  5625. If Not CreateDir(dir)
  5626. Notify "Failed to create %1 directory:~n%2".Replace("%1","Module").Replace("%2",dir)
  5627. End
  5628. EndIf
  5629. nomods=True
  5630. EndIf
  5631. dir$=bmxpath+"/tmp"
  5632. If FileType(dir)=FILETYPE_NONE
  5633. If Not CreateDir(dir)
  5634. Notify "Failed to create %1 directory:~n%2".Replace("%1","Temp").Replace("%2",dir)
  5635. End
  5636. EndIf
  5637. EndIf
  5638. dir$=bmxpath+"/cfg"
  5639. If FileType(dir)=FILETYPE_NONE
  5640. If Not CreateDir(dir)
  5641. Notify "Failed to create %1 directory:~n%2".Replace("%1","Config").Replace("%2",dir)
  5642. End
  5643. EndIf
  5644. EndIf
  5645. CheckVersion()
  5646. splash=CreateWindow("MaxIDE",ScaledSize(200),ScaledSize(200),ScaledSize(400),ScaledSize(160),Null,WINDOW_CLIENTCOORDS|WINDOW_HIDDEN|WINDOW_CENTER)
  5647. Local panel:TGadget = CreatePanel(0,0,ClientWidth(splash),ClientHeight(splash),splash,0)
  5648. SetPanelColor panel,255,255,255;SetPanelPixmap panel, LoadPixmapPNG("incbin::splash.png"), PANELPIXMAP_FIT2
  5649. Local progress:TGadget = CreateProgBar(ScaledSize(2),ClientHeight(panel)-ScaledSize(22),ClientWidth(panel)-ScaledSize(4),ScaledSize(20),panel)
  5650. ShowGadget splash;PollSystem
  5651. window=CreateWindow("MaxIDE",20,20,760,540,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_STATUS|WINDOW_HIDDEN|WINDOW_ACCEPTFILES|WINDOW_MENU)
  5652. ?Linux
  5653. SetGadgetPixmap(window, LoadPixmapPNG("incbin::window_icon.png"), GADGETPIXMAP_ICON )
  5654. ?
  5655. cmdlinereq=TCmdLineRequester.Create(Self)
  5656. 'syncmodsreq=TSyncModsRequester.Create(Self)
  5657. gotoreq=TGotoRequester.Create(Self)
  5658. findreq=TFindRequester.Create(Self)
  5659. replacereq=TReplaceRequester.Create(Self)
  5660. options=TOptionsRequester.Create(Self)
  5661. ' progress=TProgressRequester.Create(Self)
  5662. projectreq=TProjectRequester.Create(Self)
  5663. projectprops=TProjectProperties.Create(Self)
  5664. searchreq=TSearchRequester.Create(Self)
  5665. aboutreq=TAboutRequester.Create(Self)
  5666. UpdateProgBar progress, 0.1;PollSystem
  5667. ReadConfig()
  5668. Local tbSize:String
  5669. Local scale:Int = GadgetScaleFactor(Desktop())
  5670. If scale = 2 Then
  5671. tbSize = "_48"
  5672. Else If scale > 2 Then
  5673. tbSize = "_64"
  5674. End If
  5675. toolbar=CreateToolBar("incbin::toolbar" + tbSize + ".png",0,0,0,0,window )
  5676. RemoveGadgetItem toolbar, TB_CONTINUE
  5677. 'Rem
  5678. SetToolBarTips toolbar, ["{{tb_new}}","{{tb_open}}","{{tb_close}}","{{tb_save}}","","{{tb_cut}}","{{tb_copy}}","{{tb_paste}}","{{tb_find}}","",..
  5679. "{{tb_build}}","{{tb_buildrun}}","{{tb_step}}","{{tb_stepin}}","{{tb_stepout}}","{{tb_stop}}","","{{tb_home}}","{{tb_back}}","{{tb_forward}}"]
  5680. 'End Rem
  5681. If Not options.showtoolbar Then HideGadget toolbar
  5682. If OutsideDesktop(winsize)
  5683. winsize.set(20,20,760,540)
  5684. EndIf
  5685. UpdateProgBar progress, 0.2;PollSystem
  5686. SetGadgetShape(window, winsize.x, winsize.y, winsize.w, winsize.h)
  5687. client=window
  5688. split=CreateSplitter(0,0,ClientWidth(client),ClientHeight(client),client,SPLIT_VERTICAL)
  5689. SetGadgetLayout(split,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED)
  5690. tabbar=CreateTabber(0,0,ClientWidth(SplitterPanel(split,SPLITPANEL_MAIN)),ClientHeight(SplitterPanel(split,SPLITPANEL_MAIN)),SplitterPanel(split,SPLITPANEL_MAIN))
  5691. SetGadgetLayout(tabbar,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED)
  5692. debugtree=TDebugTree.CreateDebugTree(Self)
  5693. root=TNode.CreateNode("{{navtab_home}}")
  5694. helproot=root.AddNode("{{navnode_help}}")
  5695. projects=TProjects.CreateProjects(Self)
  5696. root.Append projects
  5697. ' opencoderoot=root.AddNode("Open")
  5698. coderoot=TNode.CreateNode("{{navtab_code}}")
  5699. coderoot.Open()
  5700. navbar=TNavBar.Create(Self,SplitterPanel(split,SPLITPANEL_SIDEPANE))
  5701. navbar.AddView root
  5702. navbar.AddView coderoot
  5703. debugview=navbar.AddView(debugtree)
  5704. navbar.SelectView 0
  5705. helproot.Open
  5706. projects.Open
  5707. AddHandler navbar
  5708. SetMode EDITMODE
  5709. UpdateProgBar progress, 0.3;PollSystem
  5710. quickhelp=TQuickHelp.LoadCommandsTxt(bmxpath)
  5711. helppanel=THelpPanel.Create(Self)
  5712. output=TOutputPanel.Create(Self)
  5713. activepanel=helppanel
  5714. InitMenu
  5715. InitHotkeys
  5716. RefreshAll
  5717. UpdateProgBar progress, 0.4;PollSystem 'allow repaint
  5718. Local mkdocs
  5719. If FileType( bmxpath+"/docs/html/User Guide/index.html" )<>FILETYPE_FILE
  5720. CreateDir bmxpath+"/docs/html"
  5721. CreateFile bmxpath+"/docs/html/index.html"
  5722. mkdocs=True
  5723. EndIf
  5724. helppanel.Home()
  5725. UpdateProgBar progress, 0.5;PollSystem
  5726. ' scan projects in projlist
  5727. For Local pdata:TList = EachIn projlist
  5728. projects.AddProject pdata
  5729. Next
  5730. UpdateProgBar progress, 0.6;PollSystem
  5731. Local tmpProgValue# = 0.6
  5732. Local tmpProgStep#
  5733. 'open files from .ini restorelist
  5734. If options.restoreopenfiles
  5735. If Not openlist.IsEmpty() Then tmpProgStep = (0.3/openlist.Count())
  5736. For Local f$=EachIn openlist
  5737. open=OpenSource(f$)
  5738. If open And f$=openlock open.SetLocked(True)
  5739. tmpProgValue:+tmpProgStep;UpdateProgBar progress,tmpProgValue
  5740. Next
  5741. EndIf
  5742. tmpProgValue = 0.9
  5743. If AppArgs.length > 1 Then tmpProgStep = (0.1/(AppArgs.length-1)) Else tmpProgValue = 1.0
  5744. UpdateProgBar progress,tmpProgValue;PollSystem
  5745. ' open files specified in command line
  5746. For Local i:Int = 1 Until AppArgs.length
  5747. open=OpenSource(AppArgs[i])
  5748. tmpProgValue:+tmpProgStep;UpdateProgBar progress,tmpProgValue;PollSystem
  5749. Next
  5750. HideGadget splash;FreeGadget splash
  5751. PollSystem
  5752. SetSplitterPosition(split,splitpos);SetSplitterOrientation(split,splitorientation)
  5753. If winmax MaximizeWindow(window)
  5754. ShowGadget window
  5755. PollSystem
  5756. running=True
  5757. CreateTimer(TIMER_FREQUENCY)
  5758. 'If nomods syncmodsreq.Show
  5759. 'build docs if not there
  5760. If mkdocs
  5761. If Confirm( LocalizeString("{{loaderror_docsnotfound}}") ) And CloseAll( False ) DocMods
  5762. EndIf
  5763. End Method
  5764. Method DocMods()
  5765. Local cmd$=quote(bmxpath+"/bin/makedocs")
  5766. execute cmd,LocalizeString("{{output_msg_rebuildingdocs}}"),MENUTRIGGERSYNCDOCS
  5767. ?MacOS
  5768. RanLibMods()
  5769. ?
  5770. End Method
  5771. Method SyncDocs()
  5772. helppanel.SyncDocs()
  5773. quickhelp=TQuickHelp.LoadCommandsTxt(bmxpath)
  5774. helppanel.Home
  5775. End Method
  5776. Method InitMenu()
  5777. Local menu:TGadget,file:TGadget,edit:TGadget,program:TGadget,tools:TGadget
  5778. Local help:TGadget,buildoptions:TGadget,devoptions:TGadget
  5779. Local buildmods:TGadget,buildallmods:TGadget,syncmods:TGadget,docmods:TGadget
  5780. Local platform:TGadget,architecture:TGadget
  5781. Local appoptions:TGadget
  5782. Local MENUMOD=MODIFIER_COMMAND
  5783. If options.systemkeys
  5784. MENUMOD=MODIFIER_CONTROL
  5785. EndIf
  5786. menu=WindowMenu(window)
  5787. file=CreateMenu("{{menu_file}}",0,menu)
  5788. CreateMenu "{{menu_file_new}}",MENUNEW,file,KEY_N,MENUMOD
  5789. CreateMenu "{{menu_file_open}}",MENUOPEN,file,KEY_O,MENUMOD
  5790. recentmenu=CreateMenu("{{menu_file_open_recent}}",0,file)
  5791. CreateMenu "",0,file
  5792. CreateMenu "{{menu_file_closetab}}",MENUCLOSE,file,KEY_W,MENUMOD
  5793. CreateMenu "{{menu_file_closealltabs}}",MENUCLOSEALL,file,KEY_W,MENUMOD|MODIFIER_SHIFT
  5794. CreateMenu "{{menu_file_closeothertabs}}",MENUCLOSEOTHERS,file,KEY_W,MENUMOD|MODIFIER_ALT
  5795. CreateMenu "",0,file
  5796. CreateMenu "{{menu_file_save}}",MENUSAVE,file,KEY_S,MENUMOD
  5797. CreateMenu "{{menu_file_saveas}}",MENUSAVEAS,file,KEY_S,MENUMOD|MODIFIER_SHIFT
  5798. CreateMenu "{{menu_file_saveall}}",MENUSAVEALL,file
  5799. CreateMenu "",0,file
  5800. If options.systemkeys
  5801. ?MacOS
  5802. CreateMenu "{{menu_file_nexttab}}",MENUNEXT,file,KEY_RIGHT,MENUMOD
  5803. CreateMenu "{{menu_file_prevtab}}",MENUPREV,file,KEY_LEFT,MENUMOD
  5804. ?Not MacOS
  5805. CreateMenu "{{menu_file_nexttab}}",MENUNEXT,file,KEY_RIGHT,MODIFIER_ALT
  5806. CreateMenu "{{menu_file_prevtab}}",MENUPREV,file,KEY_LEFT,MODIFIER_ALT
  5807. ?
  5808. Else
  5809. CreateMenu "{{menu_file_nexttab}}",MENUNEXT,file,KEY_RIGHT,MENUMOD
  5810. CreateMenu "{{menu_file_prevtab}}",MENUPREV,file,KEY_LEFT,MENUMOD
  5811. EndIf
  5812. CreateMenu "",0,file
  5813. CreateMenu "{{menu_file_importbb}}",MENUIMPORTBB,file
  5814. CreateMenu "",0,file
  5815. CreateMenu "{{menu_file_ideoptions}}",MENUOPTIONS,file
  5816. CreateMenu "{{menu_file_projectmanager}}",MENUPROJECTMANAGER,file
  5817. CreateMenu "",0,file
  5818. CreateMenu "{{menu_file_print}}",MENUPRINT,file,KEY_P,MENUMOD
  5819. ?Not MacOS
  5820. CreateMenu "",0,file
  5821. CreateMenu "{{menu_file_exit}}",MENUQUIT,file
  5822. ?
  5823. edit=CreateMenu("{{menu_edit}}",0,menu)
  5824. CreateMenu "{{menu_edit_undo}}",MENUUNDO,edit,KEY_Z,MENUMOD
  5825. ?MacOS
  5826. CreateMenu "{{menu_edit_redo}}",MENUREDO,edit,KEY_Z,MENUMOD|MODIFIER_SHIFT
  5827. ?Not MacOS
  5828. CreateMenu "{{menu_edit_redo}}",MENUREDO,edit,KEY_Y,MENUMOD
  5829. ?
  5830. CreateMenu "",0,edit
  5831. CreateMenu "{{menu_edit_cut}}",MENUCUT,edit,KEY_X,MENUMOD
  5832. CreateMenu "{{menu_edit_copy}}",MENUCOPY,edit,KEY_C,MENUMOD
  5833. CreateMenu "{{menu_edit_paste}}",MENUPASTE,edit,KEY_V,MENUMOD
  5834. CreateMenu "",0,edit
  5835. CreateMenu "{{menu_edit_selectall}}",MENUSELECTALL,edit,KEY_A,MENUMOD
  5836. CreateMenu "",0,edit
  5837. CreateMenu "{{menu_edit_blockindent}}",MENUINDENT,edit,KEY_CLOSEBRACKET,MENUMOD
  5838. CreateMenu "{{menu_edit_blockoutdent}}",MENUOUTDENT,edit,KEY_OPENBRACKET,MENUMOD
  5839. CreateMenu "",0,edit
  5840. CreateMenu "{{menu_edit_find}}",MENUFIND,edit,KEY_F,MENUMOD
  5841. ?MacOS
  5842. CreateMenu "{{menu_edit_findnext}}",MENUFINDNEXT,edit,KEY_G,MENUMOD
  5843. CreateMenu "{{menu_edit_replace}}",MENUREPLACE,edit,KEY_H,MENUMOD
  5844. CreateMenu "{{menu_edit_gotoline}}",MENUGOTO,edit,KEY_L,MENUMOD
  5845. ?Not MacOS
  5846. CreateMenu "{{menu_edit_findnext}}",MENUFINDNEXT,edit,KEY_F3
  5847. CreateMenu "{{menu_edit_replace}}",MENUREPLACE,edit,KEY_H,MENUMOD
  5848. CreateMenu "{{menu_edit_gotoline}}",MENUGOTO,edit,KEY_G,MENUMOD
  5849. ?
  5850. CreateMenu "",0,edit
  5851. CreateMenu "{{menu_edit_findinfiles}}",MENUFINDINFILES,edit,KEY_F,MENUMOD|MODIFIER_SHIFT
  5852. program=CreateMenu("{{menu_program}}",0,menu)
  5853. CreateMenu "{{menu_program_build}}",MENUBUILD,program,KEY_B,MENUMOD
  5854. CreateMenu "{{menu_program_buildandrun}}",MENURUN,program,KEY_R,MENUMOD
  5855. CreateMenu "{{menu_program_commandline}}",MENUCOMMANDLINE,program
  5856. CreateMenu "",0,program
  5857. CreateMenu "{{menu_program_step}}",MENUSTEP,program,KEY_F9
  5858. CreateMenu "{{menu_program_stepin}}",MENUSTEPIN,program,KEY_F10
  5859. CreateMenu "{{menu_program_stepout}}",MENUSTEPOUT,program,KEY_F11
  5860. CreateMenu "{{menu_program_terminate}}",MENUSTOP,program
  5861. CreateMenu "",0,program
  5862. buildoptions=CreateMenu("{{menu_program_buildoptions}}",0,program)
  5863. quickenable=CreateMenu("{{menu_program_buildoptions_quick}}",MENUQUICKENABLED,buildoptions)
  5864. debugenable=CreateMenu("{{menu_program_buildoptions_debug}}",MENUDEBUGENABLED,buildoptions)
  5865. If (FileType( BlitzMaxPath()+"/mod/brl.mod/blitz.mod/blitz_gc_ms.c" )=FILETYPE_FILE) ..
  5866. Or (FileType( BlitzMaxpath()+"/mod/brl.mod/blitz.mod/bdwgc" )=FILETYPE_DIR)
  5867. threadedenable=CreateMenu("{{menu_program_buildoptions_threaded}}",MENUTHREADEDENABLED,buildoptions)
  5868. EndIf
  5869. appoptions=CreateMenu("{{menu_program_appoptions}}",0,program)
  5870. consoleenable=CreateMenu("{{menu_program_buildoptions_consoleapp}}",MENUCONSOLEENABLED,appoptions)
  5871. guienable=CreateMenu("{{menu_program_buildoptions_guiapp}}",MENUGUIENABLED,appoptions)
  5872. makelibenable=CreateMenu("{{menu_program_buildoptions_makelib}}",MENUMAKELIBENABLED,appoptions)
  5873. quickscanenable=CreateMenu("{{menu_program_buildoptions_quickscan}}",MENUQUICKSCANENABLED,buildoptions)
  5874. ?macos
  5875. universalenable=CreateMenu("{{menu_program_buildoptions_universal}}",MENUUNIVERSALENABLED,buildoptions)
  5876. ?
  5877. warnoverenable=CreateMenu("{{menu_program_buildoptions_warnover}}",MENUWARNOVERENABLED,buildoptions)
  5878. platform=CreateMenu("{{menu_program_platform}}",0,program)
  5879. ?Not raspberrypi
  5880. win32enable=CreateMenu("{{menu_program_platform_win32}}",MENUWIN32ENABLED,platform)
  5881. ?linux
  5882. linuxenable=CreateMenu("{{menu_program_platform_linux}}",MENULINUXENABLED,platform)
  5883. ?
  5884. ?macos
  5885. macosxenable=CreateMenu("{{menu_program_platform_macosx}}",MENUMACOSXENABLED,platform)
  5886. iosenable=CreateMenu("{{menu_program_platform_ios}}",MENUIOSENABLED,platform)
  5887. ?
  5888. raspberrypienable=CreateMenu("{{menu_program_platform_raspberrypi}}",MENURASPBERRYPIENABLED,platform)
  5889. ?Not raspberrypi
  5890. androidenable=CreateMenu("{{menu_program_platform_android}}",MENUANDROIDENABLED,platform)
  5891. ?
  5892. nxenable=CreateMenu("{{menu_program_platform_nx}}",MENUNXENABLED,platform)
  5893. emscriptenenable=CreateMenu("{{menu_program_platform_emscripten}}",MENUEMSCRIPTENENABLED,platform)
  5894. architecture=CreateMenu("{{menu_program_arch}}",0,program)
  5895. x86enable=CreateMenu("{{menu_program_arch_x86}}",MENUX86ENABLED,architecture)
  5896. x64enable=CreateMenu("{{menu_program_arch_x64}}",MENUX64ENABLED,architecture)
  5897. ppcenable=CreateMenu("{{menu_program_arch_ppc}}",MENUPPCENABLED,architecture)
  5898. armenable=CreateMenu("{{menu_program_arch_arm}}",MENUARMENABLED,architecture)
  5899. armeabiv5enable=CreateMenu("{{menu_program_arch_armeabiv5}}",MENUARMEABIV5ENABLED,architecture)
  5900. armeabiv7aenable=CreateMenu("{{menu_program_arch_armeabiv7a}}",MENUARMEABIV7AENABLED,architecture)
  5901. arm64v8aenable=CreateMenu("{{menu_program_arch_arm64v8a}}",MENUARM64V8AENABLED,architecture)
  5902. jsenable=CreateMenu("{{menu_program_arch_js}}",MENUJSENABLED,architecture)
  5903. armv7enable=CreateMenu("{{menu_program_arch_armv7}}",MENUARMV7ENABLED,architecture)
  5904. arm64enable=CreateMenu("{{menu_program_arch_arm64}}",MENUARM64ENABLED,architecture)
  5905. appstubmenu=CreateMenu("{{menu_program_appstub}}",0,program)
  5906. devoptions=CreateMenu("{{menu_program_buildoptions_dev}}",0,program)
  5907. verboseenable=CreateMenu("{{menu_program_buildoptions_verbose}}",MENUVERBOSEENABLED,devoptions)
  5908. gdbdebugenable=CreateMenu("{{menu_program_buildoptions_gdbdebug}}",MENUGDBDEBUGENABLED,devoptions)
  5909. CreateMenu "",0,program
  5910. CreateMenu "{{menu_program_lockbuildfile}}",MENULOCKBUILD,program
  5911. CreateMenu "{{menu_program_unlockbuildfile}}",MENUUNLOCKBUILD,program
  5912. CreateMenu "",0,program
  5913. 'syncmods=CreateMenu("{{menu_program_syncmods}}",MENUSYNCMODS,program)
  5914. 'CreateMenu "",0,program
  5915. buildmods=CreateMenu("{{menu_program_buildmods}}",MENUBUILDMODULES,program,KEY_D,MENUMOD)
  5916. buildallmods=CreateMenu("{{menu_program_rebuildallmods}}",MENUBUILDALLMODULES,program)
  5917. docmods=CreateMenu("{{menu_program_rebuilddocs}}",MENUDOCMODS,program)
  5918. help=CreateMenu("{{menu_help}}",0,menu)
  5919. CreateMenu "{{menu_help_home}}",MENUHOME,help
  5920. CreateMenu "{{menu_help_back}}",MENUBACK,help
  5921. CreateMenu "{{menu_help_forward}}",MENUFORWARD,help
  5922. CreateMenu "{{menu_help_quickhelp}}",MENUQUICKHELP,help,KEY_F1
  5923. CreateMenu "{{menu_help_aboutmaxide}}",MENUABOUT,help
  5924. If quickenabled CheckMenu quickenable
  5925. If debugenabled CheckMenu debugenable
  5926. If threadedenabled CheckMenu threadedenable
  5927. If consoleenabled CheckMenu consoleenable
  5928. If guienabled CheckMenu guienable
  5929. If makelibenabled CheckMenu makelibenable
  5930. If verboseenabled CheckMenu verboseenable
  5931. If quickscanenabled CheckMenu quickscanenable
  5932. If universalenabled CheckMenu universalenable
  5933. If warnoverenabled CheckMenu warnoverenable
  5934. If gdbdebugenabled CheckMenu gdbdebugenable
  5935. Local defaultArch:Int = -1
  5936. For Local i:Int = 0 Until architectureenabled.length
  5937. If architectureenabled[i] Then
  5938. defaultArch = i
  5939. Exit
  5940. End If
  5941. Next
  5942. For Local i:Int = 0 Until platformenabled.length
  5943. If platformenabled[i] Then
  5944. UpdatePlatformMenus(i + PLATFORMOFFSET)
  5945. If defaultArch < 0 Then
  5946. DefaultArchitectureMenuForPlatform(i + PLATFORMOFFSET)
  5947. Else
  5948. UpdateArchitectureMenus(defaultArch + ARCHITECTUREOFFSET)
  5949. End If
  5950. Exit
  5951. End If
  5952. Next
  5953. 'UpdateArchitectureMenus()
  5954. ?Win32
  5955. Local mingw$=BlitzMaxPath() + "/MinGW32"
  5956. If Not FileType(mingw) Then
  5957. mingw = getenv_("MINGW")
  5958. End If
  5959. If Not mingw
  5960. DisableMenu buildmods
  5961. DisableMenu buildallmods
  5962. EndIf
  5963. ?
  5964. ' If is_demo
  5965. ' DisableMenu syncmods
  5966. ' EndIf
  5967. RefreshRecentFiles
  5968. RefreshAppStubs
  5969. UpdateWindowMenu window
  5970. End Method
  5971. Method RunCode()
  5972. If Mode=DEBUGMODE And debugtree.cancontinue
  5973. output.Go()
  5974. Return
  5975. EndIf
  5976. output.Stop()
  5977. SaveAll()
  5978. If lockedpanel
  5979. lockedpanel.invoke TOOLRUN
  5980. Else
  5981. activepanel.invoke TOOLRUN
  5982. EndIf
  5983. End Method
  5984. Method BuildCode()
  5985. output.Stop()
  5986. SaveAll()
  5987. If lockedpanel
  5988. lockedpanel.invoke TOOLBUILD
  5989. Else
  5990. activepanel.invoke TOOLBUILD
  5991. EndIf
  5992. End Method
  5993. Method AddEventHotKey(key,mods,id,data)
  5994. SetHotKeyEvent key,mods,CreateEvent(id,Null,data)
  5995. End Method
  5996. Method InitHotkeys()
  5997. AddEventHotKey KEY_F5,MODIFIER_NONE,EVENT_MENUACTION,MENURUN
  5998. AddEventHotKey KEY_F7,MODIFIER_NONE,EVENT_MENUACTION,MENUBUILD
  5999. End Method
  6000. Method SaveAll()
  6001. For Local panel:TToolPanel = EachIn panels
  6002. panel.invoke TOOLQUICKSAVE
  6003. Next
  6004. End Method
  6005. Method Restart()
  6006. If Confirm(LocalizeString("{{request_restart}}"))
  6007. Quit
  6008. EndIf
  6009. End Method
  6010. Method RefreshAll()
  6011. ' hide/show toolbar
  6012. If options.showtoolbar Then ShowGadget toolbar Else HideGadget toolbar
  6013. ' refresh panels
  6014. For Local panel:TToolPanel = EachIn panels
  6015. panel.invoke TOOLREFRESH
  6016. Next
  6017. ' refresh navbar
  6018. navbar.invoke TOOLREFRESH
  6019. ' refresh appstub menus
  6020. RefreshAppStubs
  6021. End Method
  6022. Method SnapshotWindow()
  6023. If WindowMaximized(window)
  6024. winmax=True
  6025. Else
  6026. If Not WindowMinimized(window)
  6027. winmax=False
  6028. winsize.x=GadgetX(window)
  6029. winsize.y=GadgetY(window)
  6030. winsize.w=GadgetWidth(window)
  6031. winsize.h=GadgetHeight(window)
  6032. EndIf
  6033. EndIf
  6034. options.showtoolbar = Not GadgetHidden(toolbar)
  6035. End Method
  6036. Method OnMenu(menu,extra:Object=Null)
  6037. Local index
  6038. Local tool:TTool = TTool(extra)
  6039. If tool
  6040. tool.invoke(TOOLMENU,""+menu)
  6041. Return
  6042. EndIf
  6043. Select menu
  6044. Case MENUNEW
  6045. OpenSource ""
  6046. Case MENUOPEN
  6047. OpenSource "."
  6048. Case MENUCLOSE
  6049. currentpanel.invoke TOOLCLOSE
  6050. Case MENUCLOSEALL
  6051. CloseAll True
  6052. Case MENUCLOSEOTHERS
  6053. CloseAll True, False
  6054. Case MENUSAVE
  6055. currentpanel.invoke TOOLSAVE
  6056. Case MENUSAVEAS
  6057. currentpanel.invoke TOOLSAVEAS
  6058. Case MENUSAVEALL
  6059. SaveAll()
  6060. Case MENUPRINT
  6061. currentpanel.invoke TOOLPRINT
  6062. Case MENUQUIT
  6063. Quit()
  6064. Case MENUGOTO
  6065. gotoreq.Show()
  6066. Case MENUFIND
  6067. currentpanel.invoke TOOLFIND
  6068. Case MENUFINDNEXT
  6069. currentpanel.invoke TOOLFINDNEXT
  6070. Case MENUREPLACE
  6071. replacereq.Show()
  6072. Case MENUUNDO currentpanel.invoke TOOLUNDO
  6073. Case MENUREDO currentpanel.invoke TOOLREDO
  6074. Case MENUCUT currentpanel.invoke TOOLCUT
  6075. Case MENUCOPY currentpanel.invoke TOOLCOPY
  6076. Case MENUPASTE currentpanel.invoke TOOLPASTE
  6077. Case MENUSELECTALL currentpanel.invoke TOOLSELECTALL
  6078. Case MENUBUILD
  6079. BuildCode()
  6080. Case MENURUN
  6081. RunCode()
  6082. Case MENUBUILDMODULES
  6083. If CheckDemo() BuildModules False
  6084. Case MENUBUILDALLMODULES
  6085. If CheckDemo() BuildModules True
  6086. 'Case MENUSYNCMODS
  6087. ' If CheckDemo() And CloseAll(False) syncmodsreq.Show
  6088. Case MENUDOCMODS
  6089. If CheckDemo() And CloseAll(False) DocMods
  6090. Case MENUTRIGGERDOCMODS
  6091. DocMods()
  6092. Case MENUTRIGGERSYNCDOCS
  6093. SyncDocs()
  6094. Case MENUSTEP If output output.StepOver()
  6095. Case MENUSTEPIN If output output.StepIn()
  6096. Case MENUSTEPOUT If output output.StepOut()
  6097. Case MENUSTOP If output output.Stop()
  6098. Case MENULOCKBUILD
  6099. activepanel.invoke TOOLLOCK
  6100. Case MENUUNLOCKBUILD
  6101. If lockedpanel lockedpanel.invoke TOOLUNLOCK
  6102. Case MENUCOMMANDLINE cmdlinereq.Show
  6103. Case MENUQUICKENABLED
  6104. If quickenabled
  6105. quickenabled=False
  6106. UncheckMenu quickenable
  6107. Else
  6108. quickenabled=True
  6109. CheckMenu quickenable
  6110. EndIf
  6111. UpdateWindowMenu window
  6112. Case MENUDEBUGENABLED
  6113. If debugenabled
  6114. debugenabled=False
  6115. UncheckMenu debugenable
  6116. Else
  6117. debugenabled=True
  6118. CheckMenu debugenable
  6119. EndIf
  6120. UpdateWindowMenu window
  6121. Case MENUTHREADEDENABLED
  6122. If threadedenabled
  6123. threadedenabled=False
  6124. UncheckMenu threadedenable
  6125. Else
  6126. threadedenabled=True
  6127. CheckMenu threadedenable
  6128. EndIf
  6129. UpdateWindowMenu window
  6130. Case MENUGUIENABLED
  6131. If Not guienabled
  6132. guienabled=True
  6133. CheckMenu guienable
  6134. consoleenabled=False
  6135. UncheckMenu consoleenable
  6136. makelibenabled=False
  6137. UncheckMenu makelibenable
  6138. EndIf
  6139. UpdateWindowMenu window
  6140. Case MENUCONSOLEENABLED
  6141. If Not consoleenabled
  6142. consoleenabled=True
  6143. CheckMenu consoleenable
  6144. guienabled=False
  6145. UncheckMenu guienable
  6146. makelibenabled=False
  6147. UncheckMenu makelibenable
  6148. EndIf
  6149. UpdateWindowMenu window
  6150. Case MENUMAKELIBENABLED
  6151. If Not makelibenabled
  6152. makelibenabled=True
  6153. CheckMenu makelibenable
  6154. consoleenabled=False
  6155. UncheckMenu consoleenable
  6156. guienabled=False
  6157. UncheckMenu guienable
  6158. EndIf
  6159. UpdateWindowMenu window
  6160. Case MENUVERBOSEENABLED
  6161. If verboseenabled
  6162. verboseenabled=False
  6163. UncheckMenu verboseenable
  6164. Else
  6165. verboseenabled=True
  6166. CheckMenu verboseenable
  6167. EndIf
  6168. UpdateWindowMenu window
  6169. Case MENUQUICKSCANENABLED
  6170. If quickscanenabled
  6171. quickscanenabled=False
  6172. UncheckMenu quickscanenable
  6173. Else
  6174. quickscanenabled=True
  6175. CheckMenu quickscanenable
  6176. EndIf
  6177. UpdateWindowMenu window
  6178. Case MENUUNIVERSALENABLED
  6179. If universalenabled
  6180. universalenabled=False
  6181. UncheckMenu universalenable
  6182. Else
  6183. universalenabled=True
  6184. CheckMenu universalenable
  6185. EndIf
  6186. UpdateWindowMenu window
  6187. Case MENUWARNOVERENABLED
  6188. If warnoverenabled
  6189. warnoverenabled=False
  6190. UncheckMenu warnoverenable
  6191. Else
  6192. warnoverenabled=True
  6193. CheckMenu warnoverenable
  6194. EndIf
  6195. UpdateWindowMenu window
  6196. Case MENUGDBDEBUGENABLED
  6197. If gdbdebugenabled
  6198. gdbdebugenabled=False
  6199. UncheckMenu gdbdebugenable
  6200. Else
  6201. gdbdebugenabled=True
  6202. CheckMenu gdbdebugenable
  6203. EndIf
  6204. UpdateWindowMenu window
  6205. Case MENUWIN32ENABLED, MENULINUXENABLED, MENUMACOSXENABLED, MENURASPBERRYPIENABLED, ..
  6206. MENUANDROIDENABLED, MENUEMSCRIPTENENABLED, MENUIOSENABLED, MENUNXENABLED
  6207. UpdatePlatformMenus(menu)
  6208. UpdateWindowMenu window
  6209. Case MENUX86ENABLED, MENUX64ENABLED, MENUPPCENABLED, MENUARMENABLED, ..
  6210. MENUARMEABIV5ENABLED, MENUARMEABIV7AENABLED, MENUARM64V8AENABLED, ..
  6211. MENUJSENABLED, MENUARMV7ENABLED, MENUARM64ENABLED
  6212. UpdateArchitectureMenus(menu)
  6213. UpdateWindowMenu window
  6214. Case MENUIMPORTBB
  6215. ImportBB
  6216. Case MENUFINDINFILES
  6217. If activepanel Then searchreq.ShowWithPath( ExtractDir(activepanel.path) ) Else searchreq.Show()
  6218. Case MENUPROJECTMANAGER
  6219. projectreq.Open projects
  6220. Case MENUSHOWCONSOLE
  6221. If output Then output.Open()
  6222. Case MENUOPTIONS
  6223. options.Show()
  6224. Case MENUNEXT
  6225. If Not currentpanel Return
  6226. index=currentpanel.index+1
  6227. If index=panels.length index=0
  6228. SelectPanel panels[index]
  6229. Case MENUPREV
  6230. If Not currentpanel Return
  6231. index=currentpanel.index-1
  6232. If index<0 index=panels.length-1
  6233. SelectPanel panels[index]
  6234. Case MENUQUICKHELP
  6235. currentpanel.invoke TOOLHELP
  6236. Case MENUHOME
  6237. helppanel.Home()
  6238. SelectPanel helppanel
  6239. Case MENUBACK
  6240. helppanel.Back()
  6241. SelectPanel helppanel
  6242. Case MENUFORWARD
  6243. helppanel.Forward()
  6244. SelectPanel helppanel
  6245. Case MENUABOUT
  6246. aboutreq.Show()
  6247. 'Notify (ABOUT.Replace( "{bcc_version}",BCC_VERSION ))
  6248. Case MENUINDENT
  6249. currentpanel.invoke TOOLINDENT
  6250. Case MENUOUTDENT
  6251. currentpanel.invoke TOOLOUTDENT
  6252. Case MENUNEWVIEW
  6253. navbar.invoke TOOLNEWVIEW
  6254. End Select
  6255. If menu>=MENURECENT
  6256. Local f:String = String(recentfiles.ValueAtIndex(menu-MENURECENT))
  6257. If f$ OpenSource f$
  6258. Else If menu >= APPSTUBOFFSET
  6259. Local index:Int = menu - APPSTUBOFFSET
  6260. If index < options.appstubs.length Then
  6261. selectedappstub = options.appstubs[index]
  6262. RefreshAppStubs
  6263. End If
  6264. EndIf
  6265. End Method
  6266. Method UpdatePlatformMenus(menu:Int)
  6267. Local index:Int = menu - PLATFORMOFFSET
  6268. Local platformChanged:Int = Not platformenabled[index]
  6269. For Local i:Int = 0 Until platformenabled.Length
  6270. If platformenabled[i] And i <> index Then
  6271. Select PLATFORMOFFSET + i
  6272. Case MENUWIN32ENABLED
  6273. UncheckMenu win32enable
  6274. Case MENULINUXENABLED
  6275. UncheckMenu linuxenable
  6276. Case MENUMACOSXENABLED
  6277. UncheckMenu macosxenable
  6278. Case MENUIOSENABLED
  6279. UncheckMenu iosenable
  6280. Case MENURASPBERRYPIENABLED
  6281. UncheckMenu raspberrypienable
  6282. Case MENUANDROIDENABLED
  6283. UncheckMenu androidenable
  6284. Case MENUEMSCRIPTENENABLED
  6285. UncheckMenu emscriptenenable
  6286. Case MENUNXENABLED
  6287. UncheckMenu nxenable
  6288. End Select
  6289. End If
  6290. platformenabled[i] = False
  6291. Next
  6292. platformenabled[index] = True
  6293. Select menu
  6294. Case MENUWIN32ENABLED
  6295. CheckMenu win32enable
  6296. Case MENULINUXENABLED
  6297. CheckMenu linuxenable
  6298. Case MENUMACOSXENABLED
  6299. CheckMenu macosxenable
  6300. Case MENUIOSENABLED
  6301. CheckMenu iosenable
  6302. Case MENURASPBERRYPIENABLED
  6303. CheckMenu raspberrypienable
  6304. Case MENUANDROIDENABLED
  6305. CheckMenu androidenable
  6306. Case MENUEMSCRIPTENENABLED
  6307. CheckMenu emscriptenenable
  6308. Case MENUNXENABLED
  6309. CheckMenu nxenable
  6310. End Select
  6311. UpdateArchitectureMenuState menu
  6312. If platformChanged Then
  6313. DefaultArchitectureMenuForPlatform(menu)
  6314. End If
  6315. End Method
  6316. Method UpdateArchitectureMenus(menu:Int)
  6317. Local index:Int = menu - ARCHITECTUREOFFSET
  6318. For Local i:Int = 0 Until architectureenabled.Length
  6319. If architectureenabled[i] And i <> index Then
  6320. Select ARCHITECTUREOFFSET + i
  6321. Case MENUX86ENABLED
  6322. UncheckMenu x86enable
  6323. Case MENUX64ENABLED
  6324. UncheckMenu x64enable
  6325. Case MENUPPCENABLED
  6326. UncheckMenu ppcenable
  6327. Case MENUARMENABLED
  6328. UncheckMenu armenable
  6329. Case MENUARMEABIV5ENABLED
  6330. UncheckMenu armeabiv5enable
  6331. Case MENUARMEABIV7AENABLED
  6332. UncheckMenu armeabiv7aenable
  6333. Case MENUARM64V8AENABLED
  6334. UncheckMenu arm64v8aenable
  6335. Case MENUJSENABLED
  6336. UncheckMenu jsenable
  6337. Case MENUARMV7ENABLED
  6338. UncheckMenu armv7enable
  6339. Case MENUARM64ENABLED
  6340. UncheckMenu arm64enable
  6341. End Select
  6342. End If
  6343. architectureenabled[i] = False
  6344. Next
  6345. architectureenabled[index] = True
  6346. Select menu
  6347. Case MENUX86ENABLED
  6348. CheckMenu x86enable
  6349. Case MENUX64ENABLED
  6350. CheckMenu x64enable
  6351. Case MENUPPCENABLED
  6352. CheckMenu ppcenable
  6353. Case MENUARMENABLED
  6354. CheckMenu armenable
  6355. Case MENUARMEABIV5ENABLED
  6356. CheckMenu armeabiv5enable
  6357. Case MENUARMEABIV7AENABLED
  6358. CheckMenu armeabiv7aenable
  6359. Case MENUARM64V8AENABLED
  6360. CheckMenu arm64v8aenable
  6361. Case MENUJSENABLED
  6362. CheckMenu jsenable
  6363. Case MENUARMV7ENABLED
  6364. CheckMenu armv7enable
  6365. Case MENUARM64ENABLED
  6366. CheckMenu arm64enable
  6367. End Select
  6368. End Method
  6369. Method UpdateArchitectureMenuState(platformMenu:Int)
  6370. DisableMenu x86enable
  6371. DisableMenu x64enable
  6372. DisableMenu ppcenable
  6373. DisableMenu armenable
  6374. DisableMenu armeabiv5enable
  6375. DisableMenu armeabiv7aenable
  6376. DisableMenu arm64v8aenable
  6377. DisableMenu jsenable
  6378. DisableMenu armv7enable
  6379. DisableMenu arm64enable
  6380. DisableMenu makelibenable
  6381. Select platformMenu
  6382. Case MENUWIN32ENABLED, MENULINUXENABLED
  6383. EnableMenu x86enable
  6384. EnableMenu x64enable
  6385. Case MENUMACOSXENABLED
  6386. ?Not ppc
  6387. EnableMenu x86enable
  6388. EnableMenu x64enable
  6389. ?ppc
  6390. EnableMenu ppcenable
  6391. ?
  6392. Case MENUIOSENABLED
  6393. EnableMenu x86enable
  6394. EnableMenu x64enable
  6395. EnableMenu armv7enable
  6396. EnableMenu arm64enable
  6397. Case MENURASPBERRYPIENABLED
  6398. EnableMenu armenable
  6399. Case MENUANDROIDENABLED
  6400. EnableMenu x86enable
  6401. EnableMenu x64enable
  6402. EnableMenu armeabiv5enable
  6403. EnableMenu armeabiv7aenable
  6404. EnableMenu arm64v8aenable
  6405. Case MENUEMSCRIPTENENABLED
  6406. EnableMenu jsenable
  6407. Case MENUNXENABLED
  6408. EnableMenu arm64enable
  6409. End Select
  6410. Select platformMenu
  6411. Case MENUWIN32ENABLED
  6412. EnableMenu makelibenable
  6413. Default
  6414. If makelibenabled Then
  6415. UncheckMenu makelibenable
  6416. makelibenabled = False
  6417. CheckMenu guienable
  6418. guienabled = True
  6419. End If
  6420. End Select
  6421. End Method
  6422. Method DefaultArchitectureMenuForPlatform(platformMenu:Int)
  6423. For Local i:Int = 0 Until architectureenabled.Length
  6424. If architectureenabled[i] Then
  6425. Select ARCHITECTUREOFFSET + i
  6426. Case MENUX86ENABLED
  6427. UncheckMenu x86enable
  6428. Case MENUX64ENABLED
  6429. UncheckMenu x64enable
  6430. Case MENUPPCENABLED
  6431. UncheckMenu ppcenable
  6432. Case MENUARMENABLED
  6433. UncheckMenu armenable
  6434. Case MENUARMEABIV5ENABLED
  6435. UncheckMenu armeabiv5enable
  6436. Case MENUARMEABIV7AENABLED
  6437. UncheckMenu armeabiv7aenable
  6438. Case MENUARM64V8AENABLED
  6439. UncheckMenu arm64v8aenable
  6440. Case MENUJSENABLED
  6441. UncheckMenu jsenable
  6442. Case MENUARMV7ENABLED
  6443. UncheckMenu armv7enable
  6444. Case MENUARM64ENABLED
  6445. UncheckMenu arm64enable
  6446. End Select
  6447. End If
  6448. architectureenabled[i] = False
  6449. Next
  6450. Select platformMenu
  6451. Case MENUWIN32ENABLED, MENULINUXENABLED
  6452. ?x86
  6453. CheckMenu x86enable
  6454. architectureenabled[MENUX86ENABLED - ARCHITECTUREOFFSET] = True
  6455. ?x64
  6456. CheckMenu x64enable
  6457. architectureenabled[MENUX64ENABLED - ARCHITECTUREOFFSET] = True
  6458. ?
  6459. Case MENUMACOSXENABLED
  6460. ?x86
  6461. CheckMenu x86enable
  6462. architectureenabled[MENUX86ENABLED - ARCHITECTUREOFFSET] = True
  6463. ?x64
  6464. CheckMenu x64enable
  6465. architectureenabled[MENUX64ENABLED - ARCHITECTUREOFFSET] = True
  6466. ?ppc
  6467. CheckMenu ppcenable
  6468. architectureenabled[MENUPPCENABLED - ARCHITECTUREOFFSET] = True
  6469. ?
  6470. Case MENUIOSENABLED
  6471. ?x86
  6472. CheckMenu x86enable
  6473. architectureenabled[MENUX86ENABLED - ARCHITECTUREOFFSET] = True
  6474. ?x64
  6475. CheckMenu x64enable
  6476. architectureenabled[MENUX64ENABLED - ARCHITECTUREOFFSET] = True
  6477. ?
  6478. Case MENURASPBERRYPIENABLED
  6479. CheckMenu armenable
  6480. architectureenabled[MENUARMENABLED - ARCHITECTUREOFFSET] = True
  6481. Case MENUANDROIDENABLED
  6482. CheckMenu armeabiv5enable
  6483. architectureenabled[MENUARMEABIV5ENABLED - ARCHITECTUREOFFSET] = True
  6484. Case MENUEMSCRIPTENENABLED
  6485. CheckMenu jsenable
  6486. architectureenabled[MENUJSENABLED - ARCHITECTUREOFFSET] = True
  6487. Case MENUNXENABLED
  6488. CheckMenu arm64enable
  6489. architectureenabled[MENUARM64ENABLED - ARCHITECTUREOFFSET] = True
  6490. End Select
  6491. End Method
  6492. Method GetPlatform:String()
  6493. For Local i:Int = 0 Until platformenabled.Length
  6494. If platformenabled[i] Then
  6495. Select PLATFORMOFFSET + i
  6496. Case MENUWIN32ENABLED
  6497. Return "win32"
  6498. Case MENULINUXENABLED
  6499. Return "linux"
  6500. Case MENUMACOSXENABLED
  6501. Return "macos"
  6502. Case MENUIOSENABLED
  6503. Return "ios"
  6504. Case MENURASPBERRYPIENABLED
  6505. Return "raspberrypi"
  6506. Case MENUANDROIDENABLED
  6507. Return "android"
  6508. Case MENUEMSCRIPTENENABLED
  6509. Return "emscripten"
  6510. Case MENUNXENABLED
  6511. Return "nx"
  6512. End Select
  6513. End If
  6514. Next
  6515. Return Null
  6516. End Method
  6517. Method GetArchitecture:String()
  6518. For Local i:Int = 0 Until architectureenabled.Length
  6519. If architectureenabled[i] Then
  6520. Select ARCHITECTUREOFFSET + i
  6521. Case MENUX86ENABLED
  6522. Return "x86"
  6523. Case MENUX64ENABLED
  6524. Return "x64"
  6525. Case MENUPPCENABLED
  6526. Return "ppc"
  6527. Case MENUARMENABLED
  6528. Return "arm"
  6529. Case MENUARMEABIV5ENABLED
  6530. Return "armeabi"
  6531. Case MENUARMEABIV7AENABLED
  6532. Return "armeabiv7a"
  6533. Case MENUARM64V8AENABLED
  6534. Return "arm64v8a"
  6535. Case MENUJSENABLED
  6536. Return "js"
  6537. Case MENUARMV7ENABLED
  6538. Return "armv7"
  6539. Case MENUARM64ENABLED
  6540. Return "arm64"
  6541. End Select
  6542. End If
  6543. Next
  6544. Return Null
  6545. End Method
  6546. Method poll()
  6547. Local src:TGadget
  6548. Local event = WaitEvent()
  6549. If Not activerequesters.IsEmpty()
  6550. Select event
  6551. Case EVENT_MENUACTION
  6552. src = ActiveGadget()
  6553. If src And (GadgetClass(src) = GADGET_TEXTFIELD) Then
  6554. Select EventData()
  6555. Case MENUSELECTALL
  6556. ActivateGadget(src)
  6557. Case MENUCOPY
  6558. GadgetCopy(src)
  6559. Case MENUPASTE
  6560. GadgetPaste(src)
  6561. Case MENUCUT
  6562. GadgetCut(src)
  6563. EndSelect
  6564. Return
  6565. EndIf
  6566. src = Null
  6567. Case EVENT_MOUSEENTER,EVENT_MOUSELEAVE,EVENT_GADGETLOSTFOCUS
  6568. Return
  6569. End Select
  6570. 'DebugLog CurrentEvent.ToString()
  6571. For Local activerequester:TRequester = EachIn activerequesters
  6572. If activerequester.Poll() Then Return
  6573. Next
  6574. EndIf
  6575. For Local handler:TEventHandler = EachIn eventhandlers
  6576. handler.OnEvent()
  6577. Next
  6578. src = TGadget(EventSource())
  6579. Select event
  6580. Case EVENT_GADGETACTION
  6581. Select EventSource()
  6582. Case toolbar
  6583. Select EventData()
  6584. Case TB_NEW OpenSource ""
  6585. Case TB_OPEN OpenSource "."
  6586. Case TB_CLOSE currentpanel.invoke TOOLCLOSE
  6587. Case TB_SAVE currentpanel.invoke TOOLSAVE
  6588. Case TB_CUT currentpanel.invoke TOOLCUT
  6589. Case TB_COPY currentpanel.invoke TOOLCOPY
  6590. Case TB_PASTE currentpanel.invoke TOOLPASTE
  6591. Case TB_FIND currentpanel.invoke TOOLFIND
  6592. Case TB_BUILD BuildCode
  6593. Case TB_BUILDRUN RunCode
  6594. Case TB_STEP If output output.stepover
  6595. Case TB_STEPIN If output output.stepin
  6596. Case TB_STEPOUT If output output.stepout
  6597. Case TB_STOP If output output.Stop
  6598. Case TB_HOME helppanel.Home;SelectPanel helppanel
  6599. Case TB_BACK helppanel.Back;SelectPanel helppanel
  6600. Case TB_FORWARDS helppanel.Forward;SelectPanel helppanel
  6601. End Select
  6602. Case tabbar
  6603. Local index = EventData()
  6604. If index>=0 And index<panels.length
  6605. SelectPanel panels[index]
  6606. EndIf
  6607. End Select
  6608. Case EVENT_WINDOWACCEPT, EVENT_APPOPENFILE
  6609. OpenSource EventText()
  6610. Case EVENT_APPTERMINATE
  6611. Quit()
  6612. Case EVENT_WINDOWACTIVATE
  6613. If (src=window) Then SelectPanel currentpanel
  6614. Case EVENT_WINDOWCLOSE
  6615. If (src=window) Then Quit()
  6616. Case EVENT_WINDOWMOVE, EVENT_WINDOWSIZE
  6617. If (src=window) Then SnapshotWindow()
  6618. Case EVENT_MENUACTION
  6619. OnMenu EventData(),EventExtra()
  6620. EndSelect
  6621. EndMethod
  6622. EndType
  6623. Function CacheAndLoadText$(url:Object)
  6624. Local tmpResult$
  6625. Local tmpBytes:Byte[] = LoadByteArray(url)
  6626. url = CreateRamStream( tmpBytes, tmpBytes.length, True, False )
  6627. tmpResult = LoadText(url)
  6628. TRamStream(url).Close()
  6629. Return tmpResult
  6630. EndFunction
  6631. Function ScaledSize:Int(value:Int)
  6632. Global cached:Int = GadgetScaleFactor(Desktop())
  6633. Return value * cached
  6634. End Function