fpviews.pas 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698
  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-p is more than High(s), discard for this round }
  2354. if (pe<>nil) and (pe-p > high(s)) then
  2355. pe:=nil;
  2356. if (pe<>nil) then
  2357. pe^:=#0;
  2358. s:=strpas(p);
  2359. If IsError then
  2360. Editor^.AddErrorLine(S)
  2361. else
  2362. Editor^.AddLine(S);
  2363. { restore for dispose }
  2364. if pe<>nil then
  2365. pe^:=#10;
  2366. if pe=nil then
  2367. begin
  2368. if strlen(p)<High(s) then
  2369. p:=nil
  2370. else
  2371. p:=p+High(s);
  2372. end
  2373. else
  2374. begin
  2375. p:=pe;
  2376. inc(p);
  2377. end;
  2378. end;
  2379. DeskTop^.Unlock;
  2380. Editor^.Draw;
  2381. end;
  2382. procedure TGDBWindow.UpdateCommands;
  2383. var Active: boolean;
  2384. begin
  2385. Active:=GetState(sfActive);
  2386. SetCmdState([cmSaveAs,cmHide,cmRun],Active);
  2387. SetCmdState(EditorCmds,Active);
  2388. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
  2389. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2390. end;
  2391. function TDisasLineCollection.At(Index: sw_Integer): PDisasLine;
  2392. begin
  2393. At := PDisasLine(Inherited At(Index));
  2394. end;
  2395. constructor TDisassemblyEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  2396. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  2397. begin
  2398. Inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,AFileName);
  2399. GrowMode:=gfGrowHiX+gfGrowHiY;
  2400. SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs{+efHighlightRow});
  2401. New(DisasLines,Init(500,1000));
  2402. Core^.ChangeLinesTo(DisasLines);
  2403. { do not allow to write into that window }
  2404. ReadOnly:=true;
  2405. AddLine('');
  2406. MinAddress:=0;
  2407. MaxAddress:=0;
  2408. CurL:=nil;
  2409. OwnsSource:=false;
  2410. Source:=nil;
  2411. end;
  2412. destructor TDisassemblyEditor.Done;
  2413. begin
  2414. ReleaseSource;
  2415. Inherited Done;
  2416. end;
  2417. procedure TDisassemblyEditor.ReleaseSource;
  2418. begin
  2419. if OwnsSource and assigned(source) then
  2420. begin
  2421. Desktop^.Delete(Source);
  2422. Dispose(Source,Done);
  2423. end;
  2424. OwnsSource:=false;
  2425. Source:=nil;
  2426. CurrentSource:='';
  2427. end;
  2428. procedure TDisassemblyEditor.AddSourceLine(const AFileName: string;line : longint);
  2429. var
  2430. S : String;
  2431. begin
  2432. if AFileName<>CurrentSource then
  2433. begin
  2434. ReleaseSource;
  2435. Source:=SearchOnDesktop(FileName,false);
  2436. if not assigned(Source) then
  2437. begin
  2438. Source:=ITryToOpenFile(nil,AFileName,0,line,false,false,true);
  2439. OwnsSource:=true;
  2440. end
  2441. else
  2442. OwnsSource:=false;
  2443. CurrentSource:=AFileName;
  2444. end;
  2445. if Assigned(Source) and (line>0) then
  2446. S:=Trim(Source^.Editor^.GetLineText(line-1))
  2447. else
  2448. S:='<source not found>';
  2449. CurrentLine:=Line;
  2450. inherited AddLine(AFileName+':'+IntToStr(line)+' '+S);
  2451. { display differently }
  2452. SetLineFlagState(GetLineCount-1,lfSpecialRow,true);
  2453. LimitsChanged;
  2454. end;
  2455. procedure TDisassemblyEditor.AddAssemblyLine(const S: string;AAddress : cardinal);
  2456. var
  2457. PL : PDisasLine;
  2458. LI : PEditorLineInfo;
  2459. begin
  2460. if AAddress<>0 then
  2461. inherited AddLine('$'+hexstr(AAddress,sizeof(PtrUInt)*2)+S)
  2462. else
  2463. inherited AddLine(S);
  2464. PL:=DisasLines^.At(DisasLines^.count-1);
  2465. PL^.Address:=AAddress;
  2466. LI:=PL^.GetEditorInfo(@Self);
  2467. if AAddress<>0 then
  2468. LI^.BeginsWithAsm:=true;
  2469. LimitsChanged;
  2470. if ((AAddress<minaddress) or (minaddress=0)) and (AAddress<>0) then
  2471. MinAddress:=AAddress;
  2472. if (AAddress>maxaddress) or (maxaddress=0) then
  2473. MaxAddress:=AAddress;
  2474. end;
  2475. function TDisassemblyEditor.GetCurrentLine(address : cardinal) : PDisasLine;
  2476. function IsCorrectLine(PL : PDisasLine) : boolean;
  2477. begin
  2478. IsCorrectLine:=PL^.Address=Address;
  2479. end;
  2480. Var
  2481. PL : PDisasLine;
  2482. begin
  2483. PL:=DisasLines^.FirstThat(@IsCorrectLine);
  2484. if Assigned(PL) then
  2485. begin
  2486. if assigned(CurL) then
  2487. CurL^.SetFlagState(lfDebuggerRow,false);
  2488. SetCurPtr(0,DisasLines^.IndexOf(PL));
  2489. PL^.SetFlags(lfDebuggerRow);
  2490. CurL:=PL;
  2491. TrackCursor(do_not_centre);
  2492. end;
  2493. GetCurrentLine:=PL;
  2494. end;
  2495. { PDisassemblyWindow = ^TDisassemblyWindow;
  2496. TDisassemblyWindow = object(TFPWindow)
  2497. Editor : PDisassemblyEditor;
  2498. Indicator : PIndicator; }
  2499. constructor TDisassemblyWindow.Init(var Bounds: TRect);
  2500. var HSB,VSB: PScrollBar;
  2501. R: TRect;
  2502. begin
  2503. inherited Init(Bounds,dialog_disaswindow,0);
  2504. Options:=Options or ofTileAble;
  2505. AutoNumber:=true;
  2506. HelpCtx:=hcDisassemblyWindow;
  2507. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2508. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2509. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2510. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2511. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2512. New(Indicator, Init(R));
  2513. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2514. Insert(Indicator);
  2515. GetExtent(R); R.Grow(-1,-1);
  2516. New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
  2517. Insert(Editor);
  2518. DisassemblyWindow:=@Self;
  2519. end;
  2520. procedure TDisassemblyWindow.LoadFunction(Const FuncName : string);
  2521. var
  2522. p : pchar;
  2523. begin
  2524. {$ifndef NODEBUG}
  2525. If not assigned(Debugger) then Exit;
  2526. Debugger^.Command('set print sym on');
  2527. Debugger^.Command('set width 0xffffffff');
  2528. Debugger^.Command('disas '+FuncName);
  2529. p:=StrNew(Debugger^.GetOutput);
  2530. ProcessPChar(p);
  2531. if (Debugger^.IsRunning) and (FuncName='') then
  2532. Editor^.GetCurrentLine(Debugger^.current_pc);
  2533. {$endif NODEBUG}
  2534. end;
  2535. procedure TDisassemblyWindow.LoadAddress(Addr : cardinal);
  2536. var
  2537. p : pchar;
  2538. begin
  2539. {$ifndef NODEBUG}
  2540. If not assigned(Debugger) then Exit;
  2541. Debugger^.Command('set print sym on');
  2542. Debugger^.Command('set width 0xffffffff');
  2543. Debugger^.Command('disas 0x'+HexStr(Addr,8));
  2544. p:=StrNew(Debugger^.GetOutput);
  2545. ProcessPChar(p);
  2546. if Debugger^.IsRunning and
  2547. (Debugger^.current_pc>=Editor^.MinAddress) and
  2548. (Debugger^.current_pc<=Editor^.MaxAddress) then
  2549. Editor^.GetCurrentLine(Debugger^.current_pc);
  2550. {$endif NODEBUG}
  2551. end;
  2552. function TDisassemblyWindow.ProcessPChar(p : pchar) : boolean;
  2553. var
  2554. p1: pchar;
  2555. pline : pchar;
  2556. pos1, pos2, CurLine, PrevLine : longint;
  2557. CurAddr : cardinal;
  2558. err : word;
  2559. curaddress, cursymofs, CurFile,
  2560. PrevFile, line : string;
  2561. begin
  2562. ProcessPChar:=true;
  2563. Lock;
  2564. Editor^.DisasLines^.FreeAll;
  2565. Editor^.SetFlags(Editor^.GetFlags or efSyntaxHighlight or efKeepLineAttr);
  2566. Editor^.MinAddress:=0;
  2567. Editor^.MaxAddress:=0;
  2568. Editor^.CurL:=nil;
  2569. p1:=p;
  2570. PrevFile:='';
  2571. PrevLine:=0;
  2572. while assigned(p) do
  2573. begin
  2574. pline:=strscan(p,#10);
  2575. if assigned(pline) then
  2576. pline^:=#0;
  2577. line:=strpas(p);
  2578. CurAddr:=0;
  2579. if assigned(pline) then
  2580. begin
  2581. pline^:=#10;
  2582. p:=pline+1;
  2583. end
  2584. else
  2585. p:=nil;
  2586. { now process the line }
  2587. { line is hexaddr <symbol+sym_offset at filename:line> assembly }
  2588. pos1:=pos('<',line);
  2589. if pos1>0 then
  2590. begin
  2591. curaddress:=copy(line,1,pos1-1);
  2592. if copy(curaddress,1,2)='0x' then
  2593. curaddress:='$'+copy(curaddress,3,length(curaddress)-2);
  2594. val(curaddress,CurAddr,err);
  2595. if err>0 then
  2596. val(copy(curaddress,1,err-1),CurAddr,err);
  2597. system.delete(line,1,pos1);
  2598. end;
  2599. pos1:=pos(' at ',line);
  2600. pos2:=pos('>',line);
  2601. if (pos1>0) and (pos1 < pos2) then
  2602. begin
  2603. cursymofs:=copy(line,1,pos1-1);
  2604. CurFile:=copy(line,pos1+4,pos2-pos1-4);
  2605. pos1:=pos(':',CurFile);
  2606. if pos1>0 then
  2607. begin
  2608. val(copy(CurFile,pos1+1,high(CurFile)),CurLine,err);
  2609. system.delete(CurFile,pos1,high(CurFile));
  2610. end
  2611. else
  2612. CurLine:=0;
  2613. system.delete(line,1,pos2);
  2614. end
  2615. else { no ' at ' found before '>' }
  2616. begin
  2617. cursymofs:=copy(line,1,pos2-1);
  2618. CurFile:='';
  2619. system.delete(line,1,pos2);
  2620. end;
  2621. if (CurFile<>'') and ((CurFile<>PrevFile) or (CurLine<>PrevLine)) then
  2622. begin
  2623. WriteSourceString(CurFile,CurLine);
  2624. PrevLine:=CurLine;
  2625. PrevFile:=CurFile;
  2626. end;
  2627. WriteDisassemblyString(line,curaddr);
  2628. end;
  2629. StrDispose(p1);
  2630. Editor^.ReleaseSource;
  2631. Editor^.UpdateAttrs(0,attrForceFull);
  2632. If assigned(BreakpointsCollection) then
  2633. BreakpointsCollection^.ShowBreakpoints(@Self);
  2634. Unlock;
  2635. ReDraw;
  2636. end;
  2637. procedure TDisassemblyWindow.HandleEvent(var Event: TEvent);
  2638. begin
  2639. inherited HandleEvent(Event);
  2640. end;
  2641. procedure TDisassemblyWindow.WriteSourceString(Const S : string;line : longint);
  2642. begin
  2643. Editor^.AddSourceLine(S,line);
  2644. end;
  2645. procedure TDisassemblyWindow.WriteDisassemblyString(Const S : string;address : cardinal);
  2646. begin
  2647. Editor^.AddAssemblyLine(S,address);
  2648. end;
  2649. procedure TDisassemblyWindow.SetCurAddress(address : cardinal);
  2650. begin
  2651. if (address<Editor^.MinAddress) or (address>Editor^.MaxAddress) then
  2652. LoadAddress(address);
  2653. Editor^.GetCurrentLine(address);
  2654. end;
  2655. procedure TDisassemblyWindow.UpdateCommands;
  2656. var Active: boolean;
  2657. begin
  2658. Active:=GetState(sfActive);
  2659. SetCmdState(SourceCmds+CompileCmds,Active);
  2660. SetCmdState(EditorCmds,Active);
  2661. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  2662. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2663. end;
  2664. function TDisassemblyWindow.GetPalette: PPalette;
  2665. const P: string[length(CSourceWindow)] = CSourceWindow;
  2666. begin
  2667. GetPalette:=@P;
  2668. end;
  2669. destructor TDisassemblyWindow.Done;
  2670. begin
  2671. if @Self=DisassemblyWindow then
  2672. DisassemblyWindow:=nil;
  2673. inherited Done;
  2674. end;
  2675. {$endif NODEBUG}
  2676. constructor TClipboardWindow.Init;
  2677. var R: TRect;
  2678. HSB,VSB: PScrollBar;
  2679. begin
  2680. Desktop^.GetExtent(R);
  2681. inherited Init(R, '*');
  2682. SetTitle(dialog_clipboard);
  2683. HelpCtx:=hcClipboardWindow;
  2684. Number:=wnNoNumber;
  2685. AutoNumber:=true;
  2686. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2687. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2688. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2689. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2690. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2691. New(Indicator, Init(R));
  2692. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2693. Insert(Indicator);
  2694. GetExtent(R); R.Grow(-1,-1);
  2695. New(Editor, Init(R, HSB, VSB, Indicator, ''));
  2696. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2697. Insert(Editor);
  2698. Editor^.SetFlags(Editor^.GetFlags or efUseTabCharacters);
  2699. Hide;
  2700. Clipboard:=Editor;
  2701. end;
  2702. procedure TClipboardWindow.Close;
  2703. begin
  2704. Hide;
  2705. end;
  2706. constructor TClipboardWindow.Load(var S: TStream);
  2707. begin
  2708. inherited Load(S);
  2709. Clipboard:=Editor;
  2710. end;
  2711. procedure TClipboardWindow.Store(var S: TStream);
  2712. begin
  2713. inherited Store(S);
  2714. end;
  2715. destructor TClipboardWindow.Done;
  2716. begin
  2717. inherited Done;
  2718. Clipboard:=nil;
  2719. ClipboardWindow:=nil;
  2720. end;
  2721. constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  2722. begin
  2723. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  2724. GrowMode:=gfGrowHiX+gfGrowHiY;
  2725. New(ModuleNames, Init(50,100));
  2726. NoSelection:=true;
  2727. end;
  2728. function TMessageListBox.GetLocalMenu: PMenu;
  2729. var M: PMenu;
  2730. begin
  2731. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  2732. M:=NewMenu(
  2733. NewItem(menu_msglocal_clear,'',kbNoKey,cmMsgClear,hcMsgClear,
  2734. NewLine(
  2735. NewItem(menu_msglocal_gotosource,'',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  2736. NewItem(menu_msglocal_tracksource,'',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
  2737. NewLine(
  2738. NewItem(menu_msglocal_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  2739. nil)))))));
  2740. GetLocalMenu:=M;
  2741. end;
  2742. procedure TMessageListBox.SetState(AState: Word; Enable: Boolean);
  2743. var OldState: word;
  2744. begin
  2745. OldState:=State;
  2746. inherited SetState(AState,Enable);
  2747. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  2748. SetCmdState([cmSaveAs],Enable);
  2749. end;
  2750. procedure TMessageListBox.HandleEvent(var Event: TEvent);
  2751. var DontClear: boolean;
  2752. begin
  2753. case Event.What of
  2754. evKeyDown :
  2755. begin
  2756. DontClear:=false;
  2757. case Event.KeyCode of
  2758. kbEnter :
  2759. begin
  2760. Message(@Self,evCommand,cmMsgGotoSource,nil);
  2761. ClearEvent(Event);
  2762. exit;
  2763. end;
  2764. else
  2765. DontClear:=true;
  2766. end;
  2767. if not DontClear then
  2768. ClearEvent(Event);
  2769. end;
  2770. evBroadcast :
  2771. case Event.Command of
  2772. cmListItemSelected :
  2773. if Event.InfoPtr=@Self then
  2774. Message(@Self,evCommand,cmMsgTrackSource,nil);
  2775. end;
  2776. evCommand :
  2777. begin
  2778. DontClear:=false;
  2779. case Event.Command of
  2780. cmMsgGotoSource :
  2781. if Range>0 then
  2782. begin
  2783. GotoSource;
  2784. ClearEvent(Event);
  2785. exit;
  2786. end;
  2787. cmMsgTrackSource :
  2788. if Range>0 then
  2789. TrackSource;
  2790. cmMsgClear :
  2791. Clear;
  2792. cmSaveAs :
  2793. SaveAs;
  2794. else
  2795. DontClear:=true;
  2796. end;
  2797. if not DontClear then
  2798. ClearEvent(Event);
  2799. end;
  2800. end;
  2801. inherited HandleEvent(Event);
  2802. end;
  2803. procedure TMessageListBox.AddItem(P: PMessageItem);
  2804. var W : integer;
  2805. begin
  2806. if List=nil then New(List, Init(500,500));
  2807. W:=length(P^.GetText(255));
  2808. if W>MaxWidth then
  2809. begin
  2810. MaxWidth:=W;
  2811. if HScrollBar<>nil then
  2812. HScrollBar^.SetRange(0,MaxWidth);
  2813. end;
  2814. List^.Insert(P);
  2815. SetRange(List^.Count);
  2816. if Focused=List^.Count-1-1 then
  2817. FocusItem(List^.Count-1);
  2818. DrawView;
  2819. end;
  2820. function TMessageListBox.AddModuleName(const Name: string): PString;
  2821. var P: PString;
  2822. begin
  2823. if ModuleNames<>nil then
  2824. P:=ModuleNames^.Add(Name)
  2825. else
  2826. P:=nil;
  2827. AddModuleName:=P;
  2828. end;
  2829. function TMessageListBox.GetText(Item,MaxLen: Sw_Integer): String;
  2830. var P: PMessageItem;
  2831. S: string;
  2832. begin
  2833. P:=List^.At(Item);
  2834. S:=P^.GetText(MaxLen);
  2835. GetText:=copy(S,1,MaxLen);
  2836. end;
  2837. procedure TMessageListBox.Clear;
  2838. begin
  2839. if assigned(List) then
  2840. Dispose(List, Done);
  2841. List:=nil;
  2842. MaxWidth:=0;
  2843. if assigned(ModuleNames) then
  2844. ModuleNames^.FreeAll;
  2845. SetRange(0); DrawView;
  2846. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2847. end;
  2848. procedure TMessageListBox.TrackSource;
  2849. var W: PSourceWindow;
  2850. P: PMessageItem;
  2851. R: TRect;
  2852. Row,Col: sw_integer;
  2853. Found : boolean;
  2854. begin
  2855. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2856. if Range=0 then Exit;
  2857. P:=List^.At(Focused);
  2858. if P^.Row=0 then Exit;
  2859. Desktop^.Lock;
  2860. GetNextEditorBounds(R);
  2861. R.B.Y:=Owner^.Origin.Y;
  2862. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2863. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2864. W:=EditorWindowFile(P^.GetModuleName);
  2865. if assigned(W) then
  2866. begin
  2867. W^.GetExtent(R);
  2868. R.B.Y:=Owner^.Origin.Y;
  2869. W^.ChangeBounds(R);
  2870. W^.Editor^.SetCurPtr(Col,Row);
  2871. end
  2872. else
  2873. W:=TryToOpenFile(@R,P^.GetModuleName,Col,Row,true);
  2874. { Try to find it by browsing }
  2875. if W=nil then
  2876. begin
  2877. Desktop^.UnLock;
  2878. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2879. if found then
  2880. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2881. Desktop^.Lock;
  2882. end;
  2883. if W<>nil then
  2884. begin
  2885. W^.Select;
  2886. W^.Editor^.TrackCursor(do_centre);
  2887. W^.Editor^.SetLineFlagExclusive(lfHighlightRow,Row);
  2888. end;
  2889. if Assigned(Owner) then
  2890. Owner^.Select;
  2891. Desktop^.UnLock;
  2892. end;
  2893. procedure TMessageListBox.GotoSource;
  2894. var W: PSourceWindow;
  2895. P: PMessageItem;
  2896. R:TRect;
  2897. Row,Col: sw_integer;
  2898. Found : boolean;
  2899. Event : TEvent;
  2900. begin
  2901. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2902. if Range=0 then Exit;
  2903. P:=List^.At(Focused);
  2904. if P^.Row=0 then Exit;
  2905. Desktop^.Lock;
  2906. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2907. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2908. W:=EditorWindowFile(P^.GetModuleName);
  2909. if assigned(W) then
  2910. begin
  2911. W^.GetExtent(R);
  2912. if Owner^.Origin.Y>R.A.Y+4 then
  2913. R.B.Y:=Owner^.Origin.Y;
  2914. W^.ChangeBounds(R);
  2915. W^.Editor^.SetCurPtr(Col,Row);
  2916. end
  2917. else
  2918. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2919. { Try to find it by browsing }
  2920. if W=nil then
  2921. begin
  2922. Desktop^.UnLock;
  2923. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2924. if found then
  2925. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2926. Desktop^.Lock;
  2927. end;
  2928. if assigned(W) then
  2929. begin
  2930. { Message(Owner,evCommand,cmClose,nil);
  2931. This calls close on StackWindow
  2932. rendering P invalid
  2933. so postpone it PM }
  2934. W^.GetExtent(R);
  2935. if (P^.TClass<>0) then
  2936. W^.Editor^.SetErrorMessage(P^.GetText(R.B.X-R.A.X));
  2937. W^.Select;
  2938. Owner^.Hide;
  2939. end;
  2940. Desktop^.UnLock;
  2941. if assigned(W) then
  2942. begin
  2943. Event.What:=evCommand;
  2944. Event.command:=cmClose;
  2945. Event.InfoPtr:=nil;
  2946. fpide.PutEvent(Owner,Event);
  2947. end;
  2948. end;
  2949. procedure TMessageListBox.Draw;
  2950. var
  2951. I, J, Item: Sw_Integer;
  2952. NormalColor, SelectedColor, FocusedColor, Color: Word;
  2953. ColWidth, CurCol, Indent: Integer;
  2954. B: TDrawBuffer;
  2955. Text: String;
  2956. SCOff: Byte;
  2957. TC: byte;
  2958. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  2959. begin
  2960. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  2961. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  2962. begin
  2963. NormalColor := GetColor(1);
  2964. FocusedColor := GetColor(3);
  2965. SelectedColor := GetColor(4);
  2966. end else
  2967. begin
  2968. NormalColor := GetColor(2);
  2969. SelectedColor := GetColor(4);
  2970. end;
  2971. if Transparent then
  2972. begin MT(NormalColor); MT(SelectedColor); end;
  2973. if NoSelection then
  2974. SelectedColor:=NormalColor;
  2975. if HScrollBar <> nil then Indent := HScrollBar^.Value
  2976. else Indent := 0;
  2977. ColWidth := Size.X div NumCols + 1;
  2978. for I := 0 to Size.Y - 1 do
  2979. begin
  2980. for J := 0 to NumCols-1 do
  2981. begin
  2982. Item := J*Size.Y + I + TopItem;
  2983. CurCol := J*ColWidth;
  2984. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  2985. (Focused = Item) and (Range > 0) then
  2986. begin
  2987. Color := FocusedColor;
  2988. SetCursor(CurCol+1,I);
  2989. SCOff := 0;
  2990. end
  2991. else if (Item < Range) and IsSelected(Item) then
  2992. begin
  2993. Color := SelectedColor;
  2994. SCOff := 2;
  2995. end
  2996. else
  2997. begin
  2998. Color := NormalColor;
  2999. SCOff := 4;
  3000. end;
  3001. MoveChar(B[CurCol], ' ', Color, ColWidth);
  3002. if Item < Range then
  3003. begin
  3004. Text := GetText(Item, ColWidth + Indent);
  3005. Text := Copy(Text,Indent,ColWidth);
  3006. MoveStr(B[CurCol+1], Text, Color);
  3007. if ShowMarkers then
  3008. begin
  3009. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  3010. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  3011. end;
  3012. end;
  3013. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  3014. end;
  3015. WriteLine(0, I, Size.X, 1, B);
  3016. end;
  3017. end;
  3018. constructor TMessageListBox.Load(var S: TStream);
  3019. begin
  3020. inherited Load(S);
  3021. New(ModuleNames, Init(50,100));
  3022. NoSelection:=true;
  3023. end;
  3024. procedure TMessageListBox.Store(var S: TStream);
  3025. var OL: PCollection;
  3026. ORV: sw_integer;
  3027. begin
  3028. OL:=List; ORV:=Range;
  3029. New(List, Init(1,1)); Range:=0;
  3030. inherited Store(S);
  3031. Dispose(List, Done);
  3032. List:=OL; Range:=ORV;
  3033. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  3034. collection? Pasting here a modified version of TListBox.Store+
  3035. TAdvancedListBox.Store isn't a better solution, since by eventually
  3036. changing the obj-hierarchy you'll always have to modify this, too - BG }
  3037. end;
  3038. destructor TMessageListBox.Done;
  3039. begin
  3040. inherited Done;
  3041. if List<>nil then Dispose(List, Done);
  3042. if ModuleNames<>nil then Dispose(ModuleNames, Done);
  3043. end;
  3044. constructor TMessageItem.Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  3045. begin
  3046. inherited Init;
  3047. TClass:=AClass;
  3048. Text:=NewStr(AText);
  3049. Module:=AModule;
  3050. Row:=ARow; Col:=ACol;
  3051. end;
  3052. function TMessageItem.GetText(MaxLen: Sw_integer): string;
  3053. var S: string;
  3054. begin
  3055. if Text=nil then S:='' else S:=Text^;
  3056. if (Module<>nil) then
  3057. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+S;
  3058. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  3059. GetText:=S;
  3060. end;
  3061. procedure TMessageItem.Selected;
  3062. begin
  3063. end;
  3064. function TMessageItem.GetModuleName: string;
  3065. begin
  3066. GetModuleName:=GetStr(Module);
  3067. end;
  3068. destructor TMessageItem.Done;
  3069. begin
  3070. inherited Done;
  3071. if Text<>nil then DisposeStr(Text);
  3072. { if Module<>nil then DisposeStr(Module);}
  3073. end;
  3074. procedure TFPDlgWindow.HandleEvent(var Event: TEvent);
  3075. begin
  3076. case Event.What of
  3077. evBroadcast :
  3078. case Event.Command of
  3079. cmSearchWindow+1..cmSearchWindow+99 :
  3080. if (Event.Command-cmSearchWindow=Number) then
  3081. ClearEvent(Event);
  3082. end;
  3083. end;
  3084. inherited HandleEvent(Event);
  3085. end;
  3086. (*
  3087. constructor TTab.Init(var Bounds: TRect; ATabDef: PTabDef);
  3088. begin
  3089. inherited Init(Bounds);
  3090. Options:=Options or ofSelectable or ofFirstClick or ofPreProcess or ofPostProcess;
  3091. GrowMode:=gfGrowHiX+gfGrowHiY+gfGrowRel;
  3092. TabDefs:=ATabDef;
  3093. ActiveDef:=-1;
  3094. SelectTab(0);
  3095. ReDraw;
  3096. end;
  3097. function TTab.TabCount: integer;
  3098. var i: integer;
  3099. P: PTabDef;
  3100. begin
  3101. I:=0; P:=TabDefs;
  3102. while (P<>nil) do
  3103. begin
  3104. Inc(I);
  3105. P:=P^.Next;
  3106. end;
  3107. TabCount:=I;
  3108. end;
  3109. function TTab.AtTab(Index: integer): PTabDef;
  3110. var i: integer;
  3111. P: PTabDef;
  3112. begin
  3113. i:=0; P:=TabDefs;
  3114. while (I<Index) do
  3115. begin
  3116. if P=nil then RunError($AA);
  3117. P:=P^.Next;
  3118. Inc(i);
  3119. end;
  3120. AtTab:=P;
  3121. end;
  3122. procedure TTab.SelectTab(Index: integer);
  3123. var P: PTabItem;
  3124. V: PView;
  3125. begin
  3126. if ActiveDef<>Index then
  3127. begin
  3128. if Owner<>nil then Owner^.Lock;
  3129. Lock;
  3130. { --- Update --- }
  3131. if TabDefs<>nil then
  3132. begin
  3133. DefCount:=1;
  3134. while AtTab(DefCount-1)^.Next<>nil do Inc(DefCount);
  3135. end
  3136. else DefCount:=0;
  3137. if ActiveDef<>-1 then
  3138. begin
  3139. P:=AtTab(ActiveDef)^.Items;
  3140. while P<>nil do
  3141. begin
  3142. if P^.View<>nil then Delete(P^.View);
  3143. P:=P^.Next;
  3144. end;
  3145. end;
  3146. ActiveDef:=Index;
  3147. P:=AtTab(ActiveDef)^.Items;
  3148. while P<>nil do
  3149. begin
  3150. if P^.View<>nil then Insert(P^.View);
  3151. P:=P^.Next;
  3152. end;
  3153. V:=AtTab(ActiveDef)^.DefItem;
  3154. if V<>nil then V^.Select;
  3155. ReDraw;
  3156. { --- Update --- }
  3157. UnLock;
  3158. if Owner<>nil then Owner^.UnLock;
  3159. DrawView;
  3160. end;
  3161. end;
  3162. procedure TTab.ChangeBounds(var Bounds: TRect);
  3163. var D: TPoint;
  3164. procedure DoCalcChange(P: PView);
  3165. var
  3166. R: TRect;
  3167. begin
  3168. if P^.Owner=nil then Exit; { it think this is a bug in TV }
  3169. P^.CalcBounds(R, D);
  3170. P^.ChangeBounds(R);
  3171. end;
  3172. var
  3173. P: PTabItem;
  3174. I: integer;
  3175. begin
  3176. D.X := Bounds.B.X - Bounds.A.X - Size.X;
  3177. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y;
  3178. inherited ChangeBounds(Bounds);
  3179. for I:=0 to TabCount-1 do
  3180. if I<>ActiveDef then
  3181. begin
  3182. P:=AtTab(I)^.Items;
  3183. while P<>nil do
  3184. begin
  3185. if P^.View<>nil then DoCalcChange(P^.View);
  3186. P:=P^.Next;
  3187. end;
  3188. end;
  3189. end;
  3190. procedure TTab.SelectNextTab(Forwards: boolean);
  3191. var Index: integer;
  3192. begin
  3193. Index:=ActiveDef;
  3194. if Index=-1 then Exit;
  3195. if Forwards then Inc(Index) else Dec(Index);
  3196. if Index<0 then Index:=DefCount-1 else
  3197. if Index>DefCount-1 then Index:=0;
  3198. SelectTab(Index);
  3199. end;
  3200. procedure TTab.HandleEvent(var Event: TEvent);
  3201. var Index : integer;
  3202. I : integer;
  3203. X : integer;
  3204. Len : byte;
  3205. P : TPoint;
  3206. V : PView;
  3207. CallOrig: boolean;
  3208. LastV : PView;
  3209. FirstV: PView;
  3210. function FirstSelectable: PView;
  3211. var
  3212. FV : PView;
  3213. begin
  3214. FV := First;
  3215. while (FV<>nil) and ((FV^.Options and ofSelectable)=0) and (FV<>Last) do
  3216. FV:=FV^.Next;
  3217. if FV<>nil then
  3218. if (FV^.Options and ofSelectable)=0 then FV:=nil;
  3219. FirstSelectable:=FV;
  3220. end;
  3221. function LastSelectable: PView;
  3222. var
  3223. LV : PView;
  3224. begin
  3225. LV := Last;
  3226. while (LV<>nil) and ((LV^.Options and ofSelectable)=0) and (LV<>First) do
  3227. LV:=LV^.Prev;
  3228. if LV<>nil then
  3229. if (LV^.Options and ofSelectable)=0 then LV:=nil;
  3230. LastSelectable:=LV;
  3231. end;
  3232. begin
  3233. if (Event.What and evMouseDown)<>0 then
  3234. begin
  3235. MakeLocal(Event.Where,P);
  3236. if P.Y<3 then
  3237. begin
  3238. Index:=-1; X:=1;
  3239. for i:=0 to DefCount-1 do
  3240. begin
  3241. Len:=CStrLen(AtTab(i)^.Name^);
  3242. if (P.X>=X) and (P.X<=X+Len+1) then Index:=i;
  3243. X:=X+Len+3;
  3244. end;
  3245. if Index<>-1 then
  3246. SelectTab(Index);
  3247. end;
  3248. end;
  3249. if Event.What=evKeyDown then
  3250. begin
  3251. Index:=-1;
  3252. case Event.KeyCode of
  3253. kbCtrlTab :
  3254. begin
  3255. SelectNextTab((Event.KeyShift and kbShift)=0);
  3256. ClearEvent(Event);
  3257. end;
  3258. kbTab,kbShiftTab :
  3259. if GetState(sfSelected) then
  3260. begin
  3261. if Current<>nil then
  3262. begin
  3263. LastV:=LastSelectable; FirstV:=FirstSelectable;
  3264. if ((Current=LastV) or (Current=PLabel(LastV)^.Link)) and (Event.KeyCode=kbShiftTab) then
  3265. begin
  3266. if Owner<>nil then Owner^.SelectNext(true);
  3267. end else
  3268. if ((Current=FirstV) or (Current=PLabel(FirstV)^.Link)) and (Event.KeyCode=kbTab) then
  3269. begin
  3270. Lock;
  3271. if Owner<>nil then Owner^.SelectNext(false);
  3272. UnLock;
  3273. end else
  3274. SelectNext(Event.KeyCode=kbShiftTab);
  3275. ClearEvent(Event);
  3276. end;
  3277. end;
  3278. else
  3279. for I:=0 to DefCount-1 do
  3280. begin
  3281. if Upcase(GetAltChar(Event.KeyCode))=AtTab(I)^.ShortCut
  3282. then begin
  3283. Index:=I;
  3284. ClearEvent(Event);
  3285. Break;
  3286. end;
  3287. end;
  3288. end;
  3289. if Index<>-1 then
  3290. begin
  3291. Select;
  3292. SelectTab(Index);
  3293. V:=AtTab(ActiveDef)^.DefItem;
  3294. if V<>nil then V^.Focus;
  3295. end;
  3296. end;
  3297. CallOrig:=true;
  3298. if Event.What=evKeyDown then
  3299. begin
  3300. if ((Owner<>nil) and (Owner^.Phase=phPostProcess) and (GetAltChar(Event.KeyCode)<>#0)) or GetState(sfFocused)
  3301. then
  3302. else CallOrig:=false;
  3303. end;
  3304. if CallOrig then inherited HandleEvent(Event);
  3305. end;
  3306. function TTab.GetPalette: PPalette;
  3307. begin
  3308. GetPalette:=nil;
  3309. end;
  3310. procedure TTab.Draw;
  3311. var B : TDrawBuffer;
  3312. i : integer;
  3313. C1,C2,C3,C : word;
  3314. HeaderLen : integer;
  3315. X,X2 : integer;
  3316. Name : PString;
  3317. ActiveKPos : integer;
  3318. ActiveVPos : integer;
  3319. FC : char;
  3320. ClipR : TRect;
  3321. procedure SWriteBuf(X,Y,W,H: integer; var Buf);
  3322. var i: integer;
  3323. begin
  3324. if Y+H>Size.Y then H:=Size.Y-Y;
  3325. if X+W>Size.X then W:=Size.X-X;
  3326. if Buffer=nil then WriteBuf(X,Y,W,H,Buf)
  3327. else for i:=1 to H do
  3328. Move(Buf,Buffer^[X+(Y+i-1)*Size.X],W*2);
  3329. end;
  3330. procedure ClearBuf;
  3331. begin
  3332. MoveChar(B,' ',C1,Size.X);
  3333. end;
  3334. begin
  3335. if InDraw then Exit;
  3336. InDraw:=true;
  3337. { - Start of TGroup.Draw - }
  3338. { if Buffer = nil then
  3339. begin
  3340. GetBuffer;
  3341. end; }
  3342. { - Start of TGroup.Draw - }
  3343. C1:=GetColor(1); C2:=(GetColor(7) and $f0 or $08)+GetColor(9)*256; C3:=GetColor(8)+GetColor({9}8)*256;
  3344. HeaderLen:=0; for i:=0 to DefCount-1 do HeaderLen:=HeaderLen+CStrLen(AtTab(i)^.Name^)+3; Dec(HeaderLen);
  3345. if HeaderLen>Size.X-2 then HeaderLen:=Size.X-2;
  3346. { --- 1. sor --- }
  3347. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[HeaderLen+1],'³',C1,1);
  3348. X:=1;
  3349. for i:=0 to DefCount-1 do
  3350. begin
  3351. Name:=AtTab(i)^.Name; X2:=CStrLen(Name^);
  3352. if i=ActiveDef
  3353. then begin
  3354. ActiveKPos:=X-1;
  3355. ActiveVPos:=X+X2+2;
  3356. if GetState(sfFocused) then C:=C3 else C:=C2;
  3357. end
  3358. else C:=C2;
  3359. MoveCStr(B[X],' '+Name^+' ',C); X:=X+X2+3;
  3360. MoveChar(B[X-1],'³',C1,1);
  3361. end;
  3362. SWriteBuf(0,1,Size.X,1,B);
  3363. { --- 0. sor --- }
  3364. ClearBuf; MoveChar(B[0],'Ú',C1,1);
  3365. X:=1;
  3366. for i:=0 to DefCount-1 do
  3367. begin
  3368. if I<ActiveDef then FC:='Ú'
  3369. else FC:='¿';
  3370. X2:=CStrLen(AtTab(i)^.Name^)+2;
  3371. MoveChar(B[X+X2],{'Â'}FC,C1,1);
  3372. if i=DefCount-1 then X2:=X2+1;
  3373. if X2>0 then
  3374. MoveChar(B[X],'Ä',C1,X2);
  3375. X:=X+X2+1;
  3376. end;
  3377. MoveChar(B[HeaderLen+1],'¿',C1,1);
  3378. MoveChar(B[ActiveKPos],'Ú',C1,1); MoveChar(B[ActiveVPos],'¿',C1,1);
  3379. SWriteBuf(0,0,Size.X,1,B);
  3380. { --- 2. sor --- }
  3381. MoveChar(B[1],'Ä',C1,Max(HeaderLen,0)); MoveChar(B[HeaderLen+2],'Ä',C1,Max(Size.X-HeaderLen-3,0));
  3382. MoveChar(B[Size.X-1],'¿',C1,1);
  3383. MoveChar(B[ActiveKPos],'Ù',C1,1);
  3384. if ActiveDef=0 then MoveChar(B[0],'³',C1,1)
  3385. else MoveChar(B[0],{'Ã'}'Ú',C1,1);
  3386. MoveChar(B[HeaderLen+1],'Ä'{'Á'},C1,1); MoveChar(B[ActiveVPos],'À',C1,1);
  3387. MoveChar(B[ActiveKPos+1],' ',C1,Max(ActiveVPos-ActiveKPos-1,0));
  3388. SWriteBuf(0,2,Size.X,1,B);
  3389. { --- marad‚k sor --- }
  3390. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[Size.X-1],'³',C1,1);
  3391. for i:=3 to Size.Y-1 do
  3392. SWriteBuf(0,i,Size.X,1,B);
  3393. { SWriteBuf(0,3,Size.X,Size.Y-4,B); this was wrong
  3394. because WriteBuf then expect a buffer of size size.x*(size.y-4)*2 PM }
  3395. { --- Size.X . sor --- }
  3396. MoveChar(B[0],'À',C1,1); MoveChar(B[1],'Ä',C1,Max(Size.X-2,0)); MoveChar(B[Size.X-1],'Ù',C1,1);
  3397. SWriteBuf(0,Size.Y-1,Size.X,1,B);
  3398. { - End of TGroup.Draw - }
  3399. if Buffer <> nil then
  3400. begin
  3401. Lock;
  3402. Redraw;
  3403. UnLock;
  3404. end;
  3405. if Buffer <> nil then WriteBuf(0, 0, Size.X, Size.Y, Buffer^) else
  3406. begin
  3407. GetClipRect(ClipR);
  3408. Redraw;
  3409. GetExtent(ClipR);
  3410. end;
  3411. { - End of TGroup.Draw - }
  3412. InDraw:=false;
  3413. end;
  3414. function TTab.Valid(Command: Word): Boolean;
  3415. var PT : PTabDef;
  3416. PI : PTabItem;
  3417. OK : boolean;
  3418. begin
  3419. OK:=true;
  3420. PT:=TabDefs;
  3421. while (PT<>nil) and (OK=true) do
  3422. begin
  3423. PI:=PT^.Items;
  3424. while (PI<>nil) and (OK=true) do
  3425. begin
  3426. if PI^.View<>nil then OK:=OK and PI^.View^.Valid(Command);
  3427. PI:=PI^.Next;
  3428. end;
  3429. PT:=PT^.Next;
  3430. end;
  3431. Valid:=OK;
  3432. end;
  3433. procedure TTab.SetState(AState: Word; Enable: Boolean);
  3434. begin
  3435. inherited SetState(AState,Enable);
  3436. if (AState and sfFocused)<>0 then DrawView;
  3437. end;
  3438. destructor TTab.Done;
  3439. var P,X: PTabDef;
  3440. procedure DeleteViews(P: PView);
  3441. begin
  3442. if P<>nil then Delete(P);
  3443. end;
  3444. begin
  3445. ForEach(@DeleteViews);
  3446. inherited Done;
  3447. P:=TabDefs;
  3448. while P<>nil do
  3449. begin
  3450. X:=P^.Next;
  3451. DisposeTabDef(P);
  3452. P:=X;
  3453. end;
  3454. end;
  3455. *)
  3456. constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  3457. AScreen: PScreen);
  3458. begin
  3459. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  3460. Screen:=AScreen;
  3461. if Screen=nil then
  3462. Fail;
  3463. SetState(sfCursorVis,true);
  3464. Update;
  3465. end;
  3466. procedure TScreenView.Update;
  3467. begin
  3468. SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
  3469. DrawView;
  3470. end;
  3471. procedure TScreenView.HandleEvent(var Event: TEvent);
  3472. begin
  3473. case Event.What of
  3474. evBroadcast :
  3475. case Event.Command of
  3476. cmUpdate : Update;
  3477. end;
  3478. end;
  3479. inherited HandleEvent(Event);
  3480. end;
  3481. procedure TScreenView.Draw;
  3482. var B: TDrawBuffer;
  3483. X,Y: integer;
  3484. Text,Attr: string;
  3485. P: TPoint;
  3486. begin
  3487. Screen^.GetCursorPos(P);
  3488. for Y:=Delta.Y to Delta.Y+Size.Y-1 do
  3489. begin
  3490. if Y<Screen^.GetHeight then
  3491. Screen^.GetLine(Y,Text,Attr)
  3492. else
  3493. begin Text:=''; Attr:=''; end;
  3494. Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
  3495. MoveChar(B,' ',GetColor(1),Size.X);
  3496. for X:=1 to length(Text) do
  3497. MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
  3498. WriteLine(0,Y-Delta.Y,Size.X,1,B);
  3499. end;
  3500. SetCursor(P.X-Delta.X,P.Y-Delta.Y);
  3501. end;
  3502. constructor TScreenWindow.Init(AScreen: PScreen; ANumber: integer);
  3503. var R: TRect;
  3504. VSB,HSB: PScrollBar;
  3505. begin
  3506. Desktop^.GetExtent(R);
  3507. inherited Init(R, dialog_userscreen, ANumber);
  3508. Options:=Options or ofTileAble;
  3509. GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
  3510. New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
  3511. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  3512. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
  3513. New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
  3514. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  3515. GetExtent(R); R.Grow(-1,-1);
  3516. New(ScreenView, Init(R, HSB, VSB, AScreen));
  3517. ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  3518. Insert(ScreenView);
  3519. UserScreenWindow:=@Self;
  3520. end;
  3521. destructor TScreenWindow.Done;
  3522. begin
  3523. inherited Done;
  3524. UserScreenWindow:=nil;
  3525. end;
  3526. const InTranslate : boolean = false;
  3527. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  3528. procedure TranslateAction(Action: integer);
  3529. var E: TEvent;
  3530. begin
  3531. if Action<>acNone then
  3532. begin
  3533. E:=Event;
  3534. E.What:=evMouseDown; E.Buttons:=mbLeftButton;
  3535. View^.HandleEvent(E);
  3536. Event.What:=evCommand;
  3537. Event.Command:=ActionCommands[Action];
  3538. end;
  3539. end;
  3540. begin
  3541. if InTranslate then Exit;
  3542. InTranslate:=true;
  3543. case Event.What of
  3544. evMouseDown :
  3545. if (GetShiftState and kbAlt)<>0 then
  3546. TranslateAction(AltMouseAction) else
  3547. if (GetShiftState and kbCtrl)<>0 then
  3548. TranslateAction(CtrlMouseAction);
  3549. end;
  3550. InTranslate:=false;
  3551. end;
  3552. function GetNextEditorBounds(var Bounds: TRect): boolean;
  3553. var P: PView;
  3554. begin
  3555. P:=Desktop^.Current;
  3556. while P<>nil do
  3557. begin
  3558. if P^.HelpCtx=hcSourceWindow then Break;
  3559. P:=P^.NextView;
  3560. if P=Desktop^.Current then
  3561. begin
  3562. P:=nil;
  3563. break;
  3564. end;
  3565. end;
  3566. if P=nil then Desktop^.GetExtent(Bounds) else
  3567. begin
  3568. P^.GetBounds(Bounds);
  3569. Inc(Bounds.A.X); Inc(Bounds.A.Y);
  3570. end;
  3571. GetNextEditorBounds:=P<>nil;
  3572. end;
  3573. function IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
  3574. var R: TRect;
  3575. W: PSourceWindow;
  3576. begin
  3577. if Assigned(Bounds) then R.Copy(Bounds^) else
  3578. GetNextEditorBounds(R);
  3579. PushStatus(FormatStrStr(msg_openingsourcefile,SmartPath(FileName)));
  3580. New(W, Init(R, FileName));
  3581. if ShowIt=false then
  3582. W^.Hide;
  3583. if W<>nil then
  3584. begin
  3585. if (CurX<>0) or (CurY<>0) then
  3586. with W^.Editor^ do
  3587. begin
  3588. SetCurPtr(CurX,CurY);
  3589. TrackCursor(do_centre);
  3590. end;
  3591. W^.HelpCtx:=hcSourceWindow;
  3592. Desktop^.Insert(W);
  3593. { this makes loading a lot slower and is not needed as far as I can see (FK)
  3594. Message(Application,evBroadcast,cmUpdate,nil);
  3595. }
  3596. end;
  3597. PopStatus;
  3598. IOpenEditorWindow:=W;
  3599. end;
  3600. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  3601. begin
  3602. OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
  3603. end;
  3604. function LastSourceEditor : PSourceWindow;
  3605. function IsSearchedSource(P: PView) : boolean;
  3606. begin
  3607. if assigned(P) and
  3608. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  3609. IsSearchedSource:=true
  3610. else
  3611. IsSearchedSource:=false;
  3612. end;
  3613. begin
  3614. LastSourceEditor:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  3615. end;
  3616. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  3617. var
  3618. D,DS : DirStr;
  3619. N,NS : NameStr;
  3620. E,ES : ExtStr;
  3621. SName : string;
  3622. function IsSearchedFile(W : PSourceWindow) : boolean;
  3623. var Found: boolean;
  3624. begin
  3625. Found:=false;
  3626. if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
  3627. begin
  3628. if (D='') then
  3629. SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
  3630. else
  3631. SName:=PSourceWindow(W)^.Editor^.FileName;
  3632. FSplit(SName,DS,NS,ES);
  3633. SName:=UpcaseStr(NS+ES);
  3634. if (E<>'') or (not tryexts) then
  3635. begin
  3636. if D<>'' then
  3637. Found:=UpCaseStr(DS)+SName=UpcaseStr(D+N+E)
  3638. else
  3639. Found:=SName=UpcaseStr(N+E);
  3640. end
  3641. else
  3642. begin
  3643. Found:=SName=UpcaseStr(N+'.pp');
  3644. if Found=false then
  3645. Found:=SName=UpcaseStr(N+'.pas');
  3646. end;
  3647. end;
  3648. IsSearchedFile:=found;
  3649. end;
  3650. function IsSearchedSource(P: PView) : boolean;
  3651. begin
  3652. if assigned(P) and
  3653. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  3654. IsSearchedSource:=IsSearchedFile(PSourceWindow(P))
  3655. else
  3656. IsSearchedSource:=false;
  3657. end;
  3658. begin
  3659. FSplit(FileName,D,N,E);
  3660. SearchOnDesktop:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  3661. end;
  3662. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  3663. begin
  3664. TryToOpenFile:=ITryToOpenFile(Bounds,FileName,CurX,CurY,tryexts,true,false);
  3665. end;
  3666. function TryToOpenFileMulti(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  3667. var srec:SearchRec;
  3668. dir,name,ext : string;
  3669. begin
  3670. fsplit(filename,dir,name,ext);
  3671. dir:=completedir(dir);
  3672. FindFirst(filename,anyfile,Srec);
  3673. while (DosError=0) do
  3674. begin
  3675. ITryToOpenFile(Bounds,dir+srec.name,CurX,CurY,tryexts,true,false);
  3676. FindNext(srec);
  3677. end;
  3678. FindClose(srec);
  3679. end;
  3680. function LocateSingleSourceFile(const FileName: string; tryexts: boolean): string;
  3681. var D : DirStr;
  3682. N : NameStr;
  3683. E : ExtStr;
  3684. function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
  3685. var OK: boolean;
  3686. begin
  3687. NewDir:=CompleteDir(NewDir);
  3688. OK:=ExistsFile(NewDir+NewName+NewExt);
  3689. if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
  3690. CheckDir:=OK;
  3691. end;
  3692. function CheckExt(NewExt: ExtStr): boolean;
  3693. var OK: boolean;
  3694. begin
  3695. OK:=false;
  3696. if D<>'' then OK:=CheckDir(D,N,NewExt) else
  3697. if CheckDir('.'+DirSep,N,NewExt) then OK:=true;
  3698. CheckExt:=OK;
  3699. end;
  3700. function TryToLocateIn(const DD : dirstr): boolean;
  3701. var Found: boolean;
  3702. begin
  3703. D:=CompleteDir(DD);
  3704. Found:=true;
  3705. if (E<>'') or (not tryexts) then
  3706. Found:=CheckExt(E)
  3707. else
  3708. if CheckExt('.pp') then
  3709. Found:=true
  3710. else
  3711. if CheckExt('.pas') then
  3712. Found:=true
  3713. else
  3714. if CheckExt('.inc') then
  3715. Found:=true
  3716. { try also without extension if no other exist }
  3717. else
  3718. if CheckExt('') then
  3719. Found:=true
  3720. else
  3721. Found:=false;
  3722. TryToLocateIn:=Found;
  3723. end;
  3724. var Path,DrStr: string;
  3725. Found: boolean;
  3726. begin
  3727. FSplit(FileName,D,N,E);
  3728. Found:=CheckDir(D,N,E);
  3729. if not found then
  3730. Found:=TryToLocateIn('.');
  3731. DrStr:=GetSourceDirectories;
  3732. if not Found then
  3733. While pos(ListSeparator,DrStr)>0 do
  3734. Begin
  3735. Found:=TryToLocateIn(Copy(DrStr,1,pos(ListSeparator,DrStr)-1));
  3736. if Found then
  3737. break;
  3738. DrStr:=Copy(DrStr,pos(ListSeparator,DrStr)+1,High(DrStr));
  3739. End;
  3740. if Found then Path:=FExpand(D+N+E) else Path:='';
  3741. LocateSingleSourceFile:=Path;
  3742. end;
  3743. function LocateSourceFile(const FileName: string; tryexts: boolean): string;
  3744. var P: integer;
  3745. FN,S: string;
  3746. FFN: string;
  3747. begin
  3748. FN:=FileName;
  3749. repeat
  3750. P:=Pos(ListSeparator,FN); if P=0 then P:=length(FN)+1;
  3751. S:=copy(FN,1,P-1); Delete(FN,1,P);
  3752. FFN:=LocateSingleSourceFile(S,tryexts);
  3753. until (FFN<>'') or (FN='');
  3754. LocateSourceFile:=FFN;
  3755. end;
  3756. function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean;
  3757. ShowIt,ForceNewWindow: boolean): PSourceWindow;
  3758. var
  3759. W : PSourceWindow;
  3760. DrStr: string;
  3761. begin
  3762. W:=nil;
  3763. if ForceNewWindow then
  3764. W:=nil
  3765. else
  3766. W:=SearchOnDesktop(FileName,tryexts);
  3767. if W<>nil then
  3768. begin
  3769. NewEditorOpened:=false;
  3770. { if assigned(Bounds) then
  3771. W^.ChangeBounds(Bounds^);}
  3772. W^.Editor^.SetCurPtr(CurX,CurY);
  3773. end
  3774. else
  3775. begin
  3776. DrStr:=LocateSourceFile(FileName,tryexts);
  3777. if DrStr<>'' then
  3778. W:=IOpenEditorWindow(Bounds,DrStr,CurX,CurY,ShowIt);
  3779. NewEditorOpened:=W<>nil;
  3780. if assigned(W) then
  3781. W^.Editor^.SetCurPtr(CurX,CurY);
  3782. end;
  3783. ITryToOpenFile:=W;
  3784. end;
  3785. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  3786. var OK: boolean;
  3787. E: PFileEditor;
  3788. R: TRect;
  3789. begin
  3790. R.Assign(0,0,0,0);
  3791. New(E, Init(R,nil,nil,nil,nil,FileName));
  3792. OK:=E<>nil;
  3793. if OK then
  3794. begin
  3795. PushStatus(FormatStrStr(msg_readingfileineditor,FileName));
  3796. OK:=E^.LoadFile;
  3797. PopStatus;
  3798. end;
  3799. if OK then
  3800. begin
  3801. Editor^.Lock;
  3802. E^.SelectAll(true);
  3803. Editor^.InsertFrom(E);
  3804. Editor^.SetCurPtr(0,0);
  3805. Editor^.SelectAll(false);
  3806. Editor^.UnLock;
  3807. Dispose(E, Done);
  3808. end;
  3809. StartEditor:=OK;
  3810. end;
  3811. constructor TTextScroller.Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  3812. begin
  3813. inherited Init(Bounds,'');
  3814. EventMask:=EventMask or evIdle;
  3815. Speed:=ASpeed; Lines:=AText;
  3816. end;
  3817. function TTextScroller.GetLineCount: integer;
  3818. var Count: integer;
  3819. begin
  3820. if Lines=nil then Count:=0 else
  3821. Count:=Lines^.Count;
  3822. GetLineCount:=Count;
  3823. end;
  3824. function TTextScroller.GetLine(I: integer): string;
  3825. var S: string;
  3826. begin
  3827. if I<Lines^.Count then
  3828. S:=GetStr(Lines^.At(I))
  3829. else
  3830. S:='';
  3831. GetLine:=S;
  3832. end;
  3833. procedure TTextScroller.HandleEvent(var Event: TEvent);
  3834. begin
  3835. case Event.What of
  3836. evIdle :
  3837. Update;
  3838. end;
  3839. inherited HandleEvent(Event);
  3840. end;
  3841. procedure TTextScroller.Update;
  3842. begin
  3843. if abs(GetDosTicks-LastTT)<Speed then Exit;
  3844. Scroll;
  3845. LastTT:=GetDosTicks;
  3846. end;
  3847. procedure TTextScroller.Reset;
  3848. begin
  3849. TopLine:=0;
  3850. LastTT:=GetDosTicks;
  3851. DrawView;
  3852. end;
  3853. procedure TTextScroller.Scroll;
  3854. begin
  3855. Inc(TopLine);
  3856. if TopLine>=GetLineCount then
  3857. Reset;
  3858. DrawView;
  3859. end;
  3860. procedure TTextScroller.Draw;
  3861. var B: TDrawBuffer;
  3862. C: word;
  3863. Count,Y: integer;
  3864. S: string;
  3865. begin
  3866. C:=GetColor(1);
  3867. Count:=GetLineCount;
  3868. for Y:=0 to Size.Y-1 do
  3869. begin
  3870. if Count=0 then S:='' else
  3871. S:=GetLine((TopLine+Y) mod Count);
  3872. if copy(S,1,1)=^C then
  3873. S:=CharStr(' ',Max(0,(Size.X-(length(S)-1)) div 2))+copy(S,2,255);
  3874. MoveChar(B,' ',C,Size.X);
  3875. MoveStr(B,S,C);
  3876. WriteLine(0,Y,Size.X,1,B);
  3877. end;
  3878. end;
  3879. destructor TTextScroller.Done;
  3880. begin
  3881. inherited Done;
  3882. if Lines<>nil then Dispose(Lines, Done);
  3883. end;
  3884. constructor TFPAboutDialog.Init;
  3885. var R,R2: TRect;
  3886. C: PUnsortedStringCollection;
  3887. I: integer;
  3888. OSStr: string;
  3889. procedure AddLine(S: string);
  3890. begin
  3891. C^.Insert(NewStr(S));
  3892. end;
  3893. begin
  3894. R.Assign(0,0,58,14{$ifdef NODEBUG}-1{$endif});
  3895. inherited Init(R, dialog_about);
  3896. HelpCtx:=hcAbout;
  3897. GetExtent(R); R.Grow(-3,-2);
  3898. R2.Copy(R); R2.B.Y:=R2.A.Y+1;
  3899. Insert(New(PStaticText, Init(R2, ^C'Free Pascal IDE for '+source_info.name)));
  3900. R2.Move(0,1);
  3901. Insert(New(PStaticText, Init(R2, ^C'Target CPU: '+target_cpu_string)));
  3902. R2.Move(0,1);
  3903. Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr+' '+{$i %date%})));
  3904. R2.Move(0,1);
  3905. {$ifdef USE_GRAPH_SWITCH}
  3906. Insert(New(PStaticText, Init(R2, ^C'With Graphic Support')));
  3907. R2.Move(0,1);
  3908. {$endif USE_GRAPH_SWITCH}
  3909. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_compilerversion,Full_Version_String))));
  3910. {$ifndef NODEBUG}
  3911. if pos('Fake',GDBVersion)=0 then
  3912. begin
  3913. R2.Move(0,1);
  3914. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_debugger,GDBVersion))));
  3915. R2.Move(0,1);
  3916. end
  3917. else
  3918. {$endif NODEBUG}
  3919. R2.Move(0,2);
  3920. Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-2014 by')));
  3921. R2.Move(0,2);
  3922. Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
  3923. R2.Move(0,1);
  3924. Insert(New(PStaticText, Init(R2, ^C'Pierre Muller')));
  3925. R2.Move(0,1);
  3926. Insert(New(PStaticText, Init(R2, ^C'and')));
  3927. R2.Move(0,1);
  3928. Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
  3929. New(C, Init(50,10));
  3930. for I:=1 to 7 do
  3931. AddLine('');
  3932. AddLine(^C'< Original concept >');
  3933. AddLine(^C'Borland International, Inc.');
  3934. AddLine('');
  3935. AddLine(^C'< Compiler development >');
  3936. AddLine(^C'Carl-Eric Codere');
  3937. AddLine(^C'Daniel Mantione');
  3938. AddLine(^C'Florian Kl„mpfl');
  3939. AddLine(^C'Jonas Maebe');
  3940. AddLine(^C'Mich„el Van Canneyt');
  3941. AddLine(^C'Peter Vreman');
  3942. AddLine(^C'Pierre Muller');
  3943. AddLine('');
  3944. AddLine(^C'< IDE development >');
  3945. AddLine(^C'B‚rczi G bor');
  3946. AddLine(^C'Peter Vreman');
  3947. AddLine(^C'Pierre Muller');
  3948. AddLine('');
  3949. GetExtent(R);
  3950. R.Grow(-1,-1); Inc(R.A.Y,3);
  3951. New(Scroller, Init(R, 10, C));
  3952. Scroller^.Hide;
  3953. Insert(Scroller);
  3954. R.Move(0,-1); R.B.Y:=R.A.Y+1;
  3955. New(TitleST, Init(R, ^C'Team'));
  3956. TitleST^.Hide;
  3957. Insert(TitleST);
  3958. InsertOK(@Self);
  3959. end;
  3960. procedure TFPAboutDialog.ToggleInfo;
  3961. begin
  3962. if Scroller=nil then Exit;
  3963. if Scroller^.GetState(sfVisible) then
  3964. begin
  3965. Scroller^.Hide;
  3966. TitleST^.Hide;
  3967. end
  3968. else
  3969. begin
  3970. Scroller^.Reset;
  3971. Scroller^.Show;
  3972. TitleST^.Show;
  3973. end;
  3974. end;
  3975. procedure TFPAboutDialog.HandleEvent(var Event: TEvent);
  3976. begin
  3977. case Event.What of
  3978. evKeyDown :
  3979. case Event.KeyCode of
  3980. kbAltI : { just like in BP }
  3981. begin
  3982. ToggleInfo;
  3983. ClearEvent(Event);
  3984. end;
  3985. end;
  3986. end;
  3987. inherited HandleEvent(Event);
  3988. end;
  3989. constructor TFPASCIIChart.Init;
  3990. begin
  3991. inherited Init;
  3992. HelpCtx:=hcASCIITableWindow;
  3993. Number:=SearchFreeWindowNo;
  3994. ASCIIChart:=@Self;
  3995. end;
  3996. procedure TFPASCIIChart.Store(var S: TStream);
  3997. begin
  3998. inherited Store(S);
  3999. end;
  4000. constructor TFPASCIIChart.Load(var S: TStream);
  4001. begin
  4002. inherited Load(S);
  4003. end;
  4004. procedure TFPASCIIChart.HandleEvent(var Event: TEvent);
  4005. var W: PSourceWindow;
  4006. begin
  4007. {writeln(stderr,'all what=',event.what,' cmd=', event.command);}
  4008. case Event.What of
  4009. evKeyDown :
  4010. case Event.KeyCode of
  4011. kbEsc :
  4012. begin
  4013. Close;
  4014. ClearEvent(Event);
  4015. end;
  4016. end;
  4017. evCommand :
  4018. begin
  4019. {writeln(stderr,'fpascii what=',event.what, ' cmd=', event.command, ' ',cmtransfer,' ',cmsearchwindow);}
  4020. if Event.Command=(AsciiTableCommandBase+1) then // variable
  4021. begin
  4022. W:=FirstEditorWindow;
  4023. if Assigned(W) and Assigned(Report) then
  4024. Message(W,evCommand,cmAddChar,Event.InfoPtr);
  4025. ClearEvent(Event);
  4026. end
  4027. else
  4028. case Event.Command of
  4029. cmTransfer :
  4030. begin
  4031. W:=FirstEditorWindow;
  4032. if Assigned(W) and Assigned(Report) then
  4033. Message(W,evCommand,cmAddChar,pointer(ptrint(ord(Report^.AsciiChar))));
  4034. ClearEvent(Event);
  4035. end;
  4036. cmSearchWindow+1..cmSearchWindow+99 :
  4037. if (Event.Command-cmSearchWindow=Number) then
  4038. ClearEvent(Event);
  4039. end;
  4040. end;
  4041. end;
  4042. inherited HandleEvent(Event);
  4043. end;
  4044. destructor TFPASCIIChart.Done;
  4045. begin
  4046. ASCIIChart:=nil;
  4047. inherited Done;
  4048. end;
  4049. function TVideoModeListBox.GetText(Item: pointer; MaxLen: sw_integer): string;
  4050. var P: PVideoMode;
  4051. S: string;
  4052. begin
  4053. P:=Item;
  4054. S:=IntToStr(P^.Col)+'x'+IntToStr(P^.Row)+' ';
  4055. if P^.Color then
  4056. S:=S+'color'
  4057. else
  4058. S:=S+'mono';
  4059. GetText:=copy(S,1,MaxLen);
  4060. end;
  4061. constructor TFPDesktop.Init(var Bounds: TRect);
  4062. begin
  4063. inherited Init(Bounds);
  4064. end;
  4065. procedure TFPDesktop.InitBackground;
  4066. var AV: PANSIBackground;
  4067. FileName: string;
  4068. R: TRect;
  4069. begin
  4070. AV:=nil;
  4071. FileName:=LocateFile(BackgroundPath);
  4072. if FileName<>'' then
  4073. begin
  4074. GetExtent(R);
  4075. New(AV, Init(R));
  4076. AV^.GrowMode:=gfGrowHiX+gfGrowHiY;
  4077. if AV^.LoadFile(FileName)=false then
  4078. begin
  4079. Dispose(AV, Done); AV:=nil;
  4080. end;
  4081. if Assigned(AV) then
  4082. Insert(AV);
  4083. end;
  4084. Background:=AV;
  4085. if Assigned(Background)=false then
  4086. inherited InitBackground;
  4087. end;
  4088. constructor TFPDesktop.Load(var S: TStream);
  4089. begin
  4090. inherited Load(S);
  4091. end;
  4092. procedure TFPDesktop.Store(var S: TStream);
  4093. begin
  4094. inherited Store(S);
  4095. end;
  4096. constructor TFPToolTip.Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  4097. begin
  4098. inherited Init(Bounds);
  4099. SetAlign(AAlign);
  4100. SetText(AText);
  4101. end;
  4102. procedure TFPToolTip.Draw;
  4103. var C: word;
  4104. procedure DrawLine(Y: integer; S: string);
  4105. var B: TDrawBuffer;
  4106. begin
  4107. S:=copy(S,1,Size.X-2);
  4108. case Align of
  4109. alLeft : S:=' '+S;
  4110. alRight : S:=LExpand(' '+S,Size.X);
  4111. alCenter : S:=Center(S,Size.X);
  4112. end;
  4113. MoveChar(B,' ',C,Size.X);
  4114. MoveStr(B,S,C);
  4115. WriteLine(0,Y,Size.X,1,B);
  4116. end;
  4117. var S: string;
  4118. Y: integer;
  4119. begin
  4120. C:=GetColor(1);
  4121. S:=GetText;
  4122. for Y:=0 to Size.Y-1 do
  4123. DrawLine(Y,S);
  4124. end;
  4125. function TFPToolTip.GetText: string;
  4126. begin
  4127. GetText:=GetStr(Text);
  4128. end;
  4129. procedure TFPToolTip.SetText(const AText: string);
  4130. begin
  4131. if AText<>GetText then
  4132. begin
  4133. if Assigned(Text) then DisposeStr(Text);
  4134. Text:=NewStr(AText);
  4135. DrawView;
  4136. end;
  4137. end;
  4138. function TFPToolTip.GetAlign: TAlign;
  4139. begin
  4140. GetAlign:=Align;
  4141. end;
  4142. procedure TFPToolTip.SetAlign(AAlign: TAlign);
  4143. begin
  4144. if AAlign<>Align then
  4145. begin
  4146. Align:=AAlign;
  4147. DrawView;
  4148. end;
  4149. end;
  4150. destructor TFPToolTip.Done;
  4151. begin
  4152. if Assigned(Text) then DisposeStr(Text); Text:=nil;
  4153. inherited Done;
  4154. end;
  4155. function TFPToolTip.GetPalette: PPalette;
  4156. const S: string[length(CFPToolTip)] = CFPToolTip;
  4157. begin
  4158. GetPalette:=@S;
  4159. end;
  4160. constructor TFPMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4161. PScrollBar; AIndicator: PIndicator);
  4162. begin
  4163. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,nil);
  4164. SetFlags(Flags and not (efPersistentBlocks) or efSyntaxHighlight);
  4165. end;
  4166. procedure TFPMemo.HandleEvent(var Event: TEvent);
  4167. var DontClear: boolean;
  4168. S: string;
  4169. begin
  4170. case Event.What of
  4171. evKeyDown :
  4172. begin
  4173. DontClear:=false;
  4174. case Event.KeyCode of
  4175. kbEsc:
  4176. begin
  4177. Event.What:=evCommand;
  4178. Event.Command:=cmCancel;
  4179. PutEvent(Event);
  4180. end;
  4181. else DontClear:=true;
  4182. end;
  4183. if not DontClear then ClearEvent(Event);
  4184. end;
  4185. end;
  4186. inherited HandleEvent(Event);
  4187. end;
  4188. function TFPMemo.GetPalette: PPalette;
  4189. const P: string[length(CFPMemo)] = CFPMemo;
  4190. begin
  4191. GetPalette:=@P;
  4192. end;
  4193. function TFPMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4194. begin
  4195. GetSpecSymbolCount:=0;
  4196. end;
  4197. function TFPMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4198. begin
  4199. Abstract;
  4200. GetSpecSymbol:=nil;
  4201. end;
  4202. function TFPMemo.IsReservedWord(const S: string): boolean;
  4203. begin
  4204. IsReservedWord:=false;
  4205. end;
  4206. constructor TFPCodeMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4207. PScrollBar; AIndicator: PIndicator);
  4208. begin
  4209. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator);
  4210. end;
  4211. function TFPCodeMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4212. begin
  4213. GetSpecSymbolCount:=FreePascalSpecSymbolCount[SpecClass];
  4214. end;
  4215. function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4216. begin
  4217. GetSpecSymbol:=@FreePascalEmptyString;
  4218. case SpecClass of
  4219. ssCommentPrefix :
  4220. case Index of
  4221. 0 : GetSpecSymbol:=@FreePascalCommentPrefix1;
  4222. 1 : GetSpecSymbol:=@FreePascalCommentPrefix2;
  4223. 2 : GetSpecSymbol:=@FreePascalCommentPrefix3;
  4224. end;
  4225. ssCommentSingleLinePrefix :
  4226. case Index of
  4227. 0 : GetSpecSymbol:=@FreePascalCommentSingleLinePrefix;
  4228. end;
  4229. ssCommentSuffix :
  4230. case Index of
  4231. 0 : GetSpecSymbol:=@FreePascalCommentSuffix1;
  4232. 1 : GetSpecSymbol:=@FreePascalCommentSuffix2;
  4233. end;
  4234. ssStringPrefix :
  4235. GetSpecSymbol:=@FreePascalStringPrefix;
  4236. ssStringSuffix :
  4237. GetSpecSymbol:=@FreePascalStringSuffix;
  4238. { must be uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
  4239. ssAsmPrefix :
  4240. GetSpecSymbol:=@FreePascalAsmPrefix;
  4241. ssAsmSuffix :
  4242. GetSpecSymbol:=@FreePascalAsmSuffix;
  4243. ssDirectivePrefix :
  4244. GetSpecSymbol:=@FreePascalDirectivePrefix;
  4245. ssDirectiveSuffix :
  4246. GetSpecSymbol:=@FreePascalDirectiveSuffix;
  4247. end;
  4248. end;
  4249. function TFPCodeMemo.IsReservedWord(const S: string): boolean;
  4250. begin
  4251. IsReservedWord:=IsFPReservedWord(S);
  4252. end;
  4253. {$ifdef VESA}
  4254. function VESASetVideoModeProc(const VideoMode: TVideoMode; Params: Longint): Boolean;
  4255. begin
  4256. VESASetVideoModeProc:=VESASetMode(Params);
  4257. end;
  4258. procedure InitVESAScreenModes;
  4259. var ML: TVESAModeList;
  4260. MI: TVESAModeInfoBlock;
  4261. I: integer;
  4262. begin
  4263. if VESAInit=false then Exit;
  4264. if VESAGetModeList(ML)=false then Exit;
  4265. for I:=1 to ML.Count do
  4266. begin
  4267. if VESAGetModeInfo(ML.Modes[I],MI) then
  4268. with MI do
  4269. {$ifndef DEBUG}
  4270. if (Attributes and vesa_vma_GraphicsMode)=0 then
  4271. {$else DEBUG}
  4272. if ((Attributes and vesa_vma_GraphicsMode)=0) or
  4273. { only allow 4 bit i.e. 16 color modes }
  4274. (((Attributes and vesa_vma_CanBeSetInCurrentConfig)<>0) and
  4275. (BitsPerPixel=8)) then
  4276. {$endif DEBUG}
  4277. RegisterVesaVideoMode(ML.Modes[I]);
  4278. end;
  4279. end;
  4280. procedure DoneVESAScreenModes;
  4281. begin
  4282. FreeVesaModes;
  4283. end;
  4284. {$endif}
  4285. procedure NoDebugger;
  4286. begin
  4287. InformationBox(msg_nodebuggersupportavailable,nil);
  4288. end;
  4289. procedure RegisterFPViews;
  4290. begin
  4291. RegisterType(RSourceEditor);
  4292. RegisterType(RSourceWindow);
  4293. RegisterType(RFPHelpViewer);
  4294. RegisterType(RFPHelpWindow);
  4295. RegisterType(RClipboardWindow);
  4296. RegisterType(RMessageListBox);
  4297. RegisterType(RFPDesktop);
  4298. RegisterType(RFPASCIIChart);
  4299. RegisterType(RFPDlgWindow);
  4300. {$ifndef NODEBUG}
  4301. RegisterType(RGDBWindow);
  4302. RegisterType(RGDBSourceEditor);
  4303. {$endif NODEBUG}
  4304. end;
  4305. END.