fpviews.pas 125 KB

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