maxide.bmx 220 KB

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