fpviews.pas 124 KB

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