fpviews.pas 123 KB

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