fpviews.pas 125 KB

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