fpviews.pas 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661
  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. MI: PMenuItem;
  1503. begin
  1504. MI:=
  1505. NewItem(menu_edit_cut,menu_key_edit_cut,kbShiftDel,cmCut,hcCut,
  1506. NewItem(menu_edit_copy,menu_key_edit_copy,kbCtrlIns,cmCopy,hcCopy,
  1507. NewItem(menu_edit_paste,menu_key_edit_paste,kbShiftIns,cmPaste,hcPaste,
  1508. NewItem(menu_edit_clear,menu_key_edit_clear,kbCtrlDel,cmClear,hcClear,
  1509. NewLine(
  1510. NewItem(menu_srclocal_openfileatcursor,'',kbNoKey,cmOpenAtCursor,hcOpenAtCursor,
  1511. NewItem(menu_srclocal_browseatcursor,'',kbNoKey,cmBrowseAtCursor,hcBrowseAtCursor,
  1512. NewItem(menu_srclocal_topicsearch,menu_key_help_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  1513. NewLine(
  1514. NewItem(menu_srclocal_options,'',kbNoKey,cmEditorOptions,hcEditorOptions,
  1515. nil))))))))));
  1516. if IsChangedOnDisk then
  1517. MI:=NewItem(menu_srclocal_reload,'',kbNoKey,cmDoReload,hcDoReload,
  1518. MI);
  1519. M:=NewMenu(MI);
  1520. GetLocalMenu:=M;
  1521. end;
  1522. function TSourceEditor.GetCommandTarget: PView;
  1523. begin
  1524. GetCommandTarget:=@Self;
  1525. end;
  1526. function TSourceEditor.CreateLocalMenuView(var Bounds: TRect; M: PMenu): PMenuPopup;
  1527. var MV: PAdvancedMenuPopup;
  1528. begin
  1529. New(MV, Init(Bounds,M));
  1530. CreateLocalMenuView:=MV;
  1531. end;
  1532. {$ifdef DebugUndo}
  1533. procedure TSourceEditor.DumpUndo;
  1534. var
  1535. i : sw_integer;
  1536. begin
  1537. ClearToolMessages;
  1538. AddToolCommand('UndoList Dump');
  1539. for i:=0 to Core^.UndoList^.count-1 do
  1540. with Core^.UndoList^.At(i)^ do
  1541. begin
  1542. if is_grouped_action then
  1543. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  1544. else
  1545. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.Y+1)+':'+IntToStr(StartPos.X+1)+
  1546. ' '+IntToStr(EndPos.Y+1)+':'+IntToStr(EndPos.X+1)+' "'+GetStr(Text)+'"',0,0);
  1547. end;
  1548. if Core^.RedoList^.count>0 then
  1549. AddToolCommand('RedoList Dump');
  1550. for i:=0 to Core^.RedoList^.count-1 do
  1551. with Core^.RedoList^.At(i)^ do
  1552. begin
  1553. if is_grouped_action then
  1554. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  1555. else
  1556. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.Y+1)+':'+IntToStr(StartPos.X+1)+
  1557. ' '+IntToStr(EndPos.Y+1)+':'+IntToStr(EndPos.X+1)+' "'+GetStr(Text)+'"',0,0);
  1558. end;
  1559. UpdateToolMessages;
  1560. if Assigned(MessagesWindow) then
  1561. MessagesWindow^.Focus;
  1562. end;
  1563. procedure TSourceEditor.UndoAll;
  1564. begin
  1565. While Core^.UndoList^.count>0 do
  1566. Undo;
  1567. end;
  1568. procedure TSourceEditor.RedoAll;
  1569. begin
  1570. While Core^.RedoList^.count>0 do
  1571. Redo;
  1572. end;
  1573. {$endif DebugUndo}
  1574. function TSourceEditor.Valid(Command: Word): Boolean;
  1575. var OK: boolean;
  1576. begin
  1577. OK:=inherited Valid(Command);
  1578. if OK and ({(Command=cmClose) or already handled in TFileEditor.Valid PM }
  1579. (Command=cmAskSaveAll)) then
  1580. if IsClipboard=false then
  1581. OK:=SaveAsk(false);
  1582. Valid:=OK;
  1583. end;
  1584. procedure TSourceEditor.HandleEvent(var Event: TEvent);
  1585. var DontClear: boolean;
  1586. S: string;
  1587. begin
  1588. TranslateMouseClick(@Self,Event);
  1589. case Event.What of
  1590. evKeyDown :
  1591. begin
  1592. DontClear:=false;
  1593. case Event.KeyCode of
  1594. kbCtrlEnter :
  1595. Message(@Self,evCommand,cmOpenAtCursor,nil);
  1596. else DontClear:=true;
  1597. end;
  1598. if not DontClear then ClearEvent(Event);
  1599. end;
  1600. end;
  1601. inherited HandleEvent(Event);
  1602. case Event.What of
  1603. evBroadcast :
  1604. case Event.Command of
  1605. cmCalculatorPaste :
  1606. begin
  1607. InsertText(FloatToStr(CalcClipboard,0));
  1608. ClearEvent(Event);
  1609. end;
  1610. end;
  1611. evCommand :
  1612. begin
  1613. DontClear:=false;
  1614. case Event.Command of
  1615. {$ifdef DebugUndo}
  1616. cmDumpUndo : DumpUndo;
  1617. cmUndoAll : UndoAll;
  1618. cmRedoAll : RedoAll;
  1619. {$endif DebugUndo}
  1620. cmDoReload : ReloadFile;
  1621. cmBrowseAtCursor:
  1622. begin
  1623. S:=LowerCaseStr(GetEditorCurWord(@Self,[]));
  1624. OpenOneSymbolBrowser(S);
  1625. end;
  1626. cmOpenAtCursor :
  1627. begin
  1628. S:=LowerCaseStr(GetEditorCurWord(@Self,['.']));
  1629. if Pos('.',S)<>0 then
  1630. OpenFileName:=S else
  1631. OpenFileName:=S+'.pp'+ListSeparator+
  1632. S+'.pas'+ListSeparator+
  1633. S+'.inc';
  1634. Message(Application,evCommand,cmOpen,nil);
  1635. end;
  1636. cmEditorOptions :
  1637. Message(Application,evCommand,cmEditorOptions,@Self);
  1638. cmHelp :
  1639. Message(@Self,evCommand,cmHelpTopicSearch,@Self);
  1640. cmHelpTopicSearch :
  1641. HelpTopicSearch(@Self);
  1642. else DontClear:=true;
  1643. end;
  1644. if not DontClear then ClearEvent(Event);
  1645. end;
  1646. end;
  1647. end;
  1648. constructor TFPHeapView.Init(var Bounds: TRect);
  1649. begin
  1650. if inherited Init(Bounds)=false then Fail;
  1651. Options:=Options or gfGrowHiX or gfGrowHiY;
  1652. EventMask:=EventMask or evIdle;
  1653. GrowMode:=gfGrowAll;
  1654. end;
  1655. constructor TFPHeapView.InitKb(var Bounds: TRect);
  1656. begin
  1657. if inherited InitKb(Bounds)=false then Fail;
  1658. Options:=Options or gfGrowHiX or gfGrowHiY;
  1659. EventMask:=EventMask or evIdle;
  1660. GrowMode:=gfGrowAll;
  1661. end;
  1662. procedure TFPHeapView.HandleEvent(var Event: TEvent);
  1663. begin
  1664. case Event.What of
  1665. evIdle :
  1666. Update;
  1667. end;
  1668. inherited HandleEvent(Event);
  1669. end;
  1670. constructor TFPClockView.Init(var Bounds: TRect);
  1671. begin
  1672. inherited Init(Bounds);
  1673. EventMask:=EventMask or evIdle;
  1674. end;
  1675. procedure TFPClockView.HandleEvent(var Event: TEvent);
  1676. begin
  1677. case Event.What of
  1678. evIdle :
  1679. Update;
  1680. end;
  1681. inherited HandleEvent(Event);
  1682. end;
  1683. function TFPClockView.GetPalette: PPalette;
  1684. const P: string[length(CFPClockView)] = CFPClockView;
  1685. begin
  1686. GetPalette:=@P;
  1687. end;
  1688. procedure TFPWindow.SetState(AState: Word; Enable: Boolean);
  1689. var OldState: word;
  1690. begin
  1691. OldState:=State;
  1692. inherited SetState(AState,Enable);
  1693. if AutoNumber then
  1694. if (AState and (sfVisible+sfExposed))<>0 then
  1695. if GetState(sfVisible+sfExposed) then
  1696. begin
  1697. if Number=0 then
  1698. Number:=SearchFreeWindowNo;
  1699. ReDraw;
  1700. end
  1701. else
  1702. Number:=0;
  1703. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  1704. UpdateCommands;
  1705. end;
  1706. procedure TFPWindow.UpdateCommands;
  1707. begin
  1708. end;
  1709. procedure TFPWindow.Update;
  1710. begin
  1711. ReDraw;
  1712. end;
  1713. procedure TFPWindow.SelectInDebugSession;
  1714. var
  1715. F,PrevCurrent : PView;
  1716. begin
  1717. DeskTop^.Lock;
  1718. PrevCurrent:=Desktop^.Current;
  1719. F:=PrevCurrent;
  1720. While assigned(F) and
  1721. ((F^.HelpCtx = hcGDBWindow) or
  1722. (F^.HelpCtx = hcdisassemblyWindow) or
  1723. (F^.HelpCtx = hcWatchesWindow) or
  1724. (F^.HelpCtx = hcStackWindow) or
  1725. (F^.HelpCtx = hcRegistersWindow) or
  1726. (F^.HelpCtx = hcFPURegisters)) do
  1727. F:=F^.NextView;
  1728. if F<>@Self then
  1729. Select;
  1730. if PrevCurrent<>F then
  1731. Begin
  1732. Desktop^.InsertBefore(@self,F);
  1733. PrevCurrent^.Select;
  1734. End;
  1735. DeskTop^.Unlock;
  1736. end;
  1737. procedure TFPWindow.HandleEvent(var Event: TEvent);
  1738. begin
  1739. case Event.What of
  1740. evBroadcast :
  1741. case Event.Command of
  1742. cmUpdate :
  1743. Update;
  1744. cmSearchWindow+1..cmSearchWindow+99 :
  1745. if (Event.Command-cmSearchWindow=Number) then
  1746. ClearEvent(Event);
  1747. end;
  1748. end;
  1749. inherited HandleEvent(Event);
  1750. end;
  1751. constructor TFPWindow.Load(var S: TStream);
  1752. begin
  1753. inherited Load(S);
  1754. S.Read(AutoNumber,SizeOf(AutoNumber));
  1755. end;
  1756. procedure TFPWindow.Store(var S: TStream);
  1757. begin
  1758. inherited Store(S);
  1759. S.Write(AutoNumber,SizeOf(AutoNumber));
  1760. end;
  1761. function TFPHelpViewer.GetLocalMenu: PMenu;
  1762. var M: PMenu;
  1763. begin
  1764. M:=NewMenu(
  1765. NewItem(menu_hlplocal_contents,'',kbNoKey,cmHelpContents,hcHelpContents,
  1766. NewItem(menu_hlplocal_index,menu_key_hlplocal_index,kbShiftF1,cmHelpIndex,hcHelpIndex,
  1767. NewItem(menu_hlplocal_topicsearch,menu_key_hlplocal_topicsearch,kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  1768. NewItem(menu_hlplocal_prevtopic,menu_key_hlplocal_prevtopic,kbAltF1,cmHelpPrevTopic,hcHelpPrevTopic,
  1769. NewLine(
  1770. NewItem(menu_hlplocal_copy,menu_key_hlplocal_copy,kbCtrlIns,cmCopy,hcCopy,
  1771. nil)))))));
  1772. GetLocalMenu:=M;
  1773. end;
  1774. function TFPHelpViewer.GetCommandTarget: PView;
  1775. begin
  1776. GetCommandTarget:=Application;
  1777. end;
  1778. constructor TFPHelpWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word;
  1779. AContext: THelpCtx; ANumber: Integer);
  1780. begin
  1781. inherited Init(Bounds,ATitle,ASourceFileID,AContext,ANumber);
  1782. HelpCtx:=hcHelpWindow;
  1783. HideOnClose:=true;
  1784. end;
  1785. destructor TFPHelpWindow.Done;
  1786. begin
  1787. if HelpWindow=@Self then
  1788. HelpWindow:=nil;
  1789. Inherited Done;
  1790. end;
  1791. procedure TFPHelpWindow.InitHelpView;
  1792. var R: TRect;
  1793. begin
  1794. GetExtent(R); R.Grow(-1,-1);
  1795. HelpView:=New(PFPHelpViewer, Init(R, HSB, VSB));
  1796. HelpView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1797. end;
  1798. procedure TFPHelpWindow.Show;
  1799. begin
  1800. inherited Show;
  1801. if GetState(sfVisible) and (Number=0) then
  1802. begin
  1803. Number:=SearchFreeWindowNo;
  1804. ReDraw;
  1805. end;
  1806. end;
  1807. procedure TFPHelpWindow.Hide;
  1808. begin
  1809. inherited Hide;
  1810. if GetState(sfVisible)=false then
  1811. Number:=0;
  1812. end;
  1813. procedure TFPHelpWindow.HandleEvent(var Event: TEvent);
  1814. begin
  1815. case Event.What of
  1816. evBroadcast :
  1817. case Event.Command of
  1818. cmUpdate :
  1819. ReDraw;
  1820. cmSearchWindow+1..cmSearchWindow+99 :
  1821. if (Event.Command-cmSearchWindow=Number) then
  1822. ClearEvent(Event);
  1823. end;
  1824. end;
  1825. inherited HandleEvent(Event);
  1826. end;
  1827. function TFPHelpWindow.GetPalette: PPalette;
  1828. const P: string[length(CIDEHelpDialog)] = CIDEHelpDialog;
  1829. begin
  1830. GetPalette:=@P;
  1831. end;
  1832. constructor TFPHelpWindow.Load(var S: TStream);
  1833. begin
  1834. Abstract;
  1835. end;
  1836. procedure TFPHelpWindow.Store(var S: TStream);
  1837. begin
  1838. Abstract;
  1839. end;
  1840. constructor TSourceWindow.Init(var Bounds: TRect; AFileName: string);
  1841. var HSB,VSB: PScrollBar;
  1842. R: TRect;
  1843. PA : Array[1..2] of pointer;
  1844. LoadFile: boolean;
  1845. begin
  1846. inherited Init(Bounds,AFileName,{SearchFreeWindowNo}0);
  1847. AutoNumber:=true;
  1848. Options:=Options or ofTileAble;
  1849. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1850. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1851. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1852. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1853. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1854. New(Indicator, Init(R));
  1855. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1856. Insert(Indicator);
  1857. GetExtent(R); R.Grow(-1,-1);
  1858. LoadFile:=(AFileName<>'') and (AFileName<>'*');
  1859. if (AFileName='') then
  1860. begin
  1861. Inc(GlobalNoNameCount);
  1862. NoNameCount:=GlobalNoNameCount;
  1863. end
  1864. else
  1865. NoNameCount:=-1;
  1866. if AFileName='*' then
  1867. AFileName:='';
  1868. New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
  1869. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1870. if LoadFile then
  1871. begin
  1872. if Editor^.LoadFile=false then
  1873. ErrorBox(FormatStrStr(msg_errorreadingfile,AFileName),nil)
  1874. { warn if modified, but not if modified in another
  1875. already open window PM }
  1876. else if Editor^.GetModified and (Editor^.Core^.GetBindingCount=1) then
  1877. begin
  1878. PA[1]:=@AFileName;
  1879. longint(PA[2]):={Editor^.ChangedLine}-1;
  1880. EditorDialog(edChangedOnloading,@PA);
  1881. end;
  1882. end;
  1883. Insert(Editor);
  1884. If assigned(BreakpointsCollection) then
  1885. BreakpointsCollection^.ShowBreakpoints(@Self);
  1886. UpdateTitle;
  1887. end;
  1888. procedure TSourceWindow.UpdateTitle;
  1889. var Name: string;
  1890. Count: sw_integer;
  1891. begin
  1892. if Editor^.FileName<>'' then
  1893. begin
  1894. Name:=SmartPath(Editor^.FileName);
  1895. Count:=Editor^.Core^.GetBindingCount;
  1896. if Count>1 then
  1897. begin
  1898. Name:=Name+':'+IntToStr(Editor^.Core^.GetBindingIndex(Editor)+1);
  1899. end;
  1900. SetTitle(Name);
  1901. end
  1902. else if NoNameCount>=0 then
  1903. begin
  1904. SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas');
  1905. end;
  1906. end;
  1907. function TSourceWindow.GetTitle(MaxSize: sw_Integer): TTitleStr;
  1908. begin
  1909. GetTitle:=OptimizePath(inherited GetTitle(255),MaxSize);
  1910. end;
  1911. procedure TSourceWindow.SetTitle(ATitle: string);
  1912. begin
  1913. if Title<>nil then DisposeStr(Title);
  1914. Title:=NewStr(ATitle);
  1915. {$ifdef FVISION}
  1916. If assigned(Owner) then
  1917. DrawBorder;
  1918. {$else}
  1919. Frame^.DrawView;
  1920. {$endif}
  1921. end;
  1922. procedure TSourceWindow.HandleEvent(var Event: TEvent);
  1923. var DontClear: boolean;
  1924. begin
  1925. case Event.What of
  1926. evBroadcast :
  1927. case Event.Command of
  1928. cmUpdate :
  1929. Update;
  1930. cmUpdateTitle :
  1931. UpdateTitle;
  1932. cmSearchWindow :
  1933. if @Self<>ClipboardWindow then
  1934. ClearEvent(Event);
  1935. end;
  1936. evCommand :
  1937. begin
  1938. DontClear:=false;
  1939. case Event.Command of
  1940. cmHide :
  1941. Hide;
  1942. cmSave :
  1943. if Editor^.IsClipboard=false then
  1944. if (Editor^.FileName='') and Editor^.GetModified then
  1945. Editor^.SaveAs
  1946. else
  1947. Editor^.Save;
  1948. cmSaveAs :
  1949. if Editor^.IsClipboard=false then
  1950. Editor^.SaveAs;
  1951. else DontClear:=true;
  1952. end;
  1953. if DontClear=false then ClearEvent(Event);
  1954. end;
  1955. end;
  1956. inherited HandleEvent(Event);
  1957. end;
  1958. procedure TSourceWindow.UpdateCommands;
  1959. var Active: boolean;
  1960. begin
  1961. Active:=GetState(sfActive);
  1962. if Editor^.IsClipboard=false then
  1963. begin
  1964. SetCmdState(SourceCmds+CompileCmds,Active);
  1965. SetCmdState(EditorCmds,Active);
  1966. end;
  1967. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
  1968. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  1969. end;
  1970. procedure TSourceWindow.Update;
  1971. begin
  1972. ReDraw;
  1973. end;
  1974. function TSourceWindow.GetPalette: PPalette;
  1975. const P: string[length(CSourceWindow)] = CSourceWindow;
  1976. begin
  1977. GetPalette:=@P;
  1978. end;
  1979. constructor TSourceWindow.Load(var S: TStream);
  1980. begin
  1981. Title:=S.ReadStr;
  1982. PushStatus(FormatStrStr(msg_loadingfile,GetStr(Title)));
  1983. inherited Load(S);
  1984. GetSubViewPtr(S,Indicator);
  1985. GetSubViewPtr(S,Editor);
  1986. If assigned(BreakpointsCollection) then
  1987. BreakpointsCollection^.ShowBreakpoints(@Self);
  1988. PopStatus;
  1989. end;
  1990. procedure TSourceWindow.Store(var S: TStream);
  1991. begin
  1992. S.WriteStr(Title);
  1993. PushStatus(FormatStrStr(msg_storingfile,GetStr(Title)));
  1994. inherited Store(S);
  1995. PutSubViewPtr(S,Indicator);
  1996. PutSubViewPtr(S,Editor);
  1997. PopStatus;
  1998. end;
  1999. procedure TSourceWindow.Close;
  2000. begin
  2001. inherited Close;
  2002. end;
  2003. destructor TSourceWindow.Done;
  2004. begin
  2005. PushStatus(FormatStrStr(msg_closingfile,GetStr(Title)));
  2006. if not IDEApp.IsClosing then
  2007. Message(Application,evBroadcast,cmSourceWndClosing,@Self);
  2008. inherited Done;
  2009. IDEApp.SourceWindowClosed;
  2010. { if not IDEApp.IsClosing then
  2011. Message(Application,evBroadcast,cmUpdate,@Self);}
  2012. PopStatus;
  2013. end;
  2014. function TGDBSourceEditor.Valid(Command: Word): Boolean;
  2015. var OK: boolean;
  2016. begin
  2017. OK:=TCodeEditor.Valid(Command);
  2018. { do NOT ask for save !!
  2019. if OK and ((Command=cmClose) or (Command=cmQuit)) then
  2020. if IsClipboard=false then
  2021. OK:=SaveAsk; }
  2022. Valid:=OK;
  2023. end;
  2024. procedure TGDBSourceEditor.AddLine(const S: string);
  2025. begin
  2026. if Silent or (IgnoreStringAtEnd and (S=LastCommand)) then exit;
  2027. inherited AddLine(S);
  2028. LimitsChanged;
  2029. end;
  2030. procedure TGDBSourceEditor.AddErrorLine(const S: string);
  2031. begin
  2032. if Silent then exit;
  2033. inherited AddLine(S);
  2034. { display like breakpoints in red }
  2035. SetLineFlagState(GetLineCount-1,lfBreakpoint,true);
  2036. LimitsChanged;
  2037. end;
  2038. const
  2039. GDBReservedCount = 6;
  2040. GDBReservedLongest = 3;
  2041. GDBReserved : array[1..GDBReservedCount] of String[GDBReservedLongest] =
  2042. ('gdb','b','n','s','f','bt');
  2043. function IsGDBReservedWord(const S : string) : boolean;
  2044. var
  2045. i : longint;
  2046. begin
  2047. for i:=1 to GDBReservedCount do
  2048. if (S=GDBReserved[i]) then
  2049. begin
  2050. IsGDBReservedWord:=true;
  2051. exit;
  2052. end;
  2053. IsGDBReservedWord:=false;
  2054. end;
  2055. function TGDBSourceEditor.IsReservedWord(const S: string): boolean;
  2056. begin
  2057. IsReservedWord:=IsGDBReservedWord(S);
  2058. end;
  2059. function TGDBSourceEditor.InsertNewLine: Sw_integer;
  2060. Var
  2061. S : string;
  2062. CommandCalled : boolean;
  2063. begin
  2064. if IsReadOnly then begin InsertNewLine:=-1; Exit; end;
  2065. if CurPos.Y<GetLineCount then S:=GetDisplayText(CurPos.Y) else S:='';
  2066. s:=Copy(S,1,CurPos.X);
  2067. CommandCalled:=false;
  2068. if Pos(GDBPrompt,S)=1 then
  2069. Delete(S,1,length(GDBPrompt));
  2070. if assigned(Debugger) then
  2071. if S<>'' then
  2072. begin
  2073. LastCommand:=S;
  2074. { should be true only if we are at the end ! }
  2075. IgnoreStringAtEnd:=(CurPos.Y=GetLineCount-1) and
  2076. (CurPos.X>=length(RTrim(GetDisplayText(GetLineCount-1))));
  2077. Debugger^.Command(S);
  2078. CommandCalled:=true;
  2079. IgnoreStringAtEnd:=false;
  2080. end
  2081. else if AutoRepeat and (CurPos.Y=GetLineCount-1) then
  2082. begin
  2083. Debugger^.Command(LastCommand);
  2084. CommandCalled:=true;
  2085. end;
  2086. InsertNewLine:=inherited InsertNewLine;
  2087. If CommandCalled then
  2088. InsertText(GDBPrompt);
  2089. end;
  2090. constructor TGDBWindow.Init(var Bounds: TRect);
  2091. var HSB,VSB: PScrollBar;
  2092. R: TRect;
  2093. begin
  2094. inherited Init(Bounds,dialog_gdbwindow,0);
  2095. Options:=Options or ofTileAble;
  2096. AutoNumber:=true;
  2097. HelpCtx:=hcGDBWindow;
  2098. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2099. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2100. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2101. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2102. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2103. New(Indicator, Init(R));
  2104. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2105. Insert(Indicator);
  2106. GetExtent(R); R.Grow(-1,-1);
  2107. New(Editor, Init(R, HSB, VSB, Indicator, GDBOutputFile));
  2108. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2109. Editor^.SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs);
  2110. if ExistsFile(GDBOutputFile) then
  2111. begin
  2112. if Editor^.LoadFile=false then
  2113. ErrorBox(FormatStrStr(msg_errorreadingfile,GDBOutputFile),nil);
  2114. end
  2115. else
  2116. { Empty files are buggy !! }
  2117. Editor^.AddLine('');
  2118. Insert(Editor);
  2119. if assigned(Debugger) then
  2120. Debugger^.SetWidth(Size.X-1);
  2121. Editor^.silent:=false;
  2122. Editor^.AutoRepeat:=true;
  2123. Editor^.InsertText(GDBPrompt);
  2124. end;
  2125. procedure TGDBWindow.HandleEvent(var Event: TEvent);
  2126. var DontClear: boolean;
  2127. begin
  2128. case Event.What of
  2129. evCommand :
  2130. begin
  2131. DontClear:=false;
  2132. case Event.Command of
  2133. cmSaveAs :
  2134. Editor^.SaveAs;
  2135. else DontClear:=true;
  2136. end;
  2137. if DontClear=false then ClearEvent(Event);
  2138. end;
  2139. end;
  2140. inherited HandleEvent(Event);
  2141. end;
  2142. destructor TGDBWindow.Done;
  2143. begin
  2144. if @Self=GDBWindow then
  2145. GDBWindow:=nil;
  2146. inherited Done;
  2147. end;
  2148. constructor TGDBWindow.Load(var S: TStream);
  2149. begin
  2150. inherited Load(S);
  2151. GetSubViewPtr(S,Indicator);
  2152. GetSubViewPtr(S,Editor);
  2153. GDBWindow:=@self;
  2154. end;
  2155. procedure TGDBWindow.Store(var S: TStream);
  2156. begin
  2157. inherited Store(S);
  2158. PutSubViewPtr(S,Indicator);
  2159. PutSubViewPtr(S,Editor);
  2160. end;
  2161. function TGDBWindow.GetPalette: PPalette;
  2162. const P: string[length(CSourceWindow)] = CSourceWindow;
  2163. begin
  2164. GetPalette:=@P;
  2165. end;
  2166. procedure TGDBWindow.WriteOutputText(Buf : pchar);
  2167. begin
  2168. {selected normal color ?}
  2169. WriteText(Buf,false);
  2170. end;
  2171. procedure TGDBWindow.WriteErrorText(Buf : pchar);
  2172. begin
  2173. {selected normal color ?}
  2174. WriteText(Buf,true);
  2175. end;
  2176. procedure TGDBWindow.WriteString(Const S : string);
  2177. begin
  2178. Editor^.AddLine(S);
  2179. end;
  2180. procedure TGDBWindow.WriteErrorString(Const S : string);
  2181. begin
  2182. Editor^.AddErrorLine(S);
  2183. end;
  2184. procedure TGDBWindow.WriteText(Buf : pchar;IsError : boolean);
  2185. var p,pe : pchar;
  2186. s : string;
  2187. begin
  2188. p:=buf;
  2189. DeskTop^.Lock;
  2190. While assigned(p) and (p^<>#0) do
  2191. begin
  2192. pe:=strscan(p,#10);
  2193. if pe<>nil then
  2194. pe^:=#0;
  2195. s:=strpas(p);
  2196. If IsError then
  2197. Editor^.AddErrorLine(S)
  2198. else
  2199. Editor^.AddLine(S);
  2200. { restore for dispose }
  2201. if pe<>nil then
  2202. pe^:=#10;
  2203. if pe=nil then
  2204. p:=nil
  2205. else
  2206. begin
  2207. if pe-p > High(s) then
  2208. p:=p+High(s)-1
  2209. else
  2210. begin
  2211. p:=pe;
  2212. inc(p);
  2213. end;
  2214. end;
  2215. end;
  2216. DeskTop^.Unlock;
  2217. Editor^.Draw;
  2218. end;
  2219. procedure TGDBWindow.UpdateCommands;
  2220. var Active: boolean;
  2221. begin
  2222. Active:=GetState(sfActive);
  2223. SetCmdState([cmSaveAs,cmHide,cmRun],Active);
  2224. SetCmdState(EditorCmds,Active);
  2225. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
  2226. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2227. end;
  2228. function TDisasLineCollection.At(Index: sw_Integer): PDisasLine;
  2229. begin
  2230. At := PDisasLine(Inherited At(Index));
  2231. end;
  2232. constructor TDisassemblyEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  2233. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  2234. begin
  2235. Inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,AFileName);
  2236. GrowMode:=gfGrowHiX+gfGrowHiY;
  2237. SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs{+efHighlightRow});
  2238. New(DisasLines,Init(500,1000));
  2239. Core^.ChangeLinesTo(DisasLines);
  2240. { do not allow to write into that window }
  2241. ReadOnly:=true;
  2242. AddLine('');
  2243. MinAddress:=0;
  2244. MaxAddress:=0;
  2245. CurL:=nil;
  2246. OwnsSource:=false;
  2247. Source:=nil;
  2248. end;
  2249. destructor TDisassemblyEditor.Done;
  2250. begin
  2251. ReleaseSource;
  2252. Inherited Done;
  2253. end;
  2254. procedure TDisassemblyEditor.ReleaseSource;
  2255. begin
  2256. if OwnsSource and assigned(source) then
  2257. begin
  2258. Desktop^.Delete(Source);
  2259. Dispose(Source,Done);
  2260. end;
  2261. OwnsSource:=false;
  2262. Source:=nil;
  2263. CurrentSource:='';
  2264. end;
  2265. procedure TDisassemblyEditor.AddSourceLine(const AFileName: string;line : longint);
  2266. var
  2267. S : String;
  2268. begin
  2269. if AFileName<>CurrentSource then
  2270. begin
  2271. ReleaseSource;
  2272. Source:=SearchOnDesktop(FileName,false);
  2273. if not assigned(Source) then
  2274. begin
  2275. Source:=ITryToOpenFile(nil,AFileName,0,line,false,false,true);
  2276. OwnsSource:=true;
  2277. end
  2278. else
  2279. OwnsSource:=false;
  2280. CurrentSource:=AFileName;
  2281. end;
  2282. if Assigned(Source) and (line>0) then
  2283. S:=Trim(Source^.Editor^.GetLineText(line-1))
  2284. else
  2285. S:='<source not found>';
  2286. CurrentLine:=Line;
  2287. inherited AddLine(AFileName+':'+IntToStr(line)+' '+S);
  2288. { display differently }
  2289. SetLineFlagState(GetLineCount-1,lfSpecialRow,true);
  2290. LimitsChanged;
  2291. end;
  2292. procedure TDisassemblyEditor.AddAssemblyLine(const S: string;AAddress : cardinal);
  2293. var
  2294. PL : PDisasLine;
  2295. LI : PEditorLineInfo;
  2296. begin
  2297. if AAddress<>0 then
  2298. inherited AddLine('$'+hexstr(AAddress,8)+S)
  2299. else
  2300. inherited AddLine(S);
  2301. PL:=DisasLines^.At(DisasLines^.count-1);
  2302. PL^.Address:=AAddress;
  2303. LI:=PL^.GetEditorInfo(@Self);
  2304. if AAddress<>0 then
  2305. LI^.BeginsWithAsm:=true;
  2306. LimitsChanged;
  2307. if ((AAddress<minaddress) or (minaddress=0)) and (AAddress<>0) then
  2308. MinAddress:=AAddress;
  2309. if (AAddress>maxaddress) or (maxaddress=0) then
  2310. MaxAddress:=AAddress;
  2311. end;
  2312. function TDisassemblyEditor.GetCurrentLine(address : cardinal) : PDisasLine;
  2313. function IsCorrectLine(PL : PDisasLine) : boolean;
  2314. begin
  2315. IsCorrectLine:=PL^.Address=Address;
  2316. end;
  2317. Var
  2318. PL : PDisasLine;
  2319. begin
  2320. PL:=DisasLines^.FirstThat(@IsCorrectLine);
  2321. if Assigned(PL) then
  2322. begin
  2323. if assigned(CurL) then
  2324. CurL^.SetFlagState(lfDebuggerRow,false);
  2325. SetCurPtr(0,DisasLines^.IndexOf(PL));
  2326. PL^.SetFlags(lfDebuggerRow);
  2327. CurL:=PL;
  2328. TrackCursor(false);
  2329. end;
  2330. GetCurrentLine:=PL;
  2331. end;
  2332. { PDisassemblyWindow = ^TDisassemblyWindow;
  2333. TDisassemblyWindow = object(TFPWindow)
  2334. Editor : PDisassemblyEditor;
  2335. Indicator : PIndicator; }
  2336. constructor TDisassemblyWindow.Init(var Bounds: TRect);
  2337. var HSB,VSB: PScrollBar;
  2338. R: TRect;
  2339. begin
  2340. inherited Init(Bounds,dialog_disaswindow,0);
  2341. Options:=Options or ofTileAble;
  2342. AutoNumber:=true;
  2343. HelpCtx:=hcDisassemblyWindow;
  2344. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2345. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2346. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2347. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2348. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2349. New(Indicator, Init(R));
  2350. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2351. Insert(Indicator);
  2352. GetExtent(R); R.Grow(-1,-1);
  2353. New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
  2354. Insert(Editor);
  2355. DisassemblyWindow:=@Self;
  2356. end;
  2357. procedure TDisassemblyWindow.LoadFunction(Const FuncName : string);
  2358. var
  2359. p : pchar;
  2360. begin
  2361. If not assigned(Debugger) then Exit;
  2362. Debugger^.Command('set print sym on');
  2363. Debugger^.Command('set width 0xffffffff');
  2364. Debugger^.Command('disas '+FuncName);
  2365. p:=StrNew(Debugger^.GetOutput);
  2366. ProcessPChar(p);
  2367. if (Debugger^.IsRunning) and (FuncName='') then
  2368. Editor^.GetCurrentLine(Debugger^.current_pc);
  2369. end;
  2370. procedure TDisassemblyWindow.LoadAddress(Addr : cardinal);
  2371. var
  2372. p : pchar;
  2373. begin
  2374. If not assigned(Debugger) then Exit;
  2375. Debugger^.Command('set print sym on');
  2376. Debugger^.Command('set width 0xffffffff');
  2377. Debugger^.Command('disas 0x'+HexStr(Addr,8));
  2378. p:=StrNew(Debugger^.GetOutput);
  2379. ProcessPChar(p);
  2380. if Debugger^.IsRunning and
  2381. (Debugger^.current_pc>=Editor^.MinAddress) and
  2382. (Debugger^.current_pc<=Editor^.MaxAddress) then
  2383. Editor^.GetCurrentLine(Debugger^.current_pc);
  2384. end;
  2385. function TDisassemblyWindow.ProcessPChar(p : pchar) : boolean;
  2386. var
  2387. p1: pchar;
  2388. pline : pchar;
  2389. pos1, pos2, CurLine, PrevLine : longint;
  2390. CurAddr : cardinal;
  2391. err : word;
  2392. curaddress, cursymofs, CurFile,
  2393. PrevFile, line : string;
  2394. begin
  2395. ProcessPChar:=true;
  2396. Lock;
  2397. Editor^.DisasLines^.FreeAll;
  2398. Editor^.SetFlags(Editor^.GetFlags or efSyntaxHighlight or efKeepLineAttr);
  2399. Editor^.MinAddress:=0;
  2400. Editor^.MaxAddress:=0;
  2401. Editor^.CurL:=nil;
  2402. p1:=p;
  2403. PrevFile:='';
  2404. PrevLine:=0;
  2405. while assigned(p) do
  2406. begin
  2407. pline:=strscan(p,#10);
  2408. if assigned(pline) then
  2409. pline^:=#0;
  2410. line:=strpas(p);
  2411. CurAddr:=0;
  2412. if assigned(pline) then
  2413. begin
  2414. pline^:=#10;
  2415. p:=pline+1;
  2416. end
  2417. else
  2418. p:=nil;
  2419. { now process the line }
  2420. { line is hexaddr <symbol+sym_offset at filename:line> assembly }
  2421. pos1:=pos('<',line);
  2422. if pos1>0 then
  2423. begin
  2424. curaddress:=copy(line,1,pos1-1);
  2425. val(curaddress,CurAddr,err);
  2426. if err>0 then
  2427. val(copy(curaddress,1,err-1),CurAddr,err);
  2428. system.delete(line,1,pos1);
  2429. end;
  2430. pos1:=pos(' at ',line);
  2431. pos2:=pos('>',line);
  2432. if (pos1>0) and (pos1 < pos2) then
  2433. begin
  2434. cursymofs:=copy(line,1,pos1-1);
  2435. CurFile:=copy(line,pos1+4,pos2-pos1-4);
  2436. pos1:=pos(':',CurFile);
  2437. if pos1>0 then
  2438. begin
  2439. val(copy(CurFile,pos1+1,high(CurFile)),CurLine,err);
  2440. system.delete(CurFile,pos1,high(CurFile));
  2441. end
  2442. else
  2443. CurLine:=0;
  2444. system.delete(line,1,pos2);
  2445. end
  2446. else { no ' at ' found before '>' }
  2447. begin
  2448. cursymofs:=copy(line,1,pos2-1);
  2449. CurFile:='';
  2450. system.delete(line,1,pos2);
  2451. end;
  2452. if (CurFile<>'') and ((CurFile<>PrevFile) or (CurLine<>PrevLine)) then
  2453. begin
  2454. WriteSourceString(CurFile,CurLine);
  2455. PrevLine:=CurLine;
  2456. PrevFile:=CurFile;
  2457. end;
  2458. WriteDisassemblyString(line,curaddr);
  2459. end;
  2460. StrDispose(p1);
  2461. Editor^.ReleaseSource;
  2462. Editor^.UpdateAttrs(0,attrForceFull);
  2463. If assigned(BreakpointsCollection) then
  2464. BreakpointsCollection^.ShowBreakpoints(@Self);
  2465. Unlock;
  2466. ReDraw;
  2467. end;
  2468. procedure TDisassemblyWindow.HandleEvent(var Event: TEvent);
  2469. begin
  2470. inherited HandleEvent(Event);
  2471. end;
  2472. procedure TDisassemblyWindow.WriteSourceString(Const S : string;line : longint);
  2473. begin
  2474. Editor^.AddSourceLine(S,line);
  2475. end;
  2476. procedure TDisassemblyWindow.WriteDisassemblyString(Const S : string;address : cardinal);
  2477. begin
  2478. Editor^.AddAssemblyLine(S,address);
  2479. end;
  2480. procedure TDisassemblyWindow.SetCurAddress(address : cardinal);
  2481. begin
  2482. if (address<Editor^.MinAddress) or (address>Editor^.MaxAddress) then
  2483. LoadAddress(address);
  2484. Editor^.GetCurrentLine(address);
  2485. end;
  2486. procedure TDisassemblyWindow.UpdateCommands;
  2487. var Active: boolean;
  2488. begin
  2489. Active:=GetState(sfActive);
  2490. SetCmdState(SourceCmds+CompileCmds,Active);
  2491. SetCmdState(EditorCmds,Active);
  2492. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  2493. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  2494. end;
  2495. function TDisassemblyWindow.GetPalette: PPalette;
  2496. const P: string[length(CSourceWindow)] = CSourceWindow;
  2497. begin
  2498. GetPalette:=@P;
  2499. end;
  2500. destructor TDisassemblyWindow.Done;
  2501. begin
  2502. if @Self=DisassemblyWindow then
  2503. DisassemblyWindow:=nil;
  2504. inherited Done;
  2505. end;
  2506. constructor TClipboardWindow.Init;
  2507. var R: TRect;
  2508. HSB,VSB: PScrollBar;
  2509. begin
  2510. Desktop^.GetExtent(R);
  2511. inherited Init(R, '*');
  2512. SetTitle(dialog_clipboard);
  2513. HelpCtx:=hcClipboardWindow;
  2514. Number:=wnNoNumber;
  2515. AutoNumber:=true;
  2516. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  2517. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2518. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  2519. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2520. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  2521. New(Indicator, Init(R));
  2522. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2523. Insert(Indicator);
  2524. GetExtent(R); R.Grow(-1,-1);
  2525. New(Editor, Init(R, HSB, VSB, Indicator, ''));
  2526. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2527. Insert(Editor);
  2528. Editor^.SetFlags(Editor^.GetFlags or efUseTabCharacters);
  2529. Hide;
  2530. Clipboard:=Editor;
  2531. end;
  2532. procedure TClipboardWindow.Close;
  2533. begin
  2534. Hide;
  2535. end;
  2536. constructor TClipboardWindow.Load(var S: TStream);
  2537. begin
  2538. inherited Load(S);
  2539. Clipboard:=Editor;
  2540. end;
  2541. procedure TClipboardWindow.Store(var S: TStream);
  2542. begin
  2543. inherited Store(S);
  2544. end;
  2545. destructor TClipboardWindow.Done;
  2546. begin
  2547. inherited Done;
  2548. Clipboard:=nil;
  2549. ClipboardWindow:=nil;
  2550. end;
  2551. constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  2552. begin
  2553. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  2554. GrowMode:=gfGrowHiX+gfGrowHiY;
  2555. New(ModuleNames, Init(50,100));
  2556. NoSelection:=true;
  2557. end;
  2558. function TMessageListBox.GetLocalMenu: PMenu;
  2559. var M: PMenu;
  2560. begin
  2561. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  2562. M:=NewMenu(
  2563. NewItem(menu_msglocal_clear,'',kbNoKey,cmMsgClear,hcMsgClear,
  2564. NewLine(
  2565. NewItem(menu_msglocal_gotosource,'',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  2566. NewItem(menu_msglocal_tracksource,'',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
  2567. NewLine(
  2568. NewItem(menu_msglocal_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  2569. nil)))))));
  2570. GetLocalMenu:=M;
  2571. end;
  2572. procedure TMessageListBox.SetState(AState: Word; Enable: Boolean);
  2573. var OldState: word;
  2574. begin
  2575. OldState:=State;
  2576. inherited SetState(AState,Enable);
  2577. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  2578. SetCmdState([cmSaveAs],Enable);
  2579. end;
  2580. procedure TMessageListBox.HandleEvent(var Event: TEvent);
  2581. var DontClear: boolean;
  2582. begin
  2583. case Event.What of
  2584. evKeyDown :
  2585. begin
  2586. DontClear:=false;
  2587. case Event.KeyCode of
  2588. kbEnter :
  2589. begin
  2590. Message(@Self,evCommand,cmMsgGotoSource,nil);
  2591. ClearEvent(Event);
  2592. exit;
  2593. end;
  2594. else
  2595. DontClear:=true;
  2596. end;
  2597. if not DontClear then
  2598. ClearEvent(Event);
  2599. end;
  2600. evBroadcast :
  2601. case Event.Command of
  2602. cmListItemSelected :
  2603. if Event.InfoPtr=@Self then
  2604. Message(@Self,evCommand,cmMsgTrackSource,nil);
  2605. end;
  2606. evCommand :
  2607. begin
  2608. DontClear:=false;
  2609. case Event.Command of
  2610. cmMsgGotoSource :
  2611. if Range>0 then
  2612. begin
  2613. GotoSource;
  2614. ClearEvent(Event);
  2615. exit;
  2616. end;
  2617. cmMsgTrackSource :
  2618. if Range>0 then
  2619. TrackSource;
  2620. cmMsgClear :
  2621. Clear;
  2622. cmSaveAs :
  2623. SaveAs;
  2624. else
  2625. DontClear:=true;
  2626. end;
  2627. if not DontClear then
  2628. ClearEvent(Event);
  2629. end;
  2630. end;
  2631. inherited HandleEvent(Event);
  2632. end;
  2633. procedure TMessageListBox.AddItem(P: PMessageItem);
  2634. var W : integer;
  2635. begin
  2636. if List=nil then New(List, Init(500,500));
  2637. W:=length(P^.GetText(255));
  2638. if W>MaxWidth then
  2639. begin
  2640. MaxWidth:=W;
  2641. if HScrollBar<>nil then
  2642. HScrollBar^.SetRange(0,MaxWidth);
  2643. end;
  2644. List^.Insert(P);
  2645. SetRange(List^.Count);
  2646. if Focused=List^.Count-1-1 then
  2647. FocusItem(List^.Count-1);
  2648. DrawView;
  2649. end;
  2650. function TMessageListBox.AddModuleName(const Name: string): PString;
  2651. var P: PString;
  2652. begin
  2653. if ModuleNames<>nil then
  2654. P:=ModuleNames^.Add(Name)
  2655. else
  2656. P:=nil;
  2657. AddModuleName:=P;
  2658. end;
  2659. function TMessageListBox.GetText(Item,MaxLen: Sw_Integer): String;
  2660. var P: PMessageItem;
  2661. S: string;
  2662. begin
  2663. P:=List^.At(Item);
  2664. S:=P^.GetText(MaxLen);
  2665. GetText:=copy(S,1,MaxLen);
  2666. end;
  2667. procedure TMessageListBox.Clear;
  2668. begin
  2669. if assigned(List) then
  2670. Dispose(List, Done);
  2671. List:=nil;
  2672. MaxWidth:=0;
  2673. if assigned(ModuleNames) then
  2674. ModuleNames^.FreeAll;
  2675. SetRange(0); DrawView;
  2676. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2677. end;
  2678. procedure TMessageListBox.TrackSource;
  2679. var W: PSourceWindow;
  2680. P: PMessageItem;
  2681. R: TRect;
  2682. Row,Col: sw_integer;
  2683. Found : boolean;
  2684. begin
  2685. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2686. if Range=0 then Exit;
  2687. P:=List^.At(Focused);
  2688. if P^.Row=0 then Exit;
  2689. Desktop^.Lock;
  2690. GetNextEditorBounds(R);
  2691. R.B.Y:=Owner^.Origin.Y;
  2692. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2693. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2694. W:=EditorWindowFile(P^.GetModuleName);
  2695. if assigned(W) then
  2696. begin
  2697. W^.GetExtent(R);
  2698. R.B.Y:=Owner^.Origin.Y;
  2699. W^.ChangeBounds(R);
  2700. W^.Editor^.SetCurPtr(Col,Row);
  2701. end
  2702. else
  2703. W:=TryToOpenFile(@R,P^.GetModuleName,Col,Row,true);
  2704. { Try to find it by browsing }
  2705. if W=nil then
  2706. begin
  2707. Desktop^.UnLock;
  2708. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2709. if found then
  2710. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2711. Desktop^.Lock;
  2712. end;
  2713. if W<>nil then
  2714. begin
  2715. W^.Select;
  2716. W^.Editor^.TrackCursor(true);
  2717. W^.Editor^.SetLineFlagExclusive(lfHighlightRow,Row);
  2718. end;
  2719. if Assigned(Owner) then
  2720. Owner^.Select;
  2721. Desktop^.UnLock;
  2722. end;
  2723. procedure TMessageListBox.GotoSource;
  2724. var W: PSourceWindow;
  2725. P: PMessageItem;
  2726. R:TRect;
  2727. Row,Col: sw_integer;
  2728. Found : boolean;
  2729. Event : TEvent;
  2730. begin
  2731. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  2732. if Range=0 then Exit;
  2733. P:=List^.At(Focused);
  2734. if P^.Row=0 then Exit;
  2735. Desktop^.Lock;
  2736. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  2737. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  2738. W:=EditorWindowFile(P^.GetModuleName);
  2739. if assigned(W) then
  2740. begin
  2741. W^.GetExtent(R);
  2742. if Owner^.Origin.Y>R.A.Y+4 then
  2743. R.B.Y:=Owner^.Origin.Y;
  2744. W^.ChangeBounds(R);
  2745. W^.Editor^.SetCurPtr(Col,Row);
  2746. end
  2747. else
  2748. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2749. { Try to find it by browsing }
  2750. if W=nil then
  2751. begin
  2752. Desktop^.UnLock;
  2753. Found:=IDEApp.OpenSearch(P^.GetModuleName+'*');
  2754. if found then
  2755. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  2756. Desktop^.Lock;
  2757. end;
  2758. if assigned(W) then
  2759. begin
  2760. { Message(Owner,evCommand,cmClose,nil);
  2761. This calls close on StackWindow
  2762. rendering P invalid
  2763. so postpone it PM }
  2764. W^.GetExtent(R);
  2765. if (P^.TClass<>0) then
  2766. W^.Editor^.SetErrorMessage(P^.GetText(R.B.X-R.A.X));
  2767. W^.Select;
  2768. Owner^.Hide;
  2769. end;
  2770. Desktop^.UnLock;
  2771. if assigned(W) then
  2772. begin
  2773. Event.What:=evCommand;
  2774. Event.command:=cmClose;
  2775. Event.InfoPtr:=nil;
  2776. fpide.PutEvent(Owner,Event);
  2777. end;
  2778. end;
  2779. procedure TMessageListBox.Draw;
  2780. var
  2781. I, J, Item: Sw_Integer;
  2782. NormalColor, SelectedColor, FocusedColor, Color: Word;
  2783. ColWidth, CurCol, Indent: Integer;
  2784. B: TDrawBuffer;
  2785. Text: String;
  2786. SCOff: Byte;
  2787. TC: byte;
  2788. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  2789. begin
  2790. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  2791. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  2792. begin
  2793. NormalColor := GetColor(1);
  2794. FocusedColor := GetColor(3);
  2795. SelectedColor := GetColor(4);
  2796. end else
  2797. begin
  2798. NormalColor := GetColor(2);
  2799. SelectedColor := GetColor(4);
  2800. end;
  2801. if Transparent then
  2802. begin MT(NormalColor); MT(SelectedColor); end;
  2803. if NoSelection then
  2804. SelectedColor:=NormalColor;
  2805. if HScrollBar <> nil then Indent := HScrollBar^.Value
  2806. else Indent := 0;
  2807. ColWidth := Size.X div NumCols + 1;
  2808. for I := 0 to Size.Y - 1 do
  2809. begin
  2810. for J := 0 to NumCols-1 do
  2811. begin
  2812. Item := J*Size.Y + I + TopItem;
  2813. CurCol := J*ColWidth;
  2814. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  2815. (Focused = Item) and (Range > 0) then
  2816. begin
  2817. Color := FocusedColor;
  2818. SetCursor(CurCol+1,I);
  2819. SCOff := 0;
  2820. end
  2821. else if (Item < Range) and IsSelected(Item) then
  2822. begin
  2823. Color := SelectedColor;
  2824. SCOff := 2;
  2825. end
  2826. else
  2827. begin
  2828. Color := NormalColor;
  2829. SCOff := 4;
  2830. end;
  2831. MoveChar(B[CurCol], ' ', Color, ColWidth);
  2832. if Item < Range then
  2833. begin
  2834. Text := GetText(Item, ColWidth + Indent);
  2835. Text := Copy(Text,Indent,ColWidth);
  2836. MoveStr(B[CurCol+1], Text, Color);
  2837. if ShowMarkers then
  2838. begin
  2839. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  2840. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  2841. end;
  2842. end;
  2843. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  2844. end;
  2845. WriteLine(0, I, Size.X, 1, B);
  2846. end;
  2847. end;
  2848. constructor TMessageListBox.Load(var S: TStream);
  2849. begin
  2850. inherited Load(S);
  2851. New(ModuleNames, Init(50,100));
  2852. NoSelection:=true;
  2853. end;
  2854. procedure TMessageListBox.Store(var S: TStream);
  2855. var OL: PCollection;
  2856. ORV: sw_integer;
  2857. begin
  2858. OL:=List; ORV:=Range;
  2859. New(List, Init(1,1)); Range:=0;
  2860. inherited Store(S);
  2861. Dispose(List, Done);
  2862. List:=OL; Range:=ORV;
  2863. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  2864. collection? Pasting here a modified version of TListBox.Store+
  2865. TAdvancedListBox.Store isn't a better solution, since by eventually
  2866. changing the obj-hierarchy you'll always have to modify this, too - BG }
  2867. end;
  2868. destructor TMessageListBox.Done;
  2869. begin
  2870. inherited Done;
  2871. if List<>nil then Dispose(List, Done);
  2872. if ModuleNames<>nil then Dispose(ModuleNames, Done);
  2873. end;
  2874. constructor TMessageItem.Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  2875. begin
  2876. inherited Init;
  2877. TClass:=AClass;
  2878. Text:=NewStr(AText);
  2879. Module:=AModule;
  2880. Row:=ARow; Col:=ACol;
  2881. end;
  2882. function TMessageItem.GetText(MaxLen: Sw_integer): string;
  2883. var S: string;
  2884. begin
  2885. if Text=nil then S:='' else S:=Text^;
  2886. if (Module<>nil) then
  2887. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+S;
  2888. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  2889. GetText:=S;
  2890. end;
  2891. procedure TMessageItem.Selected;
  2892. begin
  2893. end;
  2894. function TMessageItem.GetModuleName: string;
  2895. begin
  2896. GetModuleName:=GetStr(Module);
  2897. end;
  2898. destructor TMessageItem.Done;
  2899. begin
  2900. inherited Done;
  2901. if Text<>nil then DisposeStr(Text);
  2902. { if Module<>nil then DisposeStr(Module);}
  2903. end;
  2904. procedure TFPDlgWindow.HandleEvent(var Event: TEvent);
  2905. begin
  2906. case Event.What of
  2907. evBroadcast :
  2908. case Event.Command of
  2909. cmSearchWindow+1..cmSearchWindow+99 :
  2910. if (Event.Command-cmSearchWindow=Number) then
  2911. ClearEvent(Event);
  2912. end;
  2913. end;
  2914. inherited HandleEvent(Event);
  2915. end;
  2916. constructor TProgramInfoWindow.Init;
  2917. var R,R2: TRect;
  2918. HSB,VSB: PScrollBar;
  2919. ST: PStaticText;
  2920. C: word;
  2921. const White = 15;
  2922. begin
  2923. Desktop^.GetExtent(R); R.A.Y:=R.B.Y-13;
  2924. inherited Init(R, dialog_programinformation, wnNoNumber);
  2925. HelpCtx:=hcInfoWindow;
  2926. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+3;
  2927. C:=((Desktop^.GetColor(32+6) and $f0) or White)*256+Desktop^.GetColor(32+6);
  2928. New(InfoST, Init(R,'', C, false)); InfoST^.GrowMode:=gfGrowHiX;
  2929. Insert(InfoST);
  2930. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,3); R.B.Y:=R.A.Y+1;
  2931. New(ST, Init(R, CharStr('Ä', MaxViewWidth))); ST^.GrowMode:=gfGrowHiX; Insert(ST);
  2932. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,4);
  2933. R2.Copy(R); Inc(R2.B.Y); R2.A.Y:=R2.B.Y-1;
  2934. New(HSB, Init(R2)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX; Insert(HSB);
  2935. R2.Copy(R); Inc(R2.B.X); R2.A.X:=R2.B.X-1;
  2936. New(VSB, Init(R2)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2937. New(LogLB, Init(R,HSB,VSB));
  2938. LogLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2939. LogLB^.Transparent:=true;
  2940. Insert(LogLB);
  2941. Update;
  2942. end;
  2943. constructor TProgramInfoWindow.Load(var S : TStream);
  2944. begin
  2945. inherited Load(S);
  2946. GetSubViewPtr(S,InfoST);
  2947. GetSubViewPtr(S,LogLB);
  2948. end;
  2949. procedure TProgramInfoWindow.Store(var S : TStream);
  2950. begin
  2951. inherited Store(S);
  2952. PutSubViewPtr(S,InfoST);
  2953. PutSubViewPtr(S,LogLB);
  2954. end;
  2955. procedure TProgramInfoWindow.AddMessage(AClass: longint; Msg, Module: string; Line, Column: longint);
  2956. begin
  2957. if AClass>=V_Info then Line:=0;
  2958. LogLB^.AddItem(New(PCompilerMessage, Init(AClass, Msg, LogLB^.AddModuleName(Module), Line, Column)));
  2959. end;
  2960. procedure TProgramInfoWindow.ClearMessages;
  2961. begin
  2962. LogLB^.Clear;
  2963. ReDraw;
  2964. end;
  2965. procedure TProgramInfoWindow.SizeLimits(var Min, Max: TPoint);
  2966. begin
  2967. inherited SizeLimits(Min,Max);
  2968. Min.X:=30; Min.Y:=9;
  2969. end;
  2970. procedure TProgramInfoWindow.Close;
  2971. begin
  2972. Hide;
  2973. end;
  2974. procedure TProgramInfoWindow.HandleEvent(var Event: TEvent);
  2975. begin
  2976. case Event.What of
  2977. evBroadcast :
  2978. case Event.Command of
  2979. cmUpdate :
  2980. Update;
  2981. end;
  2982. end;
  2983. inherited HandleEvent(Event);
  2984. end;
  2985. procedure TProgramInfoWindow.Update;
  2986. begin
  2987. ClearFormatParams;
  2988. AddFormatParamStr(label_proginfo_currentmodule);
  2989. AddFormatParamStr(MainFile);
  2990. AddFormatParamStr(label_proginfo_lastexitcode);
  2991. AddFormatParamInt(LastExitCode);
  2992. AddFormatParamStr(label_proginfo_availablememory);
  2993. AddFormatParamInt(MemAvail div 1024);
  2994. InfoST^.SetText(
  2995. FormatStrF(
  2996. {#13+ }
  2997. '%24s : %s'#13+
  2998. '%24s : %d'#13+
  2999. '%24s : %5d'+'K'+#13+
  3000. '',
  3001. FormatParams)
  3002. );
  3003. end;
  3004. destructor TProgramInfoWindow.Done;
  3005. begin
  3006. inherited Done;
  3007. ProgramInfoWindow:=nil;
  3008. end;
  3009. constructor TTab.Init(var Bounds: TRect; ATabDef: PTabDef);
  3010. begin
  3011. inherited Init(Bounds);
  3012. Options:=Options or ofSelectable or ofFirstClick or ofPreProcess or ofPostProcess;
  3013. GrowMode:=gfGrowHiX+gfGrowHiY+gfGrowRel;
  3014. TabDefs:=ATabDef;
  3015. ActiveDef:=-1;
  3016. SelectTab(0);
  3017. ReDraw;
  3018. end;
  3019. function TTab.TabCount: integer;
  3020. var i: integer;
  3021. P: PTabDef;
  3022. begin
  3023. I:=0; P:=TabDefs;
  3024. while (P<>nil) do
  3025. begin
  3026. Inc(I);
  3027. P:=P^.Next;
  3028. end;
  3029. TabCount:=I;
  3030. end;
  3031. function TTab.AtTab(Index: integer): PTabDef;
  3032. var i: integer;
  3033. P: PTabDef;
  3034. begin
  3035. i:=0; P:=TabDefs;
  3036. while (I<Index) do
  3037. begin
  3038. if P=nil then RunError($AA);
  3039. P:=P^.Next;
  3040. Inc(i);
  3041. end;
  3042. AtTab:=P;
  3043. end;
  3044. procedure TTab.SelectTab(Index: integer);
  3045. var P: PTabItem;
  3046. V: PView;
  3047. begin
  3048. if ActiveDef<>Index then
  3049. begin
  3050. if Owner<>nil then Owner^.Lock;
  3051. Lock;
  3052. { --- Update --- }
  3053. if TabDefs<>nil then
  3054. begin
  3055. DefCount:=1;
  3056. while AtTab(DefCount-1)^.Next<>nil do Inc(DefCount);
  3057. end
  3058. else DefCount:=0;
  3059. if ActiveDef<>-1 then
  3060. begin
  3061. P:=AtTab(ActiveDef)^.Items;
  3062. while P<>nil do
  3063. begin
  3064. if P^.View<>nil then Delete(P^.View);
  3065. P:=P^.Next;
  3066. end;
  3067. end;
  3068. ActiveDef:=Index;
  3069. P:=AtTab(ActiveDef)^.Items;
  3070. while P<>nil do
  3071. begin
  3072. if P^.View<>nil then Insert(P^.View);
  3073. P:=P^.Next;
  3074. end;
  3075. V:=AtTab(ActiveDef)^.DefItem;
  3076. if V<>nil then V^.Select;
  3077. ReDraw;
  3078. { --- Update --- }
  3079. UnLock;
  3080. if Owner<>nil then Owner^.UnLock;
  3081. DrawView;
  3082. end;
  3083. end;
  3084. procedure TTab.ChangeBounds(var Bounds: TRect);
  3085. var D: TPoint;
  3086. procedure DoCalcChange(P: PView); {$ifndef FPC}far;{$endif}
  3087. var
  3088. R: TRect;
  3089. begin
  3090. if P^.Owner=nil then Exit; { it think this is a bug in TV }
  3091. P^.CalcBounds(R, D);
  3092. P^.ChangeBounds(R);
  3093. end;
  3094. var
  3095. P: PTabItem;
  3096. I: integer;
  3097. begin
  3098. D.X := Bounds.B.X - Bounds.A.X - Size.X;
  3099. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y;
  3100. inherited ChangeBounds(Bounds);
  3101. for I:=0 to TabCount-1 do
  3102. if I<>ActiveDef then
  3103. begin
  3104. P:=AtTab(I)^.Items;
  3105. while P<>nil do
  3106. begin
  3107. if P^.View<>nil then DoCalcChange(P^.View);
  3108. P:=P^.Next;
  3109. end;
  3110. end;
  3111. end;
  3112. procedure TTab.SelectNextTab(Forwards: boolean);
  3113. var Index: integer;
  3114. begin
  3115. Index:=ActiveDef;
  3116. if Index=-1 then Exit;
  3117. if Forwards then Inc(Index) else Dec(Index);
  3118. if Index<0 then Index:=DefCount-1 else
  3119. if Index>DefCount-1 then Index:=0;
  3120. SelectTab(Index);
  3121. end;
  3122. procedure TTab.HandleEvent(var Event: TEvent);
  3123. var Index : integer;
  3124. I : integer;
  3125. X : integer;
  3126. Len : byte;
  3127. P : TPoint;
  3128. V : PView;
  3129. CallOrig: boolean;
  3130. LastV : PView;
  3131. FirstV: PView;
  3132. function FirstSelectable: PView;
  3133. var
  3134. FV : PView;
  3135. begin
  3136. FV := First;
  3137. while (FV<>nil) and ((FV^.Options and ofSelectable)=0) and (FV<>Last) do
  3138. FV:=FV^.Next;
  3139. if FV<>nil then
  3140. if (FV^.Options and ofSelectable)=0 then FV:=nil;
  3141. FirstSelectable:=FV;
  3142. end;
  3143. function LastSelectable: PView;
  3144. var
  3145. LV : PView;
  3146. begin
  3147. LV := Last;
  3148. while (LV<>nil) and ((LV^.Options and ofSelectable)=0) and (LV<>First) do
  3149. LV:=LV^.Prev;
  3150. if LV<>nil then
  3151. if (LV^.Options and ofSelectable)=0 then LV:=nil;
  3152. LastSelectable:=LV;
  3153. end;
  3154. begin
  3155. if (Event.What and evMouseDown)<>0 then
  3156. begin
  3157. MakeLocal(Event.Where,P);
  3158. if P.Y<3 then
  3159. begin
  3160. Index:=-1; X:=1;
  3161. for i:=0 to DefCount-1 do
  3162. begin
  3163. Len:=CStrLen(AtTab(i)^.Name^);
  3164. if (P.X>=X) and (P.X<=X+Len+1) then Index:=i;
  3165. X:=X+Len+3;
  3166. end;
  3167. if Index<>-1 then
  3168. SelectTab(Index);
  3169. end;
  3170. end;
  3171. if Event.What=evKeyDown then
  3172. begin
  3173. Index:=-1;
  3174. case Event.KeyCode of
  3175. kbCtrlTab :
  3176. begin
  3177. SelectNextTab((Event.KeyShift and kbShift)=0);
  3178. ClearEvent(Event);
  3179. end;
  3180. kbTab,kbShiftTab :
  3181. if GetState(sfSelected) then
  3182. begin
  3183. if Current<>nil then
  3184. begin
  3185. LastV:=LastSelectable; FirstV:=FirstSelectable;
  3186. if ((Current=LastV) or (Current=PLabel(LastV)^.Link)) and (Event.KeyCode=kbShiftTab) then
  3187. begin
  3188. if Owner<>nil then Owner^.SelectNext(true);
  3189. end else
  3190. if ((Current=FirstV) or (Current=PLabel(FirstV)^.Link)) and (Event.KeyCode=kbTab) then
  3191. begin
  3192. Lock;
  3193. if Owner<>nil then Owner^.SelectNext(false);
  3194. UnLock;
  3195. end else
  3196. SelectNext(Event.KeyCode=kbShiftTab);
  3197. ClearEvent(Event);
  3198. end;
  3199. end;
  3200. else
  3201. for I:=0 to DefCount-1 do
  3202. begin
  3203. if Upcase(GetAltChar(Event.KeyCode))=AtTab(I)^.ShortCut
  3204. then begin
  3205. Index:=I;
  3206. ClearEvent(Event);
  3207. Break;
  3208. end;
  3209. end;
  3210. end;
  3211. if Index<>-1 then
  3212. begin
  3213. Select;
  3214. SelectTab(Index);
  3215. V:=AtTab(ActiveDef)^.DefItem;
  3216. if V<>nil then V^.Focus;
  3217. end;
  3218. end;
  3219. CallOrig:=true;
  3220. if Event.What=evKeyDown then
  3221. begin
  3222. if ((Owner<>nil) and (Owner^.Phase=phPostProcess) and (GetAltChar(Event.KeyCode)<>#0)) or GetState(sfFocused)
  3223. then
  3224. else CallOrig:=false;
  3225. end;
  3226. if CallOrig then inherited HandleEvent(Event);
  3227. end;
  3228. function TTab.GetPalette: PPalette;
  3229. begin
  3230. GetPalette:=nil;
  3231. end;
  3232. procedure TTab.Draw;
  3233. var B : TDrawBuffer;
  3234. i : integer;
  3235. C1,C2,C3,C : word;
  3236. HeaderLen : integer;
  3237. X,X2 : integer;
  3238. Name : PString;
  3239. ActiveKPos : integer;
  3240. ActiveVPos : integer;
  3241. FC : char;
  3242. ClipR : TRect;
  3243. procedure SWriteBuf(X,Y,W,H: integer; var Buf);
  3244. var i: integer;
  3245. begin
  3246. if Y+H>Size.Y then H:=Size.Y-Y;
  3247. if X+W>Size.X then W:=Size.X-X;
  3248. if Buffer=nil then WriteBuf(X,Y,W,H,Buf)
  3249. else for i:=1 to H do
  3250. Move(Buf,Buffer^[X+(Y+i-1)*Size.X],W*2);
  3251. end;
  3252. procedure ClearBuf;
  3253. begin
  3254. MoveChar(B,' ',C1,Size.X);
  3255. end;
  3256. begin
  3257. if InDraw then Exit;
  3258. InDraw:=true;
  3259. { - Start of TGroup.Draw - }
  3260. { if Buffer = nil then
  3261. begin
  3262. GetBuffer;
  3263. end; }
  3264. { - Start of TGroup.Draw - }
  3265. C1:=GetColor(1); C2:=(GetColor(7) and $f0 or $08)+GetColor(9)*256; C3:=GetColor(8)+GetColor({9}8)*256;
  3266. HeaderLen:=0; for i:=0 to DefCount-1 do HeaderLen:=HeaderLen+CStrLen(AtTab(i)^.Name^)+3; Dec(HeaderLen);
  3267. if HeaderLen>Size.X-2 then HeaderLen:=Size.X-2;
  3268. { --- 1. sor --- }
  3269. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[HeaderLen+1],'³',C1,1);
  3270. X:=1;
  3271. for i:=0 to DefCount-1 do
  3272. begin
  3273. Name:=AtTab(i)^.Name; X2:=CStrLen(Name^);
  3274. if i=ActiveDef
  3275. then begin
  3276. ActiveKPos:=X-1;
  3277. ActiveVPos:=X+X2+2;
  3278. if GetState(sfFocused) then C:=C3 else C:=C2;
  3279. end
  3280. else C:=C2;
  3281. MoveCStr(B[X],' '+Name^+' ',C); X:=X+X2+3;
  3282. MoveChar(B[X-1],'³',C1,1);
  3283. end;
  3284. SWriteBuf(0,1,Size.X,1,B);
  3285. { --- 0. sor --- }
  3286. ClearBuf; MoveChar(B[0],'Ú',C1,1);
  3287. X:=1;
  3288. for i:=0 to DefCount-1 do
  3289. begin
  3290. if I<ActiveDef then FC:='Ú'
  3291. else FC:='¿';
  3292. X2:=CStrLen(AtTab(i)^.Name^)+2;
  3293. MoveChar(B[X+X2],{'Â'}FC,C1,1);
  3294. if i=DefCount-1 then X2:=X2+1;
  3295. if X2>0 then
  3296. MoveChar(B[X],'Ä',C1,X2);
  3297. X:=X+X2+1;
  3298. end;
  3299. MoveChar(B[HeaderLen+1],'¿',C1,1);
  3300. MoveChar(B[ActiveKPos],'Ú',C1,1); MoveChar(B[ActiveVPos],'¿',C1,1);
  3301. SWriteBuf(0,0,Size.X,1,B);
  3302. { --- 2. sor --- }
  3303. MoveChar(B[1],'Ä',C1,Max(HeaderLen,0)); MoveChar(B[HeaderLen+2],'Ä',C1,Max(Size.X-HeaderLen-3,0));
  3304. MoveChar(B[Size.X-1],'¿',C1,1);
  3305. MoveChar(B[ActiveKPos],'Ù',C1,1);
  3306. if ActiveDef=0 then MoveChar(B[0],'³',C1,1)
  3307. else MoveChar(B[0],{'Ã'}'Ú',C1,1);
  3308. MoveChar(B[HeaderLen+1],'Ä'{'Á'},C1,1); MoveChar(B[ActiveVPos],'À',C1,1);
  3309. MoveChar(B[ActiveKPos+1],' ',C1,Max(ActiveVPos-ActiveKPos-1,0));
  3310. SWriteBuf(0,2,Size.X,1,B);
  3311. { --- marad‚k sor --- }
  3312. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[Size.X-1],'³',C1,1);
  3313. for i:=3 to Size.Y-1 do
  3314. SWriteBuf(0,i,Size.X,1,B);
  3315. { SWriteBuf(0,3,Size.X,Size.Y-4,B); this was wrong
  3316. because WriteBuf then expect a buffer of size size.x*(size.y-4)*2 PM }
  3317. { --- Size.X . sor --- }
  3318. MoveChar(B[0],'À',C1,1); MoveChar(B[1],'Ä',C1,Max(Size.X-2,0)); MoveChar(B[Size.X-1],'Ù',C1,1);
  3319. SWriteBuf(0,Size.Y-1,Size.X,1,B);
  3320. { - End of TGroup.Draw - }
  3321. if Buffer <> nil then
  3322. begin
  3323. Lock;
  3324. Redraw;
  3325. UnLock;
  3326. end;
  3327. if Buffer <> nil then WriteBuf(0, 0, Size.X, Size.Y, Buffer^) else
  3328. begin
  3329. GetClipRect(ClipR);
  3330. Redraw;
  3331. GetExtent(ClipR);
  3332. end;
  3333. { - End of TGroup.Draw - }
  3334. InDraw:=false;
  3335. end;
  3336. function TTab.Valid(Command: Word): Boolean;
  3337. var PT : PTabDef;
  3338. PI : PTabItem;
  3339. OK : boolean;
  3340. begin
  3341. OK:=true;
  3342. PT:=TabDefs;
  3343. while (PT<>nil) and (OK=true) do
  3344. begin
  3345. PI:=PT^.Items;
  3346. while (PI<>nil) and (OK=true) do
  3347. begin
  3348. if PI^.View<>nil then OK:=OK and PI^.View^.Valid(Command);
  3349. PI:=PI^.Next;
  3350. end;
  3351. PT:=PT^.Next;
  3352. end;
  3353. Valid:=OK;
  3354. end;
  3355. procedure TTab.SetState(AState: Word; Enable: Boolean);
  3356. begin
  3357. inherited SetState(AState,Enable);
  3358. if (AState and sfFocused)<>0 then DrawView;
  3359. end;
  3360. destructor TTab.Done;
  3361. var P,X: PTabDef;
  3362. procedure DeleteViews(P: PView); {$ifndef FPC}far;{$endif}
  3363. begin
  3364. if P<>nil then Delete(P);
  3365. end;
  3366. begin
  3367. ForEach(@DeleteViews);
  3368. inherited Done;
  3369. P:=TabDefs;
  3370. while P<>nil do
  3371. begin
  3372. X:=P^.Next;
  3373. DisposeTabDef(P);
  3374. P:=X;
  3375. end;
  3376. end;
  3377. constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  3378. AScreen: PScreen);
  3379. begin
  3380. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  3381. Screen:=AScreen;
  3382. if Screen=nil then
  3383. Fail;
  3384. SetState(sfCursorVis,true);
  3385. Update;
  3386. end;
  3387. procedure TScreenView.Update;
  3388. begin
  3389. SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
  3390. DrawView;
  3391. end;
  3392. procedure TScreenView.HandleEvent(var Event: TEvent);
  3393. begin
  3394. case Event.What of
  3395. evBroadcast :
  3396. case Event.Command of
  3397. cmUpdate : Update;
  3398. end;
  3399. end;
  3400. inherited HandleEvent(Event);
  3401. end;
  3402. procedure TScreenView.Draw;
  3403. var B: TDrawBuffer;
  3404. X,Y: integer;
  3405. Text,Attr: string;
  3406. P: TPoint;
  3407. begin
  3408. Screen^.GetCursorPos(P);
  3409. for Y:=Delta.Y to Delta.Y+Size.Y-1 do
  3410. begin
  3411. if Y<Screen^.GetHeight then
  3412. Screen^.GetLine(Y,Text,Attr)
  3413. else
  3414. begin Text:=''; Attr:=''; end;
  3415. Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
  3416. MoveChar(B,' ',GetColor(1),Size.X);
  3417. for X:=1 to length(Text) do
  3418. MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
  3419. WriteLine(0,Y-Delta.Y,Size.X,1,B);
  3420. end;
  3421. SetCursor(P.X-Delta.X,P.Y-Delta.Y);
  3422. end;
  3423. constructor TScreenWindow.Init(AScreen: PScreen; ANumber: integer);
  3424. var R: TRect;
  3425. VSB,HSB: PScrollBar;
  3426. begin
  3427. Desktop^.GetExtent(R);
  3428. inherited Init(R, dialog_userscreen, ANumber);
  3429. Options:=Options or ofTileAble;
  3430. GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
  3431. New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
  3432. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  3433. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
  3434. New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
  3435. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  3436. GetExtent(R); R.Grow(-1,-1);
  3437. New(ScreenView, Init(R, HSB, VSB, AScreen));
  3438. ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  3439. Insert(ScreenView);
  3440. UserScreenWindow:=@Self;
  3441. end;
  3442. destructor TScreenWindow.Done;
  3443. begin
  3444. inherited Done;
  3445. UserScreenWindow:=nil;
  3446. end;
  3447. const InTranslate : boolean = false;
  3448. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  3449. procedure TranslateAction(Action: integer);
  3450. var E: TEvent;
  3451. begin
  3452. if Action<>acNone then
  3453. begin
  3454. E:=Event;
  3455. E.What:=evMouseDown; E.Buttons:=mbLeftButton;
  3456. View^.HandleEvent(E);
  3457. Event.What:=evCommand;
  3458. Event.Command:=ActionCommands[Action];
  3459. end;
  3460. end;
  3461. begin
  3462. if InTranslate then Exit;
  3463. InTranslate:=true;
  3464. case Event.What of
  3465. evMouseDown :
  3466. if (GetShiftState and kbAlt)<>0 then
  3467. TranslateAction(AltMouseAction) else
  3468. if (GetShiftState and kbCtrl)<>0 then
  3469. TranslateAction(CtrlMouseAction);
  3470. end;
  3471. InTranslate:=false;
  3472. end;
  3473. function GetNextEditorBounds(var Bounds: TRect): boolean;
  3474. var P: PView;
  3475. begin
  3476. P:=Desktop^.Current;
  3477. while P<>nil do
  3478. begin
  3479. if P^.HelpCtx=hcSourceWindow then Break;
  3480. P:=P^.NextView;
  3481. if P=Desktop^.Current then
  3482. begin
  3483. P:=nil;
  3484. break;
  3485. end;
  3486. end;
  3487. if P=nil then Desktop^.GetExtent(Bounds) else
  3488. begin
  3489. P^.GetBounds(Bounds);
  3490. Inc(Bounds.A.X); Inc(Bounds.A.Y);
  3491. end;
  3492. GetNextEditorBounds:=P<>nil;
  3493. end;
  3494. function IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
  3495. var R: TRect;
  3496. W: PSourceWindow;
  3497. begin
  3498. if Assigned(Bounds) then R.Copy(Bounds^) else
  3499. GetNextEditorBounds(R);
  3500. PushStatus(FormatStrStr(msg_openingsourcefile,SmartPath(FileName)));
  3501. New(W, Init(R, FileName));
  3502. if ShowIt=false then
  3503. W^.Hide;
  3504. if W<>nil then
  3505. begin
  3506. if (CurX<>0) or (CurY<>0) then
  3507. with W^.Editor^ do
  3508. begin
  3509. SetCurPtr(CurX,CurY);
  3510. TrackCursor(true);
  3511. end;
  3512. W^.HelpCtx:=hcSourceWindow;
  3513. Desktop^.Insert(W);
  3514. Message(Application,evBroadcast,cmUpdate,nil);
  3515. end;
  3516. PopStatus;
  3517. IOpenEditorWindow:=W;
  3518. end;
  3519. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  3520. begin
  3521. OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
  3522. end;
  3523. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  3524. var
  3525. D,DS : DirStr;
  3526. N,NS : NameStr;
  3527. E,ES : ExtStr;
  3528. SName : string;
  3529. function IsSearchedFile(W : PSourceWindow) : boolean;
  3530. var Found: boolean;
  3531. begin
  3532. Found:=false;
  3533. if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
  3534. begin
  3535. if (D='') then
  3536. SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
  3537. else
  3538. SName:=PSourceWindow(W)^.Editor^.FileName;
  3539. FSplit(SName,DS,NS,ES);
  3540. SName:=UpcaseStr(NS+ES);
  3541. if (E<>'') or (not tryexts) then
  3542. begin
  3543. if D<>'' then
  3544. Found:=UpCaseStr(DS)+SName=UpcaseStr(D+N+E)
  3545. else
  3546. Found:=SName=UpcaseStr(N+E);
  3547. end
  3548. else
  3549. begin
  3550. Found:=SName=UpcaseStr(N+'.pp');
  3551. if Found=false then
  3552. Found:=SName=UpcaseStr(N+'.pas');
  3553. end;
  3554. end;
  3555. IsSearchedFile:=found;
  3556. end;
  3557. function IsSearchedSource(P: PView) : boolean; {$ifndef FPC}far;{$endif}
  3558. begin
  3559. if assigned(P) and
  3560. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  3561. IsSearchedSource:=IsSearchedFile(PSourceWindow(P))
  3562. else
  3563. IsSearchedSource:=false;
  3564. end;
  3565. begin
  3566. FSplit(FileName,D,N,E);
  3567. SearchOnDesktop:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  3568. end;
  3569. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  3570. begin
  3571. TryToOpenFile:=ITryToOpenFile(Bounds,FileName,CurX,CurY,tryexts,true,false);
  3572. end;
  3573. function LocateSingleSourceFile(const FileName: string; tryexts: boolean): string;
  3574. var D : DirStr;
  3575. N : NameStr;
  3576. E : ExtStr;
  3577. function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
  3578. var OK: boolean;
  3579. begin
  3580. NewDir:=CompleteDir(NewDir);
  3581. OK:=ExistsFile(NewDir+NewName+NewExt);
  3582. if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
  3583. CheckDir:=OK;
  3584. end;
  3585. function CheckExt(NewExt: ExtStr): boolean;
  3586. var OK: boolean;
  3587. begin
  3588. OK:=false;
  3589. if D<>'' then OK:=CheckDir(D,N,NewExt) else
  3590. if CheckDir('.'+DirSep,N,NewExt) then OK:=true;
  3591. CheckExt:=OK;
  3592. end;
  3593. function TryToLocateIn(const DD : dirstr): boolean;
  3594. var Found: boolean;
  3595. begin
  3596. D:=CompleteDir(DD);
  3597. Found:=true;
  3598. if (E<>'') or (not tryexts) then
  3599. Found:=CheckExt(E)
  3600. else
  3601. if CheckExt('.pp') then
  3602. Found:=true
  3603. else
  3604. if CheckExt('.pas') then
  3605. Found:=true
  3606. else
  3607. if CheckExt('.inc') then
  3608. Found:=true
  3609. { try also without extension if no other exist }
  3610. else
  3611. if CheckExt('') then
  3612. Found:=true
  3613. else
  3614. Found:=false;
  3615. TryToLocateIn:=Found;
  3616. end;
  3617. var Path,DrStr: string;
  3618. Found: boolean;
  3619. begin
  3620. FSplit(FileName,D,N,E);
  3621. Found:=CheckDir(D,N,E);
  3622. if not found then
  3623. Found:=TryToLocateIn('.');
  3624. DrStr:=GetSourceDirectories;
  3625. if not Found then
  3626. While pos(ListSeparator,DrStr)>0 do
  3627. Begin
  3628. Found:=TryToLocateIn(Copy(DrStr,1,pos(ListSeparator,DrStr)-1));
  3629. if Found then
  3630. break;
  3631. DrStr:=Copy(DrStr,pos(ListSeparator,DrStr)+1,High(DrStr));
  3632. End;
  3633. if Found then Path:=FExpand(D+N+E) else Path:='';
  3634. LocateSingleSourceFile:=Path;
  3635. end;
  3636. function LocateSourceFile(const FileName: string; tryexts: boolean): string;
  3637. var P: integer;
  3638. FN,S: string;
  3639. FFN: string;
  3640. begin
  3641. FN:=FileName;
  3642. repeat
  3643. P:=Pos(ListSeparator,FN); if P=0 then P:=length(FN)+1;
  3644. S:=copy(FN,1,P-1); Delete(FN,1,P);
  3645. FFN:=LocateSingleSourceFile(S,tryexts);
  3646. until (FFN<>'') or (FN='');
  3647. LocateSourceFile:=FFN;
  3648. end;
  3649. function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean;
  3650. ShowIt,ForceNewWindow: boolean): PSourceWindow;
  3651. var
  3652. W : PSourceWindow;
  3653. DrStr: string;
  3654. begin
  3655. W:=nil;
  3656. if ForceNewWindow then
  3657. W:=nil
  3658. else
  3659. W:=SearchOnDesktop(FileName,tryexts);
  3660. if W<>nil then
  3661. begin
  3662. NewEditorOpened:=false;
  3663. { if assigned(Bounds) then
  3664. W^.ChangeBounds(Bounds^);}
  3665. W^.Editor^.SetCurPtr(CurX,CurY);
  3666. end
  3667. else
  3668. begin
  3669. DrStr:=LocateSourceFile(FileName,tryexts);
  3670. if DrStr<>'' then
  3671. W:=IOpenEditorWindow(Bounds,DrStr,CurX,CurY,ShowIt);
  3672. NewEditorOpened:=W<>nil;
  3673. if assigned(W) then
  3674. W^.Editor^.SetCurPtr(CurX,CurY);
  3675. end;
  3676. ITryToOpenFile:=W;
  3677. end;
  3678. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  3679. var OK: boolean;
  3680. E: PFileEditor;
  3681. R: TRect;
  3682. begin
  3683. R.Assign(0,0,0,0);
  3684. New(E, Init(R,nil,nil,nil,nil,FileName));
  3685. OK:=E<>nil;
  3686. if OK then
  3687. begin
  3688. PushStatus(FormatStrStr(msg_readingfileineditor,FileName));
  3689. OK:=E^.LoadFile;
  3690. PopStatus;
  3691. end;
  3692. if OK then
  3693. begin
  3694. Editor^.Lock;
  3695. E^.SelectAll(true);
  3696. Editor^.InsertFrom(E);
  3697. Editor^.SetCurPtr(0,0);
  3698. Editor^.SelectAll(false);
  3699. Editor^.UnLock;
  3700. Dispose(E, Done);
  3701. end;
  3702. StartEditor:=OK;
  3703. end;
  3704. constructor TTextScroller.Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  3705. begin
  3706. inherited Init(Bounds,'');
  3707. EventMask:=EventMask or evIdle;
  3708. Speed:=ASpeed; Lines:=AText;
  3709. end;
  3710. function TTextScroller.GetLineCount: integer;
  3711. var Count: integer;
  3712. begin
  3713. if Lines=nil then Count:=0 else
  3714. Count:=Lines^.Count;
  3715. GetLineCount:=Count;
  3716. end;
  3717. function TTextScroller.GetLine(I: integer): string;
  3718. var S: string;
  3719. begin
  3720. if I<Lines^.Count then
  3721. S:=GetStr(Lines^.At(I))
  3722. else
  3723. S:='';
  3724. GetLine:=S;
  3725. end;
  3726. procedure TTextScroller.HandleEvent(var Event: TEvent);
  3727. begin
  3728. case Event.What of
  3729. evIdle :
  3730. Update;
  3731. end;
  3732. inherited HandleEvent(Event);
  3733. end;
  3734. procedure TTextScroller.Update;
  3735. begin
  3736. if abs(GetDosTicks-LastTT)<Speed then Exit;
  3737. Scroll;
  3738. LastTT:=GetDosTicks;
  3739. end;
  3740. procedure TTextScroller.Reset;
  3741. begin
  3742. TopLine:=0;
  3743. LastTT:=GetDosTicks;
  3744. DrawView;
  3745. end;
  3746. procedure TTextScroller.Scroll;
  3747. begin
  3748. Inc(TopLine);
  3749. if TopLine>=GetLineCount then
  3750. Reset;
  3751. DrawView;
  3752. end;
  3753. procedure TTextScroller.Draw;
  3754. var B: TDrawBuffer;
  3755. C: word;
  3756. Count,Y: integer;
  3757. S: string;
  3758. begin
  3759. C:=GetColor(1);
  3760. Count:=GetLineCount;
  3761. for Y:=0 to Size.Y-1 do
  3762. begin
  3763. if Count=0 then S:='' else
  3764. S:=GetLine((TopLine+Y) mod Count);
  3765. if copy(S,1,1)=^C then
  3766. S:=CharStr(' ',Max(0,(Size.X-(length(S)-1)) div 2))+copy(S,2,255);
  3767. MoveChar(B,' ',C,Size.X);
  3768. MoveStr(B,S,C);
  3769. WriteLine(0,Y,Size.X,1,B);
  3770. end;
  3771. end;
  3772. destructor TTextScroller.Done;
  3773. begin
  3774. inherited Done;
  3775. if Lines<>nil then Dispose(Lines, Done);
  3776. end;
  3777. constructor TFPAboutDialog.Init;
  3778. var R,R2: TRect;
  3779. C: PUnsortedStringCollection;
  3780. I: integer;
  3781. OSStr: string;
  3782. procedure AddLine(S: string);
  3783. begin
  3784. C^.Insert(NewStr(S));
  3785. end;
  3786. begin
  3787. OSStr:='';
  3788. {$ifdef go32v2}
  3789. OSStr:='Dos';
  3790. {$endif}
  3791. {$ifdef tp}
  3792. OSStr:='Dos';
  3793. {$endif}
  3794. {$ifdef linux}
  3795. OSStr:='Linux';
  3796. {$endif}
  3797. {$ifdef win32}
  3798. OSStr:='Win32';
  3799. {$endif}
  3800. {$ifdef os2}
  3801. OSStr:='OS/2';
  3802. {$endif}
  3803. {$ifdef FreeBSD}
  3804. OSStr:='FreeBSD';
  3805. {$endif}
  3806. {$ifdef NetBSD}
  3807. OSStr:='NetBSD';
  3808. {$endif}
  3809. {$ifdef OpenBSD}
  3810. OSStr:='OpenBSD';
  3811. {$endif}
  3812. R.Assign(0,0,38,14{$ifdef NODEBUG}-1{$endif});
  3813. inherited Init(R, dialog_about);
  3814. HelpCtx:=hcAbout;
  3815. GetExtent(R); R.Grow(-3,-2);
  3816. R2.Copy(R); R2.B.Y:=R2.A.Y+1;
  3817. Insert(New(PStaticText, Init(R2, ^C'FreePascal IDE for '+OSStr)));
  3818. R2.Move(0,1);
  3819. Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr
  3820. {$ifdef FPC}+' '+{$i %date%}{$endif}
  3821. {$ifdef FVISION}+' FV'{$endif}
  3822. )));
  3823. R2.Move(0,1);
  3824. {$ifdef USE_GRAPH_SWITCH}
  3825. Insert(New(PStaticText, Init(R2, ^C'With Graphic Support')));
  3826. R2.Move(0,1);
  3827. {$endif USE_GRAPH_SWITCH}
  3828. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_compilerversion,Version_String))));
  3829. {$ifndef NODEBUG}
  3830. if pos('Fake',GDBVersion)=0 then
  3831. begin
  3832. R2.Move(0,1);
  3833. Insert(New(PStaticText, Init(R2, FormatStrStr2(^C'(%s %s)',label_about_debugger,GDBVersion))));
  3834. R2.Move(0,1);
  3835. end
  3836. else
  3837. {$endif NODEBUG}
  3838. R2.Move(0,2);
  3839. Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-2002 by')));
  3840. R2.Move(0,2);
  3841. Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
  3842. R2.Move(0,1);
  3843. Insert(New(PStaticText, Init(R2, ^C'Pierre Muller')));
  3844. R2.Move(0,1);
  3845. Insert(New(PStaticText, Init(R2, ^C'and')));
  3846. R2.Move(0,1);
  3847. Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
  3848. New(C, Init(50,10));
  3849. for I:=1 to 7 do
  3850. AddLine('');
  3851. AddLine(^C'< Original concept >');
  3852. AddLine(^C'Borland International, Inc.');
  3853. AddLine('');
  3854. AddLine(^C'< Compiler development >');
  3855. AddLine(^C'Carl-Eric Codere');
  3856. AddLine(^C'Daniel Mantione');
  3857. AddLine(^C'Florian Kl„mpfl');
  3858. AddLine(^C'Jonas Maebe');
  3859. AddLine(^C'Mich„el Van Canneyt');
  3860. AddLine(^C'Peter Vreman');
  3861. AddLine(^C'Pierre Muller');
  3862. AddLine('');
  3863. AddLine(^C'< IDE development >');
  3864. AddLine(^C'B‚rczi G bor');
  3865. AddLine(^C'Peter Vreman');
  3866. AddLine(^C'Pierre Muller');
  3867. AddLine('');
  3868. GetExtent(R);
  3869. R.Grow(-1,-1); Inc(R.A.Y,3);
  3870. New(Scroller, Init(R, 10, C));
  3871. Scroller^.Hide;
  3872. Insert(Scroller);
  3873. R.Move(0,-1); R.B.Y:=R.A.Y+1;
  3874. New(TitleST, Init(R, ^C'Team'));
  3875. TitleST^.Hide;
  3876. Insert(TitleST);
  3877. InsertOK(@Self);
  3878. end;
  3879. procedure TFPAboutDialog.ToggleInfo;
  3880. begin
  3881. if Scroller=nil then Exit;
  3882. if Scroller^.GetState(sfVisible) then
  3883. begin
  3884. Scroller^.Hide;
  3885. TitleST^.Hide;
  3886. end
  3887. else
  3888. begin
  3889. Scroller^.Reset;
  3890. Scroller^.Show;
  3891. TitleST^.Show;
  3892. end;
  3893. end;
  3894. procedure TFPAboutDialog.HandleEvent(var Event: TEvent);
  3895. begin
  3896. case Event.What of
  3897. evKeyDown :
  3898. case Event.KeyCode of
  3899. kbAltI : { just like in BP }
  3900. begin
  3901. ToggleInfo;
  3902. ClearEvent(Event);
  3903. end;
  3904. end;
  3905. end;
  3906. inherited HandleEvent(Event);
  3907. end;
  3908. constructor TFPASCIIChart.Init;
  3909. begin
  3910. inherited Init;
  3911. HelpCtx:=hcASCIITableWindow;
  3912. Number:=SearchFreeWindowNo;
  3913. ASCIIChart:=@Self;
  3914. end;
  3915. procedure TFPASCIIChart.Store(var S: TStream);
  3916. begin
  3917. inherited Store(S);
  3918. end;
  3919. constructor TFPASCIIChart.Load(var S: TStream);
  3920. begin
  3921. inherited Load(S);
  3922. end;
  3923. procedure TFPASCIIChart.HandleEvent(var Event: TEvent);
  3924. var W: PSourceWindow;
  3925. begin
  3926. case Event.What of
  3927. evKeyDown :
  3928. case Event.KeyCode of
  3929. kbEsc :
  3930. begin
  3931. Close;
  3932. ClearEvent(Event);
  3933. end;
  3934. end;
  3935. evCommand :
  3936. case Event.Command of
  3937. cmTransfer :
  3938. begin
  3939. W:=FirstEditorWindow;
  3940. if Assigned(W) and Assigned(Report) then
  3941. Message(W,evCommand,cmAddChar,pointer(ord(Report^.AsciiChar)));
  3942. ClearEvent(Event);
  3943. end;
  3944. cmSearchWindow+1..cmSearchWindow+99 :
  3945. if (Event.Command-cmSearchWindow=Number) then
  3946. ClearEvent(Event);
  3947. end;
  3948. end;
  3949. inherited HandleEvent(Event);
  3950. end;
  3951. destructor TFPASCIIChart.Done;
  3952. begin
  3953. ASCIIChart:=nil;
  3954. inherited Done;
  3955. end;
  3956. function TVideoModeListBox.GetText(Item: pointer; MaxLen: sw_integer): string;
  3957. var P: PVideoMode;
  3958. S: string;
  3959. begin
  3960. P:=Item;
  3961. S:=IntToStr(P^.Col)+'x'+IntToStr(P^.Row)+' ';
  3962. if P^.Color then
  3963. S:=S+'color'
  3964. else
  3965. S:=S+'mono';
  3966. GetText:=copy(S,1,MaxLen);
  3967. end;
  3968. constructor TFPDesktop.Init(var Bounds: TRect);
  3969. begin
  3970. inherited Init(Bounds);
  3971. end;
  3972. procedure TFPDesktop.InitBackground;
  3973. var AV: PANSIBackground;
  3974. FileName: string;
  3975. R: TRect;
  3976. begin
  3977. AV:=nil;
  3978. FileName:=LocateFile(BackgroundPath);
  3979. if FileName<>'' then
  3980. begin
  3981. GetExtent(R);
  3982. New(AV, Init(R));
  3983. AV^.GrowMode:=gfGrowHiX+gfGrowHiY;
  3984. if AV^.LoadFile(FileName)=false then
  3985. begin
  3986. Dispose(AV, Done); AV:=nil;
  3987. end;
  3988. if Assigned(AV) then
  3989. Insert(AV);
  3990. end;
  3991. Background:=AV;
  3992. if Assigned(Background)=false then
  3993. inherited InitBackground;
  3994. end;
  3995. constructor TFPDesktop.Load(var S: TStream);
  3996. begin
  3997. inherited Load(S);
  3998. end;
  3999. procedure TFPDesktop.Store(var S: TStream);
  4000. begin
  4001. inherited Store(S);
  4002. end;
  4003. constructor TFPToolTip.Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  4004. begin
  4005. inherited Init(Bounds);
  4006. SetAlign(AAlign);
  4007. SetText(AText);
  4008. end;
  4009. procedure TFPToolTip.Draw;
  4010. var C: word;
  4011. procedure DrawLine(Y: integer; S: string);
  4012. var B: TDrawBuffer;
  4013. begin
  4014. S:=copy(S,1,Size.X-2);
  4015. case Align of
  4016. alLeft : S:=' '+S;
  4017. alRight : S:=LExpand(' '+S,Size.X);
  4018. alCenter : S:=Center(S,Size.X);
  4019. end;
  4020. MoveChar(B,' ',C,Size.X);
  4021. MoveStr(B,S,C);
  4022. WriteLine(0,Y,Size.X,1,B);
  4023. end;
  4024. var S: string;
  4025. Y: integer;
  4026. begin
  4027. C:=GetColor(1);
  4028. S:=GetText;
  4029. for Y:=0 to Size.Y-1 do
  4030. DrawLine(Y,S);
  4031. end;
  4032. function TFPToolTip.GetText: string;
  4033. begin
  4034. GetText:=GetStr(Text);
  4035. end;
  4036. procedure TFPToolTip.SetText(const AText: string);
  4037. begin
  4038. if AText<>GetText then
  4039. begin
  4040. if Assigned(Text) then DisposeStr(Text);
  4041. Text:=NewStr(AText);
  4042. DrawView;
  4043. end;
  4044. end;
  4045. function TFPToolTip.GetAlign: TAlign;
  4046. begin
  4047. GetAlign:=Align;
  4048. end;
  4049. procedure TFPToolTip.SetAlign(AAlign: TAlign);
  4050. begin
  4051. if AAlign<>Align then
  4052. begin
  4053. Align:=AAlign;
  4054. DrawView;
  4055. end;
  4056. end;
  4057. destructor TFPToolTip.Done;
  4058. begin
  4059. if Assigned(Text) then DisposeStr(Text); Text:=nil;
  4060. inherited Done;
  4061. end;
  4062. function TFPToolTip.GetPalette: PPalette;
  4063. const S: string[length(CFPToolTip)] = CFPToolTip;
  4064. begin
  4065. GetPalette:=@S;
  4066. end;
  4067. constructor TFPMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4068. PScrollBar; AIndicator: PIndicator);
  4069. begin
  4070. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,nil);
  4071. SetFlags(Flags and not (efPersistentBlocks) or efSyntaxHighlight);
  4072. end;
  4073. function TFPMemo.GetPalette: PPalette;
  4074. const P: string[length(CFPMemo)] = CFPMemo;
  4075. begin
  4076. GetPalette:=@P;
  4077. end;
  4078. function TFPMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4079. begin
  4080. GetSpecSymbolCount:=0;
  4081. end;
  4082. function TFPMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4083. begin
  4084. Abstract;
  4085. GetSpecSymbol:=nil;
  4086. end;
  4087. function TFPMemo.IsReservedWord(const S: string): boolean;
  4088. begin
  4089. IsReservedWord:=false;
  4090. end;
  4091. constructor TFPCodeMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  4092. PScrollBar; AIndicator: PIndicator);
  4093. begin
  4094. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator);
  4095. end;
  4096. function TFPCodeMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  4097. begin
  4098. GetSpecSymbolCount:=FreePascalSpecSymbolCount[SpecClass];
  4099. end;
  4100. function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): pstring;
  4101. begin
  4102. GetSpecSymbol:=@FreePascalEmptyString;
  4103. case SpecClass of
  4104. ssCommentPrefix :
  4105. case Index of
  4106. 0 : GetSpecSymbol:=@FreePascalCommentPrefix1;
  4107. 1 : GetSpecSymbol:=@FreePascalCommentPrefix2;
  4108. 2 : GetSpecSymbol:=@FreePascalCommentPrefix3;
  4109. end;
  4110. ssCommentSingleLinePrefix :
  4111. case Index of
  4112. 0 : GetSpecSymbol:=@FreePascalCommentSingleLinePrefix;
  4113. end;
  4114. ssCommentSuffix :
  4115. case Index of
  4116. 0 : GetSpecSymbol:=@FreePascalCommentSuffix1;
  4117. 1 : GetSpecSymbol:=@FreePascalCommentSuffix2;
  4118. end;
  4119. ssStringPrefix :
  4120. GetSpecSymbol:=@FreePascalStringPrefix;
  4121. ssStringSuffix :
  4122. GetSpecSymbol:=@FreePascalStringSuffix;
  4123. { must be uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
  4124. ssAsmPrefix :
  4125. GetSpecSymbol:=@FreePascalAsmPrefix;
  4126. ssAsmSuffix :
  4127. GetSpecSymbol:=@FreePascalAsmSuffix;
  4128. ssDirectivePrefix :
  4129. GetSpecSymbol:=@FreePascalDirectivePrefix;
  4130. ssDirectiveSuffix :
  4131. GetSpecSymbol:=@FreePascalDirectiveSuffix;
  4132. end;
  4133. end;
  4134. function TFPCodeMemo.IsReservedWord(const S: string): boolean;
  4135. begin
  4136. IsReservedWord:=IsFPReservedWord(S);
  4137. end;
  4138. {$ifdef VESA}
  4139. function VESASetVideoModeProc(const VideoMode: TVideoMode; Params: Longint): Boolean; {$ifndef FPC}far;{$endif}
  4140. begin
  4141. VESASetVideoModeProc:=VESASetMode(Params);
  4142. end;
  4143. procedure InitVESAScreenModes;
  4144. var ML: TVESAModeList;
  4145. MI: TVESAModeInfoBlock;
  4146. I: integer;
  4147. begin
  4148. if VESAInit=false then Exit;
  4149. if VESAGetModeList(ML)=false then Exit;
  4150. for I:=1 to ML.Count do
  4151. begin
  4152. if VESAGetModeInfo(ML.Modes[I],MI) then
  4153. with MI do
  4154. {$ifndef DEBUG}
  4155. if (Attributes and vesa_vma_GraphicsMode)=0 then
  4156. {$else DEBUG}
  4157. if ((Attributes and vesa_vma_GraphicsMode)=0) or
  4158. { only allow 4 bit i.e. 16 color modes }
  4159. (((Attributes and vesa_vma_CanBeSetInCurrentConfig)<>0) and
  4160. (BitsPerPixel=8)) then
  4161. {$endif DEBUG}
  4162. RegisterVesaVideoMode(ML.Modes[I]);
  4163. end;
  4164. end;
  4165. procedure DoneVESAScreenModes;
  4166. begin
  4167. FreeVesaModes;
  4168. end;
  4169. {$endif}
  4170. procedure NoDebugger;
  4171. begin
  4172. InformationBox(msg_nodebuggersupportavailable,nil);
  4173. end;
  4174. procedure RegisterFPViews;
  4175. begin
  4176. RegisterType(RSourceEditor);
  4177. RegisterType(RSourceWindow);
  4178. RegisterType(RFPHelpViewer);
  4179. RegisterType(RFPHelpWindow);
  4180. RegisterType(RClipboardWindow);
  4181. RegisterType(RMessageListBox);
  4182. RegisterType(RFPDesktop);
  4183. RegisterType(RGDBSourceEditor);
  4184. RegisterType(RGDBWindow);
  4185. RegisterType(RFPASCIIChart);
  4186. RegisterType(RProgramInfoWindow);
  4187. RegisterType(RFPDlgWindow);
  4188. end;
  4189. END.
  4190. {
  4191. $Log$
  4192. Revision 1.41 2003-02-09 23:50:10 pierre
  4193. + i386 openbsd target added
  4194. Revision 1.40 2003/01/22 00:27:58 pierre
  4195. * implement reloadfile if changed
  4196. Revision 1.39 2002/12/16 15:16:15 pierre
  4197. * try to fix the moving of breakpoints
  4198. Revision 1.38 2002/12/12 00:09:08 pierre
  4199. * move line breakpoints if lines added or deleted in editor window
  4200. Revision 1.37 2002/11/30 01:56:52 pierre
  4201. + powerpc cpu support started
  4202. Revision 1.36 2002/09/19 22:15:45 pierre
  4203. * fix compilation failure for m68k target
  4204. Revision 1.35 2002/09/13 22:28:08 pierre
  4205. * Update copyright
  4206. Revision 1.34 2002/09/12 22:07:46 pierre
  4207. * Enable go32v2 graph support in fixes branchfpusrscr.pas
  4208. Revision 1.33 2002/09/12 08:49:10 pierre
  4209. * fix typo bug in last commit
  4210. Revision 1.32 2002/09/12 08:42:07 pierre
  4211. * removed lots of unnecessary copies of strings for syntax highlighting
  4212. Revision 1.31 2002/09/11 11:23:48 pierre
  4213. * more changes to speed syntax highlighting up
  4214. Revision 1.30 2002/09/11 10:05:10 pierre
  4215. * try to speed up syntax highlighting
  4216. Revision 1.29 2002/09/07 15:40:46 peter
  4217. * old logs removed and tabs fixed
  4218. Revision 1.28 2002/09/05 10:57:08 pierre
  4219. * fix small bug in previous commit
  4220. Revision 1.27 2002/09/05 10:49:48 pierre
  4221. + FindMatchingDelimiter for pascal keywords with level counting
  4222. Revision 1.26 2002/09/05 05:58:58 pierre
  4223. + use '*' as special name for noload and also no 'nonamexx.pas title
  4224. Revision 1.25 2002/09/04 08:50:59 pierre
  4225. * TranslateCodeTemplate Shortcut is now a var parameter
  4226. Revision 1.24 2002/08/26 13:00:08 pierre
  4227. * fix bug report 2094 by restoring nonamexx.pas name if file name is incorrect
  4228. Revision 1.23 2002/06/13 11:52:01 pierre
  4229. * try to avoid crash with fvision library
  4230. Revision 1.22 2002/06/13 10:54:54 pierre
  4231. * avoid random colors in Screen view
  4232. Revision 1.21 2002/06/06 08:15:29 pierre
  4233. * fix GDBwindow indicator bug
  4234. Revision 1.20 2002/06/01 20:08:42 marco
  4235. * Renamefest
  4236. Revision 1.19 2002/05/31 12:37:10 pierre
  4237. + register asciitable char
  4238. Revision 1.18 2002/05/30 15:02:39 pierre
  4239. * avoid ugly border draw on windows without owners in fvision
  4240. Revision 1.17 2002/05/29 22:38:13 pierre
  4241. Asciitab now in fvision
  4242. Revision 1.16 2002/05/24 21:15:31 pierre
  4243. * add FV suffix in About dialog if using FVision library
  4244. Revision 1.15 2002/04/17 11:10:13 pierre
  4245. * fix last commit for corss compilation fir 1.1 IDE from 1.0.6
  4246. Revision 1.14 2002/04/16 18:12:35 carl
  4247. + compilation problems bugfixes
  4248. Revision 1.13 2002/04/02 11:17:40 pierre
  4249. * Use new SetWidth method for GDB window
  4250. Revision 1.12 2002/01/09 09:48:00 pierre
  4251. try to fix bug 1732
  4252. }