fpviews.pas 124 KB

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