fpviews.pas 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707
  1. {
  2. This file is part of the Free Pascal Integrated Development Environment
  3. Copyright (c) 1998 by Berczi Gabor
  4. Views and view-related functions for the IDE
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit FPViews;
  12. {$i globdir.inc}
  13. interface
  14. uses
  15. Dos,Objects,Drivers,
  16. FVConsts,
  17. Views,Menus,Dialogs,App,Gadgets,Tabs,
  18. ASCIITAB,
  19. WEditor,WCEdit,
  20. WUtils,WHelp,WHlpView,WViews,WANSI,
  21. Comphook,
  22. {$ifndef NODEBUG}
  23. { Needed here for CORE_ADDR definition }
  24. {$ifdef GDBMI}
  25. gdbmiint,
  26. {$else GDBMI}
  27. gdbint,
  28. {$endif GDBMI}
  29. {$endif NODEBUG}
  30. FPConst,FPUsrScr;
  31. type
  32. TEditor = TCodeEditor;
  33. PEditor = PCodeEditor;
  34. PStoreCollection = ^TStoreCollection;
  35. TStoreCollection = object(TStringCollection)
  36. function Add(const S: string): PString;
  37. end;
  38. PIntegerLine = ^TIntegerLine;
  39. TIntegerLine = object(TInputLine)
  40. constructor Init(var Bounds: TRect; AMin, AMax: longint);
  41. end;
  42. PFPHeapView = ^TFPHeapView;
  43. TFPHeapView = object(THeapView)
  44. constructor Init(var Bounds: TRect);
  45. constructor InitKb(var Bounds: TRect);
  46. procedure HandleEvent(var Event: TEvent); virtual;
  47. end;
  48. PFPClockView = ^TFPClockView;
  49. TFPClockView = object(TClockView)
  50. constructor Init(var Bounds: TRect);
  51. procedure HandleEvent(var Event: TEvent); virtual;
  52. function GetPalette: PPalette; virtual;
  53. end;
  54. PFPWindow = ^TFPWindow;
  55. TFPWindow = object(TWindow)
  56. AutoNumber: boolean;
  57. procedure HandleEvent(var Event: TEvent); virtual;
  58. procedure SetState(AState: Word; Enable: Boolean); virtual;
  59. procedure UpdateCommands; virtual;
  60. constructor Load(var S: TStream);
  61. procedure Store(var S: TStream);
  62. procedure Update; virtual;
  63. procedure SelectInDebugSession;
  64. end;
  65. PFPHelpViewer = ^TFPHelpViewer;
  66. TFPHelpViewer = object(THelpViewer)
  67. function GetLocalMenu: PMenu; virtual;
  68. function GetCommandTarget: PView; virtual;
  69. end;
  70. PFPHelpWindow = ^TFPHelpWindow;
  71. TFPHelpWindow = object(THelpWindow)
  72. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word; AContext: THelpCtx; ANumber: Integer);
  73. destructor Done;virtual;
  74. procedure InitHelpView; virtual;
  75. procedure Show; {virtual;}
  76. procedure Hide; {virtual;}
  77. procedure HandleEvent(var Event: TEvent); virtual;
  78. function GetPalette: PPalette; virtual;
  79. constructor Load(var S: TStream);
  80. procedure Store(var S: TStream);
  81. end;
  82. PTextScroller = ^TTextScroller;
  83. TTextScroller = object(TStaticText)
  84. TopLine: integer;
  85. Speed : integer;
  86. Lines : PUnsortedStringCollection;
  87. constructor Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  88. function GetLineCount: integer; virtual;
  89. function GetLine(I: integer): string; virtual;
  90. procedure HandleEvent(var Event: TEvent); virtual;
  91. procedure Update; virtual;
  92. procedure Reset; virtual;
  93. procedure Scroll; virtual;
  94. procedure Draw; virtual;
  95. destructor Done; virtual;
  96. private
  97. LastTT: longint;
  98. end;
  99. TAlign = (alLeft,alCenter,alRight);
  100. PFPToolTip = ^TFPToolTip;
  101. TFPToolTip = object(TView)
  102. constructor Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  103. procedure Draw; virtual;
  104. function GetText: string;
  105. procedure SetText(const AText: string);
  106. function GetAlign: TAlign;
  107. procedure SetAlign(AAlign: TAlign);
  108. function GetPalette: PPalette; virtual;
  109. destructor Done; virtual;
  110. private
  111. Text: PString;
  112. Align: TAlign;
  113. end;
  114. PSourceEditor = ^TSourceEditor;
  115. TSourceEditor = object(TFileEditor)
  116. CompileStamp : longint;
  117. CodeCompleteTip: PFPToolTip;
  118. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  119. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  120. {$ifndef NODEBUG}
  121. private
  122. ShouldHandleBreakpoints : boolean;
  123. {$endif NODEBUG}
  124. public
  125. { Syntax highlight }
  126. function IsReservedWord(const S: string): boolean; virtual;
  127. function IsAsmReservedWord(const S: string): boolean; virtual;
  128. function GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
  129. function GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring; virtual;
  130. { CodeTemplates }
  131. function TranslateCodeTemplate(var Shortcut: string; ALines: PUnsortedStringCollection): boolean; virtual;
  132. function SelectCodeTemplate(var ShortCut: string): boolean; virtual;
  133. { CodeComplete }
  134. function CompleteCodeWord(const WordS: string; var Text: string): boolean; virtual;
  135. procedure FindMatchingDelimiter(ScanForward: boolean); virtual;
  136. procedure SetCodeCompleteWord(const S: string); virtual;
  137. procedure AlignCodeCompleteTip;
  138. procedure HandleEvent(var Event: TEvent); virtual;
  139. {$ifdef DebugUndo}
  140. procedure DumpUndo;
  141. procedure UndoAll;
  142. procedure RedoAll;
  143. {$endif DebugUndo}
  144. function Valid(Command: Word): Boolean;virtual;
  145. function GetLocalMenu: PMenu; virtual;
  146. function GetCommandTarget: PView; virtual;
  147. function CreateLocalMenuView(var Bounds: TRect; M: PMenu): PMenuPopup; virtual;
  148. procedure ModifiedChanged; virtual;
  149. procedure InsertOptions; virtual;
  150. procedure PushInfo(Const st : string);virtual;
  151. procedure PopInfo;virtual;
  152. procedure DeleteLine(I: sw_integer); virtual;
  153. procedure BackSpace; virtual;
  154. procedure DelChar; virtual;
  155. procedure DelSelect; virtual;
  156. function InsertNewLine : Sw_integer;virtual;
  157. function InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual;
  158. procedure AddLine(const S: string); virtual;
  159. end;
  160. PSourceWindow = ^TSourceWindow;
  161. TSourceWindow = object(TFPWindow)
  162. Editor : PSourceEditor;
  163. Indicator : PIndicator;
  164. NoNameCount : longint;
  165. constructor Init(var Bounds: TRect; AFileName: string);
  166. function GetTitle(MaxSize: sw_Integer): TTitleStr; virtual;
  167. procedure SetTitle(ATitle: string); virtual;
  168. procedure UpdateTitle; virtual;
  169. procedure HandleEvent(var Event: TEvent); virtual;
  170. procedure Update; virtual;
  171. procedure UpdateCommands; virtual;
  172. function GetPalette: PPalette; virtual;
  173. constructor Load(var S: TStream);
  174. procedure Store(var S: TStream);
  175. procedure Close; virtual;
  176. destructor Done; virtual;
  177. end;
  178. {$ifndef NODEBUG}
  179. PGDBSourceEditor = ^TGDBSourceEditor;
  180. TGDBSourceEditor = object(TSourceEditor)
  181. function InsertNewLine : Sw_integer;virtual;
  182. function Valid(Command: Word): Boolean; virtual;
  183. procedure AddLine(const S: string); virtual;
  184. procedure AddErrorLine(const S: string); virtual;
  185. { Syntax highlight }
  186. function IsReservedWord(const S: string): boolean; virtual;
  187. private
  188. Silent,
  189. AutoRepeat,
  190. IgnoreStringAtEnd : boolean;
  191. LastCommand : String;
  192. end;
  193. PGDBWindow = ^TGDBWindow;
  194. TGDBWindow = object(TFPWindow)
  195. Editor : PGDBSourceEditor;
  196. Indicator : PIndicator;
  197. constructor Init(var Bounds: TRect);
  198. procedure HandleEvent(var Event: TEvent); virtual;
  199. procedure WriteText(Buf : pchar;IsError : boolean);
  200. procedure WriteString(Const S : string);
  201. procedure WriteErrorString(Const S : string);
  202. procedure WriteOutputText(Buf : pchar);
  203. procedure WriteErrorText(Buf : pchar);
  204. function GetPalette: PPalette;virtual;
  205. constructor Load(var S: TStream);
  206. procedure Store(var S: TStream);
  207. procedure UpdateCommands; virtual;
  208. destructor Done; virtual;
  209. end;
  210. PDisasLine = ^TDisasLine;
  211. TDisasLine = object(TLine)
  212. address : CORE_ADDR;{ should be target size of address for cross debuggers }
  213. end;
  214. PDisasLineCollection = ^TDisasLineCollection;
  215. TDisasLineCollection = object(TLineCollection)
  216. function At(Index: sw_Integer): PDisasLine;
  217. end;
  218. PDisassemblyEditor = ^TDisassemblyEditor;
  219. TDisassemblyEditor = object(TSourceEditor)
  220. CurrentSource : String;
  221. CurrentLine : longint;
  222. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  223. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  224. procedure ReleaseSource;
  225. destructor Done;virtual;
  226. procedure AddSourceLine(const AFileName: string;line : longint); virtual;
  227. procedure AddAssemblyLine(const S: string;AAddress : CORE_ADDR); virtual;
  228. function GetCurrentLine(address : CORE_ADDR) : PDisasLine;
  229. private
  230. Source : PSourceWindow;
  231. OwnsSource : Boolean;
  232. DisasLines : PDisasLineCollection;
  233. MinAddress,MaxAddress : CORE_ADDR;
  234. CurL : PDisasLine;
  235. end;
  236. PDisassemblyWindow = ^TDisassemblyWindow;
  237. TDisassemblyWindow = object(TFPWindow)
  238. Editor : PDisassemblyEditor;
  239. Indicator : PIndicator;
  240. constructor Init(var Bounds: TRect);
  241. procedure LoadFunction(Const FuncName : string);
  242. procedure LoadAddress(Addr : CORE_ADDR);
  243. function ProcessPChar(p : pchar) : boolean;
  244. procedure HandleEvent(var Event: TEvent); virtual;
  245. procedure WriteSourceString(Const S : string;line : longint);
  246. procedure WriteDisassemblyString(Const S : string;address : CORE_ADDR);
  247. procedure SetCurAddress(address : CORE_ADDR);
  248. procedure UpdateCommands; virtual;
  249. function GetPalette: PPalette;virtual;
  250. destructor Done; virtual;
  251. end;
  252. {$endif NODEBUG}
  253. PClipboardWindow = ^TClipboardWindow;
  254. TClipboardWindow = object(TSourceWindow)
  255. constructor Init;
  256. procedure Close; virtual;
  257. constructor Load(var S: TStream);
  258. procedure Store(var S: TStream);
  259. destructor Done; virtual;
  260. end;
  261. PMessageItem = ^TMessageItem;
  262. TMessageItem = object(TObject)
  263. TClass : longint;
  264. Text : PString;
  265. Module : PString;
  266. Row,Col : sw_integer;
  267. constructor Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  268. function GetText(MaxLen: Sw_integer): string; virtual;
  269. procedure Selected; virtual;
  270. function GetModuleName: string; virtual;
  271. destructor Done; virtual;
  272. end;
  273. PMessageListBox = ^TMessageListBox;
  274. TMessageListBox = object(THSListBox)
  275. Transparent : boolean;
  276. NoSelection : boolean;
  277. MaxWidth : Sw_integer;
  278. ModuleNames : PStoreCollection;
  279. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  280. procedure SetState(AState: Word; Enable: Boolean); virtual;
  281. procedure AddItem(P: PMessageItem); virtual;
  282. function AddModuleName(const Name: string): PString; virtual;
  283. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  284. procedure Clear; virtual;
  285. procedure TrackSource; virtual;
  286. procedure GotoSource; virtual;
  287. procedure Draw; virtual;
  288. procedure HandleEvent(var Event: TEvent); virtual;
  289. function GetLocalMenu: PMenu; virtual;
  290. constructor Load(var S: TStream);
  291. procedure Store(var S: TStream);
  292. destructor Done; virtual;
  293. end;
  294. PFPDlgWindow = ^TFPDlgWindow;
  295. TFPDlgWindow = object(TDlgWindow)
  296. procedure HandleEvent(var Event: TEvent); virtual;
  297. end;
  298. (*
  299. PTabItem = ^TTabItem;
  300. TTabItem = record
  301. Next : PTabItem;
  302. View : PView;
  303. Dis : boolean;
  304. end;
  305. PTabDef = ^TTabDef;
  306. TTabDef = record
  307. Next : PTabDef;
  308. Name : PString;
  309. Items : PTabItem;
  310. DefItem : PView;
  311. ShortCut : char;
  312. end;
  313. PTab = ^TTab;
  314. TTab = object(TGroup)
  315. TabDefs : PTabDef;
  316. ActiveDef : integer;
  317. DefCount : word;
  318. constructor Init(var Bounds: TRect; ATabDef: PTabDef);
  319. function AtTab(Index: integer): PTabDef; virtual;
  320. procedure SelectTab(Index: integer); virtual;
  321. function TabCount: integer;
  322. procedure SelectNextTab(Forwards: boolean);
  323. function Valid(Command: Word): Boolean; virtual;
  324. procedure ChangeBounds(var Bounds: TRect); virtual;
  325. procedure HandleEvent(var Event: TEvent); virtual;
  326. function GetPalette: PPalette; virtual;
  327. procedure Draw; virtual;
  328. procedure SetState(AState: Word; Enable: Boolean); virtual;
  329. destructor Done; virtual;
  330. private
  331. InDraw: boolean;
  332. end;
  333. *)
  334. PScreenView = ^TScreenView;
  335. TScreenView = object(TScroller)
  336. Screen: PScreen;
  337. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  338. AScreen: PScreen);
  339. procedure Draw; virtual;
  340. procedure Update; virtual;
  341. procedure HandleEvent(var Event: TEvent); virtual;
  342. end;
  343. PScreenWindow = ^TScreenWindow;
  344. TScreenWindow = object(TFPWindow)
  345. ScreenView : PScreenView;
  346. constructor Init(AScreen: PScreen; ANumber: integer);
  347. destructor Done; virtual;
  348. end;
  349. PFPAboutDialog = ^TFPAboutDialog;
  350. TFPAboutDialog = object(TCenterDialog)
  351. constructor Init;
  352. procedure ToggleInfo;
  353. procedure HandleEvent(var Event: TEvent); virtual;
  354. private
  355. Scroller: PTextScroller;
  356. TitleST : PStaticText;
  357. end;
  358. PFPASCIIChart = ^TFPASCIIChart;
  359. TFPASCIIChart = object(TASCIIChart)
  360. constructor Init;
  361. constructor Load(var S: TStream);
  362. procedure Store(var S: TStream);
  363. procedure HandleEvent(var Event: TEvent); virtual;
  364. destructor Done; virtual;
  365. end;
  366. PVideoModeListBox = ^TVideoModeListBox;
  367. TVideoModeListBox = object(TDropDownListBox)
  368. function GetText(Item: pointer; MaxLen: sw_integer): string; virtual;
  369. end;
  370. PFPDesktop = ^TFPDesktop;
  371. TFPDesktop = object(TDesktop)
  372. constructor Init(var Bounds: TRect);
  373. procedure InitBackground; virtual;
  374. constructor Load(var S: TStream);
  375. procedure Store(var S: TStream);
  376. end;
  377. PFPMemo = ^TFPMemo;
  378. TFPMemo = object(TCodeEditor)
  379. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  380. PScrollBar; AIndicator: PIndicator);
  381. function IsReservedWord(const S: string): boolean; virtual;
  382. function GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
  383. function GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring; virtual;
  384. function GetPalette: PPalette; virtual;
  385. procedure HandleEvent(var Event: TEvent); virtual;
  386. end;
  387. PFPCodeMemo = ^TFPCodeMemo;
  388. TFPCodeMemo = object(TFPMemo)
  389. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  390. PScrollBar; AIndicator: PIndicator);
  391. function IsReservedWord(const S: string): boolean; virtual;
  392. function GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
  393. function GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring; virtual;
  394. end;
  395. function SearchFreeWindowNo: integer;
  396. function IsWindow(P: PView): boolean;
  397. function IsThereAnyEditor: boolean;
  398. function IsThereAnyWindow: boolean;
  399. function IsThereAnyVisibleWindow: boolean;
  400. function IsThereAnyNumberedWindow: boolean;
  401. function FirstEditorWindow: PSourceWindow;
  402. function EditorWindowFile(const Name : String): PSourceWindow;
  403. procedure AskToReloadAllModifiedFiles;
  404. {$ifndef NODEBUG}
  405. function InDisassemblyWindow :boolean;
  406. {$endif NODEBUG}
  407. function NewTabItem(AView: PView; ANext: PTabItem): PTabItem;
  408. procedure DisposeTabItem(P: PTabItem);
  409. function NewTabDef(AName: string; ADefItem: PView; AItems: PTabItem; ANext: PTabDef): PTabDef;
  410. procedure DisposeTabDef(P: PTabDef);
  411. function GetEditorCurWord(Editor: PEditor; ValidSpecChars: TCharSet): string;
  412. procedure InitReservedWords;
  413. procedure DoneReservedWords;
  414. function GetReservedWordCount: integer;
  415. function GetReservedWord(Index: integer): string;
  416. function GetAsmReservedWordCount: integer;
  417. function GetAsmReservedWord(Index: integer): string;
  418. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  419. function GetNextEditorBounds(var Bounds: TRect): boolean;
  420. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  421. function IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
  422. function LastSourceEditor : PSourceWindow;
  423. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  424. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts: boolean): PSourceWindow;
  425. function TryToOpenFileMulti(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts: boolean): PSourceWindow;
  426. function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts, ShowIt,
  427. ForceNewWindow:boolean): PSourceWindow;
  428. function LocateSourceFile(const FileName: string; tryexts: boolean): string;
  429. function SearchWindow(const Title: string): PWindow;
  430. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  431. {$ifdef VESA}
  432. procedure InitVESAScreenModes;
  433. procedure DoneVESAScreenModes;
  434. {$endif}
  435. procedure NoDebugger;
  436. const
  437. SourceCmds : TCommandSet =
  438. ([cmSave,cmSaveAs,cmCompile,cmHide,cmDoReload]);
  439. EditorCmds : TCommandSet =
  440. ([cmPrint,cmFind,cmReplace,cmSearchAgain,cmJumpLine,cmHelpTopicSearch,cmSelectAll,cmUnselect]);
  441. CompileCmds : TCommandSet =
  442. ([cmMake,cmBuild,cmRun]);
  443. CalcClipboard : extended = 0;
  444. OpenFileName : string = '';
  445. OpenFileLastExt : string[12] = '*.pas';
  446. NewEditorOpened : boolean = false;
  447. var MsgParms : array[1..10] of
  448. record
  449. case byte of
  450. 0 : (Ptr : pointer);
  451. 1 : (Long: longint);
  452. end;
  453. const menu_key_common_copy_borland = 'Ctrl+Ins';
  454. menu_key_common_copy_microsoft = 'Ctrl+C';
  455. menu_key_edit_undo = 'Alt+BkSp';
  456. menu_key_edit_cut_borland = 'Shift+Del';
  457. menu_key_edit_copy_borland = menu_key_common_copy_borland;
  458. menu_key_edit_paste_borland = 'Shift+Ins';
  459. menu_key_edit_cut_microsoft = 'Ctrl+X';
  460. menu_key_edit_copy_microsoft = menu_key_common_copy_microsoft;
  461. menu_key_edit_paste_microsoft = 'Ctrl+V';
  462. menu_key_edit_all_borland = '';
  463. menu_key_edit_clear = 'Ctrl+Del';
  464. menu_key_common_helpindex = 'Shift+F1';
  465. menu_key_common_topicsearch = 'Ctrl+F1';
  466. menu_key_common_prevtopic = 'Alt+F1';
  467. menu_key_help_helpindex= menu_key_common_helpindex;
  468. menu_key_help_topicsearch = menu_key_common_topicsearch;
  469. menu_key_help_prevtopic= menu_key_common_prevtopic;
  470. menu_key_hlplocal_index = menu_key_common_helpindex;
  471. menu_key_hlplocal_topicsearch = menu_key_common_topicsearch;
  472. menu_key_hlplocal_prevtopic = menu_key_common_prevtopic;
  473. menu_key_hlplocal_copy_borland = menu_key_common_copy_borland;
  474. menu_key_hlplocal_copy_microsoft = menu_key_common_copy_microsoft;
  475. {Configurable keys.}
  476. const menu_key_edit_cut:string[63]=menu_key_edit_cut_borland;
  477. menu_key_edit_copy:string[63]=menu_key_edit_copy_borland;
  478. menu_key_edit_paste:string[63]=menu_key_edit_paste_borland;
  479. menu_key_edit_all:string[63]=menu_key_edit_all_borland;
  480. menu_key_hlplocal_copy:string[63]=menu_key_hlplocal_copy_borland;
  481. cut_key:word=kbShiftDel;
  482. copy_key:word=kbCtrlIns;
  483. paste_key:word=kbShiftIns;
  484. all_key:word=kbNoKey;
  485. procedure RegisterFPViews;
  486. implementation
  487. uses
  488. Video,Strings,Keyboard,Validate,
  489. globtype,Tokens,Version,
  490. systems,cpubase,
  491. itcpugas,
  492. {$if defined(I386) or defined(x64_86)}
  493. rax86,
  494. {$endif}
  495. {$ifdef m68k}
  496. ag68kgas,
  497. {$endif}
  498. {$ifdef USE_EXTERNAL_COMPILER}
  499. fpintf, { superseeds version_string of version unit }
  500. {$endif USE_EXTERNAL_COMPILER}
  501. {$ifdef VESA}Vesa,{$endif}
  502. FPSwitch,FPSymbol,FPDebug,FPVars,FPUtils,FPCompil,FPHelp,
  503. FPTools,FPIDE,FPCodTmp,FPCodCmp;
  504. const
  505. RSourceEditor: TStreamRec = (
  506. ObjType: 1500;
  507. VmtLink: Ofs(TypeOf(TSourceEditor)^);
  508. Load: @TSourceEditor.Load;
  509. Store: @TSourceEditor.Store
  510. );
  511. RSourceWindow: TStreamRec = (
  512. ObjType: 1501;
  513. VmtLink: Ofs(TypeOf(TSourceWindow)^);
  514. Load: @TSourceWindow.Load;
  515. Store: @TSourceWindow.Store
  516. );
  517. RFPHelpViewer: TStreamRec = (
  518. ObjType: 1502;
  519. VmtLink: Ofs(TypeOf(TFPHelpViewer)^);
  520. Load: @TFPHelpViewer.Load;
  521. Store: @TFPHelpViewer.Store
  522. );
  523. RFPHelpWindow: TStreamRec = (
  524. ObjType: 1503;
  525. VmtLink: Ofs(TypeOf(TFPHelpWindow)^);
  526. Load: @TFPHelpWindow.Load;
  527. Store: @TFPHelpWindow.Store
  528. );
  529. RClipboardWindow: TStreamRec = (
  530. ObjType: 1504;
  531. VmtLink: Ofs(TypeOf(TClipboardWindow)^);
  532. Load: @TClipboardWindow.Load;
  533. Store: @TClipboardWindow.Store
  534. );
  535. RMessageListBox: TStreamRec = (
  536. ObjType: 1505;
  537. VmtLink: Ofs(TypeOf(TMessageListBox)^);
  538. Load: @TMessageListBox.Load;
  539. Store: @TMessageListBox.Store
  540. );
  541. RFPDesktop: TStreamRec = (
  542. ObjType: 1506;
  543. VmtLink: Ofs(TypeOf(TFPDesktop)^);
  544. Load: @TFPDesktop.Load;
  545. Store: @TFPDesktop.Store
  546. );
  547. RFPASCIIChart: TStreamRec = (
  548. ObjType: 1509;
  549. VmtLink: Ofs(TypeOf(TFPASCIIChart)^);
  550. Load: @TFPASCIIChart.Load;
  551. Store: @TFPASCIIChart.Store
  552. );
  553. RFPDlgWindow: TStreamRec = (
  554. ObjType: 1511;
  555. VmtLink: Ofs(TypeOf(TFPDlgWindow)^);
  556. Load: @TFPDlgWindow.Load;
  557. Store: @TFPDlgWindow.Store
  558. );
  559. {$ifndef NODEBUG}
  560. RGDBWindow: TStreamRec = (
  561. ObjType: 1508;
  562. VmtLink: Ofs(TypeOf(TGDBWindow)^);
  563. Load: @TGDBWindow.Load;
  564. Store: @TGDBWindow.Store
  565. );
  566. RGDBSourceEditor: TStreamRec = (
  567. ObjType: 1507;
  568. VmtLink: Ofs(TypeOf(TGDBSourceEditor)^);
  569. Load: @TGDBSourceEditor.Load;
  570. Store: @TGDBSourceEditor.Store
  571. );
  572. RDisassemblyEditor: TStreamRec = (
  573. ObjType: 1512;
  574. VmtLink: Ofs(TypeOf(TDisassemblyEditor)^);
  575. Load: @TDisassemblyEditor.Load;
  576. Store: @TDisassemblyEditor.Store
  577. );
  578. RDisassemblyWindow: TStreamRec = (
  579. ObjType: 1513;
  580. VmtLink: Ofs(TypeOf(TDisassemblyWindow)^);
  581. Load: @TDisassemblyWindow.Load;
  582. Store: @TDisassemblyWindow.Store
  583. );
  584. {$endif NODEBUG}
  585. const
  586. GlobalNoNameCount : integer = 0;
  587. var
  588. ReservedWords : array[1..ReservedWordMaxLen] of PStringCollection;
  589. AsmReservedWords : array[1..ReservedWordMaxLen] of PStringCollection;
  590. {$ifdef useresstrings}
  591. resourcestring
  592. {$else}
  593. const
  594. {$endif}
  595. { Source editor local menu items }
  596. menu_srclocal_openfileatcursor = 'Open ~f~ile at cursor';
  597. menu_srclocal_browseatcursor = '~B~rowse symbol at cursor';
  598. menu_srclocal_topicsearch = 'Topic ~s~earch';
  599. menu_srclocal_options = '~O~ptions...';
  600. menu_srclocal_reload = '~R~eload modified file';
  601. { Help viewer local menu items }
  602. menu_hlplocal_debug = 'Debug infos';
  603. menu_hlplocal_contents = '~C~ontents';
  604. menu_hlplocal_index = '~I~ndex';
  605. menu_hlplocal_topicsearch = '~T~opic search';
  606. menu_hlplocal_prevtopic = '~P~revious topic';
  607. menu_hlplocal_copy = '~C~opy';
  608. { Messages local menu items }
  609. menu_msglocal_clear = '~C~lear';
  610. menu_msglocal_gotosource = '~G~oto source';
  611. menu_msglocal_tracksource = '~T~rack source';
  612. menu_edit_cut = 'Cu~t~';
  613. menu_edit_copy = '~C~opy';
  614. menu_edit_paste = '~P~aste';
  615. menu_edit_clear = 'C~l~ear';
  616. msg_errorreadingfile = 'Error reading file %s';
  617. msg_loadingfile = 'Loading %s';
  618. msg_storingfile = 'Storing %s';
  619. msg_closingfile = 'Closing %s';
  620. dialog_gdbwindow = 'GDB window';
  621. dialog_disaswindow = 'Disassembly window';
  622. dialog_clipboard = 'Clipboard';
  623. dialog_userscreen = 'User screen';
  624. dialog_about = 'About';
  625. label_about_compilerversion = 'Compiler Version';
  626. label_about_debugger = 'Debugger';
  627. menu_msglocal_saveas = 'Save ~a~s';
  628. msg_openingsourcefile = 'Opening source file... (%s)';
  629. msg_readingfileineditor = 'Reading %s into editor...';
  630. msg_nodebuggersupportavailable = 'No debugger support available.';
  631. {****************************************************************************
  632. TStoreCollection
  633. ****************************************************************************}
  634. function TStoreCollection.Add(const S: string): PString;
  635. var P: PString;
  636. Index: Sw_integer;
  637. begin
  638. if S='' then P:=nil else
  639. if Search(@S,Index) then P:=At(Index) else
  640. begin
  641. P:=NewStr(S);
  642. Insert(P);
  643. end;
  644. Add:=P;
  645. end;
  646. function IsThereAnyEditor: boolean;
  647. function EditorWindow(P: PView): boolean;
  648. begin
  649. EditorWindow:=(P^.HelpCtx=hcSourceWindow);
  650. end;
  651. begin
  652. IsThereAnyEditor:=Desktop^.FirstThat(@EditorWindow)<>nil;
  653. end;
  654. procedure AskToReloadAllModifiedFiles;
  655. procedure EditorWindowModifiedOnDisk(P: PView);
  656. begin
  657. if (P^.HelpCtx=hcSourceWindow) then
  658. PSourceWindow(P)^.Editor^.ReloadFile;
  659. end;
  660. begin
  661. Desktop^.ForEach(@EditorWindowModifiedOnDisk);
  662. end;
  663. function IsThereAnyHelpWindow: boolean;
  664. begin
  665. IsThereAnyHelpWindow:=(HelpWindow<>nil) and (HelpWindow^.GetState(sfVisible));
  666. end;
  667. function IsThereAnyNumberedWindow: boolean;
  668. var _Is: boolean;
  669. begin
  670. _Is:=Message(Desktop,evBroadcast,cmSearchWindow,nil)<>nil;
  671. _Is:=_Is or ( (ClipboardWindow<>nil) and ClipboardWindow^.GetState(sfVisible));
  672. IsThereAnyNumberedWindow:=_Is;
  673. end;
  674. function IsWindow(P: PView): boolean;
  675. var OK: boolean;
  676. begin
  677. OK:=false;
  678. if (P^.HelpCtx=hcSourceWindow) or
  679. (P^.HelpCtx=hcHelpWindow) or
  680. (P^.HelpCtx=hcClipboardWindow) or
  681. (P^.HelpCtx=hcCalcWindow) or
  682. (P^.HelpCtx=hcInfoWindow) or
  683. (P^.HelpCtx=hcBrowserWindow) or
  684. (P^.HelpCtx=hcMessagesWindow) or
  685. (P^.HelpCtx=hcCompilerMessagesWindow) or
  686. (P^.HelpCtx=hcGDBWindow) or
  687. (P^.HelpCtx=hcdisassemblyWindow) or
  688. (P^.HelpCtx=hcWatchesWindow) or
  689. (P^.HelpCtx=hcRegistersWindow) or
  690. (P^.HelpCtx=hcFPURegisters) or
  691. (P^.HelpCtx=hcVectorRegisters) or
  692. (P^.HelpCtx=hcStackWindow) or
  693. (P^.HelpCtx=hcBreakpointListWindow) or
  694. (P^.HelpCtx=hcASCIITableWindow)
  695. then
  696. OK:=true;
  697. IsWindow:=OK;
  698. end;
  699. function IsThereAnyWindow: boolean;
  700. function CheckIt(P: PView): boolean;
  701. begin
  702. CheckIt:=IsWindow(P);
  703. end;
  704. begin
  705. IsThereAnyWindow:=Desktop^.FirstThat(@CheckIt)<>nil;
  706. end;
  707. function IsThereAnyVisibleWindow: boolean;
  708. function CheckIt(P: PView): boolean;
  709. begin
  710. CheckIt:=IsWindow(P) and P^.GetState(sfVisible);
  711. end;
  712. begin
  713. IsThereAnyVisibleWindow:=Desktop^.FirstThat(@CheckIt)<>nil;
  714. end;
  715. function FirstEditorWindow: PSourceWindow;
  716. function EditorWindow(P: PView): boolean;
  717. begin
  718. EditorWindow:=(P^.HelpCtx=hcSourceWindow);
  719. end;
  720. begin
  721. FirstEditorWindow:=pointer(Desktop^.FirstThat(@EditorWindow));
  722. end;
  723. function EditorWindowFile(const Name : String): PSourceWindow;
  724. var
  725. SName : string;
  726. function EditorWindow(P: PView): boolean;
  727. begin
  728. EditorWindow:=(TypeOf(P^)=TypeOf(TSourceWindow)) and
  729. (FixFileName(PSourceWindow(P)^.Editor^.FileName)=SName);
  730. end;
  731. begin
  732. SName:=FixFileName(FExpand(Name));
  733. EditorWindowFile:=pointer(Desktop^.FirstThat(@EditorWindow));
  734. end;
  735. {$ifndef NODEBUG}
  736. function InDisassemblyWindow :boolean;
  737. var
  738. PW : PWindow;
  739. function CheckIt(P: PView): boolean;
  740. begin
  741. CheckIt:=IsWindow(P) and P^.GetState(sfVisible) and
  742. (P^.HelpCtx <> hcWatchesWindow) and
  743. (P^.HelpCtx <> hcStackWindow) and
  744. (P^.HelpCtx <> hcRegistersWindow) and
  745. (P^.HelpCtx <> hcVectorRegisters) and
  746. (P^.HelpCtx <> hcFPURegisters);
  747. end;
  748. begin
  749. PW:=PWindow(Desktop^.FirstThat(@CheckIt));
  750. InDisassemblyWindow:=Assigned(PW) and
  751. (TypeOf(PW^)=TypeOf(TDisassemblyWindow));
  752. end;
  753. {$endif NODEBUG}
  754. function GetEditorCurWord(Editor: PEditor; ValidSpecChars: TCharSet): string;
  755. var S: string;
  756. PS,PE: byte;
  757. function Trim(S: string): string;
  758. const TrimChars : set of char = [#0,#9,' ',#255];
  759. begin
  760. while (length(S)>0) and (S[1] in TrimChars) do Delete(S,1,1);
  761. while (length(S)>0) and (S[length(S)] in TrimChars) do Delete(S,length(S),1);
  762. Trim:=S;
  763. end;
  764. const AlphaNum : set of char = ['A'..'Z','0'..'9','_'];
  765. begin
  766. with Editor^ do
  767. begin
  768. S:=GetDisplayText(CurPos.Y);
  769. PS:=CurPos.X; while (PS>0) and (Upcase(S[PS]) in AlphaNum) do Dec(PS);
  770. PE:=CurPos.X; while (PE<length(S)) and (Upcase(S[PE+1]) in (AlphaNum+ValidSpecChars)) do Inc(PE);
  771. S:=Trim(copy(S,PS+1,PE-PS));
  772. end;
  773. GetEditorCurWord:=S;
  774. end;
  775. {*****************************************************************************
  776. Tab
  777. *****************************************************************************}
  778. function NewTabItem(AView: PView; ANext: PTabItem): PTabItem;
  779. var P: PTabItem;
  780. begin
  781. New(P); FillChar(P^,SizeOf(P^),0);
  782. P^.Next:=ANext; P^.View:=AView;
  783. NewTabItem:=P;
  784. end;
  785. procedure DisposeTabItem(P: PTabItem);
  786. begin
  787. if P<>nil then
  788. begin
  789. if P^.View<>nil then Dispose(P^.View, Done);
  790. Dispose(P);
  791. end;
  792. end;
  793. function NewTabDef(AName: string; ADefItem: PView; AItems: PTabItem; ANext: PTabDef): PTabDef;
  794. var P: PTabDef;
  795. x: byte;
  796. begin
  797. New(P);
  798. P^.Next:=ANext; P^.Name:=NewStr(AName); P^.Items:=AItems;
  799. x:=pos('~',AName);
  800. if (x<>0) and (x<length(AName)) then P^.ShortCut:=Upcase(AName[x+1])
  801. else P^.ShortCut:=#0;
  802. P^.DefItem:=ADefItem;
  803. NewTabDef:=P;
  804. end;
  805. procedure DisposeTabDef(P: PTabDef);
  806. var PI,X: PTabItem;
  807. begin
  808. DisposeStr(P^.Name);
  809. PI:=P^.Items;
  810. while PI<>nil do
  811. begin
  812. X:=PI^.Next;
  813. DisposeTabItem(PI);
  814. PI:=X;
  815. end;
  816. Dispose(P);
  817. end;
  818. {*****************************************************************************
  819. Reserved Words
  820. *****************************************************************************}
  821. function GetReservedWordCount: integer;
  822. var
  823. Count,I: integer;
  824. begin
  825. Count:=0;
  826. for I:=ord(Low(tToken)) to ord(High(tToken)) do
  827. with TokenInfo^[TToken(I)] do
  828. if (str<>'') and (str[1] in['A'..'Z']) and (length(str)>1) then
  829. Inc(Count);
  830. GetReservedWordCount:=Count;
  831. end;
  832. function GetReservedWord(Index: integer): string;
  833. var
  834. Count,Idx,I: integer;
  835. S: string;
  836. begin
  837. Idx:=-1;
  838. Count:=-1;
  839. I:=ord(Low(tToken));
  840. while (I<=ord(High(tToken))) and (Idx=-1) do
  841. with TokenInfo^[TToken(I)] do
  842. begin
  843. if (str<>'') and (str[1] in['A'..'Z']) and (length(str)>1) then
  844. begin
  845. Inc(Count);
  846. if Count=Index then
  847. Idx:=I;
  848. end;
  849. Inc(I);
  850. end;
  851. if Idx=-1 then
  852. S:=''
  853. else
  854. S:=TokenInfo^[TToken(Idx)].str;
  855. GetReservedWord:=S;
  856. end;
  857. {$ifdef powerpc}
  858. {$define USE_TasmCondFlag}
  859. { powerpc only has A_B prefix }
  860. const
  861. CondAsmOps = 1;
  862. CondAsmOpStr : array [0..CondAsmOps-1] of string[2] = ('b');
  863. {$define Use_gas_op2str}
  864. {$endif}
  865. {$ifdef powerpc64}
  866. {$define USE_TasmCondFlag}
  867. { powerpc64 only has A_B prefix }
  868. const
  869. CondAsmOps = 1;
  870. CondAsmOpStr : array [0..CondAsmOps-1] of string[2] = ('b');
  871. {$define Use_gas_op2str}
  872. {$endif}
  873. {$ifdef i386}
  874. {$define USE_TasmCond}
  875. {$define Use_std_op2str}
  876. {$endif}
  877. {$ifdef m68k}
  878. {$define USE_None}
  879. {$define Use_gas_op2str}
  880. {$endif}
  881. function GetAsmReservedWordCount: integer;
  882. begin
  883. GetAsmReservedWordCount:=ord(lastop) - ord(firstop)
  884. {$ifdef Use_TasmCond}
  885. + CondAsmOps*(ord(high(TasmCond))-ord(low(TasmCond)));
  886. {$endif Use_TasmCond}
  887. {$ifdef Use_TasmCondFlag}
  888. + CondAsmOps*(ord(high(TasmCondFlag))-ord(low(TasmCondFlag)));
  889. {$endif Use_TasmCondFlag}
  890. {$ifdef Use_None}
  891. ;
  892. {$endif Use_None}
  893. end;
  894. {$define NOASM}
  895. function GetAsmReservedWord(Index: integer): string;
  896. var
  897. CondNum,CondOpNum : integer;
  898. begin
  899. {$ifdef m68k}
  900. {$undef NOASM}
  901. if index <= ord(lastop) - ord(firstop) then
  902. GetAsmReservedWord:=gas_op2str[tasmop(Index+ord(firstop))]
  903. else
  904. GetAsmReservedWord:='';
  905. (*
  906. begin
  907. index:=index - (ord(lastop) - ord(firstop) );
  908. CondOpNum:= index div (ord(high(TasmCond))-ord(low(TasmCond)));
  909. CondNum:=index - (CondOpNum * (ord(high(TasmCond))-ord(low(TasmCond))));
  910. GetAsmReservedWord:=CondAsmOpStr[CondOpNum]+cond2str[TasmCond(CondNum+ord(low(TAsmCond))+1)];
  911. end;
  912. *)
  913. {$else not m68k}
  914. if index <= ord(lastop) - ord(firstop) then
  915. {$ifdef Use_gas_op2str}
  916. GetAsmReservedWord:=gas_op2str[tasmop(Index+ord(firstop))]
  917. {$endif Use_gas_op2str}
  918. {$ifdef Use_std_op2str}
  919. GetAsmReservedWord:=std_op2str[tasmop(Index+ord(firstop))]
  920. {$endif Use_std_op2str}
  921. {$ifdef Use_TASMCond}
  922. {$undef NOASM}
  923. else
  924. begin
  925. index:=index - (ord(lastop) - ord(firstop) );
  926. CondOpNum:= index div (ord(high(TasmCond))-ord(low(TasmCond)));
  927. CondNum:=index - (CondOpNum * (ord(high(TasmCond))-ord(low(TasmCond))));
  928. GetAsmReservedWord:=CondAsmOpStr[CondOpNum]+cond2str[TasmCond(CondNum+ord(low(TAsmCond))+1)];
  929. end;
  930. {$endif Use_TASMCond}
  931. {$ifdef Use_TASMCondFlag}
  932. {$undef NOASM}
  933. else
  934. begin
  935. index:=index - (ord(lastop) - ord(firstop) );
  936. CondOpNum:= index div (ord(high(TasmCondFlag))-ord(low(TasmCondFlag)));
  937. CondNum:=index - (CondOpNum * (ord(high(TasmCondFlag))-ord(low(TasmCondFlag))));
  938. GetAsmReservedWord:=CondAsmOpStr[CondOpNum]+AsmCondFlag2Str[TasmCondFlag(CondNum+ord(low(TAsmCondFlag))+1)];
  939. end;
  940. {$endif Use_TASMCond}
  941. {$endif not m68k}
  942. {$ifdef NOASM}
  943. GetAsmReservedWord:='';
  944. {$endif NOASM}
  945. end;
  946. procedure InitReservedWords;
  947. var WordS: string;
  948. Idx,I,J : sw_integer;
  949. begin
  950. InitTokens;
  951. for I:=Low(ReservedWords) to High(ReservedWords) do
  952. New(ReservedWords[I], Init(50,10));
  953. for I:=1 to GetReservedWordCount do
  954. begin
  955. WordS:=GetReservedWord(I-1); Idx:=length(WordS);
  956. if (Idx>=Low(ReservedWords)) and (Idx<=High(ReservedWords)) then
  957. ReservedWords[Idx]^.Insert(NewStr(WordS));
  958. end;
  959. for I:=Low(AsmReservedWords) to High(AsmReservedWords) do
  960. New(AsmReservedWords[I], Init(50,10));
  961. for I:=1 to GetAsmReservedWordCount do
  962. begin
  963. WordS:=UpcaseStr(GetAsmReservedWord(I-1)); Idx:=length(WordS);
  964. if (Idx>=Low(AsmReservedWords)) and (Idx<=High(AsmReservedWords)) then
  965. begin
  966. if not AsmReservedWords[Idx]^.Search(@WordS, J) then
  967. AsmReservedWords[Idx]^.Insert(NewStr(WordS));
  968. end;
  969. end;
  970. end;
  971. procedure DoneReservedWords;
  972. var I: integer;
  973. begin
  974. for I:=Low(ReservedWords) to High(ReservedWords) do
  975. if assigned(ReservedWords[I]) then
  976. begin
  977. dispose(ReservedWords[I],done);
  978. ReservedWords[I]:=nil;
  979. end;
  980. for I:=Low(AsmReservedWords) to High(AsmReservedWords) do
  981. if assigned(AsmReservedWords[I]) then
  982. begin
  983. dispose(AsmReservedWords[I],done);
  984. ReservedWords[I]:=nil;
  985. end;
  986. DoneTokens;
  987. end;
  988. function IsFPReservedWord(const S: string): boolean;
  989. var _Is: boolean;
  990. Idx,Item: sw_integer;
  991. UpS: string;
  992. begin
  993. Idx:=length(S); _Is:=false;
  994. if (Low(ReservedWords)<=Idx) and (Idx<=High(ReservedWords)) and
  995. (ReservedWords[Idx]<>nil) and (ReservedWords[Idx]^.Count<>0) then
  996. begin
  997. UpS:=UpcaseStr(S);
  998. _Is:=ReservedWords[Idx]^.Search(@UpS,Item);
  999. end;
  1000. IsFPReservedWord:=_Is;
  1001. end;
  1002. function IsFPAsmReservedWord(S: string): boolean;
  1003. var _Is: boolean;
  1004. Idx,Item,Len: sw_integer;
  1005. LastC : Char;
  1006. LastTwo : String[2];
  1007. begin
  1008. Idx:=length(S); _Is:=false;
  1009. if (Low(AsmReservedWords)<=Idx) and (Idx<=High(AsmReservedWords)) and
  1010. (AsmReservedWords[Idx]<>nil) and (AsmReservedWords[Idx]^.Count<>0) then
  1011. begin
  1012. S:=UpcaseStr(S);
  1013. _Is:=AsmReservedWords[Idx]^.Search(@S,Item);
  1014. {$ifdef i386}
  1015. if not _Is and (Length(S)>1) then
  1016. begin
  1017. LastC:=S[Length(S)];
  1018. if LastC in ['B','D','L','Q','S','T','V','W'] then
  1019. begin
  1020. Delete(S,Length(S),1);
  1021. Dec(Idx);
  1022. if (AsmReservedWords[Idx]<>nil) and (AsmReservedWords[Idx]^.Count<>0) then
  1023. _Is:=AsmReservedWords[Idx]^.Search(@S,Item);
  1024. if not _Is and (Length(S)>1) then
  1025. begin
  1026. LastTwo:=S[Length(S)]+LastC;
  1027. if (LastTwo='BL') or
  1028. (LastTwo='WL') or
  1029. (LastTwo='BW') then
  1030. begin
  1031. Delete(S,Length(S),1);
  1032. Dec(Idx);
  1033. if (AsmReservedWords[Idx]<>nil) and (AsmReservedWords[Idx]^.Count<>0) then
  1034. _Is:=AsmReservedWords[Idx]^.Search(@S,Item);
  1035. end;
  1036. end;
  1037. end;
  1038. end;
  1039. {$endif i386}
  1040. end;
  1041. IsFPAsmReservedWord:=_Is;
  1042. end;
  1043. {*****************************************************************************
  1044. SearchWindow
  1045. *****************************************************************************}
  1046. function SearchWindowWithNo(No: integer): PWindow;
  1047. var P: PWindow;
  1048. begin
  1049. P:=Message(Desktop,evBroadcast,cmSearchWindow+No,nil);
  1050. if pointer(P)=pointer(Desktop) then P:=nil;
  1051. SearchWindowWithNo:=P;
  1052. end;
  1053. function SearchWindow(const Title: string): PWindow;
  1054. function Match(P: PView): boolean;
  1055. var W: PWindow;
  1056. OK: boolean;
  1057. begin
  1058. W:=nil;
  1059. { we have a crash here because of the TStatusLine
  1060. that can also have one of these values
  1061. but is not a Window object PM }
  1062. if P<>pointer(StatusLine) then
  1063. if IsWindow(P) then
  1064. W:=PWindow(P);
  1065. OK:=(W<>nil);
  1066. if OK then
  1067. begin
  1068. OK:=CompareText(W^.GetTitle(255),Title)=0;
  1069. end;
  1070. Match:=OK;
  1071. end;
  1072. var W: PView;
  1073. begin
  1074. W:=Application^.FirstThat(@Match);
  1075. { This is wrong because TStatusLine is also considered PM }
  1076. if not Assigned(W) then W:=Desktop^.FirstThat(@Match);
  1077. { But why do we need to check all ??
  1078. Probably because of the ones which were not inserted into
  1079. Desktop as the Messages view
  1080. Exactly. Some windows are inserted directly in the Application and not
  1081. in the Desktop. btw. Does TStatusLine.HelpCtx really change? Why?
  1082. Only GetHelpCtx should return different values depending on the
  1083. focused view (and it's helpctx), but TStatusLine's HelpCtx field
  1084. shouldn't change... Gabor
  1085. if Assigned(W)=false then W:=Desktop^.FirstThat(@Match);}
  1086. SearchWindow:=PWindow(W);
  1087. end;
  1088. function SearchFreeWindowNo: integer;
  1089. var No: integer;
  1090. begin
  1091. No:=1;
  1092. while (No<100) and (SearchWindowWithNo(No)<>nil) do
  1093. Inc(No);
  1094. if No=100 then No:=0;
  1095. SearchFreeWindowNo:=No;
  1096. end;
  1097. {*****************************************************************************
  1098. TIntegerLine
  1099. *****************************************************************************}
  1100. constructor TIntegerLine.Init(var Bounds: TRect; AMin, AMax: longint);
  1101. begin
  1102. if inherited Init(Bounds, Bounds.B.X-Bounds.A.X-1)=false then
  1103. Fail;
  1104. Validator:=New(PRangeValidator, Init(AMin, AMax));
  1105. end;
  1106. {*****************************************************************************
  1107. SourceEditor
  1108. *****************************************************************************}
  1109. function SearchCoreForFileName(AFileName: string): PCodeEditorCore;
  1110. var EC: PCodeEditorCore;
  1111. function Check(P: PView): boolean;
  1112. var OK: boolean;
  1113. begin
  1114. OK:=P^.HelpCtx=hcSourceWindow;
  1115. if OK then
  1116. with PSourceWindow(P)^ do
  1117. if FixFileName(Editor^.FileName)=AFileName then
  1118. begin
  1119. EC:=Editor^.Core;
  1120. OK:=true;
  1121. end
  1122. else
  1123. OK:=false;
  1124. Check:=OK;
  1125. end;
  1126. begin
  1127. EC:=nil;
  1128. AFileName:=FixFileName(AFileName);
  1129. { do not use the same core for all new files }
  1130. if AFileName<>'' then
  1131. Desktop^.FirstThat(@Check);
  1132. SearchCoreForFileName:=EC;
  1133. end;
  1134. constructor TSourceEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  1135. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  1136. var EC: PCodeEditorCore;
  1137. begin
  1138. EC:=SearchCoreForFileName(AFileName);
  1139. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,EC,AFileName);
  1140. SetStoreUndo(true);
  1141. CompileStamp:=0;
  1142. end;
  1143. Const
  1144. FreePascalSpecSymbolCount : array [TSpecSymbolClass] of integer =
  1145. (
  1146. 3,{ssCommentPrefix}
  1147. 1,{ssCommentSingleLinePrefix}
  1148. 2,{ssCommentSuffix}
  1149. 1,{ssStringPrefix}
  1150. 1,{ssStringSuffix}
  1151. 1,{ssDirectivePrefix}
  1152. 1,{ssDirectiveSuffix}
  1153. 1,{ssAsmPrefix}
  1154. 1 {ssAsmSuffix}
  1155. );
  1156. FreePascalEmptyString : string[1] = '';
  1157. FreePascalCommentPrefix1 : string[1] = '{';
  1158. FreePascalCommentPrefix2 : string[2] = '(*';
  1159. FreePascalCommentPrefix3 : string[2] = '//';
  1160. FreePascalCommentSingleLinePrefix : string[2] = '//';
  1161. FreePascalCommentSuffix1 : string[1] = '}';
  1162. FreePascalCommentSuffix2 : string[2] = '*)';
  1163. FreePascalStringPrefix : string[1] = '''';
  1164. FreePascalStringSuffix : string[1] = '''';
  1165. FreePascalDirectivePrefix : string[2] = '{$';
  1166. FreePascalDirectiveSuffix : string[1] = '}';
  1167. FreePascalAsmPrefix : string[3] = 'ASM';
  1168. FreePascalAsmSuffix : string[3] = 'END';
  1169. function TSourceEditor.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  1170. begin
  1171. GetSpecSymbolCount:=FreePascalSpecSymbolCount[SpecClass];
  1172. end;
  1173. function TSourceEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  1174. begin
  1175. GetSpecSymbol:=@FreePascalEmptyString;
  1176. case SpecClass of
  1177. ssCommentPrefix :
  1178. case Index of
  1179. 0 : GetSpecSymbol:=@FreePascalCommentPrefix1;
  1180. 1 : GetSpecSymbol:=@FreePascalCommentPrefix2;
  1181. 2 : GetSpecSymbol:=@FreePascalCommentPrefix3;
  1182. end;
  1183. ssCommentSingleLinePrefix :
  1184. case Index of
  1185. 0 : GetSpecSymbol:=@FreePascalCommentSingleLinePrefix;
  1186. end;
  1187. ssCommentSuffix :
  1188. case Index of
  1189. 0 : GetSpecSymbol:=@FreePascalCommentSuffix1;
  1190. 1 : GetSpecSymbol:=@FreePascalCommentSuffix2;
  1191. end;
  1192. ssStringPrefix :
  1193. GetSpecSymbol:=@FreePascalStringPrefix;
  1194. ssStringSuffix :
  1195. GetSpecSymbol:=@FreePascalStringSuffix;
  1196. { must be uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
  1197. ssAsmPrefix :
  1198. GetSpecSymbol:=@FreePascalAsmPrefix;
  1199. ssAsmSuffix :
  1200. GetSpecSymbol:=@FreePascalAsmSuffix;
  1201. ssDirectivePrefix :
  1202. GetSpecSymbol:=@FreePascalDirectivePrefix;
  1203. ssDirectiveSuffix :
  1204. GetSpecSymbol:=@FreePascalDirectiveSuffix;
  1205. end;
  1206. end;
  1207. function TSourceEditor.IsReservedWord(const S: string): boolean;
  1208. begin
  1209. IsReservedWord:=IsFPReservedWord(S);
  1210. end;
  1211. function TSourceEditor.IsAsmReservedWord(const S: string): boolean;
  1212. begin
  1213. IsAsmReservedWord:=IsFPAsmReservedWord(S);
  1214. end;
  1215. function TSourceEditor.TranslateCodeTemplate(var Shortcut: string; ALines: PUnsortedStringCollection): boolean;
  1216. begin
  1217. TranslateCodeTemplate:=FPTranslateCodeTemplate(ShortCut,ALines);
  1218. end;
  1219. function TSourceEditor.SelectCodeTemplate(var ShortCut: string): boolean;
  1220. var D: PCodeTemplatesDialog;
  1221. OK: boolean;
  1222. begin
  1223. New(D, Init(true,ShortCut));
  1224. OK:=Desktop^.ExecView(D)=cmOK;
  1225. if OK then ShortCut:=D^.GetSelectedShortCut;
  1226. Dispose(D, Done);
  1227. SelectCodeTemplate:=OK;
  1228. end;
  1229. function TSourceEditor.CompleteCodeWord(const WordS: string; var Text: string): boolean;
  1230. begin
  1231. CompleteCodeWord:=FPCompleteCodeWord(WordS,Text);
  1232. end;
  1233. procedure TSourceEditor.FindMatchingDelimiter(ScanForward: boolean);
  1234. var
  1235. St,nextResWord : String;
  1236. LineText,LineAttr: string;
  1237. Res,found,addit : boolean;
  1238. JumpPos: TPoint;
  1239. X,Y,lexchange,curlevel,linecount : sw_integer;
  1240. function GetLexChange(const S : string) : sw_integer;
  1241. begin
  1242. if (S='END') or (S='THEN') or (S='UNTIL') then
  1243. GetLexChange:=-1
  1244. else if (S='ASM') or (S='BEGIN') or (S='CASE') or (S='CLASS') or
  1245. (S='IF') or (S='OBJECT') or (S='RECORD') or (S='REPEAT') then
  1246. GetLexChange:=+1
  1247. else
  1248. GetLexChange:=0;
  1249. end;
  1250. begin
  1251. st:=UpcaseStr(GetCurrentWord);
  1252. if st<>'' then
  1253. Res:=IsReservedWord(St)
  1254. else
  1255. Res:=false;
  1256. LexChange:=GetLexChange(St);
  1257. if not res or (LexChange=0) or not
  1258. IsFlagSet(efSyntaxHighlight) then
  1259. Inherited FindMatchingDelimiter(ScanForward)
  1260. else
  1261. begin
  1262. JumpPos.X:=-1; JumpPos.Y:=-1;
  1263. Y:=CurPos.Y; X:=CurPos.X;
  1264. found:=false;
  1265. LineCount:=0;
  1266. curlevel:=lexchange;
  1267. if LexChange>0 then
  1268. begin
  1269. repeat
  1270. Inc(LineCount);
  1271. NextResWord:='';
  1272. GetDisplayTextFormat(Y,LineText,LineAttr);
  1273. if LineCount<>1 then X:=-1
  1274. else if ord(LineAttr[X+1])<>coReservedWordColor then
  1275. exit;
  1276. repeat
  1277. Inc(X);
  1278. if X<length(LineText) then
  1279. begin
  1280. AddIt:=ord(LineAttr[X+1])=coReservedWordColor;
  1281. if AddIt then
  1282. NextResWord:=NextResWord+UpCase(LineText[X+1]);
  1283. end;
  1284. if ((X=length(LineText)) or (Not AddIt)) and
  1285. (NextResWord<>'') and
  1286. IsReservedWord(NextResWord) then
  1287. begin
  1288. LexChange:=GetLexChange(NextResWord);
  1289. CurLevel:=CurLevel+LexChange;
  1290. if CurLevel=0 then
  1291. begin
  1292. JumpPos.X:=X-Length(NextResWord);
  1293. JumpPos.Y:=Y;
  1294. end;
  1295. NextResWord:='';
  1296. end;
  1297. until (X>=length(LineText)) or (JumpPos.X<>-1);
  1298. Inc(Y);
  1299. until (Y>=GetLineCount) or (JumpPos.X<>-1);
  1300. if (Y=GetLineCount) and (JumpPos.X=-1) then
  1301. begin
  1302. ErrorBox('No match',nil);
  1303. exit;
  1304. end;
  1305. end
  1306. else if (LexChange<0) then
  1307. begin
  1308. repeat
  1309. Inc(LineCount);
  1310. NextResWord:='';
  1311. GetDisplayTextFormat(Y,LineText,LineAttr);
  1312. if LineCount<>1 then
  1313. X:=Length(LineText)
  1314. else if ord(LineAttr[X+1])<>coReservedWordColor then
  1315. exit;
  1316. repeat
  1317. Dec(X);
  1318. if X>=0 then
  1319. begin
  1320. AddIt:=ord(LineAttr[X+1])=coReservedWordColor;
  1321. if AddIt then
  1322. NextResWord:=UpCase(LineText[X+1])+NextResWord;
  1323. end;
  1324. if ((X=0) or (Not AddIt)) and
  1325. (NextResWord<>'') and
  1326. IsReservedWord(NextResWord) then
  1327. begin
  1328. LexChange:=GetLexChange(NextResWord);
  1329. CurLevel:=CurLevel+LexChange;
  1330. if CurLevel=0 then
  1331. begin
  1332. if AddIt then
  1333. JumpPos.X:=X
  1334. else
  1335. JumpPos.X:=X+1;
  1336. JumpPos.Y:=Y;
  1337. end;
  1338. NextResWord:='';
  1339. end;
  1340. until (X<=0) or (JumpPos.X<>-1);
  1341. Dec(Y);
  1342. until (Y<0) or (JumpPos.X<>-1);
  1343. if (Y<0) and (JumpPos.X=-1) then
  1344. begin
  1345. ErrorBox('No match',nil);
  1346. exit;
  1347. end;
  1348. end;
  1349. if JumpPos.X<>-1 then
  1350. begin
  1351. SetCurPtr(JumpPos.X,JumpPos.Y);
  1352. TrackCursor(do_centre);
  1353. end;
  1354. end;
  1355. end;
  1356. procedure TSourceEditor.SetCodeCompleteWord(const S: string);
  1357. var R: TRect;
  1358. begin
  1359. inherited SetCodeCompleteWord(S);
  1360. if S='' then
  1361. begin
  1362. if Assigned(CodeCompleteTip) then Dispose(CodeCompleteTip, Done);
  1363. CodeCompleteTip:=nil;
  1364. end
  1365. else
  1366. begin
  1367. R.Assign(0,0,20,1);
  1368. if Assigned(CodeCompleteTip)=false then
  1369. begin
  1370. New(CodeCompleteTip, Init(R, S, alCenter));
  1371. CodeCompleteTip^.Hide;
  1372. Application^.Insert(CodeCompleteTip);
  1373. end
  1374. else
  1375. CodeCompleteTip^.SetText(S);
  1376. AlignCodeCompleteTip;
  1377. end;
  1378. end;
  1379. procedure TSourceEditor.AlignCodeCompleteTip;
  1380. var P: TPoint;
  1381. S: string;
  1382. R: TRect;
  1383. begin
  1384. if Assigned(CodeCompleteTip)=false then Exit;
  1385. S:=CodeCompleteTip^.GetText;
  1386. P.Y:=CurPos.Y;
  1387. { determine the center of current word fragment }
  1388. P.X:=CurPos.X-(length(GetCodeCompleteFrag) div 2);
  1389. { calculate position for centering the complete word over/below the current }
  1390. P.X:=P.X-(length(S) div 2);
  1391. P.X:=P.X-Delta.X;
  1392. P.Y:=P.Y-Delta.Y;
  1393. MakeGlobal(P,P);
  1394. if Assigned(CodeCompleteTip^.Owner) then
  1395. CodeCompleteTip^.Owner^.MakeLocal(P,P);
  1396. { ensure that the tooltip stays in screen }
  1397. P.X:=Min(Max(0,P.X),ScreenWidth-length(S)-2-1);
  1398. { align it vertically }
  1399. if P.Y>round(ScreenHeight*3/4) then
  1400. Dec(P.Y)
  1401. else
  1402. Inc(P.Y);
  1403. R.Assign(P.X,P.Y,P.X+1+length(S)+1,P.Y+1);
  1404. CodeCompleteTip^.Locate(R);
  1405. if CodeCompleteTip^.GetState(sfVisible)=false then
  1406. CodeCompleteTip^.Show;
  1407. end;
  1408. procedure TSourceEditor.ModifiedChanged;
  1409. begin
  1410. inherited ModifiedChanged;
  1411. if (@Self<>Clipboard) and GetModified then
  1412. begin
  1413. { global flags }
  1414. EditorModified:=true;
  1415. { reset compile flags as the file is
  1416. not the same as at the compilation anymore }
  1417. CompileStamp:=-1;
  1418. end;
  1419. end;
  1420. procedure TSourceEditor.InsertOptions;
  1421. var C: PUnsortedStringCollection;
  1422. Y: sw_integer;
  1423. S: string;
  1424. begin
  1425. Lock;
  1426. New(C, Init(10,10));
  1427. GetCompilerOptionLines(C);
  1428. if C^.Count>0 then
  1429. begin
  1430. for Y:=0 to C^.Count-1 do
  1431. begin
  1432. S:=C^.At(Y)^;
  1433. InsertLine(Y,S);
  1434. end;
  1435. AdjustSelectionPos(0,0,0,C^.Count);
  1436. UpdateAttrs(0,attrAll);
  1437. DrawLines(0);
  1438. SetModified(true);
  1439. end;
  1440. Dispose(C, Done);
  1441. UnLock;
  1442. end;
  1443. procedure TSourceEditor.PushInfo(Const st : string);
  1444. begin
  1445. PushStatus(st);
  1446. end;
  1447. procedure TSourceEditor.PopInfo;
  1448. begin
  1449. PopStatus;
  1450. end;
  1451. procedure TSourceEditor.DeleteLine(I: sw_integer);
  1452. begin
  1453. inherited DeleteLine(I);
  1454. {$ifndef NODEBUG}
  1455. If ShouldHandleBreakpoints then
  1456. BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1);
  1457. {$endif NODEBUG}
  1458. end;
  1459. procedure TSourceEditor.BackSpace;
  1460. {$ifndef NODEBUG}
  1461. var
  1462. MoveBreakpointToPreviousLine,WasEnabled : boolean;
  1463. PBStart,PBEnd : PBreakpoint;
  1464. I : longint;
  1465. {$endif NODEBUG}
  1466. begin
  1467. {$ifdef NODEBUG}
  1468. inherited Backspace;
  1469. {$else}
  1470. MoveBreakpointToPreviousLine:=(CurPos.X=0) and (CurPos.Y>0);
  1471. If MoveBreakpointToPreviousLine then
  1472. begin
  1473. ShouldHandleBreakpoints:=false;
  1474. I:=CurPos.Y+1;
  1475. PBEnd:=BreakpointsCollection^.FindBreakpointAt(@Self,I);
  1476. PBStart:=BreakpointsCollection^.FindBreakpointAt(@Self,I-1);
  1477. end;
  1478. inherited Backspace;
  1479. if MoveBreakpointToPreviousLine then
  1480. begin
  1481. ShouldHandleBreakpoints:=true;
  1482. if assigned(PBEnd) then
  1483. begin
  1484. if assigned(PBStart) then
  1485. begin
  1486. if PBEnd^.state=bs_enabled then
  1487. PBStart^.state:=bs_enabled;
  1488. BreakpointsCollection^.Free(PBEnd);
  1489. end
  1490. else
  1491. begin
  1492. WasEnabled:=PBEnd^.state=bs_enabled;
  1493. if WasEnabled then
  1494. begin
  1495. PBEnd^.state:=bs_disabled;
  1496. PBEnd^.UpdateSource;
  1497. end;
  1498. PBEnd^.line:=I-1;
  1499. if WasEnabled then
  1500. begin
  1501. PBEnd^.state:=bs_enabled;
  1502. PBEnd^.UpdateSource;
  1503. end;
  1504. end;
  1505. end;
  1506. BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1);
  1507. end;
  1508. {$endif NODEBUG}
  1509. end;
  1510. function TSourceEditor.InsertNewLine : Sw_integer;
  1511. {$ifndef NODEBUG}
  1512. var
  1513. MoveBreakpointToNextLine : boolean;
  1514. I : longint;
  1515. {$endif NODEBUG}
  1516. begin
  1517. {$ifdef NODEBUG}
  1518. InsertNewLine:=inherited InsertNewLine;
  1519. {$else}
  1520. ShouldHandleBreakpoints:=false;
  1521. MoveBreakpointToNextLine:=Cursor.x<Length(RTrim(GetDisplayText(CurPos.Y)));
  1522. I:=CurPos.Y+1;
  1523. InsertNewLine:=inherited InsertNewLine;
  1524. if MoveBreakpointToNextLine then
  1525. BreakpointsCollection^.AdaptBreakpoints(@Self,I-1,1)
  1526. else
  1527. BreakpointsCollection^.AdaptBreakpoints(@Self,I,1);
  1528. ShouldHandleBreakpoints:=true;
  1529. {$endif NODEBUG}
  1530. end;
  1531. procedure TSourceEditor.DelChar;
  1532. var
  1533. S: string;
  1534. I,CI : sw_integer;
  1535. {$ifndef NODEBUG}
  1536. PBStart,PBEnd : PBreakpoint;
  1537. MoveBreakpointOneLineUp,WasEnabled : boolean;
  1538. {$endif NODEBUG}
  1539. begin
  1540. if IsReadOnly then Exit;
  1541. S:=GetLineText(CurPos.Y);
  1542. I:=CurPos.Y+1;
  1543. CI:=LinePosToCharIdx(CurPos.Y,CurPos.X);
  1544. {$ifndef NODEBUG}
  1545. if ((CI>length(S)) or (S='')) and (CurPos.Y<GetLineCount-1) then
  1546. begin
  1547. MoveBreakpointOneLineUp:=true;
  1548. ShouldHandleBreakpoints:=false;
  1549. PBEnd:=BreakpointsCollection^.FindBreakpointAt(@Self,I+1);
  1550. PBStart:=BreakpointsCollection^.FindBreakpointAt(@Self,I);
  1551. end
  1552. else
  1553. MoveBreakpointOneLineUp:=false;
  1554. {$endif NODEBUG}
  1555. Inherited DelChar;
  1556. {$ifndef NODEBUG}
  1557. if MoveBreakpointOneLineUp then
  1558. begin
  1559. ShouldHandleBreakpoints:=true;
  1560. if assigned(PBEnd) then
  1561. begin
  1562. if assigned(PBStart) then
  1563. begin
  1564. if PBEnd^.state=bs_enabled then
  1565. PBStart^.state:=bs_enabled;
  1566. BreakpointsCollection^.Free(PBEnd);
  1567. end
  1568. else
  1569. begin
  1570. WasEnabled:=PBEnd^.state=bs_enabled;
  1571. if WasEnabled then
  1572. begin
  1573. PBEnd^.state:=bs_disabled;
  1574. PBEnd^.UpdateSource;
  1575. end;
  1576. PBEnd^.line:=I;
  1577. if WasEnabled then
  1578. begin
  1579. PBEnd^.state:=bs_enabled;
  1580. PBEnd^.UpdateSource;
  1581. end;
  1582. end;
  1583. end;
  1584. BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1);
  1585. end;
  1586. {$endif NODEBUG}
  1587. end;
  1588. procedure TSourceEditor.DelSelect;
  1589. {$ifndef NODEBUG}
  1590. var
  1591. MoveBreakpointToFirstLine,WasEnabled : boolean;
  1592. PBStart,PBEnd : PBreakpoint;
  1593. I,J : longint;
  1594. {$endif NODEBUG}
  1595. begin
  1596. {$ifdef NODEBUG}
  1597. inherited DelSelect;
  1598. {$else}
  1599. ShouldHandleBreakpoints:=false;
  1600. J:=SelEnd.Y-SelStart.Y;
  1601. MoveBreakpointToFirstLine:=J>0;
  1602. PBEnd:=BreakpointsCollection^.FindBreakpointAt(@Self,SelEnd.Y);
  1603. PBStart:=BreakpointsCollection^.FindBreakpointAt(@Self,SelEnd.Y);
  1604. I:=SelStart.Y;
  1605. inherited DelSelect;
  1606. if MoveBreakpointToFirstLine and assigned(PBEnd) then
  1607. begin
  1608. If assigned(PBStart) then
  1609. begin
  1610. if PBEnd^.state=bs_enabled then
  1611. PBStart^.state:=bs_enabled;
  1612. BreakpointsCollection^.Free(PBEnd);
  1613. end
  1614. else
  1615. begin
  1616. WasEnabled:=PBEnd^.state=bs_enabled;
  1617. if WasEnabled then
  1618. begin
  1619. PBEnd^.state:=bs_disabled;
  1620. PBEnd^.UpdateSource;
  1621. end;
  1622. PBEnd^.line:=I;
  1623. if WasEnabled then
  1624. begin
  1625. PBEnd^.state:=bs_enabled;
  1626. PBEnd^.UpdateSource;
  1627. end;
  1628. end;
  1629. end;
  1630. BreakpointsCollection^.AdaptBreakpoints(@Self,I,-J);
  1631. ShouldHandleBreakpoints:=true;
  1632. {$endif NODEBUG}
  1633. end;
  1634. function TSourceEditor.InsertLine(LineNo: sw_integer; const S: string): PCustomLine;
  1635. begin
  1636. InsertLine := inherited InsertLine(LineNo,S);
  1637. {$ifndef NODEBUG}
  1638. If ShouldHandleBreakpoints then
  1639. BreakpointsCollection^.AdaptBreakpoints(@Self,LineNo,1);
  1640. {$endif NODEBUG}
  1641. end;
  1642. procedure TSourceEditor.AddLine(const S: string);
  1643. begin
  1644. inherited AddLine(S);
  1645. {$ifndef NODEBUG}
  1646. BreakpointsCollection^.AdaptBreakpoints(@Self,GetLineCount,1);
  1647. {$endif NODEBUG}
  1648. end;
  1649. function TSourceEditor.GetLocalMenu: PMenu;
  1650. var M: PMenu;
  1651. MI: PMenuItem;
  1652. begin
  1653. MI:=
  1654. NewItem(menu_edit_cut,menu_key_edit_cut,cut_key,cmCut,hcCut,
  1655. NewItem(menu_edit_copy,menu_key_edit_copy,copy_key,cmCopy,hcCopy,
  1656. NewItem(menu_edit_paste,menu_key_edit_paste,paste_key,cmPaste,hcPaste,
  1657. NewItem(menu_edit_clear,menu_key_edit_clear,kbCtrlDel,cmClear,hcClear,
  1658. NewLine(
  1659. NewItem(menu_srclocal_openfileatcursor,'',kbNoKey,cmOpenAtCursor,hcOpenAtCursor,
  1660. NewItem(menu_srclocal_browseatcursor,'',kbNoKey,cmBrowseAtCursor,hcBrowseAtCursor,
  1661. NewItem(menu_srclocal_topicsearch,menu_key_help_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  1662. NewLine(
  1663. NewItem(menu_srclocal_options,'',kbNoKey,cmEditorOptions,hcEditorOptions,
  1664. nil))))))))));
  1665. if IsChangedOnDisk then
  1666. MI:=NewItem(menu_srclocal_reload,'',kbNoKey,cmDoReload,hcDoReload,
  1667. MI);
  1668. M:=NewMenu(MI);
  1669. GetLocalMenu:=M;
  1670. end;
  1671. function TSourceEditor.GetCommandTarget: PView;
  1672. begin
  1673. GetCommandTarget:=@Self;
  1674. end;
  1675. function TSourceEditor.CreateLocalMenuView(var Bounds: TRect; M: PMenu): PMenuPopup;
  1676. var MV: PAdvancedMenuPopup;
  1677. begin
  1678. New(MV, Init(Bounds,M));
  1679. CreateLocalMenuView:=MV;
  1680. end;
  1681. {$ifdef DebugUndo}
  1682. procedure TSourceEditor.DumpUndo;
  1683. var
  1684. i : sw_integer;
  1685. begin
  1686. ClearToolMessages;
  1687. AddToolCommand('UndoList Dump');
  1688. for i:=0 to Core^.UndoList^.count-1 do
  1689. with Core^.UndoList^.At(i)^ do
  1690. begin
  1691. if is_grouped_action then
  1692. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  1693. else
  1694. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.Y+1)+':'+IntToStr(StartPos.X+1)+
  1695. ' '+IntToStr(EndPos.Y+1)+':'+IntToStr(EndPos.X+1)+' "'+GetStr(Text)+'"',0,0);
  1696. end;
  1697. if Core^.RedoList^.count>0 then
  1698. AddToolCommand('RedoList Dump');
  1699. for i:=0 to Core^.RedoList^.count-1 do
  1700. with Core^.RedoList^.At(i)^ do
  1701. begin
  1702. if is_grouped_action then
  1703. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  1704. else
  1705. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.Y+1)+':'+IntToStr(StartPos.X+1)+
  1706. ' '+IntToStr(EndPos.Y+1)+':'+IntToStr(EndPos.X+1)+' "'+GetStr(Text)+'"',0,0);
  1707. end;
  1708. UpdateToolMessages;
  1709. if Assigned(MessagesWindow) then
  1710. MessagesWindow^.Focus;
  1711. end;
  1712. procedure TSourceEditor.UndoAll;
  1713. begin
  1714. While Core^.UndoList^.count>0 do
  1715. Undo;
  1716. end;
  1717. procedure TSourceEditor.RedoAll;
  1718. begin
  1719. While Core^.RedoList^.count>0 do
  1720. Redo;
  1721. end;
  1722. {$endif DebugUndo}
  1723. function TSourceEditor.Valid(Command: Word): Boolean;
  1724. var OK: boolean;
  1725. begin
  1726. OK:=inherited Valid(Command);
  1727. if OK and ({(Command=cmClose) or already handled in TFileEditor.Valid PM }
  1728. (Command=cmAskSaveAll)) then
  1729. if IsClipboard=false then
  1730. OK:=SaveAsk(false);
  1731. Valid:=OK;
  1732. end;
  1733. procedure TSourceEditor.HandleEvent(var Event: TEvent);
  1734. var DontClear: boolean;
  1735. S: string;
  1736. begin
  1737. TranslateMouseClick(@Self,Event);
  1738. case Event.What of
  1739. evKeyDown :
  1740. begin
  1741. DontClear:=false;
  1742. case Event.KeyCode of
  1743. kbCtrlEnter :
  1744. Message(@Self,evCommand,cmOpenAtCursor,nil);
  1745. else DontClear:=true;
  1746. end;
  1747. if not DontClear then ClearEvent(Event);
  1748. end;
  1749. end;
  1750. inherited HandleEvent(Event);
  1751. case Event.What of
  1752. evBroadcast :
  1753. case Event.Command of
  1754. cmCalculatorPaste :
  1755. begin
  1756. InsertText(FloatToStr(CalcClipboard,0));
  1757. ClearEvent(Event);
  1758. end;
  1759. end;
  1760. evCommand :
  1761. begin
  1762. DontClear:=false;
  1763. case Event.Command of
  1764. {$ifdef DebugUndo}
  1765. cmDumpUndo : DumpUndo;
  1766. cmUndoAll : UndoAll;
  1767. cmRedoAll : RedoAll;
  1768. {$endif DebugUndo}
  1769. cmDoReload : ReloadFile;
  1770. cmBrowseAtCursor:
  1771. begin
  1772. S:=LowerCaseStr(GetEditorCurWord(@Self,[]));
  1773. OpenOneSymbolBrowser(S);
  1774. end;
  1775. cmOpenAtCursor :
  1776. begin
  1777. S:=LowerCaseStr(GetEditorCurWord(@Self,['.']));
  1778. if Pos('.',S)<>0 then
  1779. OpenFileName:=S else
  1780. OpenFileName:=S+'.pp'+ListSeparator+
  1781. S+'.pas'+ListSeparator+
  1782. S+'.inc';
  1783. Message(Application,evCommand,cmOpen,nil);
  1784. end;
  1785. cmEditorOptions :
  1786. Message(Application,evCommand,cmEditorOptions,@Self);
  1787. cmHelp :
  1788. Message(@Self,evCommand,cmHelpTopicSearch,@Self);
  1789. cmHelpTopicSearch :
  1790. HelpTopicSearch(@Self);
  1791. else DontClear:=true;
  1792. end;
  1793. if not DontClear then ClearEvent(Event);
  1794. end;
  1795. end;
  1796. end;
  1797. constructor TFPHeapView.Init(var Bounds: TRect);
  1798. begin
  1799. if inherited Init(Bounds)=false then Fail;
  1800. Options:=Options or gfGrowHiX or gfGrowHiY;
  1801. EventMask:=EventMask or evIdle;
  1802. GrowMode:=gfGrowAll;
  1803. end;
  1804. constructor TFPHeapView.InitKb(var Bounds: TRect);
  1805. begin
  1806. if inherited InitKb(Bounds)=false then Fail;
  1807. Options:=Options or gfGrowHiX or gfGrowHiY;
  1808. EventMask:=EventMask or evIdle;
  1809. GrowMode:=gfGrowAll;
  1810. end;
  1811. procedure TFPHeapView.HandleEvent(var Event: TEvent);
  1812. begin
  1813. case Event.What of
  1814. evIdle :
  1815. Update;
  1816. end;
  1817. inherited HandleEvent(Event);
  1818. end;
  1819. constructor TFPClockView.Init(var Bounds: TRect);
  1820. begin
  1821. inherited Init(Bounds);
  1822. EventMask:=EventMask or evIdle;
  1823. end;
  1824. procedure TFPClockView.HandleEvent(var Event: TEvent);
  1825. begin
  1826. case Event.What of
  1827. evIdle :
  1828. Update;
  1829. end;
  1830. inherited HandleEvent(Event);
  1831. end;
  1832. function TFPClockView.GetPalette: PPalette;
  1833. const P: string[length(CFPClockView)] = CFPClockView;
  1834. begin
  1835. GetPalette:=@P;
  1836. end;
  1837. procedure TFPWindow.SetState(AState: Word; Enable: Boolean);
  1838. var OldState: word;
  1839. begin
  1840. OldState:=State;
  1841. inherited SetState(AState,Enable);
  1842. if AutoNumber then
  1843. if (AState and (sfVisible+sfExposed))<>0 then
  1844. if GetState(sfVisible+sfExposed) then
  1845. begin
  1846. if Number=0 then
  1847. Number:=SearchFreeWindowNo;
  1848. ReDraw;
  1849. end
  1850. else
  1851. Number:=0;
  1852. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  1853. UpdateCommands;
  1854. end;
  1855. procedure TFPWindow.UpdateCommands;
  1856. begin
  1857. end;
  1858. procedure TFPWindow.Update;
  1859. begin
  1860. ReDraw;
  1861. end;
  1862. procedure TFPWindow.SelectInDebugSession;
  1863. var
  1864. F,PrevCurrent : PView;
  1865. begin
  1866. DeskTop^.Lock;
  1867. PrevCurrent:=Desktop^.Current;
  1868. F:=PrevCurrent;
  1869. While assigned(F) and
  1870. ((F^.HelpCtx = hcGDBWindow) or
  1871. (F^.HelpCtx = hcdisassemblyWindow) or
  1872. (F^.HelpCtx = hcWatchesWindow) or
  1873. (F^.HelpCtx = hcStackWindow) or
  1874. (F^.HelpCtx = hcRegistersWindow) or
  1875. (F^.HelpCtx = hcVectorRegisters) or
  1876. (F^.HelpCtx = hcFPURegisters)) do
  1877. F:=F^.NextView;
  1878. if F<>@Self then
  1879. Select;
  1880. if PrevCurrent<>F then
  1881. Begin
  1882. Desktop^.InsertBefore(@self,F);
  1883. PrevCurrent^.Select;
  1884. End;
  1885. DeskTop^.Unlock;
  1886. end;
  1887. procedure TFPWindow.HandleEvent(var Event: TEvent);
  1888. begin
  1889. case Event.What of
  1890. evBroadcast :
  1891. case Event.Command of
  1892. cmUpdate :
  1893. Update;
  1894. cmSearchWindow+1..cmSearchWindow+99 :
  1895. if (Event.Command-cmSearchWindow=Number) then
  1896. ClearEvent(Event);
  1897. end;
  1898. end;
  1899. inherited HandleEvent(Event);
  1900. end;
  1901. constructor TFPWindow.Load(var S: TStream);
  1902. begin
  1903. inherited Load(S);
  1904. S.Read(AutoNumber,SizeOf(AutoNumber));
  1905. end;
  1906. procedure TFPWindow.Store(var S: TStream);
  1907. begin
  1908. inherited Store(S);
  1909. S.Write(AutoNumber,SizeOf(AutoNumber));
  1910. end;
  1911. function TFPHelpViewer.GetLocalMenu: PMenu;
  1912. var M: PMenu;
  1913. begin
  1914. M:=NewMenu(
  1915. {$ifdef DEBUG}
  1916. NewItem(menu_hlplocal_debug,'',kbNoKey,cmHelpDebug,hcHelpDebug,
  1917. {$endif DEBUG}
  1918. NewItem(menu_hlplocal_contents,'',kbNoKey,cmHelpContents,hcHelpContents,
  1919. NewItem(menu_hlplocal_index,menu_key_hlplocal_index,kbShiftF1,cmHelpIndex,hcHelpIndex,
  1920. NewItem(menu_hlplocal_topicsearch,menu_key_hlplocal_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  1921. NewItem(menu_hlplocal_prevtopic,menu_key_hlplocal_prevtopic,kbAltF1,cmHelpPrevTopic,hcHelpPrevTopic,
  1922. NewLine(
  1923. NewItem(menu_hlplocal_copy,menu_key_hlplocal_copy,copy_key,cmCopy,hcCopy,
  1924. nil)))))))
  1925. {$ifdef DEBUG}
  1926. )
  1927. {$endif DEBUG}
  1928. ;
  1929. GetLocalMenu:=M;
  1930. end;
  1931. function TFPHelpViewer.GetCommandTarget: PView;
  1932. begin
  1933. GetCommandTarget:=Application;
  1934. end;
  1935. constructor TFPHelpWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word;
  1936. AContext: THelpCtx; ANumber: Integer);
  1937. begin
  1938. inherited Init(Bounds,ATitle,ASourceFileID,AContext,ANumber);
  1939. HelpCtx:=hcHelpWindow;
  1940. HideOnClose:=true;
  1941. end;
  1942. destructor TFPHelpWindow.Done;
  1943. begin
  1944. if HelpWindow=@Self then
  1945. HelpWindow:=nil;
  1946. Inherited Done;
  1947. end;
  1948. procedure TFPHelpWindow.InitHelpView;
  1949. var R: TRect;
  1950. begin
  1951. GetExtent(R); R.Grow(-1,-1);
  1952. HelpView:=New(PFPHelpViewer, Init(R, HSB, VSB));
  1953. HelpView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1954. end;
  1955. procedure TFPHelpWindow.Show;
  1956. begin
  1957. inherited Show;
  1958. if GetState(sfVisible) and (Number=0) then
  1959. begin
  1960. Number:=SearchFreeWindowNo;
  1961. ReDraw;
  1962. end;
  1963. end;
  1964. procedure TFPHelpWindow.Hide;
  1965. begin
  1966. inherited Hide;
  1967. if GetState(sfVisible)=false then
  1968. Number:=0;
  1969. end;
  1970. procedure TFPHelpWindow.HandleEvent(var Event: TEvent);
  1971. begin
  1972. case Event.What of
  1973. evBroadcast :
  1974. case Event.Command of
  1975. cmUpdate :
  1976. ReDraw;
  1977. cmSearchWindow+1..cmSearchWindow+99 :
  1978. if (Event.Command-cmSearchWindow=Number) then
  1979. ClearEvent(Event);
  1980. end;
  1981. end;
  1982. inherited HandleEvent(Event);
  1983. end;
  1984. function TFPHelpWindow.GetPalette: PPalette;
  1985. const P: string[length(CIDEHelpDialog)] = CIDEHelpDialog;
  1986. begin
  1987. GetPalette:=@P;
  1988. end;
  1989. constructor TFPHelpWindow.Load(var S: TStream);
  1990. begin
  1991. Abstract;
  1992. end;
  1993. procedure TFPHelpWindow.Store(var S: TStream);
  1994. begin
  1995. Abstract;
  1996. end;
  1997. constructor TSourceWindow.Init(var Bounds: TRect; AFileName: string);
  1998. var HSB,VSB: PScrollBar;
  1999. R: TRect;
  2000. PA : Array[1..2] of pointer;
  2001. LoadFile: boolean;
  2002. begin
  2003. inherited Init(Bounds,AFileName,{SearchFreeWindowNo}0);
  2004. AutoNumber:=true;
  2005. Options:=Options or ofTileAble;
  2006. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2007. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2008. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2009. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2010. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2011. New(Indicator, Init(R));
  2012. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2013. Insert(Indicator);
  2014. GetExtent(R); R.Grow(-1,-1);
  2015. LoadFile:=(AFileName<>'') and (AFileName<>'*');
  2016. if (AFileName='') then
  2017. begin
  2018. Inc(GlobalNoNameCount);
  2019. NoNameCount:=GlobalNoNameCount;
  2020. end
  2021. else
  2022. NoNameCount:=-1;
  2023. if AFileName='*' then
  2024. AFileName:='';
  2025. New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
  2026. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2027. if LoadFile then
  2028. begin
  2029. if Editor^.LoadFile=false then
  2030. ErrorBox(FormatStrStr(msg_errorreadingfile,AFileName),nil)
  2031. { warn if modified, but not if modified in another
  2032. already open window PM }
  2033. else if Editor^.GetModified and (Editor^.Core^.GetBindingCount=1) then
  2034. begin
  2035. PA[1]:=@AFileName;
  2036. Ptrint(PA[2]):={Editor^.ChangedLine}-1;
  2037. EditorDialog(edChangedOnloading,@PA);
  2038. end;
  2039. end;
  2040. Insert(Editor);
  2041. {$ifndef NODEBUG}
  2042. If assigned(BreakpointsCollection) then
  2043. BreakpointsCollection^.ShowBreakpoints(@Self);
  2044. {$endif NODEBUG}
  2045. UpdateTitle;
  2046. end;
  2047. procedure TSourceWindow.UpdateTitle;
  2048. var Name: string;
  2049. Count: sw_integer;
  2050. begin
  2051. if Editor^.FileName<>'' then
  2052. begin
  2053. Name:=SmartPath(Editor^.FileName);
  2054. Count:=Editor^.Core^.GetBindingCount;
  2055. if Count>1 then
  2056. begin
  2057. Name:=Name+':'+IntToStr(Editor^.Core^.GetBindingIndex(Editor)+1);
  2058. end;
  2059. SetTitle(Name);
  2060. end
  2061. else if NoNameCount>=0 then
  2062. begin
  2063. SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas');
  2064. end;
  2065. end;
  2066. function TSourceWindow.GetTitle(MaxSize: sw_Integer): TTitleStr;
  2067. begin
  2068. GetTitle:=OptimizePath(inherited GetTitle(255),MaxSize);
  2069. end;
  2070. procedure TSourceWindow.SetTitle(ATitle: string);
  2071. begin
  2072. if Title<>nil then DisposeStr(Title);
  2073. Title:=NewStr(ATitle);
  2074. Frame^.DrawView;
  2075. end;
  2076. procedure TSourceWindow.HandleEvent(var Event: TEvent);
  2077. var DontClear: boolean;
  2078. begin
  2079. case Event.What of
  2080. evBroadcast :
  2081. case Event.Command of
  2082. cmUpdate :
  2083. Update;
  2084. cmUpdateTitle :
  2085. UpdateTitle;
  2086. cmSearchWindow :
  2087. if @Self<>ClipboardWindow then
  2088. ClearEvent(Event);
  2089. end;
  2090. evCommand :
  2091. begin
  2092. DontClear:=false;
  2093. case Event.Command of
  2094. cmHide :
  2095. Hide;
  2096. cmSave :
  2097. if Editor^.IsClipboard=false then
  2098. if (Editor^.FileName='') then
  2099. Editor^.SaveAs
  2100. else
  2101. Editor^.Save;
  2102. cmSaveAs :
  2103. if Editor^.IsClipboard=false then
  2104. Editor^.SaveAs;
  2105. else DontClear:=true;
  2106. end;
  2107. if DontClear=false then ClearEvent(Event);
  2108. end;
  2109. end;
  2110. inherited HandleEvent(Event);
  2111. end;
  2112. procedure TSourceWindow.UpdateCommands;
  2113. var Active: boolean;
  2114. begin
  2115. Active:=GetState(sfActive);
  2116. if Editor^.IsClipboard=false then
  2117. begin
  2118. SetCmdState(SourceCmds+CompileCmds,Active);
  2119. SetCmdState(EditorCmds,Active);
  2120. end;
  2121. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
  2122. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2123. end;
  2124. procedure TSourceWindow.Update;
  2125. begin
  2126. ReDraw;
  2127. end;
  2128. function TSourceWindow.GetPalette: PPalette;
  2129. const P: string[length(CSourceWindow)] = CSourceWindow;
  2130. begin
  2131. GetPalette:=@P;
  2132. end;
  2133. constructor TSourceWindow.Load(var S: TStream);
  2134. begin
  2135. Title:=S.ReadStr;
  2136. PushStatus(FormatStrStr(msg_loadingfile,GetStr(Title)));
  2137. inherited Load(S);
  2138. GetSubViewPtr(S,Indicator);
  2139. GetSubViewPtr(S,Editor);
  2140. {$ifndef NODEBUG}
  2141. If assigned(BreakpointsCollection) then
  2142. BreakpointsCollection^.ShowBreakpoints(@Self);
  2143. {$endif NODEBUG}
  2144. PopStatus;
  2145. end;
  2146. procedure TSourceWindow.Store(var S: TStream);
  2147. begin
  2148. S.WriteStr(Title);
  2149. PushStatus(FormatStrStr(msg_storingfile,GetStr(Title)));
  2150. inherited Store(S);
  2151. PutSubViewPtr(S,Indicator);
  2152. PutSubViewPtr(S,Editor);
  2153. PopStatus;
  2154. end;
  2155. procedure TSourceWindow.Close;
  2156. begin
  2157. inherited Close;
  2158. end;
  2159. destructor TSourceWindow.Done;
  2160. begin
  2161. PushStatus(FormatStrStr(msg_closingfile,GetStr(Title)));
  2162. if not IDEApp.IsClosing then
  2163. Message(Application,evBroadcast,cmSourceWndClosing,@Self);
  2164. inherited Done;
  2165. IDEApp.SourceWindowClosed;
  2166. { if not IDEApp.IsClosing then
  2167. Message(Application,evBroadcast,cmUpdate,@Self);}
  2168. PopStatus;
  2169. end;
  2170. {$ifndef NODEBUG}
  2171. function TGDBSourceEditor.Valid(Command: Word): Boolean;
  2172. var OK: boolean;
  2173. begin
  2174. OK:=TCodeEditor.Valid(Command);
  2175. { do NOT ask for save !!
  2176. if OK and ((Command=cmClose) or (Command=cmQuit)) then
  2177. if IsClipboard=false then
  2178. OK:=SaveAsk; }
  2179. Valid:=OK;
  2180. end;
  2181. procedure TGDBSourceEditor.AddLine(const S: string);
  2182. begin
  2183. if Silent or (IgnoreStringAtEnd and (S=LastCommand)) then exit;
  2184. inherited AddLine(S);
  2185. LimitsChanged;
  2186. end;
  2187. procedure TGDBSourceEditor.AddErrorLine(const S: string);
  2188. begin
  2189. if Silent then exit;
  2190. inherited AddLine(S);
  2191. { display like breakpoints in red }
  2192. SetLineFlagState(GetLineCount-1,lfBreakpoint,true);
  2193. LimitsChanged;
  2194. end;
  2195. const
  2196. GDBReservedCount = 6;
  2197. GDBReservedLongest = 3;
  2198. GDBReserved : array[1..GDBReservedCount] of String[GDBReservedLongest] =
  2199. ('gdb','b','n','s','f','bt');
  2200. function IsGDBReservedWord(const S : string) : boolean;
  2201. var
  2202. i : longint;
  2203. begin
  2204. for i:=1 to GDBReservedCount do
  2205. if (S=GDBReserved[i]) then
  2206. begin
  2207. IsGDBReservedWord:=true;
  2208. exit;
  2209. end;
  2210. IsGDBReservedWord:=false;
  2211. end;
  2212. function TGDBSourceEditor.IsReservedWord(const S: string): boolean;
  2213. begin
  2214. IsReservedWord:=IsGDBReservedWord(S);
  2215. end;
  2216. function TGDBSourceEditor.InsertNewLine: Sw_integer;
  2217. Var
  2218. S : string;
  2219. CommandCalled : boolean;
  2220. begin
  2221. if IsReadOnly then begin InsertNewLine:=-1; Exit; end;
  2222. if CurPos.Y<GetLineCount then S:=GetDisplayText(CurPos.Y) else S:='';
  2223. s:=Copy(S,1,CurPos.X);
  2224. CommandCalled:=false;
  2225. if Pos(GDBPrompt,S)=1 then
  2226. Delete(S,1,length(GDBPrompt));
  2227. {$ifndef NODEBUG}
  2228. if assigned(Debugger) then
  2229. if S<>'' then
  2230. begin
  2231. LastCommand:=S;
  2232. { should be true only if we are at the end ! }
  2233. IgnoreStringAtEnd:=(CurPos.Y=GetLineCount-1) and
  2234. (CurPos.X>=length(RTrim(GetDisplayText(GetLineCount-1))));
  2235. Debugger^.Command(S);
  2236. CommandCalled:=true;
  2237. IgnoreStringAtEnd:=false;
  2238. end
  2239. else if AutoRepeat and (CurPos.Y=GetLineCount-1) then
  2240. begin
  2241. Debugger^.Command(LastCommand);
  2242. CommandCalled:=true;
  2243. end;
  2244. {$endif NODEBUG}
  2245. InsertNewLine:=inherited InsertNewLine;
  2246. If CommandCalled then
  2247. InsertText(GDBPrompt);
  2248. end;
  2249. constructor TGDBWindow.Init(var Bounds: TRect);
  2250. var HSB,VSB: PScrollBar;
  2251. R: TRect;
  2252. begin
  2253. inherited Init(Bounds,dialog_gdbwindow,0);
  2254. Options:=Options or ofTileAble;
  2255. AutoNumber:=true;
  2256. HelpCtx:=hcGDBWindow;
  2257. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2258. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2259. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2260. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2261. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2262. New(Indicator, Init(R));
  2263. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2264. Insert(Indicator);
  2265. GetExtent(R); R.Grow(-1,-1);
  2266. New(Editor, Init(R, HSB, VSB, Indicator, GDBOutputFile));
  2267. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2268. Editor^.SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs);
  2269. if ExistsFile(GDBOutputFile) then
  2270. begin
  2271. if Editor^.LoadFile=false then
  2272. ErrorBox(FormatStrStr(msg_errorreadingfile,GDBOutputFile),nil);
  2273. end
  2274. else
  2275. { Empty files are buggy !! }
  2276. Editor^.AddLine('');
  2277. Insert(Editor);
  2278. {$ifndef NODEBUG}
  2279. {$ifndef GDBMI}
  2280. if assigned(Debugger) then
  2281. Debugger^.SetCommand('width ' + IntToStr(Size.X-1));
  2282. {$endif GDBMI}
  2283. {$endif NODEBUG}
  2284. Editor^.silent:=false;
  2285. Editor^.AutoRepeat:=true;
  2286. Editor^.InsertText(GDBPrompt);
  2287. end;
  2288. procedure TGDBWindow.HandleEvent(var Event: TEvent);
  2289. var DontClear: boolean;
  2290. begin
  2291. case Event.What of
  2292. evCommand :
  2293. begin
  2294. DontClear:=false;
  2295. case Event.Command of
  2296. cmSaveAs :
  2297. Editor^.SaveAs;
  2298. else DontClear:=true;
  2299. end;
  2300. if DontClear=false then ClearEvent(Event);
  2301. end;
  2302. end;
  2303. inherited HandleEvent(Event);
  2304. end;
  2305. destructor TGDBWindow.Done;
  2306. begin
  2307. if @Self=GDBWindow then
  2308. GDBWindow:=nil;
  2309. inherited Done;
  2310. end;
  2311. constructor TGDBWindow.Load(var S: TStream);
  2312. begin
  2313. inherited Load(S);
  2314. GetSubViewPtr(S,Indicator);
  2315. GetSubViewPtr(S,Editor);
  2316. GDBWindow:=@self;
  2317. end;
  2318. procedure TGDBWindow.Store(var S: TStream);
  2319. begin
  2320. inherited Store(S);
  2321. PutSubViewPtr(S,Indicator);
  2322. PutSubViewPtr(S,Editor);
  2323. end;
  2324. function TGDBWindow.GetPalette: PPalette;
  2325. const P: string[length(CSourceWindow)] = CSourceWindow;
  2326. begin
  2327. GetPalette:=@P;
  2328. end;
  2329. procedure TGDBWindow.WriteOutputText(Buf : pchar);
  2330. begin
  2331. {selected normal color ?}
  2332. WriteText(Buf,false);
  2333. end;
  2334. procedure TGDBWindow.WriteErrorText(Buf : pchar);
  2335. begin
  2336. {selected normal color ?}
  2337. WriteText(Buf,true);
  2338. end;
  2339. procedure TGDBWindow.WriteString(Const S : string);
  2340. begin
  2341. Editor^.AddLine(S);
  2342. end;
  2343. procedure TGDBWindow.WriteErrorString(Const S : string);
  2344. begin
  2345. Editor^.AddErrorLine(S);
  2346. end;
  2347. procedure TGDBWindow.WriteText(Buf : pchar;IsError : boolean);
  2348. var p,pe : pchar;
  2349. s : string;
  2350. begin
  2351. p:=buf;
  2352. DeskTop^.Lock;
  2353. While assigned(p) and (p^<>#0) do
  2354. begin
  2355. pe:=strscan(p,#10);
  2356. { if pe-p is more than High(s), discard for this round }
  2357. if (pe<>nil) and (pe-p > high(s)) then
  2358. pe:=nil;
  2359. if (pe<>nil) then
  2360. pe^:=#0;
  2361. s:=strpas(p);
  2362. If IsError then
  2363. Editor^.AddErrorLine(S)
  2364. else
  2365. Editor^.AddLine(S);
  2366. { restore for dispose }
  2367. if pe<>nil then
  2368. pe^:=#10;
  2369. if pe=nil then
  2370. begin
  2371. if strlen(p)<High(s) then
  2372. p:=nil
  2373. else
  2374. p:=p+High(s);
  2375. end
  2376. else
  2377. begin
  2378. p:=pe;
  2379. inc(p);
  2380. end;
  2381. end;
  2382. DeskTop^.Unlock;
  2383. Editor^.Draw;
  2384. end;
  2385. procedure TGDBWindow.UpdateCommands;
  2386. var Active: boolean;
  2387. begin
  2388. Active:=GetState(sfActive);
  2389. SetCmdState([cmSaveAs,cmHide,cmRun],Active);
  2390. SetCmdState(EditorCmds,Active);
  2391. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
  2392. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2393. end;
  2394. function TDisasLineCollection.At(Index: sw_Integer): PDisasLine;
  2395. begin
  2396. At := PDisasLine(Inherited At(Index));
  2397. end;
  2398. constructor TDisassemblyEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  2399. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  2400. begin
  2401. Inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,AFileName);
  2402. GrowMode:=gfGrowHiX+gfGrowHiY;
  2403. SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs{+efHighlightRow});
  2404. New(DisasLines,Init(500,1000));
  2405. Core^.ChangeLinesTo(DisasLines);
  2406. { do not allow to write into that window }
  2407. ReadOnly:=true;
  2408. AddLine('');
  2409. MinAddress:=0;
  2410. MaxAddress:=0;
  2411. CurL:=nil;
  2412. OwnsSource:=false;
  2413. Source:=nil;
  2414. end;
  2415. destructor TDisassemblyEditor.Done;
  2416. begin
  2417. ReleaseSource;
  2418. Inherited Done;
  2419. end;
  2420. procedure TDisassemblyEditor.ReleaseSource;
  2421. begin
  2422. if OwnsSource and assigned(source) then
  2423. begin
  2424. Desktop^.Delete(Source);
  2425. Dispose(Source,Done);
  2426. end;
  2427. OwnsSource:=false;
  2428. Source:=nil;
  2429. CurrentSource:='';
  2430. end;
  2431. procedure TDisassemblyEditor.AddSourceLine(const AFileName: string;line : longint);
  2432. var
  2433. S : String;
  2434. begin
  2435. if AFileName<>CurrentSource then
  2436. begin
  2437. ReleaseSource;
  2438. Source:=SearchOnDesktop(FileName,false);
  2439. if not assigned(Source) then
  2440. begin
  2441. Source:=ITryToOpenFile(nil,AFileName,0,line,false,false,true);
  2442. OwnsSource:=true;
  2443. end
  2444. else
  2445. OwnsSource:=false;
  2446. CurrentSource:=AFileName;
  2447. end;
  2448. if Assigned(Source) and (line>0) then
  2449. S:=Trim(Source^.Editor^.GetLineText(line-1))
  2450. else
  2451. S:='<source not found>';
  2452. CurrentLine:=Line;
  2453. inherited AddLine(AFileName+':'+IntToStr(line)+' '+S);
  2454. { display differently }
  2455. SetLineFlagState(GetLineCount-1,lfSpecialRow,true);
  2456. LimitsChanged;
  2457. end;
  2458. procedure TDisassemblyEditor.AddAssemblyLine(const S: string;AAddress : CORE_ADDR);
  2459. var
  2460. PL : PDisasLine;
  2461. LI : PEditorLineInfo;
  2462. begin
  2463. if AAddress<>0 then
  2464. inherited AddLine('$'+hexstr(AAddress,sizeof(CORE_ADDR)*2)+S)
  2465. else
  2466. inherited AddLine(S);
  2467. PL:=DisasLines^.At(DisasLines^.count-1);
  2468. PL^.Address:=AAddress;
  2469. LI:=PL^.GetEditorInfo(@Self);
  2470. if AAddress<>0 then
  2471. LI^.BeginsWithAsm:=true;
  2472. LimitsChanged;
  2473. if ((AAddress<minaddress) or (minaddress=0)) and (AAddress<>0) then
  2474. MinAddress:=AAddress;
  2475. if (AAddress>maxaddress) or (maxaddress=0) then
  2476. MaxAddress:=AAddress;
  2477. end;
  2478. function TDisassemblyEditor.GetCurrentLine(address : CORE_ADDR) : PDisasLine;
  2479. function IsCorrectLine(PL : PDisasLine) : boolean;
  2480. begin
  2481. IsCorrectLine:=PL^.Address=Address;
  2482. end;
  2483. Var
  2484. PL : PDisasLine;
  2485. begin
  2486. PL:=DisasLines^.FirstThat(@IsCorrectLine);
  2487. if Assigned(PL) then
  2488. begin
  2489. if assigned(CurL) then
  2490. CurL^.SetFlagState(lfDebuggerRow,false);
  2491. SetCurPtr(0,DisasLines^.IndexOf(PL));
  2492. PL^.SetFlags(lfDebuggerRow);
  2493. CurL:=PL;
  2494. TrackCursor(do_not_centre);
  2495. end;
  2496. GetCurrentLine:=PL;
  2497. end;
  2498. { PDisassemblyWindow = ^TDisassemblyWindow;
  2499. TDisassemblyWindow = object(TFPWindow)
  2500. Editor : PDisassemblyEditor;
  2501. Indicator : PIndicator; }
  2502. constructor TDisassemblyWindow.Init(var Bounds: TRect);
  2503. var HSB,VSB: PScrollBar;
  2504. R: TRect;
  2505. begin
  2506. inherited Init(Bounds,dialog_disaswindow,0);
  2507. Options:=Options or ofTileAble;
  2508. AutoNumber:=true;
  2509. HelpCtx:=hcDisassemblyWindow;
  2510. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2511. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2512. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2513. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2514. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2515. New(Indicator, Init(R));
  2516. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2517. Insert(Indicator);
  2518. GetExtent(R); R.Grow(-1,-1);
  2519. New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
  2520. Insert(Editor);
  2521. DisassemblyWindow:=@Self;
  2522. end;
  2523. procedure TDisassemblyWindow.LoadFunction(Const FuncName : string);
  2524. var
  2525. p : pchar;
  2526. begin
  2527. {$ifndef NODEBUG}
  2528. If not assigned(Debugger) then Exit;
  2529. Debugger^.SetCommand('print symbol on');
  2530. Debugger^.SetCommand('width 0xffffffff');
  2531. Debugger^.Command('disas /m '+FuncName);
  2532. p:=StrNew(Debugger^.GetOutput);
  2533. ProcessPChar(p);
  2534. if (Debugger^.IsRunning) and (FuncName='') then
  2535. Editor^.GetCurrentLine(Debugger^.current_pc);
  2536. {$endif NODEBUG}
  2537. end;
  2538. procedure TDisassemblyWindow.LoadAddress(Addr : CORE_ADDR);
  2539. var
  2540. p : pchar;
  2541. begin
  2542. {$ifndef NODEBUG}
  2543. If not assigned(Debugger) then Exit;
  2544. Debugger^.SetCommand('print symbol on');
  2545. Debugger^.SetCommand('width 0xffffffff');
  2546. Debugger^.Command('disas /m 0x'+HexStr(Addr,sizeof(Addr)*2));
  2547. p:=StrNew(Debugger^.GetOutput);
  2548. ProcessPChar(p);
  2549. if Debugger^.IsRunning and
  2550. (Debugger^.current_pc>=Editor^.MinAddress) and
  2551. (Debugger^.current_pc<=Editor^.MaxAddress) then
  2552. Editor^.GetCurrentLine(Debugger^.current_pc);
  2553. {$endif NODEBUG}
  2554. end;
  2555. function TDisassemblyWindow.ProcessPChar(p : pchar) : boolean;
  2556. var
  2557. p1: pchar;
  2558. pline : pchar;
  2559. pos1, pos2, CurLine, PrevLine : longint;
  2560. CurAddr : CORE_ADDR;
  2561. err : word;
  2562. curaddress, cursymofs, CurFile,
  2563. PrevFile, line : string;
  2564. begin
  2565. ProcessPChar:=true;
  2566. Lock;
  2567. Editor^.DisasLines^.FreeAll;
  2568. Editor^.SetFlags(Editor^.GetFlags or efSyntaxHighlight or efKeepLineAttr);
  2569. Editor^.MinAddress:=0;
  2570. Editor^.MaxAddress:=0;
  2571. Editor^.CurL:=nil;
  2572. p1:=p;
  2573. PrevFile:='';
  2574. PrevLine:=0;
  2575. while assigned(p) do
  2576. begin
  2577. pline:=strscan(p,#10);
  2578. if assigned(pline) then
  2579. pline^:=#0;
  2580. line:=trim(strpas(p));
  2581. CurAddr:=0;
  2582. if assigned(pline) then
  2583. begin
  2584. pline^:=#10;
  2585. p:=pline+1;
  2586. end
  2587. else
  2588. p:=nil;
  2589. { now process the line }
  2590. { Remove current position marker }
  2591. if copy(line,1,3)='=> ' then
  2592. begin
  2593. system.delete(line,1,3);
  2594. end;
  2595. { line is hexaddr <symbol+sym_offset at filename:line> assembly }
  2596. pos1:=pos('<',line);
  2597. if pos1>0 then
  2598. begin
  2599. curaddress:=trim(copy(line,1,pos1-1));
  2600. if copy(curaddress,1,2)='0x' then
  2601. curaddress:='$'+copy(curaddress,3,length(curaddress)-2);
  2602. val(curaddress,CurAddr,err);
  2603. if err>0 then
  2604. val(copy(curaddress,1,err-1),CurAddr,err);
  2605. system.delete(line,1,pos1);
  2606. end;
  2607. pos1:=pos(' at ',line);
  2608. pos2:=pos('>',line);
  2609. if (pos1>0) and (pos1 < pos2) then
  2610. begin
  2611. cursymofs:=copy(line,1,pos1-1);
  2612. CurFile:=copy(line,pos1+4,pos2-pos1-4);
  2613. pos1:=pos(':',CurFile);
  2614. if pos1>0 then
  2615. begin
  2616. val(copy(CurFile,pos1+1,high(CurFile)),CurLine,err);
  2617. system.delete(CurFile,pos1,high(CurFile));
  2618. end
  2619. else
  2620. CurLine:=0;
  2621. system.delete(line,1,pos2);
  2622. end
  2623. else { no ' at ' found before '>' }
  2624. begin
  2625. cursymofs:=copy(line,1,pos2-1);
  2626. CurFile:='';
  2627. system.delete(line,1,pos2);
  2628. end;
  2629. if (CurFile<>'') and ((CurFile<>PrevFile) or (CurLine<>PrevLine)) then
  2630. begin
  2631. WriteSourceString(CurFile,CurLine);
  2632. PrevLine:=CurLine;
  2633. PrevFile:=CurFile;
  2634. end;
  2635. WriteDisassemblyString(line,curaddr);
  2636. end;
  2637. StrDispose(p1);
  2638. Editor^.ReleaseSource;
  2639. Editor^.UpdateAttrs(0,attrForceFull);
  2640. If assigned(BreakpointsCollection) then
  2641. BreakpointsCollection^.ShowBreakpoints(@Self);
  2642. Unlock;
  2643. ReDraw;
  2644. end;
  2645. procedure TDisassemblyWindow.HandleEvent(var Event: TEvent);
  2646. begin
  2647. inherited HandleEvent(Event);
  2648. end;
  2649. procedure TDisassemblyWindow.WriteSourceString(Const S : string;line : longint);
  2650. begin
  2651. Editor^.AddSourceLine(S,line);
  2652. end;
  2653. procedure TDisassemblyWindow.WriteDisassemblyString(Const S : string;address : CORE_ADDR);
  2654. begin
  2655. Editor^.AddAssemblyLine(S,address);
  2656. end;
  2657. procedure TDisassemblyWindow.SetCurAddress(address : CORE_ADDR);
  2658. begin
  2659. if (address<Editor^.MinAddress) or (address>Editor^.MaxAddress) then
  2660. LoadAddress(address);
  2661. Editor^.GetCurrentLine(address);
  2662. end;
  2663. procedure TDisassemblyWindow.UpdateCommands;
  2664. var Active: boolean;
  2665. begin
  2666. Active:=GetState(sfActive);
  2667. SetCmdState(SourceCmds+CompileCmds,Active);
  2668. SetCmdState(EditorCmds,Active);
  2669. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  2670. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2671. end;
  2672. function TDisassemblyWindow.GetPalette: PPalette;
  2673. const P: string[length(CSourceWindow)] = CSourceWindow;
  2674. begin
  2675. GetPalette:=@P;
  2676. end;
  2677. destructor TDisassemblyWindow.Done;
  2678. begin
  2679. if @Self=DisassemblyWindow then
  2680. DisassemblyWindow:=nil;
  2681. inherited Done;
  2682. end;
  2683. {$endif NODEBUG}
  2684. constructor TClipboardWindow.Init;
  2685. var R: TRect;
  2686. HSB,VSB: PScrollBar;
  2687. begin
  2688. Desktop^.GetExtent(R);
  2689. inherited Init(R, '*');
  2690. SetTitle(dialog_clipboard);
  2691. HelpCtx:=hcClipboardWindow;
  2692. Number:=wnNoNumber;
  2693. AutoNumber:=true;
  2694. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2695. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2696. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2697. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2698. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2699. New(Indicator, Init(R));
  2700. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2701. Insert(Indicator);
  2702. GetExtent(R); R.Grow(-1,-1);
  2703. New(Editor, Init(R, HSB, VSB, Indicator, ''));
  2704. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2705. Insert(Editor);
  2706. Editor^.SetFlags(Editor^.GetFlags or efUseTabCharacters);
  2707. Hide;
  2708. Clipboard:=Editor;
  2709. end;
  2710. procedure TClipboardWindow.Close;
  2711. begin
  2712. Hide;
  2713. end;
  2714. constructor TClipboardWindow.Load(var S: TStream);
  2715. begin
  2716. inherited Load(S);
  2717. Clipboard:=Editor;
  2718. end;
  2719. procedure TClipboardWindow.Store(var S: TStream);
  2720. begin
  2721. inherited Store(S);
  2722. end;
  2723. destructor TClipboardWindow.Done;
  2724. begin
  2725. inherited Done;
  2726. Clipboard:=nil;
  2727. ClipboardWindow:=nil;
  2728. end;
  2729. constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  2730. begin
  2731. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  2732. GrowMode:=gfGrowHiX+gfGrowHiY;
  2733. New(ModuleNames, Init(50,100));
  2734. NoSelection:=true;
  2735. end;
  2736. function TMessageListBox.GetLocalMenu: PMenu;
  2737. var M: PMenu;
  2738. begin
  2739. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  2740. M:=NewMenu(
  2741. NewItem(menu_msglocal_clear,'',kbNoKey,cmMsgClear,hcMsgClear,
  2742. NewLine(
  2743. NewItem(menu_msglocal_gotosource,'',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  2744. NewItem(menu_msglocal_tracksource,'',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
  2745. NewLine(
  2746. NewItem(menu_msglocal_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  2747. nil)))))));
  2748. GetLocalMenu:=M;
  2749. end;
  2750. procedure TMessageListBox.SetState(AState: Word; Enable: Boolean);
  2751. var OldState: word;
  2752. begin
  2753. OldState:=State;
  2754. inherited SetState(AState,Enable);
  2755. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  2756. SetCmdState([cmSaveAs],Enable);
  2757. end;
  2758. procedure TMessageListBox.HandleEvent(var Event: TEvent);
  2759. var DontClear: boolean;
  2760. begin
  2761. case Event.What of
  2762. evKeyDown :
  2763. begin
  2764. DontClear:=false;
  2765. case Event.KeyCode of
  2766. kbEnter :
  2767. begin
  2768. Message(@Self,evCommand,cmMsgGotoSource,nil);
  2769. ClearEvent(Event);
  2770. exit;
  2771. end;
  2772. else
  2773. DontClear:=true;
  2774. end;
  2775. if not DontClear then
  2776. ClearEvent(Event);
  2777. end;
  2778. evBroadcast :
  2779. case Event.Command of
  2780. cmListItemSelected :
  2781. if Event.InfoPtr=@Self then
  2782. Message(@Self,evCommand,cmMsgTrackSource,nil);
  2783. end;
  2784. evCommand :
  2785. begin
  2786. DontClear:=false;
  2787. case Event.Command of
  2788. cmMsgGotoSource :
  2789. if Range>0 then
  2790. begin
  2791. GotoSource;
  2792. ClearEvent(Event);
  2793. exit;
  2794. end;
  2795. cmMsgTrackSource :
  2796. if Range>0 then
  2797. TrackSource;
  2798. cmMsgClear :
  2799. Clear;
  2800. cmSaveAs :
  2801. SaveAs;
  2802. else
  2803. DontClear:=true;
  2804. end;
  2805. if not DontClear then
  2806. ClearEvent(Event);
  2807. end;
  2808. end;
  2809. inherited HandleEvent(Event);
  2810. end;
  2811. procedure TMessageListBox.AddItem(P: PMessageItem);
  2812. var W : integer;
  2813. begin
  2814. if List=nil then New(List, Init(500,500));
  2815. W:=length(P^.GetText(255));
  2816. if W>MaxWidth then
  2817. begin
  2818. MaxWidth:=W;
  2819. if HScrollBar<>nil then
  2820. HScrollBar^.SetRange(0,MaxWidth);
  2821. end;
  2822. List^.Insert(P);
  2823. SetRange(List^.Count);
  2824. if Focused=List^.Count-1-1 then
  2825. FocusItem(List^.Count-1);
  2826. DrawView;
  2827. end;
  2828. function TMessageListBox.AddModuleName(const Name: string): PString;
  2829. var P: PString;
  2830. begin
  2831. if ModuleNames<>nil then
  2832. P:=ModuleNames^.Add(Name)
  2833. else
  2834. P:=nil;
  2835. AddModuleName:=P;
  2836. end;
  2837. function TMessageListBox.GetText(Item,MaxLen: Sw_Integer): String;
  2838. var P: PMessageItem;
  2839. S: string;
  2840. begin
  2841. P:=List^.At(Item);
  2842. S:=P^.GetText(MaxLen);
  2843. GetText:=copy(S,1,MaxLen);
  2844. end;
  2845. procedure TMessageListBox.Clear;
  2846. begin
  2847. if assigned(List) then
  2848. Dispose(List, Done);
  2849. List:=nil;
  2850. MaxWidth:=0;
  2851. if assigned(ModuleNames) then
  2852. ModuleNames^.FreeAll;
  2853. SetRange(0); DrawView;
  2854. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2855. end;
  2856. procedure TMessageListBox.TrackSource;
  2857. var W: PSourceWindow;
  2858. P: PMessageItem;
  2859. R: TRect;
  2860. Row,Col: sw_integer;
  2861. Found : boolean;
  2862. begin
  2863. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2864. if Range=0 then Exit;
  2865. P:=List^.At(Focused);
  2866. if P^.Row=0 then Exit;
  2867. Desktop^.Lock;
  2868. GetNextEditorBounds(R);
  2869. R.B.Y:=Owner^.Origin.Y;
  2870. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2871. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2872. W:=EditorWindowFile(P^.GetModuleName);
  2873. if assigned(W) then
  2874. begin
  2875. W^.GetExtent(R);
  2876. R.B.Y:=Owner^.Origin.Y;
  2877. W^.ChangeBounds(R);
  2878. W^.Editor^.SetCurPtr(Col,Row);
  2879. end
  2880. else
  2881. W:=TryToOpenFile(@R,P^.GetModuleName,Col,Row,true);
  2882. { Try to find it by browsing }
  2883. if W=nil then
  2884. begin
  2885. Desktop^.UnLock;
  2886. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2887. if found then
  2888. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2889. Desktop^.Lock;
  2890. end;
  2891. if W<>nil then
  2892. begin
  2893. W^.Select;
  2894. W^.Editor^.TrackCursor(do_centre);
  2895. W^.Editor^.SetLineFlagExclusive(lfHighlightRow,Row);
  2896. end;
  2897. if Assigned(Owner) then
  2898. Owner^.Select;
  2899. Desktop^.UnLock;
  2900. end;
  2901. procedure TMessageListBox.GotoSource;
  2902. var W: PSourceWindow;
  2903. P: PMessageItem;
  2904. R:TRect;
  2905. Row,Col: sw_integer;
  2906. Found : boolean;
  2907. Event : TEvent;
  2908. begin
  2909. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2910. if Range=0 then Exit;
  2911. P:=List^.At(Focused);
  2912. if P^.Row=0 then Exit;
  2913. Desktop^.Lock;
  2914. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2915. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2916. W:=EditorWindowFile(P^.GetModuleName);
  2917. if assigned(W) then
  2918. begin
  2919. W^.GetExtent(R);
  2920. if Owner^.Origin.Y>R.A.Y+4 then
  2921. R.B.Y:=Owner^.Origin.Y;
  2922. W^.ChangeBounds(R);
  2923. W^.Editor^.SetCurPtr(Col,Row);
  2924. end
  2925. else
  2926. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2927. { Try to find it by browsing }
  2928. if W=nil then
  2929. begin
  2930. Desktop^.UnLock;
  2931. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2932. if found then
  2933. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2934. Desktop^.Lock;
  2935. end;
  2936. if assigned(W) then
  2937. begin
  2938. { Message(Owner,evCommand,cmClose,nil);
  2939. This calls close on StackWindow
  2940. rendering P invalid
  2941. so postpone it PM }
  2942. W^.GetExtent(R);
  2943. if (P^.TClass<>0) then
  2944. W^.Editor^.SetErrorMessage(P^.GetText(R.B.X-R.A.X));
  2945. W^.Select;
  2946. Owner^.Hide;
  2947. end;
  2948. Desktop^.UnLock;
  2949. if assigned(W) then
  2950. begin
  2951. Event.What:=evCommand;
  2952. Event.command:=cmClose;
  2953. Event.InfoPtr:=nil;
  2954. fpide.PutEvent(Owner,Event);
  2955. end;
  2956. end;
  2957. procedure TMessageListBox.Draw;
  2958. var
  2959. I, J, Item: Sw_Integer;
  2960. NormalColor, SelectedColor, FocusedColor, Color: Word;
  2961. ColWidth, CurCol, Indent: Integer;
  2962. B: TDrawBuffer;
  2963. Text: String;
  2964. SCOff: Byte;
  2965. TC: byte;
  2966. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  2967. begin
  2968. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  2969. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  2970. begin
  2971. NormalColor := GetColor(1);
  2972. FocusedColor := GetColor(3);
  2973. SelectedColor := GetColor(4);
  2974. end else
  2975. begin
  2976. NormalColor := GetColor(2);
  2977. SelectedColor := GetColor(4);
  2978. end;
  2979. if Transparent then
  2980. begin MT(NormalColor); MT(SelectedColor); end;
  2981. if NoSelection then
  2982. SelectedColor:=NormalColor;
  2983. if HScrollBar <> nil then Indent := HScrollBar^.Value
  2984. else Indent := 0;
  2985. ColWidth := Size.X div NumCols + 1;
  2986. for I := 0 to Size.Y - 1 do
  2987. begin
  2988. for J := 0 to NumCols-1 do
  2989. begin
  2990. Item := J*Size.Y + I + TopItem;
  2991. CurCol := J*ColWidth;
  2992. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  2993. (Focused = Item) and (Range > 0) then
  2994. begin
  2995. Color := FocusedColor;
  2996. SetCursor(CurCol+1,I);
  2997. SCOff := 0;
  2998. end
  2999. else if (Item < Range) and IsSelected(Item) then
  3000. begin
  3001. Color := SelectedColor;
  3002. SCOff := 2;
  3003. end
  3004. else
  3005. begin
  3006. Color := NormalColor;
  3007. SCOff := 4;
  3008. end;
  3009. MoveChar(B[CurCol], ' ', Color, ColWidth);
  3010. if Item < Range then
  3011. begin
  3012. Text := GetText(Item, ColWidth + Indent);
  3013. Text := Copy(Text,Indent,ColWidth);
  3014. MoveStr(B[CurCol+1], Text, Color);
  3015. if ShowMarkers then
  3016. begin
  3017. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  3018. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  3019. end;
  3020. end;
  3021. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  3022. end;
  3023. WriteLine(0, I, Size.X, 1, B);
  3024. end;
  3025. end;
  3026. constructor TMessageListBox.Load(var S: TStream);
  3027. begin
  3028. inherited Load(S);
  3029. New(ModuleNames, Init(50,100));
  3030. NoSelection:=true;
  3031. end;
  3032. procedure TMessageListBox.Store(var S: TStream);
  3033. var OL: PCollection;
  3034. ORV: sw_integer;
  3035. begin
  3036. OL:=List; ORV:=Range;
  3037. New(List, Init(1,1)); Range:=0;
  3038. inherited Store(S);
  3039. Dispose(List, Done);
  3040. List:=OL; Range:=ORV;
  3041. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  3042. collection? Pasting here a modified version of TListBox.Store+
  3043. TAdvancedListBox.Store isn't a better solution, since by eventually
  3044. changing the obj-hierarchy you'll always have to modify this, too - BG }
  3045. end;
  3046. destructor TMessageListBox.Done;
  3047. begin
  3048. inherited Done;
  3049. if List<>nil then Dispose(List, Done);
  3050. if ModuleNames<>nil then Dispose(ModuleNames, Done);
  3051. end;
  3052. constructor TMessageItem.Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  3053. begin
  3054. inherited Init;
  3055. TClass:=AClass;
  3056. Text:=NewStr(AText);
  3057. Module:=AModule;
  3058. Row:=ARow; Col:=ACol;
  3059. end;
  3060. function TMessageItem.GetText(MaxLen: Sw_integer): string;
  3061. var S: string;
  3062. begin
  3063. if Text=nil then S:='' else S:=Text^;
  3064. if (Module<>nil) then
  3065. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+S;
  3066. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  3067. GetText:=S;
  3068. end;
  3069. procedure TMessageItem.Selected;
  3070. begin
  3071. end;
  3072. function TMessageItem.GetModuleName: string;
  3073. begin
  3074. GetModuleName:=GetStr(Module);
  3075. end;
  3076. destructor TMessageItem.Done;
  3077. begin
  3078. inherited Done;
  3079. if Text<>nil then DisposeStr(Text);
  3080. { if Module<>nil then DisposeStr(Module);}
  3081. end;
  3082. procedure TFPDlgWindow.HandleEvent(var Event: TEvent);
  3083. begin
  3084. case Event.What of
  3085. evBroadcast :
  3086. case Event.Command of
  3087. cmSearchWindow+1..cmSearchWindow+99 :
  3088. if (Event.Command-cmSearchWindow=Number) then
  3089. ClearEvent(Event);
  3090. end;
  3091. end;
  3092. inherited HandleEvent(Event);
  3093. end;
  3094. (*
  3095. constructor TTab.Init(var Bounds: TRect; ATabDef: PTabDef);
  3096. begin
  3097. inherited Init(Bounds);
  3098. Options:=Options or ofSelectable or ofFirstClick or ofPreProcess or ofPostProcess;
  3099. GrowMode:=gfGrowHiX+gfGrowHiY+gfGrowRel;
  3100. TabDefs:=ATabDef;
  3101. ActiveDef:=-1;
  3102. SelectTab(0);
  3103. ReDraw;
  3104. end;
  3105. function TTab.TabCount: integer;
  3106. var i: integer;
  3107. P: PTabDef;
  3108. begin
  3109. I:=0; P:=TabDefs;
  3110. while (P<>nil) do
  3111. begin
  3112. Inc(I);
  3113. P:=P^.Next;
  3114. end;
  3115. TabCount:=I;
  3116. end;
  3117. function TTab.AtTab(Index: integer): PTabDef;
  3118. var i: integer;
  3119. P: PTabDef;
  3120. begin
  3121. i:=0; P:=TabDefs;
  3122. while (I<Index) do
  3123. begin
  3124. if P=nil then RunError($AA);
  3125. P:=P^.Next;
  3126. Inc(i);
  3127. end;
  3128. AtTab:=P;
  3129. end;
  3130. procedure TTab.SelectTab(Index: integer);
  3131. var P: PTabItem;
  3132. V: PView;
  3133. begin
  3134. if ActiveDef<>Index then
  3135. begin
  3136. if Owner<>nil then Owner^.Lock;
  3137. Lock;
  3138. { --- Update --- }
  3139. if TabDefs<>nil then
  3140. begin
  3141. DefCount:=1;
  3142. while AtTab(DefCount-1)^.Next<>nil do Inc(DefCount);
  3143. end
  3144. else DefCount:=0;
  3145. if ActiveDef<>-1 then
  3146. begin
  3147. P:=AtTab(ActiveDef)^.Items;
  3148. while P<>nil do
  3149. begin
  3150. if P^.View<>nil then Delete(P^.View);
  3151. P:=P^.Next;
  3152. end;
  3153. end;
  3154. ActiveDef:=Index;
  3155. P:=AtTab(ActiveDef)^.Items;
  3156. while P<>nil do
  3157. begin
  3158. if P^.View<>nil then Insert(P^.View);
  3159. P:=P^.Next;
  3160. end;
  3161. V:=AtTab(ActiveDef)^.DefItem;
  3162. if V<>nil then V^.Select;
  3163. ReDraw;
  3164. { --- Update --- }
  3165. UnLock;
  3166. if Owner<>nil then Owner^.UnLock;
  3167. DrawView;
  3168. end;
  3169. end;
  3170. procedure TTab.ChangeBounds(var Bounds: TRect);
  3171. var D: TPoint;
  3172. procedure DoCalcChange(P: PView);
  3173. var
  3174. R: TRect;
  3175. begin
  3176. if P^.Owner=nil then Exit; { it think this is a bug in TV }
  3177. P^.CalcBounds(R, D);
  3178. P^.ChangeBounds(R);
  3179. end;
  3180. var
  3181. P: PTabItem;
  3182. I: integer;
  3183. begin
  3184. D.X := Bounds.B.X - Bounds.A.X - Size.X;
  3185. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y;
  3186. inherited ChangeBounds(Bounds);
  3187. for I:=0 to TabCount-1 do
  3188. if I<>ActiveDef then
  3189. begin
  3190. P:=AtTab(I)^.Items;
  3191. while P<>nil do
  3192. begin
  3193. if P^.View<>nil then DoCalcChange(P^.View);
  3194. P:=P^.Next;
  3195. end;
  3196. end;
  3197. end;
  3198. procedure TTab.SelectNextTab(Forwards: boolean);
  3199. var Index: integer;
  3200. begin
  3201. Index:=ActiveDef;
  3202. if Index=-1 then Exit;
  3203. if Forwards then Inc(Index) else Dec(Index);
  3204. if Index<0 then Index:=DefCount-1 else
  3205. if Index>DefCount-1 then Index:=0;
  3206. SelectTab(Index);
  3207. end;
  3208. procedure TTab.HandleEvent(var Event: TEvent);
  3209. var Index : integer;
  3210. I : integer;
  3211. X : integer;
  3212. Len : byte;
  3213. P : TPoint;
  3214. V : PView;
  3215. CallOrig: boolean;
  3216. LastV : PView;
  3217. FirstV: PView;
  3218. function FirstSelectable: PView;
  3219. var
  3220. FV : PView;
  3221. begin
  3222. FV := First;
  3223. while (FV<>nil) and ((FV^.Options and ofSelectable)=0) and (FV<>Last) do
  3224. FV:=FV^.Next;
  3225. if FV<>nil then
  3226. if (FV^.Options and ofSelectable)=0 then FV:=nil;
  3227. FirstSelectable:=FV;
  3228. end;
  3229. function LastSelectable: PView;
  3230. var
  3231. LV : PView;
  3232. begin
  3233. LV := Last;
  3234. while (LV<>nil) and ((LV^.Options and ofSelectable)=0) and (LV<>First) do
  3235. LV:=LV^.Prev;
  3236. if LV<>nil then
  3237. if (LV^.Options and ofSelectable)=0 then LV:=nil;
  3238. LastSelectable:=LV;
  3239. end;
  3240. begin
  3241. if (Event.What and evMouseDown)<>0 then
  3242. begin
  3243. MakeLocal(Event.Where,P);
  3244. if P.Y<3 then
  3245. begin
  3246. Index:=-1; X:=1;
  3247. for i:=0 to DefCount-1 do
  3248. begin
  3249. Len:=CStrLen(AtTab(i)^.Name^);
  3250. if (P.X>=X) and (P.X<=X+Len+1) then Index:=i;
  3251. X:=X+Len+3;
  3252. end;
  3253. if Index<>-1 then
  3254. SelectTab(Index);
  3255. end;
  3256. end;
  3257. if Event.What=evKeyDown then
  3258. begin
  3259. Index:=-1;
  3260. case Event.KeyCode of
  3261. kbCtrlTab :
  3262. begin
  3263. SelectNextTab((Event.KeyShift and kbShift)=0);
  3264. ClearEvent(Event);
  3265. end;
  3266. kbTab,kbShiftTab :
  3267. if GetState(sfSelected) then
  3268. begin
  3269. if Current<>nil then
  3270. begin
  3271. LastV:=LastSelectable; FirstV:=FirstSelectable;
  3272. if ((Current=LastV) or (Current=PLabel(LastV)^.Link)) and (Event.KeyCode=kbShiftTab) then
  3273. begin
  3274. if Owner<>nil then Owner^.SelectNext(true);
  3275. end else
  3276. if ((Current=FirstV) or (Current=PLabel(FirstV)^.Link)) and (Event.KeyCode=kbTab) then
  3277. begin
  3278. Lock;
  3279. if Owner<>nil then Owner^.SelectNext(false);
  3280. UnLock;
  3281. end else
  3282. SelectNext(Event.KeyCode=kbShiftTab);
  3283. ClearEvent(Event);
  3284. end;
  3285. end;
  3286. else
  3287. for I:=0 to DefCount-1 do
  3288. begin
  3289. if Upcase(GetAltChar(Event.KeyCode))=AtTab(I)^.ShortCut
  3290. then begin
  3291. Index:=I;
  3292. ClearEvent(Event);
  3293. Break;
  3294. end;
  3295. end;
  3296. end;
  3297. if Index<>-1 then
  3298. begin
  3299. Select;
  3300. SelectTab(Index);
  3301. V:=AtTab(ActiveDef)^.DefItem;
  3302. if V<>nil then V^.Focus;
  3303. end;
  3304. end;
  3305. CallOrig:=true;
  3306. if Event.What=evKeyDown then
  3307. begin
  3308. if ((Owner<>nil) and (Owner^.Phase=phPostProcess) and (GetAltChar(Event.KeyCode)<>#0)) or GetState(sfFocused)
  3309. then
  3310. else CallOrig:=false;
  3311. end;
  3312. if CallOrig then inherited HandleEvent(Event);
  3313. end;
  3314. function TTab.GetPalette: PPalette;
  3315. begin
  3316. GetPalette:=nil;
  3317. end;
  3318. procedure TTab.Draw;
  3319. var B : TDrawBuffer;
  3320. i : integer;
  3321. C1,C2,C3,C : word;
  3322. HeaderLen : integer;
  3323. X,X2 : integer;
  3324. Name : PString;
  3325. ActiveKPos : integer;
  3326. ActiveVPos : integer;
  3327. FC : char;
  3328. ClipR : TRect;
  3329. procedure SWriteBuf(X,Y,W,H: integer; var Buf);
  3330. var i: integer;
  3331. begin
  3332. if Y+H>Size.Y then H:=Size.Y-Y;
  3333. if X+W>Size.X then W:=Size.X-X;
  3334. if Buffer=nil then WriteBuf(X,Y,W,H,Buf)
  3335. else for i:=1 to H do
  3336. Move(Buf,Buffer^[X+(Y+i-1)*Size.X],W*2);
  3337. end;
  3338. procedure ClearBuf;
  3339. begin
  3340. MoveChar(B,' ',C1,Size.X);
  3341. end;
  3342. begin
  3343. if InDraw then Exit;
  3344. InDraw:=true;
  3345. { - Start of TGroup.Draw - }
  3346. { if Buffer = nil then
  3347. begin
  3348. GetBuffer;
  3349. end; }
  3350. { - Start of TGroup.Draw - }
  3351. C1:=GetColor(1); C2:=(GetColor(7) and $f0 or $08)+GetColor(9)*256; C3:=GetColor(8)+GetColor({9}8)*256;
  3352. HeaderLen:=0; for i:=0 to DefCount-1 do HeaderLen:=HeaderLen+CStrLen(AtTab(i)^.Name^)+3; Dec(HeaderLen);
  3353. if HeaderLen>Size.X-2 then HeaderLen:=Size.X-2;
  3354. { --- 1. sor --- }
  3355. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[HeaderLen+1],'³',C1,1);
  3356. X:=1;
  3357. for i:=0 to DefCount-1 do
  3358. begin
  3359. Name:=AtTab(i)^.Name; X2:=CStrLen(Name^);
  3360. if i=ActiveDef
  3361. then begin
  3362. ActiveKPos:=X-1;
  3363. ActiveVPos:=X+X2+2;
  3364. if GetState(sfFocused) then C:=C3 else C:=C2;
  3365. end
  3366. else C:=C2;
  3367. MoveCStr(B[X],' '+Name^+' ',C); X:=X+X2+3;
  3368. MoveChar(B[X-1],'³',C1,1);
  3369. end;
  3370. SWriteBuf(0,1,Size.X,1,B);
  3371. { --- 0. sor --- }
  3372. ClearBuf; MoveChar(B[0],'Ú',C1,1);
  3373. X:=1;
  3374. for i:=0 to DefCount-1 do
  3375. begin
  3376. if I<ActiveDef then FC:='Ú'
  3377. else FC:='¿';
  3378. X2:=CStrLen(AtTab(i)^.Name^)+2;
  3379. MoveChar(B[X+X2],{'Â'}FC,C1,1);
  3380. if i=DefCount-1 then X2:=X2+1;
  3381. if X2>0 then
  3382. MoveChar(B[X],'Ä',C1,X2);
  3383. X:=X+X2+1;
  3384. end;
  3385. MoveChar(B[HeaderLen+1],'¿',C1,1);
  3386. MoveChar(B[ActiveKPos],'Ú',C1,1); MoveChar(B[ActiveVPos],'¿',C1,1);
  3387. SWriteBuf(0,0,Size.X,1,B);
  3388. { --- 2. sor --- }
  3389. MoveChar(B[1],'Ä',C1,Max(HeaderLen,0)); MoveChar(B[HeaderLen+2],'Ä',C1,Max(Size.X-HeaderLen-3,0));
  3390. MoveChar(B[Size.X-1],'¿',C1,1);
  3391. MoveChar(B[ActiveKPos],'Ù',C1,1);
  3392. if ActiveDef=0 then MoveChar(B[0],'³',C1,1)
  3393. else MoveChar(B[0],{'Ã'}'Ú',C1,1);
  3394. MoveChar(B[HeaderLen+1],'Ä'{'Á'},C1,1); MoveChar(B[ActiveVPos],'À',C1,1);
  3395. MoveChar(B[ActiveKPos+1],' ',C1,Max(ActiveVPos-ActiveKPos-1,0));
  3396. SWriteBuf(0,2,Size.X,1,B);
  3397. { --- marad‚k sor --- }
  3398. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[Size.X-1],'³',C1,1);
  3399. for i:=3 to Size.Y-1 do
  3400. SWriteBuf(0,i,Size.X,1,B);
  3401. { SWriteBuf(0,3,Size.X,Size.Y-4,B); this was wrong
  3402. because WriteBuf then expect a buffer of size size.x*(size.y-4)*2 PM }
  3403. { --- Size.X . sor --- }
  3404. MoveChar(B[0],'À',C1,1); MoveChar(B[1],'Ä',C1,Max(Size.X-2,0)); MoveChar(B[Size.X-1],'Ù',C1,1);
  3405. SWriteBuf(0,Size.Y-1,Size.X,1,B);
  3406. { - End of TGroup.Draw - }
  3407. if Buffer <> nil then
  3408. begin
  3409. Lock;
  3410. Redraw;
  3411. UnLock;
  3412. end;
  3413. if Buffer <> nil then WriteBuf(0, 0, Size.X, Size.Y, Buffer^) else
  3414. begin
  3415. GetClipRect(ClipR);
  3416. Redraw;
  3417. GetExtent(ClipR);
  3418. end;
  3419. { - End of TGroup.Draw - }
  3420. InDraw:=false;
  3421. end;
  3422. function TTab.Valid(Command: Word): Boolean;
  3423. var PT : PTabDef;
  3424. PI : PTabItem;
  3425. OK : boolean;
  3426. begin
  3427. OK:=true;
  3428. PT:=TabDefs;
  3429. while (PT<>nil) and (OK=true) do
  3430. begin
  3431. PI:=PT^.Items;
  3432. while (PI<>nil) and (OK=true) do
  3433. begin
  3434. if PI^.View<>nil then OK:=OK and PI^.View^.Valid(Command);
  3435. PI:=PI^.Next;
  3436. end;
  3437. PT:=PT^.Next;
  3438. end;
  3439. Valid:=OK;
  3440. end;
  3441. procedure TTab.SetState(AState: Word; Enable: Boolean);
  3442. begin
  3443. inherited SetState(AState,Enable);
  3444. if (AState and sfFocused)<>0 then DrawView;
  3445. end;
  3446. destructor TTab.Done;
  3447. var P,X: PTabDef;
  3448. procedure DeleteViews(P: PView);
  3449. begin
  3450. if P<>nil then Delete(P);
  3451. end;
  3452. begin
  3453. ForEach(@DeleteViews);
  3454. inherited Done;
  3455. P:=TabDefs;
  3456. while P<>nil do
  3457. begin
  3458. X:=P^.Next;
  3459. DisposeTabDef(P);
  3460. P:=X;
  3461. end;
  3462. end;
  3463. *)
  3464. constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  3465. AScreen: PScreen);
  3466. begin
  3467. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  3468. Screen:=AScreen;
  3469. if Screen=nil then
  3470. Fail;
  3471. SetState(sfCursorVis,true);
  3472. Update;
  3473. end;
  3474. procedure TScreenView.Update;
  3475. begin
  3476. SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
  3477. DrawView;
  3478. end;
  3479. procedure TScreenView.HandleEvent(var Event: TEvent);
  3480. begin
  3481. case Event.What of
  3482. evBroadcast :
  3483. case Event.Command of
  3484. cmUpdate : Update;
  3485. end;
  3486. end;
  3487. inherited HandleEvent(Event);
  3488. end;
  3489. procedure TScreenView.Draw;
  3490. var B: TDrawBuffer;
  3491. X,Y: integer;
  3492. Text,Attr: string;
  3493. P: TPoint;
  3494. begin
  3495. Screen^.GetCursorPos(P);
  3496. for Y:=Delta.Y to Delta.Y+Size.Y-1 do
  3497. begin
  3498. if Y<Screen^.GetHeight then
  3499. Screen^.GetLine(Y,Text,Attr)
  3500. else
  3501. begin Text:=''; Attr:=''; end;
  3502. Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
  3503. MoveChar(B,' ',GetColor(1),Size.X);
  3504. for X:=1 to length(Text) do
  3505. MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
  3506. WriteLine(0,Y-Delta.Y,Size.X,1,B);
  3507. end;
  3508. SetCursor(P.X-Delta.X,P.Y-Delta.Y);
  3509. end;
  3510. constructor TScreenWindow.Init(AScreen: PScreen; ANumber: integer);
  3511. var R: TRect;
  3512. VSB,HSB: PScrollBar;
  3513. begin
  3514. Desktop^.GetExtent(R);
  3515. inherited Init(R, dialog_userscreen, ANumber);
  3516. Options:=Options or ofTileAble;
  3517. GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
  3518. New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
  3519. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  3520. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
  3521. New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
  3522. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  3523. GetExtent(R); R.Grow(-1,-1);
  3524. New(ScreenView, Init(R, HSB, VSB, AScreen));
  3525. ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  3526. Insert(ScreenView);
  3527. UserScreenWindow:=@Self;
  3528. end;
  3529. destructor TScreenWindow.Done;
  3530. begin
  3531. inherited Done;
  3532. UserScreenWindow:=nil;
  3533. end;
  3534. const InTranslate : boolean = false;
  3535. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  3536. procedure TranslateAction(Action: integer);
  3537. var E: TEvent;
  3538. begin
  3539. if Action<>acNone then
  3540. begin
  3541. E:=Event;
  3542. E.What:=evMouseDown; E.Buttons:=mbLeftButton;
  3543. View^.HandleEvent(E);
  3544. Event.What:=evCommand;
  3545. Event.Command:=ActionCommands[Action];
  3546. end;
  3547. end;
  3548. begin
  3549. if InTranslate then Exit;
  3550. InTranslate:=true;
  3551. case Event.What of
  3552. evMouseDown :
  3553. if (GetShiftState and kbAlt)<>0 then
  3554. TranslateAction(AltMouseAction) else
  3555. if (GetShiftState and kbCtrl)<>0 then
  3556. TranslateAction(CtrlMouseAction);
  3557. end;
  3558. InTranslate:=false;
  3559. end;
  3560. function GetNextEditorBounds(var Bounds: TRect): boolean;
  3561. var P: PView;
  3562. begin
  3563. P:=Desktop^.Current;
  3564. while P<>nil do
  3565. begin
  3566. if P^.HelpCtx=hcSourceWindow then Break;
  3567. P:=P^.NextView;
  3568. if P=Desktop^.Current then
  3569. begin
  3570. P:=nil;
  3571. break;
  3572. end;
  3573. end;
  3574. if P=nil then Desktop^.GetExtent(Bounds) else
  3575. begin
  3576. P^.GetBounds(Bounds);
  3577. Inc(Bounds.A.X); Inc(Bounds.A.Y);
  3578. end;
  3579. GetNextEditorBounds:=P<>nil;
  3580. end;
  3581. function IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
  3582. var R: TRect;
  3583. W: PSourceWindow;
  3584. begin
  3585. if Assigned(Bounds) then R.Copy(Bounds^) else
  3586. GetNextEditorBounds(R);
  3587. PushStatus(FormatStrStr(msg_openingsourcefile,SmartPath(FileName)));
  3588. New(W, Init(R, FileName));
  3589. if ShowIt=false then
  3590. W^.Hide;
  3591. if W<>nil then
  3592. begin
  3593. if (CurX<>0) or (CurY<>0) then
  3594. with W^.Editor^ do
  3595. begin
  3596. SetCurPtr(CurX,CurY);
  3597. TrackCursor(do_centre);
  3598. end;
  3599. W^.HelpCtx:=hcSourceWindow;
  3600. Desktop^.Insert(W);
  3601. { this makes loading a lot slower and is not needed as far as I can see (FK)
  3602. Message(Application,evBroadcast,cmUpdate,nil);
  3603. }
  3604. end;
  3605. PopStatus;
  3606. IOpenEditorWindow:=W;
  3607. end;
  3608. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  3609. begin
  3610. OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
  3611. end;
  3612. function LastSourceEditor : PSourceWindow;
  3613. function IsSearchedSource(P: PView) : boolean;
  3614. begin
  3615. if assigned(P) and
  3616. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  3617. IsSearchedSource:=true
  3618. else
  3619. IsSearchedSource:=false;
  3620. end;
  3621. begin
  3622. LastSourceEditor:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  3623. end;
  3624. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  3625. var
  3626. D,DS : DirStr;
  3627. N,NS : NameStr;
  3628. E,ES : ExtStr;
  3629. SName : string;
  3630. function IsSearchedFile(W : PSourceWindow) : boolean;
  3631. var Found: boolean;
  3632. begin
  3633. Found:=false;
  3634. if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
  3635. begin
  3636. if (D='') then
  3637. SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
  3638. else
  3639. SName:=PSourceWindow(W)^.Editor^.FileName;
  3640. FSplit(SName,DS,NS,ES);
  3641. SName:=UpcaseStr(NS+ES);
  3642. if (E<>'') or (not tryexts) then
  3643. begin
  3644. if D<>'' then
  3645. Found:=UpCaseStr(DS)+SName=UpcaseStr(D+N+E)
  3646. else
  3647. Found:=SName=UpcaseStr(N+E);
  3648. end
  3649. else
  3650. begin
  3651. Found:=SName=UpcaseStr(N+'.pp');
  3652. if Found=false then
  3653. Found:=SName=UpcaseStr(N+'.pas');
  3654. end;
  3655. end;
  3656. IsSearchedFile:=found;
  3657. end;
  3658. function IsSearchedSource(P: PView) : boolean;
  3659. begin
  3660. if assigned(P) and
  3661. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  3662. IsSearchedSource:=IsSearchedFile(PSourceWindow(P))
  3663. else
  3664. IsSearchedSource:=false;
  3665. end;
  3666. begin
  3667. FSplit(FileName,D,N,E);
  3668. SearchOnDesktop:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  3669. end;
  3670. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  3671. begin
  3672. TryToOpenFile:=ITryToOpenFile(Bounds,FileName,CurX,CurY,tryexts,true,false);
  3673. end;
  3674. function TryToOpenFileMulti(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  3675. var srec:SearchRec;
  3676. dir,name,ext : string;
  3677. begin
  3678. fsplit(filename,dir,name,ext);
  3679. dir:=completedir(dir);
  3680. FindFirst(filename,anyfile,Srec);
  3681. while (DosError=0) do
  3682. begin
  3683. ITryToOpenFile(Bounds,dir+srec.name,CurX,CurY,tryexts,true,false);
  3684. FindNext(srec);
  3685. end;
  3686. FindClose(srec);
  3687. end;
  3688. function LocateSingleSourceFile(const FileName: string; tryexts: boolean): string;
  3689. var D : DirStr;
  3690. N : NameStr;
  3691. E : ExtStr;
  3692. function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
  3693. var OK: boolean;
  3694. begin
  3695. NewDir:=CompleteDir(NewDir);
  3696. OK:=ExistsFile(NewDir+NewName+NewExt);
  3697. if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
  3698. CheckDir:=OK;
  3699. end;
  3700. function CheckExt(NewExt: ExtStr): boolean;
  3701. var OK: boolean;
  3702. begin
  3703. OK:=false;
  3704. if D<>'' then OK:=CheckDir(D,N,NewExt) else
  3705. if CheckDir('.'+DirSep,N,NewExt) then OK:=true;
  3706. CheckExt:=OK;
  3707. end;
  3708. function TryToLocateIn(const DD : dirstr): boolean;
  3709. var Found: boolean;
  3710. begin
  3711. D:=CompleteDir(DD);
  3712. Found:=true;
  3713. if (E<>'') or (not tryexts) then
  3714. Found:=CheckExt(E)
  3715. else
  3716. if CheckExt('.pp') then
  3717. Found:=true
  3718. else
  3719. if CheckExt('.pas') then
  3720. Found:=true
  3721. else
  3722. if CheckExt('.inc') then
  3723. Found:=true
  3724. { try also without extension if no other exist }
  3725. else
  3726. if CheckExt('') then
  3727. Found:=true
  3728. else
  3729. Found:=false;
  3730. TryToLocateIn:=Found;
  3731. end;
  3732. var Path,DrStr: string;
  3733. Found: boolean;
  3734. begin
  3735. FSplit(FileName,D,N,E);
  3736. Found:=CheckDir(D,N,E);
  3737. if not found then
  3738. Found:=TryToLocateIn('.');
  3739. DrStr:=GetSourceDirectories;
  3740. if not Found then
  3741. While pos(ListSeparator,DrStr)>0 do
  3742. Begin
  3743. Found:=TryToLocateIn(Copy(DrStr,1,pos(ListSeparator,DrStr)-1));
  3744. if Found then
  3745. break;
  3746. DrStr:=Copy(DrStr,pos(ListSeparator,DrStr)+1,High(DrStr));
  3747. End;
  3748. if Found then Path:=FExpand(D+N+E) else Path:='';
  3749. LocateSingleSourceFile:=Path;
  3750. end;
  3751. function LocateSourceFile(const FileName: string; tryexts: boolean): string;
  3752. var P: integer;
  3753. FN,S: string;
  3754. FFN: string;
  3755. begin
  3756. FN:=FileName;
  3757. repeat
  3758. P:=Pos(ListSeparator,FN); if P=0 then P:=length(FN)+1;
  3759. S:=copy(FN,1,P-1); Delete(FN,1,P);
  3760. FFN:=LocateSingleSourceFile(S,tryexts);
  3761. until (FFN<>'') or (FN='');
  3762. LocateSourceFile:=FFN;
  3763. end;
  3764. function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean;
  3765. ShowIt,ForceNewWindow: boolean): PSourceWindow;
  3766. var
  3767. W : PSourceWindow;
  3768. DrStr: string;
  3769. begin
  3770. W:=nil;
  3771. if ForceNewWindow then
  3772. W:=nil
  3773. else
  3774. W:=SearchOnDesktop(FileName,tryexts);
  3775. if W<>nil then
  3776. begin
  3777. NewEditorOpened:=false;
  3778. { if assigned(Bounds) then
  3779. W^.ChangeBounds(Bounds^);}
  3780. W^.Editor^.SetCurPtr(CurX,CurY);
  3781. end
  3782. else
  3783. begin
  3784. DrStr:=LocateSourceFile(FileName,tryexts);
  3785. if DrStr<>'' then
  3786. W:=IOpenEditorWindow(Bounds,DrStr,CurX,CurY,ShowIt);
  3787. NewEditorOpened:=W<>nil;
  3788. if assigned(W) then
  3789. W^.Editor^.SetCurPtr(CurX,CurY);
  3790. end;
  3791. ITryToOpenFile:=W;
  3792. end;
  3793. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  3794. var OK: boolean;
  3795. E: PFileEditor;
  3796. R: TRect;
  3797. begin
  3798. R.Assign(0,0,0,0);
  3799. New(E, Init(R,nil,nil,nil,nil,FileName));
  3800. OK:=E<>nil;
  3801. if OK then
  3802. begin
  3803. PushStatus(FormatStrStr(msg_readingfileineditor,FileName));
  3804. OK:=E^.LoadFile;
  3805. PopStatus;
  3806. end;
  3807. if OK then
  3808. begin
  3809. Editor^.Lock;
  3810. E^.SelectAll(true);
  3811. Editor^.InsertFrom(E);
  3812. Editor^.SetCurPtr(0,0);
  3813. Editor^.SelectAll(false);
  3814. Editor^.UnLock;
  3815. Dispose(E, Done);
  3816. end;
  3817. StartEditor:=OK;
  3818. end;
  3819. constructor TTextScroller.Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  3820. begin
  3821. inherited Init(Bounds,'');
  3822. EventMask:=EventMask or evIdle;
  3823. Speed:=ASpeed; Lines:=AText;
  3824. end;
  3825. function TTextScroller.GetLineCount: integer;
  3826. var Count: integer;
  3827. begin
  3828. if Lines=nil then Count:=0 else
  3829. Count:=Lines^.Count;
  3830. GetLineCount:=Count;
  3831. end;
  3832. function TTextScroller.GetLine(I: integer): string;
  3833. var S: string;
  3834. begin
  3835. if I<Lines^.Count then
  3836. S:=GetStr(Lines^.At(I))
  3837. else
  3838. S:='';
  3839. GetLine:=S;
  3840. end;
  3841. procedure TTextScroller.HandleEvent(var Event: TEvent);
  3842. begin
  3843. case Event.What of
  3844. evIdle :
  3845. Update;
  3846. end;
  3847. inherited HandleEvent(Event);
  3848. end;
  3849. procedure TTextScroller.Update;
  3850. begin
  3851. if abs(GetDosTicks-LastTT)<Speed then Exit;
  3852. Scroll;
  3853. LastTT:=GetDosTicks;
  3854. end;
  3855. procedure TTextScroller.Reset;
  3856. begin
  3857. TopLine:=0;
  3858. LastTT:=GetDosTicks;
  3859. DrawView;
  3860. end;
  3861. procedure TTextScroller.Scroll;
  3862. begin
  3863. Inc(TopLine);
  3864. if TopLine>=GetLineCount then
  3865. Reset;
  3866. DrawView;
  3867. end;
  3868. procedure TTextScroller.Draw;
  3869. var B: TDrawBuffer;
  3870. C: word;
  3871. Count,Y: integer;
  3872. S: string;
  3873. begin
  3874. C:=GetColor(1);
  3875. Count:=GetLineCount;
  3876. for Y:=0 to Size.Y-1 do
  3877. begin
  3878. if Count=0 then S:='' else
  3879. S:=GetLine((TopLine+Y) mod Count);
  3880. if copy(S,1,1)=^C then
  3881. S:=CharStr(' ',Max(0,(Size.X-(length(S)-1)) div 2))+copy(S,2,255);
  3882. MoveChar(B,' ',C,Size.X);
  3883. MoveStr(B,S,C);
  3884. WriteLine(0,Y,Size.X,1,B);
  3885. end;
  3886. end;
  3887. destructor TTextScroller.Done;
  3888. begin
  3889. inherited Done;
  3890. if Lines<>nil then Dispose(Lines, Done);
  3891. end;
  3892. constructor TFPAboutDialog.Init;
  3893. var R,R2: TRect;
  3894. C: PUnsortedStringCollection;
  3895. I: integer;
  3896. OSStr: string;
  3897. procedure AddLine(S: string);
  3898. begin
  3899. C^.Insert(NewStr(S));
  3900. end;
  3901. begin
  3902. R.Assign(0,0,58,14{$ifdef NODEBUG}-1{$endif});
  3903. inherited Init(R, dialog_about);
  3904. HelpCtx:=hcAbout;
  3905. GetExtent(R); R.Grow(-3,-2);
  3906. R2.Copy(R); R2.B.Y:=R2.A.Y+1;
  3907. Insert(New(PStaticText, Init(R2, ^C'Free Pascal IDE for '+source_info.name)));
  3908. R2.Move(0,1);
  3909. Insert(New(PStaticText, Init(R2, ^C'Target CPU: '+target_cpu_string)));
  3910. R2.Move(0,1);
  3911. Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr+' '+{$i %date%})));
  3912. R2.Move(0,1);
  3913. {$ifdef USE_GRAPH_SWITCH}
  3914. Insert(New(PStaticText, Init(R2, ^C'With Graphic Support')));
  3915. R2.Move(0,1);
  3916. {$endif USE_GRAPH_SWITCH}
  3917. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_compilerversion,Full_Version_String))));
  3918. {$ifndef NODEBUG}
  3919. if pos('Fake',GDBVersion)=0 then
  3920. begin
  3921. R2.Move(0,1);
  3922. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_debugger,GDBVersion))));
  3923. R2.Move(0,1);
  3924. end
  3925. else
  3926. {$endif NODEBUG}
  3927. R2.Move(0,2);
  3928. Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-2014 by')));
  3929. R2.Move(0,2);
  3930. Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
  3931. R2.Move(0,1);
  3932. Insert(New(PStaticText, Init(R2, ^C'Pierre Muller')));
  3933. R2.Move(0,1);
  3934. Insert(New(PStaticText, Init(R2, ^C'and')));
  3935. R2.Move(0,1);
  3936. Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
  3937. New(C, Init(50,10));
  3938. for I:=1 to 7 do
  3939. AddLine('');
  3940. AddLine(^C'< Original concept >');
  3941. AddLine(^C'Borland International, Inc.');
  3942. AddLine('');
  3943. AddLine(^C'< Compiler development >');
  3944. AddLine(^C'Carl-Eric Codere');
  3945. AddLine(^C'Daniel Mantione');
  3946. AddLine(^C'Florian Kl„mpfl');
  3947. AddLine(^C'Jonas Maebe');
  3948. AddLine(^C'Mich„el Van Canneyt');
  3949. AddLine(^C'Peter Vreman');
  3950. AddLine(^C'Pierre Muller');
  3951. AddLine('');
  3952. AddLine(^C'< IDE development >');
  3953. AddLine(^C'B‚rczi G bor');
  3954. AddLine(^C'Peter Vreman');
  3955. AddLine(^C'Pierre Muller');
  3956. AddLine('');
  3957. GetExtent(R);
  3958. R.Grow(-1,-1); Inc(R.A.Y,3);
  3959. New(Scroller, Init(R, 10, C));
  3960. Scroller^.Hide;
  3961. Insert(Scroller);
  3962. R.Move(0,-1); R.B.Y:=R.A.Y+1;
  3963. New(TitleST, Init(R, ^C'Team'));
  3964. TitleST^.Hide;
  3965. Insert(TitleST);
  3966. InsertOK(@Self);
  3967. end;
  3968. procedure TFPAboutDialog.ToggleInfo;
  3969. begin
  3970. if Scroller=nil then Exit;
  3971. if Scroller^.GetState(sfVisible) then
  3972. begin
  3973. Scroller^.Hide;
  3974. TitleST^.Hide;
  3975. end
  3976. else
  3977. begin
  3978. Scroller^.Reset;
  3979. Scroller^.Show;
  3980. TitleST^.Show;
  3981. end;
  3982. end;
  3983. procedure TFPAboutDialog.HandleEvent(var Event: TEvent);
  3984. begin
  3985. case Event.What of
  3986. evKeyDown :
  3987. case Event.KeyCode of
  3988. kbAltI : { just like in BP }
  3989. begin
  3990. ToggleInfo;
  3991. ClearEvent(Event);
  3992. end;
  3993. end;
  3994. end;
  3995. inherited HandleEvent(Event);
  3996. end;
  3997. constructor TFPASCIIChart.Init;
  3998. begin
  3999. inherited Init;
  4000. HelpCtx:=hcASCIITableWindow;
  4001. Number:=SearchFreeWindowNo;
  4002. ASCIIChart:=@Self;
  4003. end;
  4004. procedure TFPASCIIChart.Store(var S: TStream);
  4005. begin
  4006. inherited Store(S);
  4007. end;
  4008. constructor TFPASCIIChart.Load(var S: TStream);
  4009. begin
  4010. inherited Load(S);
  4011. end;
  4012. procedure TFPASCIIChart.HandleEvent(var Event: TEvent);
  4013. var W: PSourceWindow;
  4014. begin
  4015. {writeln(stderr,'all what=',event.what,' cmd=', event.command);}
  4016. case Event.What of
  4017. evKeyDown :
  4018. case Event.KeyCode of
  4019. kbEsc :
  4020. begin
  4021. Close;
  4022. ClearEvent(Event);
  4023. end;
  4024. end;
  4025. evCommand :
  4026. begin
  4027. {writeln(stderr,'fpascii what=',event.what, ' cmd=', event.command, ' ',cmtransfer,' ',cmsearchwindow);}
  4028. if Event.Command=(AsciiTableCommandBase+1) then // variable
  4029. begin
  4030. W:=FirstEditorWindow;
  4031. if Assigned(W) and Assigned(Report) then
  4032. Message(W,evCommand,cmAddChar,Event.InfoPtr);
  4033. ClearEvent(Event);
  4034. end
  4035. else
  4036. case Event.Command of
  4037. cmTransfer :
  4038. begin
  4039. W:=FirstEditorWindow;
  4040. if Assigned(W) and Assigned(Report) then
  4041. Message(W,evCommand,cmAddChar,pointer(ptrint(ord(Report^.AsciiChar))));
  4042. ClearEvent(Event);
  4043. end;
  4044. cmSearchWindow+1..cmSearchWindow+99 :
  4045. if (Event.Command-cmSearchWindow=Number) then
  4046. ClearEvent(Event);
  4047. end;
  4048. end;
  4049. end;
  4050. inherited HandleEvent(Event);
  4051. end;
  4052. destructor TFPASCIIChart.Done;
  4053. begin
  4054. ASCIIChart:=nil;
  4055. inherited Done;
  4056. end;
  4057. function TVideoModeListBox.GetText(Item: pointer; MaxLen: sw_integer): string;
  4058. var P: PVideoMode;
  4059. S: string;
  4060. begin
  4061. P:=Item;
  4062. S:=IntToStr(P^.Col)+'x'+IntToStr(P^.Row)+' ';
  4063. if P^.Color then
  4064. S:=S+'color'
  4065. else
  4066. S:=S+'mono';
  4067. GetText:=copy(S,1,MaxLen);
  4068. end;
  4069. constructor TFPDesktop.Init(var Bounds: TRect);
  4070. begin
  4071. inherited Init(Bounds);
  4072. end;
  4073. procedure TFPDesktop.InitBackground;
  4074. var AV: PANSIBackground;
  4075. FileName: string;
  4076. R: TRect;
  4077. begin
  4078. AV:=nil;
  4079. FileName:=LocateFile(BackgroundPath);
  4080. if FileName<>'' then
  4081. begin
  4082. GetExtent(R);
  4083. New(AV, Init(R));
  4084. AV^.GrowMode:=gfGrowHiX+gfGrowHiY;
  4085. if AV^.LoadFile(FileName)=false then
  4086. begin
  4087. Dispose(AV, Done); AV:=nil;
  4088. end;
  4089. if Assigned(AV) then
  4090. Insert(AV);
  4091. end;
  4092. Background:=AV;
  4093. if Assigned(Background)=false then
  4094. inherited InitBackground;
  4095. end;
  4096. constructor TFPDesktop.Load(var S: TStream);
  4097. begin
  4098. inherited Load(S);
  4099. end;
  4100. procedure TFPDesktop.Store(var S: TStream);
  4101. begin
  4102. inherited Store(S);
  4103. end;
  4104. constructor TFPToolTip.Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  4105. begin
  4106. inherited Init(Bounds);
  4107. SetAlign(AAlign);
  4108. SetText(AText);
  4109. end;
  4110. procedure TFPToolTip.Draw;
  4111. var C: word;
  4112. procedure DrawLine(Y: integer; S: string);
  4113. var B: TDrawBuffer;
  4114. begin
  4115. S:=copy(S,1,Size.X-2);
  4116. case Align of
  4117. alLeft : S:=' '+S;
  4118. alRight : S:=LExpand(' '+S,Size.X);
  4119. alCenter : S:=Center(S,Size.X);
  4120. end;
  4121. MoveChar(B,' ',C,Size.X);
  4122. MoveStr(B,S,C);
  4123. WriteLine(0,Y,Size.X,1,B);
  4124. end;
  4125. var S: string;
  4126. Y: integer;
  4127. begin
  4128. C:=GetColor(1);
  4129. S:=GetText;
  4130. for Y:=0 to Size.Y-1 do
  4131. DrawLine(Y,S);
  4132. end;
  4133. function TFPToolTip.GetText: string;
  4134. begin
  4135. GetText:=GetStr(Text);
  4136. end;
  4137. procedure TFPToolTip.SetText(const AText: string);
  4138. begin
  4139. if AText<>GetText then
  4140. begin
  4141. if Assigned(Text) then DisposeStr(Text);
  4142. Text:=NewStr(AText);
  4143. DrawView;
  4144. end;
  4145. end;
  4146. function TFPToolTip.GetAlign: TAlign;
  4147. begin
  4148. GetAlign:=Align;
  4149. end;
  4150. procedure TFPToolTip.SetAlign(AAlign: TAlign);
  4151. begin
  4152. if AAlign<>Align then
  4153. begin
  4154. Align:=AAlign;
  4155. DrawView;
  4156. end;
  4157. end;
  4158. destructor TFPToolTip.Done;
  4159. begin
  4160. if Assigned(Text) then DisposeStr(Text); Text:=nil;
  4161. inherited Done;
  4162. end;
  4163. function TFPToolTip.GetPalette: PPalette;
  4164. const S: string[length(CFPToolTip)] = CFPToolTip;
  4165. begin
  4166. GetPalette:=@S;
  4167. end;
  4168. constructor TFPMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4169. PScrollBar; AIndicator: PIndicator);
  4170. begin
  4171. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,nil);
  4172. SetFlags(Flags and not (efPersistentBlocks) or efSyntaxHighlight);
  4173. end;
  4174. procedure TFPMemo.HandleEvent(var Event: TEvent);
  4175. var DontClear: boolean;
  4176. S: string;
  4177. begin
  4178. case Event.What of
  4179. evKeyDown :
  4180. begin
  4181. DontClear:=false;
  4182. case Event.KeyCode of
  4183. kbEsc:
  4184. begin
  4185. Event.What:=evCommand;
  4186. Event.Command:=cmCancel;
  4187. PutEvent(Event);
  4188. end;
  4189. else DontClear:=true;
  4190. end;
  4191. if not DontClear then ClearEvent(Event);
  4192. end;
  4193. end;
  4194. inherited HandleEvent(Event);
  4195. end;
  4196. function TFPMemo.GetPalette: PPalette;
  4197. const P: string[length(CFPMemo)] = CFPMemo;
  4198. begin
  4199. GetPalette:=@P;
  4200. end;
  4201. function TFPMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4202. begin
  4203. GetSpecSymbolCount:=0;
  4204. end;
  4205. function TFPMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4206. begin
  4207. Abstract;
  4208. GetSpecSymbol:=nil;
  4209. end;
  4210. function TFPMemo.IsReservedWord(const S: string): boolean;
  4211. begin
  4212. IsReservedWord:=false;
  4213. end;
  4214. constructor TFPCodeMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4215. PScrollBar; AIndicator: PIndicator);
  4216. begin
  4217. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator);
  4218. end;
  4219. function TFPCodeMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4220. begin
  4221. GetSpecSymbolCount:=FreePascalSpecSymbolCount[SpecClass];
  4222. end;
  4223. function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4224. begin
  4225. GetSpecSymbol:=@FreePascalEmptyString;
  4226. case SpecClass of
  4227. ssCommentPrefix :
  4228. case Index of
  4229. 0 : GetSpecSymbol:=@FreePascalCommentPrefix1;
  4230. 1 : GetSpecSymbol:=@FreePascalCommentPrefix2;
  4231. 2 : GetSpecSymbol:=@FreePascalCommentPrefix3;
  4232. end;
  4233. ssCommentSingleLinePrefix :
  4234. case Index of
  4235. 0 : GetSpecSymbol:=@FreePascalCommentSingleLinePrefix;
  4236. end;
  4237. ssCommentSuffix :
  4238. case Index of
  4239. 0 : GetSpecSymbol:=@FreePascalCommentSuffix1;
  4240. 1 : GetSpecSymbol:=@FreePascalCommentSuffix2;
  4241. end;
  4242. ssStringPrefix :
  4243. GetSpecSymbol:=@FreePascalStringPrefix;
  4244. ssStringSuffix :
  4245. GetSpecSymbol:=@FreePascalStringSuffix;
  4246. { must be uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
  4247. ssAsmPrefix :
  4248. GetSpecSymbol:=@FreePascalAsmPrefix;
  4249. ssAsmSuffix :
  4250. GetSpecSymbol:=@FreePascalAsmSuffix;
  4251. ssDirectivePrefix :
  4252. GetSpecSymbol:=@FreePascalDirectivePrefix;
  4253. ssDirectiveSuffix :
  4254. GetSpecSymbol:=@FreePascalDirectiveSuffix;
  4255. end;
  4256. end;
  4257. function TFPCodeMemo.IsReservedWord(const S: string): boolean;
  4258. begin
  4259. IsReservedWord:=IsFPReservedWord(S);
  4260. end;
  4261. {$ifdef VESA}
  4262. function VESASetVideoModeProc(const VideoMode: TVideoMode; Params: Longint): Boolean;
  4263. begin
  4264. VESASetVideoModeProc:=VESASetMode(Params);
  4265. end;
  4266. procedure InitVESAScreenModes;
  4267. var ML: TVESAModeList;
  4268. MI: TVESAModeInfoBlock;
  4269. I: integer;
  4270. begin
  4271. if VESAInit=false then Exit;
  4272. if VESAGetModeList(ML)=false then Exit;
  4273. for I:=1 to ML.Count do
  4274. begin
  4275. if VESAGetModeInfo(ML.Modes[I],MI) then
  4276. with MI do
  4277. {$ifndef DEBUG}
  4278. if (Attributes and vesa_vma_GraphicsMode)=0 then
  4279. {$else DEBUG}
  4280. if ((Attributes and vesa_vma_GraphicsMode)=0) or
  4281. { only allow 4 bit i.e. 16 color modes }
  4282. (((Attributes and vesa_vma_CanBeSetInCurrentConfig)<>0) and
  4283. (BitsPerPixel=8)) then
  4284. {$endif DEBUG}
  4285. RegisterVesaVideoMode(ML.Modes[I]);
  4286. end;
  4287. end;
  4288. procedure DoneVESAScreenModes;
  4289. begin
  4290. FreeVesaModes;
  4291. end;
  4292. {$endif}
  4293. procedure NoDebugger;
  4294. begin
  4295. InformationBox(msg_nodebuggersupportavailable,nil);
  4296. end;
  4297. procedure RegisterFPViews;
  4298. begin
  4299. RegisterType(RSourceEditor);
  4300. RegisterType(RSourceWindow);
  4301. RegisterType(RFPHelpViewer);
  4302. RegisterType(RFPHelpWindow);
  4303. RegisterType(RClipboardWindow);
  4304. RegisterType(RMessageListBox);
  4305. RegisterType(RFPDesktop);
  4306. RegisterType(RFPASCIIChart);
  4307. RegisterType(RFPDlgWindow);
  4308. {$ifndef NODEBUG}
  4309. RegisterType(RGDBWindow);
  4310. RegisterType(RGDBSourceEditor);
  4311. {$endif NODEBUG}
  4312. end;
  4313. END.