fpviews.pas 124 KB

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