fpviews.pas 125 KB

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