fpviews.pas 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518
  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,Commands,HelpCtx,Views,Menus,Dialogs,App,Gadgets,
  17. ASCIITAB,
  18. {$ifdef EDITORS}
  19. Editors,
  20. {$else}
  21. WEditor,
  22. {$endif}
  23. WUtils,WHelp,WHlpView,WViews,
  24. Comphook,
  25. FPConst,FPUsrScr;
  26. type
  27. {$IFNDEF EDITORS}
  28. TEditor = TCodeEditor; PEditor = PCodeEditor;
  29. {$ENDIF}
  30. PStoreCollection = ^TStoreCollection;
  31. TStoreCollection = object(TStringCollection)
  32. function Add(const S: string): PString;
  33. end;
  34. PIntegerLine = ^TIntegerLine;
  35. TIntegerLine = object(TInputLine)
  36. constructor Init(var Bounds: TRect; AMin, AMax: longint);
  37. end;
  38. PFPHeapView = ^TFPHeapView;
  39. TFPHeapView = object(THeapView)
  40. constructor Init(var Bounds: TRect);
  41. constructor InitKb(var Bounds: TRect);
  42. procedure HandleEvent(var Event: TEvent); virtual;
  43. end;
  44. PFPClockView = ^TFPClockView;
  45. TFPClockView = object(TClockView)
  46. constructor Init(var Bounds: TRect);
  47. procedure HandleEvent(var Event: TEvent); virtual;
  48. function GetPalette: PPalette; virtual;
  49. end;
  50. TFPWindow = object(TWindow)
  51. AutoNumber: boolean;
  52. procedure HandleEvent(var Event: TEvent); virtual;
  53. procedure SetState(AState: Word; Enable: Boolean); virtual;
  54. constructor Load(var S: TStream);
  55. procedure Store(var S: TStream);
  56. procedure Update;
  57. end;
  58. PFPHelpViewer = ^TFPHelpViewer;
  59. TFPHelpViewer = object(THelpViewer)
  60. function GetLocalMenu: PMenu; virtual;
  61. function GetCommandTarget: PView; virtual;
  62. end;
  63. PFPHelpWindow = ^TFPHelpWindow;
  64. TFPHelpWindow = object(THelpWindow)
  65. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word; AContext: THelpCtx; ANumber: Integer);
  66. destructor Done;virtual;
  67. procedure InitHelpView; virtual;
  68. procedure Show; virtual;
  69. procedure Hide; virtual;
  70. procedure HandleEvent(var Event: TEvent); virtual;
  71. function GetPalette: PPalette; virtual;
  72. constructor Load(var S: TStream);
  73. procedure Store(var S: TStream);
  74. end;
  75. PTextScroller = ^TTextScroller;
  76. TTextScroller = object(TStaticText)
  77. TopLine: integer;
  78. Speed : integer;
  79. Lines : PUnsortedStringCollection;
  80. constructor Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  81. function GetLineCount: integer; virtual;
  82. function GetLine(I: integer): string; virtual;
  83. procedure HandleEvent(var Event: TEvent); virtual;
  84. procedure Update; virtual;
  85. procedure Reset; virtual;
  86. procedure Scroll; virtual;
  87. procedure Draw; virtual;
  88. destructor Done; virtual;
  89. private
  90. LastTT: longint;
  91. end;
  92. TAlign = (alLeft,alCenter,alRight);
  93. PFPToolTip = ^TFPToolTip;
  94. TFPToolTip = object(TView)
  95. constructor Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  96. procedure Draw; virtual;
  97. function GetText: string;
  98. procedure SetText(const AText: string);
  99. function GetAlign: TAlign;
  100. procedure SetAlign(AAlign: TAlign);
  101. function GetPalette: PPalette; virtual;
  102. destructor Done; virtual;
  103. private
  104. Text: PString;
  105. Align: TAlign;
  106. end;
  107. PSourceEditor = ^TSourceEditor;
  108. TSourceEditor = object(TFileEditor)
  109. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  110. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  111. {$ifndef EDITORS}
  112. public
  113. CodeCompleteTip: PFPToolTip;
  114. { Syntax highlight }
  115. function IsReservedWord(const S: string): boolean; virtual;
  116. function GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
  117. function GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
  118. { CodeTemplates }
  119. function TranslateCodeTemplate(const Shortcut: string; ALines: PUnsortedStringCollection): boolean; virtual;
  120. { CodeComplete }
  121. function CompleteCodeWord(const WordS: string; var Text: string): boolean; virtual;
  122. procedure SetCodeCompleteWord(const S: string); virtual;
  123. procedure AlignCodeCompleteTip;
  124. {$endif}
  125. procedure HandleEvent(var Event: TEvent); virtual;
  126. {$ifdef DebugUndo}
  127. procedure DumpUndo;
  128. procedure UndoAll;
  129. procedure RedoAll;
  130. {$endif DebugUndo}
  131. function GetLocalMenu: PMenu; virtual;
  132. function GetCommandTarget: PView; virtual;
  133. function CreateLocalMenuView(var Bounds: TRect; M: PMenu): PMenuPopup; virtual;
  134. procedure ModifiedChanged; virtual;
  135. end;
  136. PSourceWindow = ^TSourceWindow;
  137. TSourceWindow = object(TFPWindow)
  138. Editor : PSourceEditor;
  139. Indicator : PIndicator;
  140. constructor Init(var Bounds: TRect; AFileName: string);
  141. procedure SetTitle(ATitle: string); virtual;
  142. procedure UpdateTitle; virtual;
  143. procedure HandleEvent(var Event: TEvent); virtual;
  144. procedure SetState(AState: Word; Enable: Boolean); virtual;
  145. procedure SelectInDebugSession;
  146. procedure Update; virtual;
  147. procedure UpdateCommands; virtual;
  148. function GetPalette: PPalette; virtual;
  149. constructor Load(var S: TStream);
  150. procedure Store(var S: TStream);
  151. destructor Done; virtual;
  152. end;
  153. PGDBSourceEditor = ^TGDBSourceEditor;
  154. TGDBSourceEditor = object(TSourceEditor)
  155. function InsertLine : Sw_integer;virtual;
  156. function Valid(Command: Word): Boolean; virtual;
  157. procedure AddLine(const S: string); virtual;
  158. procedure AddErrorLine(const S: string); virtual;
  159. private
  160. Silent,
  161. AutoRepeat,
  162. IgnoreStringAtEnd : boolean;
  163. LastCommand : String;
  164. end;
  165. PGDBWindow = ^TGDBWindow;
  166. TGDBWindow = object(TFPWindow)
  167. Editor : PGDBSourceEditor;
  168. Indicator : PIndicator;
  169. constructor Init(var Bounds: TRect);
  170. procedure WriteText(Buf : pchar;IsError : boolean);
  171. procedure WriteString(Const S : string);
  172. procedure WriteErrorString(Const S : string);
  173. procedure WriteOutputText(Buf : pchar);
  174. procedure WriteErrorText(Buf : pchar);
  175. function GetPalette: PPalette;virtual;
  176. constructor Load(var S: TStream);
  177. procedure Store(var S: TStream);
  178. destructor Done; virtual;
  179. end;
  180. PClipboardWindow = ^TClipboardWindow;
  181. TClipboardWindow = object(TSourceWindow)
  182. constructor Init;
  183. procedure Close; virtual;
  184. constructor Load(var S: TStream);
  185. procedure Store(var S: TStream);
  186. destructor Done; virtual;
  187. end;
  188. PMessageItem = ^TMessageItem;
  189. TMessageItem = object(TObject)
  190. TClass : longint;
  191. Text : PString;
  192. Module : PString;
  193. Row,Col : sw_integer;
  194. constructor Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  195. function GetText(MaxLen: Sw_integer): string; virtual;
  196. procedure Selected; virtual;
  197. function GetModuleName: string; virtual;
  198. destructor Done; virtual;
  199. end;
  200. PMessageListBox = ^TMessageListBox;
  201. TMessageListBox = object(THSListBox)
  202. Transparent : boolean;
  203. NoSelection : boolean;
  204. MaxWidth : Sw_integer;
  205. ModuleNames : PStoreCollection;
  206. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  207. procedure AddItem(P: PMessageItem); virtual;
  208. function AddModuleName(const Name: string): PString; virtual;
  209. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  210. procedure Clear; virtual;
  211. procedure TrackSource; virtual;
  212. procedure GotoSource; virtual;
  213. procedure Draw; virtual;
  214. procedure HandleEvent(var Event: TEvent); virtual;
  215. function GetLocalMenu: PMenu; virtual;
  216. constructor Load(var S: TStream);
  217. procedure Store(var S: TStream);
  218. destructor Done; virtual;
  219. end;
  220. {$ifdef OLDCOMP}
  221. PCompilerMessage = ^TCompilerMessage;
  222. TCompilerMessage = object(TMessageItem)
  223. function GetText(MaxLen: Sw_Integer): String; virtual;
  224. end;
  225. {$endif}
  226. PProgramInfoWindow = ^TProgramInfoWindow;
  227. TProgramInfoWindow = object(TDlgWindow)
  228. InfoST: PColorStaticText;
  229. LogLB : PMessageListBox;
  230. constructor Init;
  231. constructor Load(var S: TStream);
  232. procedure Store(var S: TStream);
  233. procedure AddMessage(AClass: longint; Msg, Module: string; Line, Column: longint);
  234. procedure ClearMessages;
  235. procedure SizeLimits(var Min, Max: TPoint); virtual;
  236. procedure Close; virtual;
  237. procedure HandleEvent(var Event: TEvent); virtual;
  238. procedure Update; virtual;
  239. destructor Done; virtual;
  240. end;
  241. PTabItem = ^TTabItem;
  242. TTabItem = record
  243. Next : PTabItem;
  244. View : PView;
  245. Dis : boolean;
  246. end;
  247. PTabDef = ^TTabDef;
  248. TTabDef = record
  249. Next : PTabDef;
  250. Name : PString;
  251. Items : PTabItem;
  252. DefItem : PView;
  253. ShortCut : char;
  254. end;
  255. PTab = ^TTab;
  256. TTab = object(TGroup)
  257. TabDefs : PTabDef;
  258. ActiveDef : integer;
  259. DefCount : word;
  260. constructor Init(var Bounds: TRect; ATabDef: PTabDef);
  261. function AtTab(Index: integer): PTabDef; virtual;
  262. procedure SelectTab(Index: integer); virtual;
  263. function TabCount: integer;
  264. procedure SelectNextTab(Forwards: boolean);
  265. function Valid(Command: Word): Boolean; virtual;
  266. procedure ChangeBounds(var Bounds: TRect); virtual;
  267. procedure HandleEvent(var Event: TEvent); virtual;
  268. function GetPalette: PPalette; virtual;
  269. procedure Draw; virtual;
  270. procedure SetState(AState: Word; Enable: Boolean); virtual;
  271. destructor Done; virtual;
  272. private
  273. InDraw: boolean;
  274. end;
  275. PScreenView = ^TScreenView;
  276. TScreenView = object(TScroller)
  277. Screen: PScreen;
  278. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  279. AScreen: PScreen);
  280. procedure Draw; virtual;
  281. procedure Update; virtual;
  282. procedure HandleEvent(var Event: TEvent); virtual;
  283. end;
  284. PScreenWindow = ^TScreenWindow;
  285. TScreenWindow = object(TFPWindow)
  286. ScreenView : PScreenView;
  287. constructor Init(AScreen: PScreen; ANumber: integer);
  288. destructor Done; virtual;
  289. end;
  290. PFPAboutDialog = ^TFPAboutDialog;
  291. TFPAboutDialog = object(TCenterDialog)
  292. constructor Init;
  293. procedure ToggleInfo;
  294. procedure HandleEvent(var Event: TEvent); virtual;
  295. private
  296. Scroller: PTextScroller;
  297. TitleST : PStaticText;
  298. end;
  299. PFPASCIIChart = ^TFPASCIIChart;
  300. TFPASCIIChart = object(TASCIIChart)
  301. constructor Init;
  302. constructor Load(var S: TStream);
  303. procedure Store(var S: TStream);
  304. procedure HandleEvent(var Event: TEvent); virtual;
  305. destructor Done; virtual;
  306. end;
  307. PVideoModeListBox = ^TVideoModeListBox;
  308. TVideoModeListBox = object(TDropDownListBox)
  309. function GetText(Item: pointer; MaxLen: sw_integer): string; virtual;
  310. end;
  311. PFPDesktop = ^TFPDesktop;
  312. TFPDesktop = object(TDesktop)
  313. constructor Load(var S: TStream);
  314. procedure Store(var S: TStream);
  315. end;
  316. PFPCodeMemo = ^TFPCodeMemo;
  317. TFPCodeMemo = object(TCodeEditor)
  318. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  319. PScrollBar; AIndicator: PIndicator; ABufSize:Sw_Word);
  320. function IsReservedWord(const S: string): boolean; virtual;
  321. function GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
  322. function GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
  323. function GetPalette: PPalette; virtual;
  324. end;
  325. function SearchFreeWindowNo: integer;
  326. function IsThereAnyEditor: boolean;
  327. function IsThereAnyWindow: boolean;
  328. function FirstEditorWindow: PSourceWindow;
  329. function EditorWindowFile(const Name : String): PSourceWindow;
  330. function NewTabItem(AView: PView; ANext: PTabItem): PTabItem;
  331. procedure DisposeTabItem(P: PTabItem);
  332. function NewTabDef(AName: string; ADefItem: PView; AItems: PTabItem; ANext: PTabDef): PTabDef;
  333. procedure DisposeTabDef(P: PTabDef);
  334. function GetEditorCurWord(Editor: PEditor): string;
  335. procedure InitReservedWords;
  336. procedure DoneReservedWords;
  337. function GetReservedWordCount: integer;
  338. function GetReservedWord(Index: integer): string;
  339. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  340. function GetNextEditorBounds(var Bounds: TRect): boolean;
  341. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  342. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  343. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  344. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  345. {$ifdef VESA}
  346. procedure InitVESAScreenModes;
  347. {$endif}
  348. procedure NoDebugger;
  349. const
  350. SourceCmds : TCommandSet =
  351. ([cmSave,cmSaveAs,cmCompile]);
  352. EditorCmds : TCommandSet =
  353. ([cmFind,cmReplace,cmSearchAgain,cmJumpLine,cmHelpTopicSearch]);
  354. CompileCmds : TCommandSet =
  355. ([cmMake,cmBuild,cmRun]);
  356. CalcClipboard : extended = 0;
  357. OpenFileName : string{$ifdef GABOR}[50]{$endif} = '';
  358. OpenFileLastExt : string[12] = '*.pas';
  359. NewEditorOpened : boolean = false;
  360. var MsgParms : array[1..10] of
  361. record
  362. case byte of
  363. 0 : (Ptr : pointer);
  364. 1 : (Long: longint);
  365. end;
  366. procedure RegisterFPViews;
  367. implementation
  368. uses
  369. {$ifdef GABOR}crt,{$endif}
  370. Video,Strings,Keyboard,Memory,MsgBox,Validate,
  371. Tokens,Version,
  372. {$ifndef NODEBUG}
  373. gdbint,
  374. {$endif NODEBUG}
  375. {$ifdef VESA}Vesa,{$endif}
  376. FPSwitch,FPSymbol,FPDebug,FPVars,FPUtils,FPCompile,FPHelp,
  377. FPTools,FPIDE,FPCodTmp,FPCodCmp;
  378. const
  379. RSourceEditor: TStreamRec = (
  380. ObjType: 1500;
  381. VmtLink: Ofs(TypeOf(TSourceEditor)^);
  382. Load: @TSourceEditor.Load;
  383. Store: @TSourceEditor.Store
  384. );
  385. RSourceWindow: TStreamRec = (
  386. ObjType: 1501;
  387. VmtLink: Ofs(TypeOf(TSourceWindow)^);
  388. Load: @TSourceWindow.Load;
  389. Store: @TSourceWindow.Store
  390. );
  391. RFPHelpViewer: TStreamRec = (
  392. ObjType: 1502;
  393. VmtLink: Ofs(TypeOf(TFPHelpViewer)^);
  394. Load: @TFPHelpViewer.Load;
  395. Store: @TFPHelpViewer.Store
  396. );
  397. RFPHelpWindow: TStreamRec = (
  398. ObjType: 1503;
  399. VmtLink: Ofs(TypeOf(TFPHelpWindow)^);
  400. Load: @TFPHelpWindow.Load;
  401. Store: @TFPHelpWindow.Store
  402. );
  403. RClipboardWindow: TStreamRec = (
  404. ObjType: 1504;
  405. VmtLink: Ofs(TypeOf(TClipboardWindow)^);
  406. Load: @TClipboardWindow.Load;
  407. Store: @TClipboardWindow.Store
  408. );
  409. RMessageListBox: TStreamRec = (
  410. ObjType: 1505;
  411. VmtLink: Ofs(TypeOf(TMessageListBox)^);
  412. Load: @TMessageListBox.Load;
  413. Store: @TMessageListBox.Store
  414. );
  415. RFPDesktop: TStreamRec = (
  416. ObjType: 1506;
  417. VmtLink: Ofs(TypeOf(TFPDesktop)^);
  418. Load: @TFPDesktop.Load;
  419. Store: @TFPDesktop.Store
  420. );
  421. RGDBSourceEditor: TStreamRec = (
  422. ObjType: 1507;
  423. VmtLink: Ofs(TypeOf(TGDBSourceEditor)^);
  424. Load: @TGDBSourceEditor.Load;
  425. Store: @TGDBSourceEditor.Store
  426. );
  427. RGDBWindow: TStreamRec = (
  428. ObjType: 1508;
  429. VmtLink: Ofs(TypeOf(TGDBWindow)^);
  430. Load: @TGDBWindow.Load;
  431. Store: @TGDBWindow.Store
  432. );
  433. RFPASCIIChart: TStreamRec = (
  434. ObjType: 1509;
  435. VmtLink: Ofs(TypeOf(TFPASCIIChart)^);
  436. Load: @TFPASCIIChart.Load;
  437. Store: @TFPASCIIChart.Store
  438. );
  439. RProgramInfoWindow: TStreamRec = (
  440. ObjType: 1510;
  441. VmtLink: Ofs(TypeOf(TProgramInfoWindow)^);
  442. Load: @TProgramInfoWindow.Load;
  443. Store: @TProgramInfoWindow.Store
  444. );
  445. const
  446. NoNameCount : integer = 0;
  447. var
  448. ReservedWords : array[1..ReservedWordMaxLen] of PStringCollection;
  449. {****************************************************************************
  450. TStoreCollection
  451. ****************************************************************************}
  452. function TStoreCollection.Add(const S: string): PString;
  453. var P: PString;
  454. Index: Sw_integer;
  455. begin
  456. if S='' then P:=nil else
  457. if Search(@S,Index) then P:=At(Index) else
  458. begin
  459. P:=NewStr(S);
  460. Insert(P);
  461. end;
  462. Add:=P;
  463. end;
  464. function IsThereAnyEditor: boolean;
  465. function EditorWindow(P: PView): boolean; {$ifndef FPC}far;{$endif}
  466. begin
  467. EditorWindow:=(P^.HelpCtx=hcSourceWindow);
  468. end;
  469. begin
  470. IsThereAnyEditor:=Desktop^.FirstThat(@EditorWindow)<>nil;
  471. end;
  472. function IsThereAnyHelpWindow: boolean;
  473. begin
  474. IsThereAnyHelpWindow:=(HelpWindow<>nil) and (HelpWindow^.GetState(sfVisible));
  475. end;
  476. function IsThereAnyWindow: boolean;
  477. var _Is: boolean;
  478. begin
  479. _Is:=Message(Desktop,evBroadcast,cmSearchWindow,nil)<>nil;
  480. _Is:=_Is or ( (ClipboardWindow<>nil) and ClipboardWindow^.GetState(sfVisible));
  481. IsThereAnyWindow:=_Is;
  482. end;
  483. function FirstEditorWindow: PSourceWindow;
  484. function EditorWindow(P: PView): boolean; {$ifndef FPC}far;{$endif}
  485. begin
  486. EditorWindow:=(P^.HelpCtx=hcSourceWindow);
  487. end;
  488. begin
  489. FirstEditorWindow:=pointer(Desktop^.FirstThat(@EditorWindow));
  490. end;
  491. function EditorWindowFile(const Name : String): PSourceWindow;
  492. function EditorWindow(P: PView): boolean; {$ifndef FPC}far;{$endif}
  493. begin
  494. EditorWindow:=(TypeOf(P^)=TypeOf(TSourceWindow)) and
  495. {$ifdef linux}
  496. (PSourceWindow(P)^.Editor^.FileName=Name);
  497. {$else}
  498. (UpcaseStr(PSourceWindow(P)^.Editor^.FileName)=UpcaseStr(Name));
  499. {$endif def linux}
  500. end;
  501. begin
  502. EditorWindowFile:=pointer(Desktop^.FirstThat(@EditorWindow));
  503. end;
  504. function GetEditorCurWord(Editor: PEditor): string;
  505. var S: string;
  506. PS,PE: byte;
  507. function Trim(S: string): string;
  508. const TrimChars : set of char = [#0,#9,' ',#255];
  509. begin
  510. while (length(S)>0) and (S[1] in TrimChars) do Delete(S,1,1);
  511. while (length(S)>0) and (S[length(S)] in TrimChars) do Delete(S,length(S),1);
  512. Trim:=S;
  513. end;
  514. const AlphaNum : set of char = ['A'..'Z','0'..'9','_'];
  515. begin
  516. with Editor^ do
  517. begin
  518. {$ifdef EDITORS}
  519. S:='';
  520. {$else}
  521. S:=GetLineText(CurPos.Y);
  522. PS:=CurPos.X; while (PS>0) and (Upcase(S[PS]) in AlphaNum) do Dec(PS);
  523. PE:=CurPos.X; while (PE<length(S)) and (Upcase(S[PE+1]) in AlphaNum) do Inc(PE);
  524. S:=Trim(copy(S,PS+1,PE-PS));
  525. {$endif}
  526. end;
  527. GetEditorCurWord:=S;
  528. end;
  529. {*****************************************************************************
  530. Tab
  531. *****************************************************************************}
  532. function NewTabItem(AView: PView; ANext: PTabItem): PTabItem;
  533. var P: PTabItem;
  534. begin
  535. New(P); FillChar(P^,SizeOf(P^),0);
  536. P^.Next:=ANext; P^.View:=AView;
  537. NewTabItem:=P;
  538. end;
  539. procedure DisposeTabItem(P: PTabItem);
  540. begin
  541. if P<>nil then
  542. begin
  543. if P^.View<>nil then Dispose(P^.View, Done);
  544. Dispose(P);
  545. end;
  546. end;
  547. function NewTabDef(AName: string; ADefItem: PView; AItems: PTabItem; ANext: PTabDef): PTabDef;
  548. var P: PTabDef;
  549. x: byte;
  550. begin
  551. New(P);
  552. P^.Next:=ANext; P^.Name:=NewStr(AName); P^.Items:=AItems;
  553. x:=pos('~',AName);
  554. if (x<>0) and (x<length(AName)) then P^.ShortCut:=Upcase(AName[x+1])
  555. else P^.ShortCut:=#0;
  556. P^.DefItem:=ADefItem;
  557. NewTabDef:=P;
  558. end;
  559. procedure DisposeTabDef(P: PTabDef);
  560. var PI,X: PTabItem;
  561. begin
  562. DisposeStr(P^.Name);
  563. PI:=P^.Items;
  564. while PI<>nil do
  565. begin
  566. X:=PI^.Next;
  567. DisposeTabItem(PI);
  568. PI:=X;
  569. end;
  570. Dispose(P);
  571. end;
  572. {*****************************************************************************
  573. Reserved Words
  574. *****************************************************************************}
  575. function GetReservedWordCount: integer;
  576. var
  577. Count,I: integer;
  578. begin
  579. Count:=0;
  580. for I:=ord(Low(tToken)) to ord(High(tToken)) do
  581. with TokenInfo^[TToken(I)] do
  582. if (str<>'') and (str[1] in['A'..'Z']) then
  583. Inc(Count);
  584. GetReservedWordCount:=Count;
  585. end;
  586. function GetReservedWord(Index: integer): string;
  587. var
  588. Count,Idx,I: integer;
  589. S: string;
  590. begin
  591. Idx:=-1;
  592. Count:=-1;
  593. I:=ord(Low(tToken));
  594. while (I<=ord(High(tToken))) and (Idx=-1) do
  595. with TokenInfo^[TToken(I)] do
  596. begin
  597. if (str<>'') and (str[1] in['A'..'Z']) then
  598. begin
  599. Inc(Count);
  600. if Count=Index then
  601. Idx:=I;
  602. end;
  603. Inc(I);
  604. end;
  605. if Idx=-1 then
  606. S:=''
  607. else
  608. S:=TokenInfo^[TToken(Idx)].str;
  609. GetReservedWord:=S;
  610. end;
  611. procedure InitReservedWords;
  612. var WordS: string;
  613. Idx,I: integer;
  614. begin
  615. InitTokens;
  616. for I:=Low(ReservedWords) to High(ReservedWords) do
  617. New(ReservedWords[I], Init(50,10));
  618. for I:=1 to GetReservedWordCount do
  619. begin
  620. WordS:=GetReservedWord(I-1); Idx:=length(WordS);
  621. ReservedWords[Idx]^.Insert(NewStr(WordS));
  622. end;
  623. end;
  624. procedure DoneReservedWords;
  625. var I: integer;
  626. begin
  627. for I:=Low(ReservedWords) to High(ReservedWords) do
  628. if assigned(ReservedWords[I]) then
  629. begin
  630. dispose(ReservedWords[I],done);
  631. ReservedWords[I]:=nil;
  632. end;
  633. DoneTokens;
  634. end;
  635. function IsFPReservedWord(S: string): boolean;
  636. var _Is: boolean;
  637. Idx,Item: sw_integer;
  638. begin
  639. Idx:=length(S); _Is:=false;
  640. if (Low(ReservedWords)<=Idx) and (Idx<=High(ReservedWords)) and
  641. (ReservedWords[Idx]<>nil) and (ReservedWords[Idx]^.Count<>0) then
  642. begin
  643. S:=UpcaseStr(S);
  644. _Is:=ReservedWords[Idx]^.Search(@S,Item);
  645. end;
  646. IsFPReservedWord:=_Is;
  647. end;
  648. {*****************************************************************************
  649. SearchWindow
  650. *****************************************************************************}
  651. function SearchWindowWithNo(No: integer): PWindow;
  652. var P: PSourceWindow;
  653. begin
  654. P:=Message(Desktop,evBroadcast,cmSearchWindow+No,nil);
  655. if pointer(P)=pointer(Desktop) then P:=nil;
  656. SearchWindowWithNo:=P;
  657. end;
  658. function SearchFreeWindowNo: integer;
  659. var No: integer;
  660. begin
  661. No:=1;
  662. while (No<100) and (SearchWindowWithNo(No)<>nil) do
  663. Inc(No);
  664. if No=100 then No:=0;
  665. SearchFreeWindowNo:=No;
  666. end;
  667. {*****************************************************************************
  668. TIntegerLine
  669. *****************************************************************************}
  670. constructor TIntegerLine.Init(var Bounds: TRect; AMin, AMax: longint);
  671. begin
  672. inherited Init(Bounds, Bounds.B.X-Bounds.A.X-1);
  673. Validator:=New(PRangeValidator, Init(AMin, AMax));
  674. end;
  675. {*****************************************************************************
  676. SourceEditor
  677. *****************************************************************************}
  678. {$ifndef EDITORS}
  679. constructor TSourceEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  680. PScrollBar; AIndicator: PIndicator;const AFileName: string);
  681. begin
  682. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,AFileName);
  683. StoreUndo:=true;
  684. end;
  685. function TSourceEditor.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  686. var Count: integer;
  687. begin
  688. case SpecClass of
  689. ssCommentPrefix : Count:=3;
  690. ssCommentSingleLinePrefix : Count:=1;
  691. ssCommentSuffix : Count:=2;
  692. ssStringPrefix : Count:=1;
  693. ssStringSuffix : Count:=1;
  694. ssAsmPrefix : Count:=1;
  695. ssAsmSuffix : Count:=1;
  696. ssDirectivePrefix : Count:=1;
  697. ssDirectiveSuffix : Count:=1;
  698. end;
  699. GetSpecSymbolCount:=Count;
  700. end;
  701. function TSourceEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
  702. var S: string[20];
  703. begin
  704. case SpecClass of
  705. ssCommentPrefix :
  706. case Index of
  707. 0 : S:='{';
  708. 1 : S:='(*';
  709. 2 : S:='//';
  710. end;
  711. ssCommentSingleLinePrefix :
  712. case Index of
  713. 0 : S:='//';
  714. end;
  715. ssCommentSuffix :
  716. case Index of
  717. 0 : S:='}';
  718. 1 : S:='*)';
  719. end;
  720. ssStringPrefix :
  721. S:='''';
  722. ssStringSuffix :
  723. S:='''';
  724. ssAsmPrefix :
  725. S:='asm';
  726. ssAsmSuffix :
  727. S:='end';
  728. ssDirectivePrefix :
  729. S:='{$';
  730. ssDirectiveSuffix :
  731. S:='}';
  732. end;
  733. GetSpecSymbol:=S;
  734. end;
  735. function TSourceEditor.IsReservedWord(const S: string): boolean;
  736. begin
  737. IsReservedWord:=IsFPReservedWord(S);
  738. end;
  739. function TSourceEditor.TranslateCodeTemplate(const Shortcut: string; ALines: PUnsortedStringCollection): boolean;
  740. begin
  741. TranslateCodeTemplate:=FPTranslateCodeTemplate(ShortCut,ALines);
  742. end;
  743. function TSourceEditor.CompleteCodeWord(const WordS: string; var Text: string): boolean;
  744. begin
  745. CompleteCodeWord:=FPCompleteCodeWord(WordS,Text);
  746. end;
  747. procedure TSourceEditor.SetCodeCompleteWord(const S: string);
  748. var R: TRect;
  749. begin
  750. inherited SetCodeCompleteWord(S);
  751. if S='' then
  752. begin
  753. if Assigned(CodeCompleteTip) then Dispose(CodeCompleteTip, Done);
  754. CodeCompleteTip:=nil;
  755. end
  756. else
  757. begin
  758. R.Assign(0,0,20,1);
  759. if Assigned(CodeCompleteTip)=false then
  760. begin
  761. New(CodeCompleteTip, Init(R, S, alCenter));
  762. CodeCompleteTip^.Hide;
  763. Application^.Insert(CodeCompleteTip);
  764. end
  765. else
  766. CodeCompleteTip^.SetText(S);
  767. AlignCodeCompleteTip;
  768. end;
  769. end;
  770. procedure TSourceEditor.AlignCodeCompleteTip;
  771. var P: TPoint;
  772. S: string;
  773. R: TRect;
  774. begin
  775. if Assigned(CodeCompleteTip)=false then Exit;
  776. S:=CodeCompleteTip^.GetText;
  777. P.Y:=CurPos.Y;
  778. { determine the center of current word fragment }
  779. P.X:=CurPos.X-(length(GetCodeCompleteFrag) div 2);
  780. { calculate position for centering the complete word over/below the current }
  781. P.X:=P.X-(length(S) div 2);
  782. P.X:=P.X-Delta.X;
  783. P.Y:=P.Y-Delta.Y;
  784. MakeGlobal(P,P);
  785. if Assigned(CodeCompleteTip^.Owner) then
  786. CodeCompleteTip^.Owner^.MakeLocal(P,P);
  787. { ensure that the tooltip stays in screen }
  788. P.X:=Min(Max(0,P.X),ScreenWidth-length(S)-2-1);
  789. { align it vertically }
  790. if P.Y>round(ScreenHeight*3/4) then
  791. Dec(P.Y)
  792. else
  793. Inc(P.Y);
  794. R.Assign(P.X,P.Y,P.X+1+length(S)+1,P.Y+1);
  795. CodeCompleteTip^.Locate(R);
  796. if CodeCompleteTip^.GetState(sfVisible)=false then
  797. CodeCompleteTip^.Show;
  798. end;
  799. {$endif EDITORS}
  800. procedure TSourceEditor.ModifiedChanged;
  801. begin
  802. inherited ModifiedChanged;
  803. if (@Self<>Clipboard) and Modified then
  804. EditorModified:=true;
  805. end;
  806. function TSourceEditor.GetLocalMenu: PMenu;
  807. var M: PMenu;
  808. begin
  809. M:=NewMenu(
  810. NewItem('Cu~t~','Shift+Del',kbShiftDel,cmCut,hcCut,
  811. NewItem('~C~opy','Ctrl+Ins',kbCtrlIns,cmCopy,hcCopy,
  812. NewItem('~P~aste','Shift+Ins',kbShiftIns,cmPaste,hcPaste,
  813. NewItem('C~l~ear','Ctrl+Del',kbCtrlDel,cmClear,hcClear,
  814. NewLine(
  815. NewItem('Open ~f~ile at cursor','',kbNoKey,cmOpenAtCursor,hcOpenAtCursor,
  816. NewItem('~B~rowse symbol at cursor','',kbNoKey,cmBrowseAtCursor,hcBrowseAtCursor,
  817. NewItem('Topic ~s~earch','Ctrl+F1',kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  818. NewLine(
  819. NewItem('~O~ptions...','',kbNoKey,cmEditorOptions,hcEditorOptions,
  820. nil)))))))))));
  821. GetLocalMenu:=M;
  822. end;
  823. function TSourceEditor.GetCommandTarget: PView;
  824. begin
  825. GetCommandTarget:=@Self;
  826. end;
  827. function TSourceEditor.CreateLocalMenuView(var Bounds: TRect; M: PMenu): PMenuPopup;
  828. var MV: PAdvancedMenuPopup;
  829. begin
  830. New(MV, Init(Bounds,M));
  831. CreateLocalMenuView:=MV;
  832. end;
  833. {$ifdef DebugUndo}
  834. procedure TSourceEditor.DumpUndo;
  835. var
  836. i : sw_integer;
  837. begin
  838. ClearToolMessages;
  839. AddToolCommand('UndoList Dump');
  840. for i:=0 to UndoList^.count-1 do
  841. with UndoList^.At(i)^ do
  842. begin
  843. if is_grouped_action then
  844. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  845. else
  846. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.X)+':'+IntToStr(StartPos.Y)+
  847. ' '+IntToStr(EndPos.X)+':'+IntToStr(EndPos.Y)+' "'+GetStr(Text)+'"',0,0);
  848. end;
  849. if RedoList^.count>0 then
  850. AddToolCommand('RedoList Dump');
  851. for i:=0 to RedoList^.count-1 do
  852. with RedoList^.At(i)^ do
  853. begin
  854. if is_grouped_action then
  855. AddToolMessage('','Group '+ActionString[action]+' '+IntToStr(ActionCount)+' elementary actions',0,0)
  856. else
  857. AddToolMessage('',ActionString[action]+' '+IntToStr(StartPos.X)+':'+IntToStr(StartPos.Y)+
  858. ' '+IntToStr(EndPos.X)+':'+IntToStr(EndPos.Y)+' "'+GetStr(Text)+'"',0,0);
  859. end;
  860. UpdateToolMessages;
  861. if Assigned(MessagesWindow) then
  862. MessagesWindow^.Focus;
  863. end;
  864. procedure TSourceEditor.UndoAll;
  865. begin
  866. While UndoList^.count>0 do
  867. Undo;
  868. end;
  869. procedure TSourceEditor.RedoAll;
  870. begin
  871. While RedoList^.count>0 do
  872. Redo;
  873. end;
  874. {$endif DebugUndo}
  875. procedure TSourceEditor.HandleEvent(var Event: TEvent);
  876. var DontClear: boolean;
  877. S: string;
  878. begin
  879. TranslateMouseClick(@Self,Event);
  880. case Event.What of
  881. evCommand :
  882. begin
  883. DontClear:=false;
  884. case Event.Command of
  885. {$ifdef DebugUndo}
  886. cmDumpUndo : DumpUndo;
  887. cmUndoAll : UndoAll;
  888. cmRedoAll : RedoAll;
  889. {$endif DebugUndo}
  890. cmBrowseAtCursor:
  891. begin
  892. S:=LowerCaseStr(GetEditorCurWord(@Self));
  893. OpenOneSymbolBrowser(S);
  894. end;
  895. cmOpenAtCursor :
  896. begin
  897. S:=LowerCaseStr(GetEditorCurWord(@Self));
  898. OpenFileName:=S+'.pp'+ListSeparator+
  899. S+'.pas'+ListSeparator+
  900. S+'.inc';
  901. Message(Application,evCommand,cmOpen,nil);
  902. end;
  903. cmEditorOptions :
  904. Message(Application,evCommand,cmEditorOptions,@Self);
  905. cmHelp :
  906. Message(@Self,evCommand,cmHelpTopicSearch,@Self);
  907. cmHelpTopicSearch :
  908. HelpTopicSearch(@Self);
  909. else DontClear:=true;
  910. end;
  911. if not DontClear then ClearEvent(Event);
  912. end;
  913. evKeyDown :
  914. begin
  915. DontClear:=false;
  916. case Event.KeyCode of
  917. kbCtrlEnter :
  918. Message(@Self,evCommand,cmOpenAtCursor,nil);
  919. else DontClear:=true;
  920. end;
  921. if not DontClear then ClearEvent(Event);
  922. end;
  923. end;
  924. inherited HandleEvent(Event);
  925. end;
  926. constructor TFPHeapView.Init(var Bounds: TRect);
  927. begin
  928. inherited Init(Bounds);
  929. Options:=Options or gfGrowHiX or gfGrowHiY;
  930. EventMask:=EventMask or evIdle;
  931. GrowMode:=gfGrowAll;
  932. end;
  933. constructor TFPHeapView.InitKb(var Bounds: TRect);
  934. begin
  935. inherited InitKb(Bounds);
  936. Options:=Options or gfGrowHiX or gfGrowHiY;
  937. EventMask:=EventMask or evIdle;
  938. GrowMode:=gfGrowAll;
  939. end;
  940. procedure TFPHeapView.HandleEvent(var Event: TEvent);
  941. begin
  942. case Event.What of
  943. evIdle :
  944. Update;
  945. end;
  946. inherited HandleEvent(Event);
  947. end;
  948. constructor TFPClockView.Init(var Bounds: TRect);
  949. begin
  950. inherited Init(Bounds);
  951. EventMask:=EventMask or evIdle;
  952. end;
  953. procedure TFPClockView.HandleEvent(var Event: TEvent);
  954. begin
  955. case Event.What of
  956. evIdle :
  957. Update;
  958. end;
  959. inherited HandleEvent(Event);
  960. end;
  961. function TFPClockView.GetPalette: PPalette;
  962. const P: string[length(CFPClockView)] = CFPClockView;
  963. begin
  964. GetPalette:=@P;
  965. end;
  966. procedure TFPWindow.SetState(AState: Word; Enable: Boolean);
  967. begin
  968. inherited SetState(AState,Enable);
  969. if AutoNumber then
  970. if (AState and (sfVisible+sfExposed))<>0 then
  971. if GetState(sfVisible+sfExposed) then
  972. begin
  973. if Number=0 then
  974. Number:=SearchFreeWindowNo;
  975. ReDraw;
  976. end
  977. else
  978. Number:=0;
  979. end;
  980. procedure TFPWindow.Update;
  981. begin
  982. ReDraw;
  983. end;
  984. procedure TFPWindow.HandleEvent(var Event: TEvent);
  985. begin
  986. case Event.What of
  987. evBroadcast :
  988. case Event.Command of
  989. cmUpdate :
  990. Update;
  991. cmSearchWindow+1..cmSearchWindow+99 :
  992. if (Event.Command-cmSearchWindow=Number) then
  993. ClearEvent(Event);
  994. end;
  995. end;
  996. inherited HandleEvent(Event);
  997. end;
  998. constructor TFPWindow.Load(var S: TStream);
  999. begin
  1000. inherited Load(S);
  1001. S.Read(AutoNumber,SizeOf(AutoNumber));
  1002. end;
  1003. procedure TFPWindow.Store(var S: TStream);
  1004. begin
  1005. inherited Store(S);
  1006. S.Write(AutoNumber,SizeOf(AutoNumber));
  1007. end;
  1008. function TFPHelpViewer.GetLocalMenu: PMenu;
  1009. var M: PMenu;
  1010. begin
  1011. M:=NewMenu(
  1012. NewItem('C~o~ntents','',kbNoKey,cmHelpContents,hcHelpContents,
  1013. NewItem('~I~ndex','Shift+F1',kbShiftF1,cmHelpIndex,hcHelpIndex,
  1014. NewItem('~T~opic search','Ctrl+F1',kbCtrlF1,cmHelpTopicSearch,hcHelpTopicSearch,
  1015. NewItem('~P~revious topic','Alt+F1',kbAltF1,cmHelpPrevTopic,hcHelpPrevTopic,
  1016. NewLine(
  1017. NewItem('~C~opy','Ctrl+Ins',kbCtrlIns,cmCopy,hcCopy,
  1018. nil)))))));
  1019. GetLocalMenu:=M;
  1020. end;
  1021. function TFPHelpViewer.GetCommandTarget: PView;
  1022. begin
  1023. GetCommandTarget:=Application;
  1024. end;
  1025. constructor TFPHelpWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ASourceFileID: word;
  1026. AContext: THelpCtx; ANumber: Integer);
  1027. begin
  1028. inherited Init(Bounds,ATitle,ASourceFileID,AContext,ANumber);
  1029. HelpCtx:=hcHelpWindow;
  1030. HideOnClose:=true;
  1031. end;
  1032. destructor TFPHelpWindow.Done;
  1033. begin
  1034. if HelpWindow=@Self then
  1035. HelpWindow:=nil;
  1036. Inherited Done;
  1037. end;
  1038. procedure TFPHelpWindow.InitHelpView;
  1039. var R: TRect;
  1040. begin
  1041. GetExtent(R); R.Grow(-1,-1);
  1042. HelpView:=New(PFPHelpViewer, Init(R, HSB, VSB));
  1043. HelpView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1044. end;
  1045. procedure TFPHelpWindow.Show;
  1046. begin
  1047. inherited Show;
  1048. if GetState(sfVisible) and (Number=0) then
  1049. begin
  1050. Number:=SearchFreeWindowNo;
  1051. ReDraw;
  1052. end;
  1053. end;
  1054. procedure TFPHelpWindow.Hide;
  1055. begin
  1056. inherited Hide;
  1057. if GetState(sfVisible)=false then
  1058. Number:=0;
  1059. end;
  1060. procedure TFPHelpWindow.HandleEvent(var Event: TEvent);
  1061. begin
  1062. case Event.What of
  1063. evBroadcast :
  1064. case Event.Command of
  1065. cmUpdate :
  1066. ReDraw;
  1067. cmSearchWindow+1..cmSearchWindow+99 :
  1068. if (Event.Command-cmSearchWindow=Number) then
  1069. ClearEvent(Event);
  1070. end;
  1071. end;
  1072. inherited HandleEvent(Event);
  1073. end;
  1074. function TFPHelpWindow.GetPalette: PPalette;
  1075. const P: string[length(CIDEHelpDialog)] = CIDEHelpDialog;
  1076. begin
  1077. GetPalette:=@P;
  1078. end;
  1079. constructor TFPHelpWindow.Load(var S: TStream);
  1080. begin
  1081. Abstract;
  1082. end;
  1083. procedure TFPHelpWindow.Store(var S: TStream);
  1084. begin
  1085. Abstract;
  1086. end;
  1087. constructor TSourceWindow.Init(var Bounds: TRect; AFileName: string);
  1088. var HSB,VSB: PScrollBar;
  1089. R: TRect;
  1090. LoadFile: boolean;
  1091. begin
  1092. inherited Init(Bounds,AFileName,SearchFreeWindowNo);
  1093. Options:=Options or ofTileAble;
  1094. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1095. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1096. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1097. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1098. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1099. New(Indicator, Init(R));
  1100. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1101. Insert(Indicator);
  1102. GetExtent(R); R.Grow(-1,-1);
  1103. LoadFile:=AFileName<>'';
  1104. if not LoadFile then
  1105. begin SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas'); Inc(NonameCount); end;
  1106. New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
  1107. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1108. if LoadFile then
  1109. if Editor^.LoadFile=false then
  1110. ErrorBox(#3'Error reading file.',nil);
  1111. Insert(Editor);
  1112. UpdateTitle;
  1113. end;
  1114. procedure TSourceWindow.UpdateTitle;
  1115. var Name: string;
  1116. begin
  1117. if Editor^.FileName<>'' then
  1118. begin Name:=SmartPath(Editor^.FileName); SetTitle(Name); end;
  1119. end;
  1120. procedure TSourceWindow.SetTitle(ATitle: string);
  1121. begin
  1122. if Title<>nil then DisposeStr(Title);
  1123. Title:=NewStr(ATitle);
  1124. Frame^.DrawView;
  1125. end;
  1126. procedure TSourceWindow.HandleEvent(var Event: TEvent);
  1127. var DontClear: boolean;
  1128. begin
  1129. case Event.What of
  1130. evBroadcast :
  1131. case Event.Command of
  1132. cmUpdate :
  1133. Update;
  1134. cmUpdateTitle :
  1135. UpdateTitle;
  1136. cmSearchWindow :
  1137. if @Self<>ClipboardWindow then
  1138. ClearEvent(Event);
  1139. end;
  1140. evCommand :
  1141. begin
  1142. DontClear:=false;
  1143. case Event.Command of
  1144. cmSave :
  1145. if Editor^.IsClipboard=false then
  1146. Editor^.Save;
  1147. cmSaveAs :
  1148. if Editor^.IsClipboard=false then
  1149. Editor^.SaveAs;
  1150. else DontClear:=true;
  1151. end;
  1152. if DontClear=false then ClearEvent(Event);
  1153. end;
  1154. end;
  1155. inherited HandleEvent(Event);
  1156. end;
  1157. procedure TSourceWindow.SetState(AState: Word; Enable: Boolean);
  1158. var OldState: word;
  1159. begin
  1160. OldState:=State;
  1161. inherited SetState(AState,Enable);
  1162. if ((AState xor OldState) and sfActive)<>0 then
  1163. UpdateCommands;
  1164. end;
  1165. procedure TSourceWindow.UpdateCommands;
  1166. var Active: boolean;
  1167. begin
  1168. Active:=GetState(sfActive);
  1169. if Editor^.IsClipboard=false then
  1170. begin
  1171. SetCmdState(SourceCmds+CompileCmds,Active);
  1172. SetCmdState(EditorCmds,Active);
  1173. end;
  1174. if Active=false then
  1175. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  1176. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  1177. end;
  1178. procedure TSourceWindow.Update;
  1179. begin
  1180. ReDraw;
  1181. end;
  1182. procedure TSourceWindow.SelectInDebugSession;
  1183. var
  1184. F,PrevCurrent : PView;
  1185. begin
  1186. DeskTop^.Lock;
  1187. PrevCurrent:=Desktop^.Current;
  1188. F:=PrevCurrent;
  1189. While assigned(F) and
  1190. ((F^.HelpCtx = hcGDBWindow) or
  1191. (F^.HelpCtx = hcWatches) or {hcStack,}
  1192. (F^.HelpCtx = hcRegisters)) do
  1193. F:=F^.NextView;
  1194. if F<>@Self then
  1195. Select;
  1196. if PrevCurrent<>F then
  1197. Begin
  1198. Desktop^.InsertBefore(@self,F);
  1199. PrevCurrent^.Select;
  1200. End;
  1201. DeskTop^.Unlock;
  1202. end;
  1203. function TSourceWindow.GetPalette: PPalette;
  1204. const P: string[length(CSourceWindow)] = CSourceWindow;
  1205. begin
  1206. GetPalette:=@P;
  1207. end;
  1208. constructor TSourceWindow.Load(var S: TStream);
  1209. begin
  1210. Title:=S.ReadStr;
  1211. PushStatus('Loading '+GetStr(Title));
  1212. inherited Load(S);
  1213. GetSubViewPtr(S,Indicator);
  1214. GetSubViewPtr(S,Editor);
  1215. PopStatus;
  1216. end;
  1217. procedure TSourceWindow.Store(var S: TStream);
  1218. begin
  1219. S.WriteStr(Title);
  1220. PushStatus('Storing '+GetStr(Title));
  1221. inherited Store(S);
  1222. PutSubViewPtr(S,Indicator);
  1223. PutSubViewPtr(S,Editor);
  1224. PopStatus;
  1225. end;
  1226. destructor TSourceWindow.Done;
  1227. begin
  1228. PushStatus('Closing '+GetStr(Title));
  1229. if not IDEApp.IsClosing then
  1230. Message(Application,evBroadcast,cmSourceWndClosing,@Self);
  1231. inherited Done;
  1232. PopStatus;
  1233. if not IDEApp.IsClosing then
  1234. Message(Application,evBroadcast,cmUpdate,@Self);
  1235. end;
  1236. function TGDBSourceEditor.Valid(Command: Word): Boolean;
  1237. var OK: boolean;
  1238. begin
  1239. OK:=TCodeEditor.Valid(Command);
  1240. { do NOT ask for save !!
  1241. if OK and ((Command=cmClose) or (Command=cmQuit)) then
  1242. if IsClipboard=false then
  1243. OK:=SaveAsk; }
  1244. Valid:=OK;
  1245. end;
  1246. procedure TGDBSourceEditor.AddLine(const S: string);
  1247. begin
  1248. if Silent or (IgnoreStringAtEnd and (S=LastCommand)) then exit;
  1249. inherited AddLine(S);
  1250. LimitsChanged;
  1251. end;
  1252. procedure TGDBSourceEditor.AddErrorLine(const S: string);
  1253. begin
  1254. if Silent then exit;
  1255. inherited AddLine(S);
  1256. { display like breakpoints in red }
  1257. Lines^.At(GetLineCount-1)^.IsBreakpoint:=true;
  1258. LimitsChanged;
  1259. end;
  1260. function TGDBSourceEditor.InsertLine: Sw_integer;
  1261. Var
  1262. S : string;
  1263. begin
  1264. if IsReadOnly then begin InsertLine:=-1; Exit; end;
  1265. if CurPos.Y<GetLineCount then S:=GetDisplayText(CurPos.Y) else S:='';
  1266. s:=Copy(S,1,CurPos.X);
  1267. if assigned(Debugger) then
  1268. if S<>'' then
  1269. begin
  1270. LastCommand:=S;
  1271. { should be true only if we are at the end ! }
  1272. IgnoreStringAtEnd:=(CurPos.Y=GetLineCount-1) and
  1273. (CurPos.X=length(GetDisplayText(GetLineCount-1)));
  1274. Debugger^.Command(S);
  1275. IgnoreStringAtEnd:=false;
  1276. end
  1277. else if AutoRepeat then
  1278. Debugger^.Command(LastCommand);
  1279. InsertLine:=inherited InsertLine;
  1280. end;
  1281. constructor TGDBWindow.Init(var Bounds: TRect);
  1282. var HSB,VSB: PScrollBar;
  1283. R: TRect;
  1284. begin
  1285. inherited Init(Bounds,'GDB window',0);
  1286. Options:=Options or ofTileAble;
  1287. AutoNumber:=true;
  1288. HelpCtx:=hcGDBWindow;
  1289. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1290. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1291. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1292. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1293. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1294. New(Indicator, Init(R));
  1295. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1296. Insert(Indicator);
  1297. GetExtent(R); R.Grow(-1,-1);
  1298. New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
  1299. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1300. if ExistsFile(GDBOutputFile) then
  1301. begin
  1302. if Editor^.LoadFile=false then
  1303. ErrorBox(#3'Error reading file'#13#3+GDBOutputFile,nil);
  1304. end
  1305. else
  1306. { Empty files are buggy !! }
  1307. Editor^.AddLine('');
  1308. Insert(Editor);
  1309. if assigned(Debugger) then
  1310. Debugger^.Command('set width '+IntToStr(Size.X-1));
  1311. Editor^.silent:=false;
  1312. Editor^.AutoRepeat:=true;
  1313. end;
  1314. destructor TGDBWindow.Done;
  1315. begin
  1316. if @Self=GDBWindow then
  1317. GDBWindow:=nil;
  1318. inherited Done;
  1319. end;
  1320. constructor TGDBWindow.Load(var S: TStream);
  1321. begin
  1322. inherited Load(S);
  1323. GetSubViewPtr(S,Indicator);
  1324. GetSubViewPtr(S,Editor);
  1325. end;
  1326. procedure TGDBWindow.Store(var S: TStream);
  1327. begin
  1328. inherited Store(S);
  1329. PutSubViewPtr(S,Indicator);
  1330. PutSubViewPtr(S,Editor);
  1331. end;
  1332. function TGDBWindow.GetPalette: PPalette;
  1333. const P: string[length(CSourceWindow)] = CSourceWindow;
  1334. begin
  1335. GetPalette:=@P;
  1336. end;
  1337. procedure TGDBWindow.WriteOutputText(Buf : pchar);
  1338. begin
  1339. {selected normal color ?}
  1340. WriteText(Buf,false);
  1341. end;
  1342. procedure TGDBWindow.WriteErrorText(Buf : pchar);
  1343. begin
  1344. {selected normal color ?}
  1345. WriteText(Buf,true);
  1346. end;
  1347. procedure TGDBWindow.WriteString(Const S : string);
  1348. begin
  1349. Editor^.AddLine(S);
  1350. end;
  1351. procedure TGDBWindow.WriteErrorString(Const S : string);
  1352. begin
  1353. Editor^.AddErrorLine(S);
  1354. end;
  1355. procedure TGDBWindow.WriteText(Buf : pchar;IsError : boolean);
  1356. var p,pe : pchar;
  1357. s : string;
  1358. begin
  1359. p:=buf;
  1360. DeskTop^.Lock;
  1361. While assigned(p) do
  1362. begin
  1363. pe:=strscan(p,#10);
  1364. if pe<>nil then
  1365. pe^:=#0;
  1366. s:=strpas(p);
  1367. If IsError then
  1368. Editor^.AddErrorLine(S)
  1369. else
  1370. Editor^.AddLine(S);
  1371. { restore for dispose }
  1372. if pe<>nil then
  1373. pe^:=#10;
  1374. if pe=nil then
  1375. p:=nil
  1376. else
  1377. begin
  1378. p:=pe;
  1379. inc(p);
  1380. end;
  1381. end;
  1382. DeskTop^.Unlock;
  1383. Editor^.Draw;
  1384. end;
  1385. constructor TClipboardWindow.Init;
  1386. var R: TRect;
  1387. HSB,VSB: PScrollBar;
  1388. begin
  1389. Desktop^.GetExtent(R);
  1390. inherited Init(R, '');
  1391. SetTitle('Clipboard');
  1392. HelpCtx:=hcClipboardWindow;
  1393. Number:=wnNoNumber;
  1394. AutoNumber:=true;
  1395. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1396. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1397. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1398. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1399. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1400. New(Indicator, Init(R));
  1401. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1402. Insert(Indicator);
  1403. GetExtent(R); R.Grow(-1,-1);
  1404. New(Editor, Init(R, HSB, VSB, Indicator, ''));
  1405. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1406. Insert(Editor);
  1407. Hide;
  1408. Clipboard:=Editor;
  1409. end;
  1410. procedure TClipboardWindow.Close;
  1411. begin
  1412. Hide;
  1413. end;
  1414. constructor TClipboardWindow.Load(var S: TStream);
  1415. begin
  1416. inherited Load(S);
  1417. Clipboard:=Editor;
  1418. end;
  1419. procedure TClipboardWindow.Store(var S: TStream);
  1420. begin
  1421. inherited Store(S);
  1422. end;
  1423. destructor TClipboardWindow.Done;
  1424. begin
  1425. inherited Done;
  1426. Clipboard:=nil;
  1427. ClipboardWindow:=nil;
  1428. end;
  1429. constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  1430. begin
  1431. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  1432. GrowMode:=gfGrowHiX+gfGrowHiY;
  1433. New(ModuleNames, Init(50,100));
  1434. NoSelection:=true;
  1435. end;
  1436. function TMessageListBox.GetLocalMenu: PMenu;
  1437. var M: PMenu;
  1438. begin
  1439. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  1440. M:=NewMenu(
  1441. NewItem('~C~lear','',kbNoKey,cmMsgClear,hcMsgClear,
  1442. NewLine(
  1443. NewItem('~G~oto source','',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  1444. NewItem('~T~rack source','',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
  1445. nil)))));
  1446. GetLocalMenu:=M;
  1447. end;
  1448. procedure TMessageListBox.HandleEvent(var Event: TEvent);
  1449. var DontClear: boolean;
  1450. begin
  1451. case Event.What of
  1452. evKeyDown :
  1453. begin
  1454. DontClear:=false;
  1455. case Event.KeyCode of
  1456. kbEnter :
  1457. Message(@Self,evCommand,cmMsgGotoSource,nil);
  1458. else
  1459. DontClear:=true;
  1460. end;
  1461. if not DontClear then
  1462. ClearEvent(Event);
  1463. end;
  1464. evBroadcast :
  1465. case Event.Command of
  1466. cmListItemSelected :
  1467. if Event.InfoPtr=@Self then
  1468. Message(@Self,evCommand,cmMsgTrackSource,nil);
  1469. end;
  1470. evCommand :
  1471. begin
  1472. DontClear:=false;
  1473. case Event.Command of
  1474. cmMsgGotoSource :
  1475. if Range>0 then
  1476. GotoSource;
  1477. cmMsgTrackSource :
  1478. if Range>0 then
  1479. TrackSource;
  1480. cmMsgClear :
  1481. Clear;
  1482. else
  1483. DontClear:=true;
  1484. end;
  1485. if not DontClear then
  1486. ClearEvent(Event);
  1487. end;
  1488. end;
  1489. inherited HandleEvent(Event);
  1490. end;
  1491. procedure TMessageListBox.AddItem(P: PMessageItem);
  1492. var W : integer;
  1493. begin
  1494. if List=nil then New(List, Init(500,500));
  1495. W:=length(P^.GetText(255));
  1496. if W>MaxWidth then
  1497. begin
  1498. MaxWidth:=W;
  1499. if HScrollBar<>nil then
  1500. HScrollBar^.SetRange(0,MaxWidth);
  1501. end;
  1502. List^.Insert(P);
  1503. SetRange(List^.Count);
  1504. if Focused=List^.Count-1-1 then
  1505. FocusItem(List^.Count-1);
  1506. DrawView;
  1507. end;
  1508. function TMessageListBox.AddModuleName(const Name: string): PString;
  1509. var P: PString;
  1510. begin
  1511. if ModuleNames<>nil then
  1512. P:=ModuleNames^.Add(Name)
  1513. else
  1514. P:=nil;
  1515. AddModuleName:=P;
  1516. end;
  1517. function TMessageListBox.GetText(Item,MaxLen: Sw_Integer): String;
  1518. var P: PMessageItem;
  1519. S: string;
  1520. begin
  1521. P:=List^.At(Item);
  1522. S:=P^.GetText(MaxLen);
  1523. GetText:=copy(S,1,MaxLen);
  1524. end;
  1525. procedure TMessageListBox.Clear;
  1526. begin
  1527. if assigned(List) then
  1528. Dispose(List, Done);
  1529. List:=nil;
  1530. MaxWidth:=0;
  1531. if assigned(ModuleNames) then
  1532. ModuleNames^.FreeAll;
  1533. SetRange(0); DrawView;
  1534. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1535. end;
  1536. procedure TMessageListBox.TrackSource;
  1537. var W: PSourceWindow;
  1538. P: PMessageItem;
  1539. R: TRect;
  1540. Row,Col: sw_integer;
  1541. begin
  1542. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1543. if Range=0 then Exit;
  1544. P:=List^.At(Focused);
  1545. if P^.Row=0 then Exit;
  1546. Desktop^.Lock;
  1547. GetNextEditorBounds(R);
  1548. {$ifdef OLDCOMP}
  1549. if Assigned(Owner) and (Owner=pointer(ProgramInfoWindow)) then
  1550. {$endif}
  1551. R.B.Y:=Owner^.Origin.Y;
  1552. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  1553. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  1554. W:=EditorWindowFile(P^.GetModuleName);
  1555. if assigned(W) then
  1556. begin
  1557. W^.GetExtent(R);
  1558. {$ifdef OLDCOMP}
  1559. if Assigned(Owner) and (Owner=pointer(ProgramInfoWindow)) then
  1560. {$endif}
  1561. R.B.Y:=Owner^.Origin.Y;
  1562. W^.ChangeBounds(R);
  1563. W^.Editor^.SetCurPtr(Col,Row);
  1564. end
  1565. else
  1566. W:=TryToOpenFile(@R,P^.GetModuleName,Col,Row,true);
  1567. if W<>nil then
  1568. begin
  1569. W^.Select;
  1570. W^.Editor^.TrackCursor(true);
  1571. W^.Editor^.SetHighlightRow(Row);
  1572. end;
  1573. if Assigned(Owner) then
  1574. Owner^.Select;
  1575. Desktop^.UnLock;
  1576. end;
  1577. procedure TMessageListBox.GotoSource;
  1578. var W: PSourceWindow;
  1579. P: PMessageItem;
  1580. R:TRect;
  1581. Row,Col: sw_integer;
  1582. begin
  1583. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1584. if Range=0 then Exit;
  1585. P:=List^.At(Focused);
  1586. if P^.Row=0 then Exit;
  1587. Desktop^.Lock;
  1588. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  1589. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  1590. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  1591. if assigned(W) then
  1592. begin
  1593. { Message(Owner,evCommand,cmClose,nil);
  1594. This calls close on StackWindow
  1595. rendering P invalid
  1596. so postpone it PM }
  1597. W^.GetExtent(R);
  1598. if (P^.TClass<>0) then
  1599. W^.Editor^.SetErrorMessage(P^.GetText(R.B.X-R.A.X));
  1600. W^.Select;
  1601. Message(Owner,evCommand,cmClose,nil);
  1602. end;
  1603. Desktop^.UnLock;
  1604. end;
  1605. procedure TMessageListBox.Draw;
  1606. var
  1607. I, J, Item: Sw_Integer;
  1608. NormalColor, SelectedColor, FocusedColor, Color: Word;
  1609. ColWidth, CurCol, Indent: Integer;
  1610. B: TDrawBuffer;
  1611. Text: String;
  1612. SCOff: Byte;
  1613. TC: byte;
  1614. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  1615. begin
  1616. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  1617. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  1618. begin
  1619. NormalColor := GetColor(1);
  1620. FocusedColor := GetColor(3);
  1621. SelectedColor := GetColor(4);
  1622. end else
  1623. begin
  1624. NormalColor := GetColor(2);
  1625. SelectedColor := GetColor(4);
  1626. end;
  1627. if Transparent then
  1628. begin MT(NormalColor); MT(SelectedColor); end;
  1629. if NoSelection then
  1630. SelectedColor:=NormalColor;
  1631. if HScrollBar <> nil then Indent := HScrollBar^.Value
  1632. else Indent := 0;
  1633. ColWidth := Size.X div NumCols + 1;
  1634. for I := 0 to Size.Y - 1 do
  1635. begin
  1636. for J := 0 to NumCols-1 do
  1637. begin
  1638. Item := J*Size.Y + I + TopItem;
  1639. CurCol := J*ColWidth;
  1640. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  1641. (Focused = Item) and (Range > 0) then
  1642. begin
  1643. Color := FocusedColor;
  1644. SetCursor(CurCol+1,I);
  1645. SCOff := 0;
  1646. end
  1647. else if (Item < Range) and IsSelected(Item) then
  1648. begin
  1649. Color := SelectedColor;
  1650. SCOff := 2;
  1651. end
  1652. else
  1653. begin
  1654. Color := NormalColor;
  1655. SCOff := 4;
  1656. end;
  1657. MoveChar(B[CurCol], ' ', Color, ColWidth);
  1658. if Item < Range then
  1659. begin
  1660. Text := GetText(Item, ColWidth + Indent);
  1661. Text := Copy(Text,Indent,ColWidth);
  1662. MoveStr(B[CurCol+1], Text, Color);
  1663. if ShowMarkers then
  1664. begin
  1665. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  1666. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  1667. end;
  1668. end;
  1669. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  1670. end;
  1671. WriteLine(0, I, Size.X, 1, B);
  1672. end;
  1673. end;
  1674. constructor TMessageListBox.Load(var S: TStream);
  1675. begin
  1676. inherited Load(S);
  1677. New(ModuleNames, Init(50,100));
  1678. NoSelection:=true;
  1679. end;
  1680. procedure TMessageListBox.Store(var S: TStream);
  1681. var OL: PCollection;
  1682. ORV: sw_integer;
  1683. begin
  1684. OL:=List; ORV:=Range;
  1685. New(List, Init(1,1)); Range:=0;
  1686. inherited Store(S);
  1687. Dispose(List, Done);
  1688. List:=OL; Range:=ORV;
  1689. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  1690. collection? Pasting here a modified version of TListBox.Store+
  1691. TAdvancedListBox.Store isn't a better solution, since by eventually
  1692. changing the obj-hierarchy you'll always have to modify this, too - BG }
  1693. end;
  1694. destructor TMessageListBox.Done;
  1695. begin
  1696. inherited Done;
  1697. if List<>nil then Dispose(List, Done);
  1698. if ModuleNames<>nil then Dispose(ModuleNames, Done);
  1699. end;
  1700. constructor TMessageItem.Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  1701. begin
  1702. inherited Init;
  1703. TClass:=AClass;
  1704. Text:=NewStr(AText);
  1705. Module:=AModule;
  1706. Row:=ARow; Col:=ACol;
  1707. end;
  1708. function TMessageItem.GetText(MaxLen: Sw_integer): string;
  1709. var S: string;
  1710. begin
  1711. if Text=nil then S:='' else S:=Text^;
  1712. if (Module<>nil) then
  1713. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+S;
  1714. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  1715. GetText:=S;
  1716. end;
  1717. procedure TMessageItem.Selected;
  1718. begin
  1719. end;
  1720. function TMessageItem.GetModuleName: string;
  1721. begin
  1722. GetModuleName:=GetStr(Module);
  1723. end;
  1724. destructor TMessageItem.Done;
  1725. begin
  1726. inherited Done;
  1727. if Text<>nil then DisposeStr(Text);
  1728. { if Module<>nil then DisposeStr(Module);}
  1729. end;
  1730. {$ifdef OLDCOMP}
  1731. function TCompilerMessage.GetText(MaxLen: Integer): String;
  1732. var ClassS: string[20];
  1733. S: string;
  1734. begin
  1735. if TClass=
  1736. V_Fatal then ClassS:='Fatal' else if TClass =
  1737. V_Error then ClassS:='Error' else if TClass =
  1738. V_Normal then ClassS:='' else if TClass =
  1739. V_Warning then ClassS:='Warning' else if TClass =
  1740. V_Note then ClassS:='Note' else if TClass =
  1741. V_Hint then ClassS:='Hint' else if TClass =
  1742. V_Macro then ClassS:='Macro' else if TClass =
  1743. V_Procedure then ClassS:='Procedure' else if TClass =
  1744. V_Conditional then ClassS:='Conditional' else if TClass =
  1745. V_Info then ClassS:='Info' else if TClass =
  1746. V_Status then ClassS:='Status' else if TClass =
  1747. V_Used then ClassS:='Used' else if TClass =
  1748. V_Tried then ClassS:='Tried' else if TClass =
  1749. V_Debug then ClassS:='Debug'
  1750. else
  1751. ClassS:='???';
  1752. if ClassS<>'' then
  1753. ClassS:=RExpand(ClassS,0)+': ';
  1754. S:=ClassS;
  1755. if (Module<>nil) {and (ID<>0)} then
  1756. S:=S+NameAndExtOf(Module^)+'('+IntToStr(Row)+') ';
  1757. if Text<>nil then S:=S+Text^;
  1758. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  1759. GetText:=S;
  1760. end;
  1761. {$endif}
  1762. constructor TProgramInfoWindow.Init;
  1763. var R,R2: TRect;
  1764. HSB,VSB: PScrollBar;
  1765. ST: PStaticText;
  1766. C: word;
  1767. const White = 15;
  1768. begin
  1769. Desktop^.GetExtent(R); R.A.Y:=R.B.Y-13;
  1770. inherited Init(R, 'Program Information', wnNoNumber);
  1771. HelpCtx:=hcInfoWindow;
  1772. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+3;
  1773. C:=((Desktop^.GetColor(32+6) and $f0) or White)*256+Desktop^.GetColor(32+6);
  1774. New(InfoST, Init(R,'', C)); InfoST^.GrowMode:=gfGrowHiX;
  1775. InfoST^.DontWrap:=true;
  1776. Insert(InfoST);
  1777. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,3); R.B.Y:=R.A.Y+1;
  1778. New(ST, Init(R, CharStr('Ä', MaxViewWidth))); ST^.GrowMode:=gfGrowHiX; Insert(ST);
  1779. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,4);
  1780. R2.Copy(R); Inc(R2.B.Y); R2.A.Y:=R2.B.Y-1;
  1781. New(HSB, Init(R2)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX; Insert(HSB);
  1782. R2.Copy(R); Inc(R2.B.X); R2.A.X:=R2.B.X-1;
  1783. New(VSB, Init(R2)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1784. New(LogLB, Init(R,HSB,VSB));
  1785. LogLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1786. LogLB^.Transparent:=true;
  1787. Insert(LogLB);
  1788. Update;
  1789. end;
  1790. constructor TProgramInfoWindow.Load(var S : TStream);
  1791. begin
  1792. inherited Load(S);
  1793. GetSubViewPtr(S,InfoST);
  1794. GetSubViewPtr(S,LogLB);
  1795. end;
  1796. procedure TProgramInfoWindow.Store(var S : TStream);
  1797. begin
  1798. inherited Store(S);
  1799. PutSubViewPtr(S,InfoST);
  1800. PutSubViewPtr(S,LogLB);
  1801. end;
  1802. procedure TProgramInfoWindow.AddMessage(AClass: longint; Msg, Module: string; Line, Column: longint);
  1803. begin
  1804. if AClass>=V_Info then Line:=0;
  1805. LogLB^.AddItem(New(PCompilerMessage, Init(AClass, Msg, LogLB^.AddModuleName(Module), Line, Column)));
  1806. end;
  1807. procedure TProgramInfoWindow.ClearMessages;
  1808. begin
  1809. LogLB^.Clear;
  1810. ReDraw;
  1811. end;
  1812. procedure TProgramInfoWindow.SizeLimits(var Min, Max: TPoint);
  1813. begin
  1814. inherited SizeLimits(Min,Max);
  1815. Min.X:=30; Min.Y:=9;
  1816. end;
  1817. procedure TProgramInfoWindow.Close;
  1818. begin
  1819. Hide;
  1820. end;
  1821. procedure TProgramInfoWindow.HandleEvent(var Event: TEvent);
  1822. begin
  1823. case Event.What of
  1824. evBroadcast :
  1825. case Event.Command of
  1826. cmUpdate :
  1827. Update;
  1828. end;
  1829. end;
  1830. inherited HandleEvent(Event);
  1831. end;
  1832. procedure TProgramInfoWindow.Update;
  1833. begin
  1834. InfoST^.SetText(
  1835. {#13+ }
  1836. ' Current module : '+MainFile+#13+
  1837. ' Last exit code : '+IntToStr(LastExitCode)+#13+
  1838. ' Available memory : '+IntToStrL(MemAvail div 1024,5)+'K'+#13+
  1839. ''
  1840. );
  1841. end;
  1842. destructor TProgramInfoWindow.Done;
  1843. begin
  1844. inherited Done;
  1845. ProgramInfoWindow:=nil;
  1846. end;
  1847. constructor TTab.Init(var Bounds: TRect; ATabDef: PTabDef);
  1848. begin
  1849. inherited Init(Bounds);
  1850. Options:=Options or ofSelectable or ofFirstClick or ofPreProcess or ofPostProcess;
  1851. GrowMode:=gfGrowHiX+gfGrowHiY+gfGrowRel;
  1852. TabDefs:=ATabDef;
  1853. ActiveDef:=-1;
  1854. SelectTab(0);
  1855. ReDraw;
  1856. end;
  1857. function TTab.TabCount: integer;
  1858. var i: integer;
  1859. P: PTabDef;
  1860. begin
  1861. I:=0; P:=TabDefs;
  1862. while (P<>nil) do
  1863. begin
  1864. Inc(I);
  1865. P:=P^.Next;
  1866. end;
  1867. TabCount:=I;
  1868. end;
  1869. function TTab.AtTab(Index: integer): PTabDef;
  1870. var i: integer;
  1871. P: PTabDef;
  1872. begin
  1873. i:=0; P:=TabDefs;
  1874. while (I<Index) do
  1875. begin
  1876. if P=nil then RunError($AA);
  1877. P:=P^.Next;
  1878. Inc(i);
  1879. end;
  1880. AtTab:=P;
  1881. end;
  1882. procedure TTab.SelectTab(Index: integer);
  1883. var P: PTabItem;
  1884. V: PView;
  1885. begin
  1886. if ActiveDef<>Index then
  1887. begin
  1888. if Owner<>nil then Owner^.Lock;
  1889. Lock;
  1890. { --- Update --- }
  1891. if TabDefs<>nil then
  1892. begin
  1893. DefCount:=1;
  1894. while AtTab(DefCount-1)^.Next<>nil do Inc(DefCount);
  1895. end
  1896. else DefCount:=0;
  1897. if ActiveDef<>-1 then
  1898. begin
  1899. P:=AtTab(ActiveDef)^.Items;
  1900. while P<>nil do
  1901. begin
  1902. if P^.View<>nil then Delete(P^.View);
  1903. P:=P^.Next;
  1904. end;
  1905. end;
  1906. ActiveDef:=Index;
  1907. P:=AtTab(ActiveDef)^.Items;
  1908. while P<>nil do
  1909. begin
  1910. if P^.View<>nil then Insert(P^.View);
  1911. P:=P^.Next;
  1912. end;
  1913. V:=AtTab(ActiveDef)^.DefItem;
  1914. if V<>nil then V^.Select;
  1915. ReDraw;
  1916. { --- Update --- }
  1917. UnLock;
  1918. if Owner<>nil then Owner^.UnLock;
  1919. DrawView;
  1920. end;
  1921. end;
  1922. procedure TTab.ChangeBounds(var Bounds: TRect);
  1923. var D: TPoint;
  1924. procedure DoCalcChange(P: PView); {$ifndef FPC}far;{$endif}
  1925. var
  1926. R: TRect;
  1927. begin
  1928. if P^.Owner=nil then Exit; { it think this is a bug in TV }
  1929. P^.CalcBounds(R, D);
  1930. P^.ChangeBounds(R);
  1931. end;
  1932. var
  1933. P: PTabItem;
  1934. I: integer;
  1935. begin
  1936. D.X := Bounds.B.X - Bounds.A.X - Size.X;
  1937. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y;
  1938. inherited ChangeBounds(Bounds);
  1939. for I:=0 to TabCount-1 do
  1940. if I<>ActiveDef then
  1941. begin
  1942. P:=AtTab(I)^.Items;
  1943. while P<>nil do
  1944. begin
  1945. if P^.View<>nil then DoCalcChange(P^.View);
  1946. P:=P^.Next;
  1947. end;
  1948. end;
  1949. end;
  1950. procedure TTab.SelectNextTab(Forwards: boolean);
  1951. var Index: integer;
  1952. begin
  1953. Index:=ActiveDef;
  1954. if Index=-1 then Exit;
  1955. if Forwards then Inc(Index) else Dec(Index);
  1956. if Index<0 then Index:=DefCount-1 else
  1957. if Index>DefCount-1 then Index:=0;
  1958. SelectTab(Index);
  1959. end;
  1960. procedure TTab.HandleEvent(var Event: TEvent);
  1961. var Index : integer;
  1962. I : integer;
  1963. X : integer;
  1964. Len : byte;
  1965. P : TPoint;
  1966. V : PView;
  1967. CallOrig: boolean;
  1968. LastV : PView;
  1969. FirstV: PView;
  1970. function FirstSelectable: PView;
  1971. var
  1972. FV : PView;
  1973. begin
  1974. FV := First;
  1975. while (FV<>nil) and ((FV^.Options and ofSelectable)=0) and (FV<>Last) do
  1976. FV:=FV^.Next;
  1977. if FV<>nil then
  1978. if (FV^.Options and ofSelectable)=0 then FV:=nil;
  1979. FirstSelectable:=FV;
  1980. end;
  1981. function LastSelectable: PView;
  1982. var
  1983. LV : PView;
  1984. begin
  1985. LV := Last;
  1986. while (LV<>nil) and ((LV^.Options and ofSelectable)=0) and (LV<>First) do
  1987. LV:=LV^.Prev;
  1988. if LV<>nil then
  1989. if (LV^.Options and ofSelectable)=0 then LV:=nil;
  1990. LastSelectable:=LV;
  1991. end;
  1992. begin
  1993. if (Event.What and evMouseDown)<>0 then
  1994. begin
  1995. MakeLocal(Event.Where,P);
  1996. if P.Y<3 then
  1997. begin
  1998. Index:=-1; X:=1;
  1999. for i:=0 to DefCount-1 do
  2000. begin
  2001. Len:=CStrLen(AtTab(i)^.Name^);
  2002. if (P.X>=X) and (P.X<=X+Len+1) then Index:=i;
  2003. X:=X+Len+3;
  2004. end;
  2005. if Index<>-1 then
  2006. SelectTab(Index);
  2007. end;
  2008. end;
  2009. if Event.What=evKeyDown then
  2010. begin
  2011. Index:=-1;
  2012. case Event.KeyCode of
  2013. kbCtrlTab :
  2014. begin
  2015. SelectNextTab((Event.KeyShift and kbShift)=0);
  2016. ClearEvent(Event);
  2017. end;
  2018. kbTab,kbShiftTab :
  2019. if GetState(sfSelected) then
  2020. begin
  2021. if Current<>nil then
  2022. begin
  2023. LastV:=LastSelectable; FirstV:=FirstSelectable;
  2024. if ((Current=LastV) or (Current=PLabel(LastV)^.Link)) and (Event.KeyCode=kbShiftTab) then
  2025. begin
  2026. if Owner<>nil then Owner^.SelectNext(true);
  2027. end else
  2028. if ((Current=FirstV) or (Current=PLabel(FirstV)^.Link)) and (Event.KeyCode=kbTab) then
  2029. begin
  2030. Lock;
  2031. if Owner<>nil then Owner^.SelectNext(false);
  2032. UnLock;
  2033. end else
  2034. SelectNext(Event.KeyCode=kbShiftTab);
  2035. ClearEvent(Event);
  2036. end;
  2037. end;
  2038. else
  2039. for I:=0 to DefCount-1 do
  2040. begin
  2041. if Upcase(GetAltChar(Event.KeyCode))=AtTab(I)^.ShortCut
  2042. then begin
  2043. Index:=I;
  2044. ClearEvent(Event);
  2045. Break;
  2046. end;
  2047. end;
  2048. end;
  2049. if Index<>-1 then
  2050. begin
  2051. Select;
  2052. SelectTab(Index);
  2053. V:=AtTab(ActiveDef)^.DefItem;
  2054. if V<>nil then V^.Focus;
  2055. end;
  2056. end;
  2057. CallOrig:=true;
  2058. if Event.What=evKeyDown then
  2059. begin
  2060. if ((Owner<>nil) and (Owner^.Phase=phPostProcess) and (GetAltChar(Event.KeyCode)<>#0)) or GetState(sfFocused)
  2061. then
  2062. else CallOrig:=false;
  2063. end;
  2064. if CallOrig then inherited HandleEvent(Event);
  2065. end;
  2066. function TTab.GetPalette: PPalette;
  2067. begin
  2068. GetPalette:=nil;
  2069. end;
  2070. procedure TTab.Draw;
  2071. var B : TDrawBuffer;
  2072. i : integer;
  2073. C1,C2,C3,C : word;
  2074. HeaderLen : integer;
  2075. X,X2 : integer;
  2076. Name : PString;
  2077. ActiveKPos : integer;
  2078. ActiveVPos : integer;
  2079. FC : char;
  2080. ClipR : TRect;
  2081. procedure SWriteBuf(X,Y,W,H: integer; var Buf);
  2082. var i: integer;
  2083. begin
  2084. if Y+H>Size.Y then H:=Size.Y-Y;
  2085. if X+W>Size.X then W:=Size.X-X;
  2086. if Buffer=nil then WriteBuf(X,Y,W,H,Buf)
  2087. else for i:=1 to H do
  2088. Move(Buf,Buffer^[X+(Y+i-1)*Size.X],W*2);
  2089. end;
  2090. procedure ClearBuf;
  2091. begin
  2092. MoveChar(B,' ',C1,Size.X);
  2093. end;
  2094. begin
  2095. if InDraw then Exit;
  2096. InDraw:=true;
  2097. { - Start of TGroup.Draw - }
  2098. if Buffer = nil then
  2099. begin
  2100. GetBuffer;
  2101. end;
  2102. { - Start of TGroup.Draw - }
  2103. C1:=GetColor(1); C2:=(GetColor(7) and $f0 or $08)+GetColor(9)*256; C3:=GetColor(8)+GetColor({9}8)*256;
  2104. HeaderLen:=0; for i:=0 to DefCount-1 do HeaderLen:=HeaderLen+CStrLen(AtTab(i)^.Name^)+3; Dec(HeaderLen);
  2105. if HeaderLen>Size.X-2 then HeaderLen:=Size.X-2;
  2106. { --- 1. sor --- }
  2107. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[HeaderLen+1],'³',C1,1);
  2108. X:=1;
  2109. for i:=0 to DefCount-1 do
  2110. begin
  2111. Name:=AtTab(i)^.Name; X2:=CStrLen(Name^);
  2112. if i=ActiveDef
  2113. then begin
  2114. ActiveKPos:=X-1;
  2115. ActiveVPos:=X+X2+2;
  2116. if GetState(sfFocused) then C:=C3 else C:=C2;
  2117. end
  2118. else C:=C2;
  2119. MoveCStr(B[X],' '+Name^+' ',C); X:=X+X2+3;
  2120. MoveChar(B[X-1],'³',C1,1);
  2121. end;
  2122. SWriteBuf(0,1,Size.X,1,B);
  2123. { --- 0. sor --- }
  2124. ClearBuf; MoveChar(B[0],'Ú',C1,1);
  2125. X:=1;
  2126. for i:=0 to DefCount-1 do
  2127. begin
  2128. if I<ActiveDef then FC:='Ú'
  2129. else FC:='¿';
  2130. X2:=CStrLen(AtTab(i)^.Name^)+2;
  2131. MoveChar(B[X+X2],{'Â'}FC,C1,1);
  2132. if i=DefCount-1 then X2:=X2+1;
  2133. if X2>0 then
  2134. MoveChar(B[X],'Ä',C1,X2);
  2135. X:=X+X2+1;
  2136. end;
  2137. MoveChar(B[HeaderLen+1],'¿',C1,1);
  2138. MoveChar(B[ActiveKPos],'Ú',C1,1); MoveChar(B[ActiveVPos],'¿',C1,1);
  2139. SWriteBuf(0,0,Size.X,1,B);
  2140. { --- 2. sor --- }
  2141. MoveChar(B[1],'Ä',C1,Max(HeaderLen,0)); MoveChar(B[HeaderLen+2],'Ä',C1,Max(Size.X-HeaderLen-3,0));
  2142. MoveChar(B[Size.X-1],'¿',C1,1);
  2143. MoveChar(B[ActiveKPos],'Ù',C1,1);
  2144. if ActiveDef=0 then MoveChar(B[0],'³',C1,1)
  2145. else MoveChar(B[0],{'Ã'}'Ú',C1,1);
  2146. MoveChar(B[HeaderLen+1],'Ä'{'Á'},C1,1); MoveChar(B[ActiveVPos],'À',C1,1);
  2147. MoveChar(B[ActiveKPos+1],' ',C1,Max(ActiveVPos-ActiveKPos-1,0));
  2148. SWriteBuf(0,2,Size.X,1,B);
  2149. { --- marad‚k sor --- }
  2150. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[Size.X-1],'³',C1,1);
  2151. SWriteBuf(0,3,Size.X,Size.Y-4,B);
  2152. { --- Size.X . sor --- }
  2153. MoveChar(B[0],'À',C1,1); MoveChar(B[1],'Ä',C1,Max(Size.X-2,0)); MoveChar(B[Size.X-1],'Ù',C1,1);
  2154. SWriteBuf(0,Size.Y-1,Size.X,1,B);
  2155. { - End of TGroup.Draw - }
  2156. if Buffer <> nil then
  2157. begin
  2158. Lock;
  2159. Redraw;
  2160. UnLock;
  2161. end;
  2162. if Buffer <> nil then WriteBuf(0, 0, Size.X, Size.Y, Buffer^) else
  2163. begin
  2164. GetClipRect(ClipR);
  2165. Redraw;
  2166. GetExtent(ClipR);
  2167. end;
  2168. { - End of TGroup.Draw - }
  2169. InDraw:=false;
  2170. end;
  2171. function TTab.Valid(Command: Word): Boolean;
  2172. var PT : PTabDef;
  2173. PI : PTabItem;
  2174. OK : boolean;
  2175. begin
  2176. OK:=true;
  2177. PT:=TabDefs;
  2178. while (PT<>nil) and (OK=true) do
  2179. begin
  2180. PI:=PT^.Items;
  2181. while (PI<>nil) and (OK=true) do
  2182. begin
  2183. if PI^.View<>nil then OK:=OK and PI^.View^.Valid(Command);
  2184. PI:=PI^.Next;
  2185. end;
  2186. PT:=PT^.Next;
  2187. end;
  2188. Valid:=OK;
  2189. end;
  2190. procedure TTab.SetState(AState: Word; Enable: Boolean);
  2191. begin
  2192. inherited SetState(AState,Enable);
  2193. if (AState and sfFocused)<>0 then DrawView;
  2194. end;
  2195. destructor TTab.Done;
  2196. var P,X: PTabDef;
  2197. procedure DeleteViews(P: PView); {$ifndef FPC}far;{$endif}
  2198. begin
  2199. if P<>nil then Delete(P);
  2200. end;
  2201. begin
  2202. ForEach(@DeleteViews);
  2203. inherited Done;
  2204. P:=TabDefs;
  2205. while P<>nil do
  2206. begin
  2207. X:=P^.Next;
  2208. DisposeTabDef(P);
  2209. P:=X;
  2210. end;
  2211. end;
  2212. constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  2213. AScreen: PScreen);
  2214. begin
  2215. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  2216. Screen:=AScreen;
  2217. if Screen=nil then
  2218. Fail;
  2219. SetState(sfCursorVis,true);
  2220. Update;
  2221. end;
  2222. procedure TScreenView.Update;
  2223. begin
  2224. SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
  2225. DrawView;
  2226. end;
  2227. procedure TScreenView.HandleEvent(var Event: TEvent);
  2228. begin
  2229. case Event.What of
  2230. evBroadcast :
  2231. case Event.Command of
  2232. cmUpdate : Update;
  2233. end;
  2234. end;
  2235. inherited HandleEvent(Event);
  2236. end;
  2237. procedure TScreenView.Draw;
  2238. var B: TDrawBuffer;
  2239. X,Y: integer;
  2240. Text,Attr: string;
  2241. P: TPoint;
  2242. begin
  2243. Screen^.GetCursorPos(P);
  2244. for Y:=Delta.Y to Delta.Y+Size.Y-1 do
  2245. begin
  2246. if Y<Screen^.GetHeight then
  2247. Screen^.GetLine(Y,Text,Attr)
  2248. else
  2249. begin Text:=''; Attr:=''; end;
  2250. Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
  2251. MoveChar(B,' ',0,Size.X);
  2252. for X:=1 to length(Text) do
  2253. MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
  2254. WriteLine(0,Y-Delta.Y,Size.X,1,B);
  2255. end;
  2256. SetCursor(P.X-Delta.X,P.Y-Delta.Y);
  2257. end;
  2258. constructor TScreenWindow.Init(AScreen: PScreen; ANumber: integer);
  2259. var R: TRect;
  2260. VSB,HSB: PScrollBar;
  2261. begin
  2262. Desktop^.GetExtent(R);
  2263. inherited Init(R, 'User screen', ANumber);
  2264. Options:=Options or ofTileAble;
  2265. GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
  2266. New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
  2267. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2268. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
  2269. New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
  2270. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2271. GetExtent(R); R.Grow(-1,-1);
  2272. New(ScreenView, Init(R, HSB, VSB, AScreen));
  2273. ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2274. Insert(ScreenView);
  2275. UserScreenWindow:=@Self;
  2276. end;
  2277. destructor TScreenWindow.Done;
  2278. begin
  2279. inherited Done;
  2280. UserScreenWindow:=nil;
  2281. end;
  2282. const InTranslate : boolean = false;
  2283. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  2284. procedure TranslateAction(Action: integer);
  2285. var E: TEvent;
  2286. begin
  2287. if Action<>acNone then
  2288. begin
  2289. E:=Event;
  2290. E.What:=evMouseDown; E.Buttons:=mbLeftButton;
  2291. View^.HandleEvent(E);
  2292. Event.What:=evCommand;
  2293. Event.Command:=ActionCommands[Action];
  2294. end;
  2295. end;
  2296. begin
  2297. if InTranslate then Exit;
  2298. InTranslate:=true;
  2299. case Event.What of
  2300. evMouseDown :
  2301. if (GetShiftState and kbAlt)<>0 then
  2302. TranslateAction(AltMouseAction) else
  2303. if (GetShiftState and kbCtrl)<>0 then
  2304. TranslateAction(CtrlMouseAction);
  2305. end;
  2306. InTranslate:=false;
  2307. end;
  2308. function GetNextEditorBounds(var Bounds: TRect): boolean;
  2309. var P: PView;
  2310. begin
  2311. P:=Desktop^.Current;
  2312. while P<>nil do
  2313. begin
  2314. if P^.HelpCtx=hcSourceWindow then Break;
  2315. P:=P^.NextView;
  2316. if P=Desktop^.Current then
  2317. begin
  2318. P:=nil;
  2319. break;
  2320. end;
  2321. end;
  2322. if P=nil then Desktop^.GetExtent(Bounds) else
  2323. begin
  2324. P^.GetBounds(Bounds);
  2325. Inc(Bounds.A.X); Inc(Bounds.A.Y);
  2326. end;
  2327. GetNextEditorBounds:=P<>nil;
  2328. end;
  2329. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  2330. var R: TRect;
  2331. W: PSourceWindow;
  2332. begin
  2333. if Assigned(Bounds) then R.Copy(Bounds^) else
  2334. GetNextEditorBounds(R);
  2335. PushStatus('Opening source file... ('+SmartPath(FileName)+')');
  2336. New(W, Init(R, FileName));
  2337. if W<>nil then
  2338. begin
  2339. if (CurX<>0) or (CurY<>0) then
  2340. with W^.Editor^ do
  2341. begin
  2342. SetCurPtr(CurX,CurY);
  2343. TrackCursor(true);
  2344. end;
  2345. W^.HelpCtx:=hcSourceWindow;
  2346. Desktop^.Insert(W);
  2347. If assigned(BreakpointsCollection) then
  2348. BreakpointsCollection^.ShowBreakpoints(W);
  2349. Message(Application,evBroadcast,cmUpdate,nil);
  2350. end;
  2351. PopStatus;
  2352. OpenEditorWindow:=W;
  2353. end;
  2354. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  2355. var
  2356. V: PView;
  2357. W: PWindow;
  2358. I: integer;
  2359. D,DS : DirStr;
  2360. N,NS : NameStr;
  2361. E,ES : ExtStr;
  2362. Found : boolean;
  2363. SName : string;
  2364. function IsSearchedFile(W : PSourceWindow) : boolean;
  2365. var Found: boolean;
  2366. begin
  2367. Found:=false;
  2368. if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
  2369. begin
  2370. if (D='') then
  2371. SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
  2372. else
  2373. SName:=PSourceWindow(W)^.Editor^.FileName;
  2374. FSplit(SName,DS,NS,ES);
  2375. SName:=UpcaseStr(NS+ES);
  2376. if (E<>'') or (not tryexts) then
  2377. begin
  2378. if D<>'' then
  2379. Found:=UpCaseStr(DS)+SName=UpcaseStr(D+N+E)
  2380. else
  2381. Found:=SName=UpcaseStr(N+E);
  2382. end
  2383. else
  2384. begin
  2385. Found:=SName=UpcaseStr(N+'.pp');
  2386. if Found=false then
  2387. Found:=SName=UpcaseStr(N+'.pas');
  2388. end;
  2389. end;
  2390. IsSearchedFile:=found;
  2391. end;
  2392. function IsSearchedSource(P: PView) : boolean; {$ifndef FPC}far;{$endif}
  2393. begin
  2394. if assigned(P) and
  2395. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  2396. IsSearchedSource:=IsSearchedFile(PSourceWindow(P))
  2397. else
  2398. IsSearchedSource:=false;
  2399. end;
  2400. begin
  2401. FSplit(FileName,D,N,E);
  2402. SearchOnDesktop:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  2403. end;
  2404. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  2405. var D : DirStr;
  2406. N : NameStr;
  2407. E : ExtStr;
  2408. DrStr : String;
  2409. function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
  2410. var OK: boolean;
  2411. begin
  2412. NewDir:=CompleteDir(NewDir);
  2413. OK:=ExistsFile(NewDir+NewName+NewExt);
  2414. if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
  2415. CheckDir:=OK;
  2416. end;
  2417. function CheckExt(NewExt: ExtStr): boolean;
  2418. var OK: boolean;
  2419. begin
  2420. OK:=false;
  2421. if D<>'' then OK:=CheckDir(D,N,NewExt) else
  2422. if CheckDir('.'+DirSep,N,NewExt) then OK:=true;
  2423. CheckExt:=OK;
  2424. end;
  2425. function TryToOpen(const DD : dirstr): PSourceWindow;
  2426. var Found: boolean;
  2427. W : PSourceWindow;
  2428. begin
  2429. D:=CompleteDir(DD);
  2430. Found:=true;
  2431. if (E<>'') or (not tryexts) then
  2432. Found:=CheckExt(E)
  2433. else
  2434. if CheckExt('.pp') then
  2435. Found:=true
  2436. else
  2437. if CheckExt('.pas') then
  2438. Found:=true
  2439. else
  2440. if CheckExt('.inc') then
  2441. Found:=true
  2442. else
  2443. Found:=false;
  2444. if Found=false then
  2445. W:=nil
  2446. else
  2447. begin
  2448. FileName:=FExpand(D+N+E);
  2449. W:=OpenEditorWindow(Bounds,FileName,CurX,CurY);
  2450. end;
  2451. TryToOpen:=W;
  2452. end;
  2453. var
  2454. W : PSourceWindow;
  2455. begin
  2456. W:=SearchOnDesktop(FileName,tryexts);
  2457. if W<>nil then
  2458. begin
  2459. NewEditorOpened:=false;
  2460. { if assigned(Bounds) then
  2461. W^.ChangeBounds(Bounds^);}
  2462. W^.Editor^.SetCurPtr(CurX,CurY);
  2463. end
  2464. else
  2465. begin
  2466. FSplit(FileName,D,N,E);
  2467. DrStr:=GetSourceDirectories;
  2468. While pos(';',DrStr)>0 do
  2469. Begin
  2470. W:=TryToOpen(Copy(DrStr,1,pos(';',DrStr)-1));
  2471. if assigned(W) then
  2472. break;
  2473. DrStr:=Copy(DrStr,pos(';',DrStr)+1,255);
  2474. End;
  2475. if not assigned(W) then
  2476. W:=TryToOpen(DrStr);
  2477. NewEditorOpened:=W<>nil;
  2478. if assigned(W) then
  2479. W^.Editor^.SetCurPtr(CurX,CurY);
  2480. end;
  2481. TryToOpenFile:=W;
  2482. end;
  2483. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  2484. var OK: boolean;
  2485. E: PFileEditor;
  2486. R: TRect;
  2487. begin
  2488. R.Assign(0,0,0,0);
  2489. New(E, Init(R,nil,nil,nil,FileName));
  2490. OK:=E<>nil;
  2491. if OK then OK:=E^.LoadFile;
  2492. if OK then
  2493. begin
  2494. E^.SelectAll(true);
  2495. Editor^.InsertFrom(E);
  2496. Editor^.SetCurPtr(0,0);
  2497. Editor^.SelectAll(false);
  2498. Dispose(E, Done);
  2499. end;
  2500. StartEditor:=OK;
  2501. end;
  2502. constructor TTextScroller.Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  2503. begin
  2504. inherited Init(Bounds,'');
  2505. EventMask:=EventMask or evIdle;
  2506. Speed:=ASpeed; Lines:=AText;
  2507. end;
  2508. function TTextScroller.GetLineCount: integer;
  2509. var Count: integer;
  2510. begin
  2511. if Lines=nil then Count:=0 else
  2512. Count:=Lines^.Count;
  2513. GetLineCount:=Count;
  2514. end;
  2515. function TTextScroller.GetLine(I: integer): string;
  2516. var S: string;
  2517. begin
  2518. if I<Lines^.Count then
  2519. S:=GetStr(Lines^.At(I))
  2520. else
  2521. S:='';
  2522. GetLine:=S;
  2523. end;
  2524. procedure TTextScroller.HandleEvent(var Event: TEvent);
  2525. begin
  2526. case Event.What of
  2527. evIdle :
  2528. Update;
  2529. end;
  2530. inherited HandleEvent(Event);
  2531. end;
  2532. procedure TTextScroller.Update;
  2533. begin
  2534. if abs(GetDosTicks-LastTT)<Speed then Exit;
  2535. Scroll;
  2536. LastTT:=GetDosTicks;
  2537. end;
  2538. procedure TTextScroller.Reset;
  2539. begin
  2540. TopLine:=0;
  2541. LastTT:=GetDosTicks;
  2542. DrawView;
  2543. end;
  2544. procedure TTextScroller.Scroll;
  2545. begin
  2546. Inc(TopLine);
  2547. if TopLine>=GetLineCount then
  2548. Reset;
  2549. DrawView;
  2550. end;
  2551. procedure TTextScroller.Draw;
  2552. var B: TDrawBuffer;
  2553. C: word;
  2554. Count,Y: integer;
  2555. S: string;
  2556. begin
  2557. C:=GetColor(1);
  2558. Count:=GetLineCount;
  2559. for Y:=0 to Size.Y-1 do
  2560. begin
  2561. if Count=0 then S:='' else
  2562. S:=GetLine((TopLine+Y) mod Count);
  2563. if copy(S,1,1)=^C then
  2564. S:=CharStr(' ',Max(0,(Size.X-(length(S)-1)) div 2))+copy(S,2,255);
  2565. MoveChar(B,' ',C,Size.X);
  2566. MoveStr(B,S,C);
  2567. WriteLine(0,Y,Size.X,1,B);
  2568. end;
  2569. end;
  2570. destructor TTextScroller.Done;
  2571. begin
  2572. inherited Done;
  2573. if Lines<>nil then Dispose(Lines, Done);
  2574. end;
  2575. constructor TFPAboutDialog.Init;
  2576. var R,R2: TRect;
  2577. C: PUnsortedStringCollection;
  2578. I: integer;
  2579. OSStr: string;
  2580. procedure AddLine(S: string);
  2581. begin
  2582. C^.Insert(NewStr(S));
  2583. end;
  2584. begin
  2585. OSStr:='';
  2586. {$ifdef go32v2}
  2587. OSStr:='Dos';
  2588. {$endif}
  2589. {$ifdef tp}
  2590. OSStr:='Dos';
  2591. {$endif}
  2592. {$ifdef linux}
  2593. OSStr:='Linux';
  2594. {$endif}
  2595. {$ifdef win32}
  2596. OSStr:='Win32';
  2597. {$endif}
  2598. {$ifdef os2}
  2599. OSStr:='OS/2';
  2600. {$endif}
  2601. R.Assign(0,0,38,13);
  2602. inherited Init(R, 'About');
  2603. GetExtent(R); R.Grow(-3,-2);
  2604. R2.Copy(R); R2.B.Y:=R2.A.Y+1;
  2605. Insert(New(PStaticText, Init(R2, ^C'FreePascal IDE for '+OSStr)));
  2606. R2.Move(0,1);
  2607. Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr
  2608. {$ifdef FPC}+' '+{$i %date%}{$endif}
  2609. )));
  2610. R2.Move(0,1);
  2611. Insert(New(PStaticText, Init(R2, ^C'(Compiler Version '+Version_String+')')));
  2612. {$ifndef NODEBUG}
  2613. if pos('Fake',GDBVersion)=0 then
  2614. begin
  2615. R2.Move(0,1);
  2616. Insert(New(PStaticText, Init(R2, ^C'(Debugger '+GDBVersion+')')));
  2617. R2.Move(0,1);
  2618. end
  2619. else
  2620. {$endif NODEBUG}
  2621. R2.Move(0,2);
  2622. Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-2000 by')));
  2623. R2.Move(0,2);
  2624. Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
  2625. R2.Move(0,1);
  2626. Insert(New(PStaticText, Init(R2, ^C'Pierre Muller')));
  2627. R2.Move(0,1);
  2628. Insert(New(PStaticText, Init(R2, ^C'and')));
  2629. R2.Move(0,1);
  2630. Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
  2631. New(C, Init(50,10));
  2632. for I:=1 to 7 do
  2633. AddLine('');
  2634. AddLine(^C'< Original concept >');
  2635. AddLine(^C'Borland International, Inc.');
  2636. AddLine('');
  2637. AddLine(^C'< Compiler development >');
  2638. AddLine(^C'Carl-Eric Codere');
  2639. AddLine(^C'Daniel Mantione');
  2640. AddLine(^C'Florian Kl„mpfl');
  2641. AddLine(^C'Jonas Maebe');
  2642. AddLine(^C'Mich„el Van Canneyt');
  2643. AddLine(^C'Peter Vreman');
  2644. AddLine(^C'Pierre Muller');
  2645. AddLine('');
  2646. AddLine(^C'< IDE development >');
  2647. AddLine(^C'B‚rczi G bor');
  2648. AddLine(^C'Peter Vreman');
  2649. AddLine(^C'Pierre Muller');
  2650. AddLine('');
  2651. GetExtent(R);
  2652. R.Grow(-1,-1); Inc(R.A.Y,3);
  2653. New(Scroller, Init(R, 10, C));
  2654. Scroller^.Hide;
  2655. Insert(Scroller);
  2656. R.Move(0,-1); R.B.Y:=R.A.Y+1;
  2657. New(TitleST, Init(R, ^C'Team'));
  2658. TitleST^.Hide;
  2659. Insert(TitleST);
  2660. InsertOK(@Self);
  2661. end;
  2662. procedure TFPAboutDialog.ToggleInfo;
  2663. begin
  2664. if Scroller=nil then Exit;
  2665. if Scroller^.GetState(sfVisible) then
  2666. begin
  2667. Scroller^.Hide;
  2668. TitleST^.Hide;
  2669. end
  2670. else
  2671. begin
  2672. Scroller^.Reset;
  2673. Scroller^.Show;
  2674. TitleST^.Show;
  2675. end;
  2676. end;
  2677. procedure TFPAboutDialog.HandleEvent(var Event: TEvent);
  2678. begin
  2679. case Event.What of
  2680. evKeyDown :
  2681. case Event.KeyCode of
  2682. kbAltI : { just like in BP }
  2683. begin
  2684. ToggleInfo;
  2685. ClearEvent(Event);
  2686. end;
  2687. end;
  2688. end;
  2689. inherited HandleEvent(Event);
  2690. end;
  2691. constructor TFPASCIIChart.Init;
  2692. begin
  2693. inherited Init;
  2694. HelpCtx:=hcASCIITableWindow;
  2695. Number:=SearchFreeWindowNo;
  2696. ASCIIChart:=@Self;
  2697. end;
  2698. procedure TFPASCIIChart.Store(var S: TStream);
  2699. begin
  2700. inherited Store(S);
  2701. end;
  2702. constructor TFPASCIIChart.Load(var S: TStream);
  2703. begin
  2704. inherited Load(S);
  2705. end;
  2706. procedure TFPASCIIChart.HandleEvent(var Event: TEvent);
  2707. var W: PSourceWindow;
  2708. begin
  2709. case Event.What of
  2710. evKeyDown :
  2711. case Event.KeyCode of
  2712. kbEsc :
  2713. begin
  2714. Close;
  2715. ClearEvent(Event);
  2716. end;
  2717. end;
  2718. evCommand :
  2719. case Event.Command of
  2720. cmTransfer :
  2721. begin
  2722. W:=FirstEditorWindow;
  2723. if Assigned(W) and Assigned(Report) then
  2724. Message(W,evCommand,cmAddChar,pointer(ord(Report^.AsciiChar)));
  2725. ClearEvent(Event);
  2726. end;
  2727. end;
  2728. end;
  2729. inherited HandleEvent(Event);
  2730. end;
  2731. destructor TFPASCIIChart.Done;
  2732. begin
  2733. ASCIIChart:=nil;
  2734. inherited Done;
  2735. end;
  2736. function TVideoModeListBox.GetText(Item: pointer; MaxLen: sw_integer): string;
  2737. var P: PVideoModeList;
  2738. S: string;
  2739. begin
  2740. P:=Item;
  2741. S:=IntToStr(P^.Col)+'x'+IntToStr(P^.Row)+' ';
  2742. if P^.Color then
  2743. S:=S+'color'
  2744. else
  2745. S:=S+'mono';
  2746. GetText:=copy(S,1,MaxLen);
  2747. end;
  2748. constructor TFPDesktop.Load(var S: TStream);
  2749. begin
  2750. inherited Load(S);
  2751. end;
  2752. procedure TFPDesktop.Store(var S: TStream);
  2753. begin
  2754. inherited Store(S);
  2755. end;
  2756. constructor TFPToolTip.Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  2757. begin
  2758. inherited Init(Bounds);
  2759. SetAlign(AAlign);
  2760. SetText(AText);
  2761. end;
  2762. procedure TFPToolTip.Draw;
  2763. var C: word;
  2764. procedure DrawLine(Y: integer; S: string);
  2765. var B: TDrawBuffer;
  2766. begin
  2767. S:=copy(S,1,Size.X-2);
  2768. case Align of
  2769. alLeft : S:=' '+S;
  2770. alRight : S:=LExpand(' '+S,Size.X);
  2771. alCenter : S:=Center(S,Size.X);
  2772. end;
  2773. MoveChar(B,' ',C,Size.X);
  2774. MoveStr(B,S,C);
  2775. WriteLine(0,Y,Size.X,1,B);
  2776. end;
  2777. var S: string;
  2778. Y: integer;
  2779. begin
  2780. C:=GetColor(1);
  2781. S:=GetText;
  2782. for Y:=0 to Size.Y-1 do
  2783. DrawLine(Y,S);
  2784. end;
  2785. function TFPToolTip.GetText: string;
  2786. begin
  2787. GetText:=GetStr(Text);
  2788. end;
  2789. procedure TFPToolTip.SetText(const AText: string);
  2790. begin
  2791. if AText<>GetText then
  2792. begin
  2793. if Assigned(Text) then DisposeStr(Text);
  2794. Text:=NewStr(AText);
  2795. DrawView;
  2796. end;
  2797. end;
  2798. function TFPToolTip.GetAlign: TAlign;
  2799. begin
  2800. GetAlign:=Align;
  2801. end;
  2802. procedure TFPToolTip.SetAlign(AAlign: TAlign);
  2803. begin
  2804. if AAlign<>Align then
  2805. begin
  2806. Align:=AAlign;
  2807. DrawView;
  2808. end;
  2809. end;
  2810. destructor TFPToolTip.Done;
  2811. begin
  2812. if Assigned(Text) then DisposeStr(Text); Text:=nil;
  2813. inherited Done;
  2814. end;
  2815. function TFPToolTip.GetPalette: PPalette;
  2816. const S: string[length(CFPToolTip)] = CFPToolTip;
  2817. begin
  2818. GetPalette:=@S;
  2819. end;
  2820. constructor TFPCodeMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  2821. PScrollBar; AIndicator: PIndicator; ABufSize:Sw_Word);
  2822. begin
  2823. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,ABufSize);
  2824. SetFlags(Flags and not (efPersistentBlocks) or efSyntaxHighlight);
  2825. end;
  2826. function TFPCodeMemo.GetPalette: PPalette;
  2827. const P: string[length(CFPCodeMemo)] = CFPCodeMemo;
  2828. begin
  2829. GetPalette:=@P;
  2830. end;
  2831. function TFPCodeMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  2832. var Count: integer;
  2833. begin
  2834. case SpecClass of
  2835. ssCommentPrefix : Count:=3;
  2836. ssCommentSingleLinePrefix : Count:=1;
  2837. ssCommentSuffix : Count:=2;
  2838. ssStringPrefix : Count:=1;
  2839. ssStringSuffix : Count:=1;
  2840. ssAsmPrefix : Count:=1;
  2841. ssAsmSuffix : Count:=1;
  2842. ssDirectivePrefix : Count:=1;
  2843. ssDirectiveSuffix : Count:=1;
  2844. end;
  2845. GetSpecSymbolCount:=Count;
  2846. end;
  2847. function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
  2848. var S: string[20];
  2849. begin
  2850. case SpecClass of
  2851. ssCommentPrefix :
  2852. case Index of
  2853. 0 : S:='{';
  2854. 1 : S:='(*';
  2855. 2 : S:='//';
  2856. end;
  2857. ssCommentSingleLinePrefix :
  2858. case Index of
  2859. 0 : S:='//';
  2860. end;
  2861. ssCommentSuffix :
  2862. case Index of
  2863. 0 : S:='}';
  2864. 1 : S:='*)';
  2865. end;
  2866. ssStringPrefix :
  2867. S:='''';
  2868. ssStringSuffix :
  2869. S:='''';
  2870. ssAsmPrefix :
  2871. S:='asm';
  2872. ssAsmSuffix :
  2873. S:='end';
  2874. ssDirectivePrefix :
  2875. S:='{$';
  2876. ssDirectiveSuffix :
  2877. S:='}';
  2878. end;
  2879. GetSpecSymbol:=S;
  2880. end;
  2881. function TFPCodeMemo.IsReservedWord(const S: string): boolean;
  2882. begin
  2883. IsReservedWord:=IsFPReservedWord(S);
  2884. end;
  2885. {$ifdef VESA}
  2886. function VESASetVideoModeProc(const VideoMode: TVideoMode; Params: Longint): Boolean; {$ifndef FPC}far;{$endif}
  2887. begin
  2888. VESASetVideoModeProc:=VESASetMode(Params);
  2889. end;
  2890. procedure InitVESAScreenModes;
  2891. var ML: TVESAModeList;
  2892. MI: TVESAModeInfoBlock;
  2893. I: integer;
  2894. begin
  2895. if VESAInit=false then Exit;
  2896. if VESAGetModeList(ML)=false then Exit;
  2897. for I:=1 to ML.Count do
  2898. begin
  2899. if VESAGetModeInfo(ML.Modes[I],MI) then
  2900. with MI do
  2901. if (Attributes and vesa_vma_GraphicsMode)=0 then
  2902. RegisterVideoMode(XResolution,YResolution,
  2903. (Attributes and vesa_vma_ColorMode)<>0,{$ifdef FPC}@{$endif}VESASetVideoModeProc,ML.Modes[I]);
  2904. end;
  2905. end;
  2906. {$endif}
  2907. procedure NoDebugger;
  2908. begin
  2909. InformationBox('No debugger support available.',nil);
  2910. end;
  2911. procedure RegisterFPViews;
  2912. begin
  2913. RegisterType(RSourceEditor);
  2914. RegisterType(RSourceWindow);
  2915. RegisterType(RFPHelpViewer);
  2916. RegisterType(RFPHelpWindow);
  2917. RegisterType(RClipboardWindow);
  2918. RegisterType(RMessageListBox);
  2919. RegisterType(RFPDesktop);
  2920. RegisterType(RGDBSourceEditor);
  2921. RegisterType(RGDBWindow);
  2922. RegisterType(RFPASCIIChart);
  2923. RegisterType(RProgramInfoWindow);
  2924. end;
  2925. END.
  2926. {
  2927. $Log$
  2928. Revision 1.60 2000-02-07 23:40:38 pierre
  2929. * avoid closing the StackWindow too early
  2930. Revision 1.59 2000/02/07 10:36:43 michael
  2931. + Something went wrong when unzipping
  2932. Revision 1.58 2000/02/06 23:42:47 pierre
  2933. + Use ErrorLine on GotoSource
  2934. Revision 1.57 2000/02/04 00:03:30 pierre
  2935. + SelectInDebugSession lets CPU and watches in front
  2936. Revision 1.56 2000/02/02 22:51:49 pierre
  2937. * use desktop^.current for GetNextEditorBounds
  2938. Revision 1.55 2000/02/01 10:58:41 pierre
  2939. * avoid Search sometimes disabled for Editor Windows
  2940. Revision 1.54 2000/01/10 14:59:50 pierre
  2941. * TProgramInfo was not registered
  2942. Revision 1.53 2000/01/07 14:02:52 pierre
  2943. + date string added
  2944. Revision 1.52 2000/01/03 11:38:34 michael
  2945. Changes from Gabor
  2946. Revision 1.51 1999/12/20 14:23:17 pierre
  2947. * MyApp renamed IDEApp
  2948. * TDebugController.ResetDebuggerRows added to
  2949. get resetting of debugger rows
  2950. Revision 1.50 1999/12/16 16:55:52 pierre
  2951. * fix of web bug 756
  2952. Revision 1.49 1999/11/25 00:25:43 pierre
  2953. * add Status when loading/saving files
  2954. Revision 1.48 1999/11/22 16:02:12 pierre
  2955. * TryToOpenFile failed tofind a sourcewindow if it has no number
  2956. Revision 1.47 1999/11/18 13:39:24 pierre
  2957. * Better info for Undo debugging
  2958. Revision 1.46 1999/11/10 00:44:12 pierre
  2959. * Grouped Undo action signaled in 'Dump Undo'
  2960. Revision 1.45 1999/10/29 14:50:07 pierre
  2961. * About dialog changes
  2962. Revision 1.44 1999/10/27 12:10:42 pierre
  2963. + With DebugUndo added 3 menu items
  2964. "Dump Undo" "Undo All" and "Redo All"
  2965. for Undo checks
  2966. Revision 1.43 1999/10/25 16:55:13 pierre
  2967. * adapted to a small weditor change
  2968. Revision 1.42 1999/09/16 14:34:59 pierre
  2969. + TBreakpoint and TWatch registering
  2970. + WatchesCollection and BreakpointsCollection stored in desk file
  2971. * Syntax highlighting was broken
  2972. Revision 1.41 1999/09/13 16:24:43 peter
  2973. + clock
  2974. * backspace unident like tp7
  2975. Revision 1.40 1999/09/09 16:30:37 pierre
  2976. * ModuleNames was not created in TMessageListBox.Load
  2977. Revision 1.39 1999/09/03 12:54:07 pierre
  2978. * adapted to modified tokens unit
  2979. * TryToOpen works better
  2980. Revision 1.38 1999/08/31 16:18:33 pierre
  2981. + TGDBWindow.Load and Store + Registration
  2982. Revision 1.37 1999/08/16 18:25:26 peter
  2983. * Adjusting the selection when the editor didn't contain any line.
  2984. * Reserved word recognition redesigned, but this didn't affect the overall
  2985. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  2986. The syntax scanner loop is a bit slow but the main problem is the
  2987. recognition of special symbols. Switching off symbol processing boosts
  2988. the performance up to ca. 200%...
  2989. * The editor didn't allow copying (for ex to clipboard) of a single character
  2990. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  2991. * Compiler Messages window (actually the whole desktop) did not act on any
  2992. keypress when compilation failed and thus the window remained visible
  2993. + Message windows are now closed upon pressing Esc
  2994. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  2995. only when neccessary
  2996. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  2997. + LineSelect (Ctrl+K+L) implemented
  2998. * The IDE had problems closing help windows before saving the desktop
  2999. Revision 1.36 1999/08/03 20:22:39 peter
  3000. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  3001. + Desktop saving should work now
  3002. - History saved
  3003. - Clipboard content saved
  3004. - Desktop saved
  3005. - Symbol info saved
  3006. * syntax-highlight bug fixed, which compared special keywords case sensitive
  3007. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  3008. * with 'whole words only' set, the editor didn't found occourences of the
  3009. searched text, if the text appeared previously in the same line, but didn't
  3010. satisfied the 'whole-word' condition
  3011. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  3012. (ie. the beginning of the selection)
  3013. * when started typing in a new line, but not at the start (X=0) of it,
  3014. the editor inserted the text one character more to left as it should...
  3015. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  3016. * Shift shouldn't cause so much trouble in TCodeEditor now...
  3017. * Syntax highlight had problems recognizing a special symbol if it was
  3018. prefixed by another symbol character in the source text
  3019. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  3020. Revision 1.35 1999/07/12 13:14:22 pierre
  3021. * LineEnd bug corrected, now goes end of text even if selected
  3022. + Until Return for debugger
  3023. + Code for Quit inside GDB Window
  3024. Revision 1.34 1999/06/30 23:58:20 pierre
  3025. + BreakpointsList Window implemented
  3026. with Edit/New/Delete functions
  3027. + Individual breakpoint dialog with support for all types
  3028. ignorecount and conditions
  3029. (commands are not yet implemented, don't know if this wolud be useful)
  3030. awatch and rwatch have problems because GDB does not annotate them
  3031. I fixed v4.16 for this
  3032. Revision 1.33 1999/06/28 19:32:28 peter
  3033. * fixes from gabor
  3034. Revision 1.32 1999/06/21 23:37:08 pierre
  3035. * VESASetVideoModeProc return value was not set
  3036. Revision 1.31 1999/06/02 11:19:13 pierre
  3037. * @ is now required for FPC for procedure address passing in functions
  3038. Revision 1.30 1999/05/22 13:44:33 peter
  3039. * fixed couple of bugs
  3040. Revision 1.29 1999/04/15 08:58:08 peter
  3041. * syntax highlight fixes
  3042. * browser updates
  3043. Revision 1.28 1999/04/07 21:55:56 peter
  3044. + object support for browser
  3045. * html help fixes
  3046. * more desktop saving things
  3047. * NODEBUG directive to exclude debugger
  3048. Revision 1.27 1999/04/01 10:27:06 pierre
  3049. + file(line) in start of message added
  3050. Revision 1.26 1999/03/23 16:16:41 peter
  3051. * linux fixes
  3052. Revision 1.25 1999/03/23 15:11:37 peter
  3053. * desktop saving things
  3054. * vesa mode
  3055. * preferences dialog
  3056. Revision 1.24 1999/03/21 22:51:37 florian
  3057. + functional screen mode switching added
  3058. Revision 1.23 1999/03/19 16:04:33 peter
  3059. * new compiler dialog
  3060. Revision 1.22 1999/03/16 00:44:45 peter
  3061. * forgotten in last commit :(
  3062. Revision 1.21 1999/03/08 14:58:16 peter
  3063. + prompt with dialogs for tools
  3064. Revision 1.20 1999/03/01 15:42:08 peter
  3065. + Added dummy entries for functions not yet implemented
  3066. * MenuBar didn't update itself automatically on command-set changes
  3067. * Fixed Debugging/Profiling options dialog
  3068. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
  3069. * efBackSpaceUnindents works correctly
  3070. + 'Messages' window implemented
  3071. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  3072. + Added TP message-filter support (for ex. you can call GREP thru
  3073. GREP2MSG and view the result in the messages window - just like in TP)
  3074. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  3075. so topic search didn't work...
  3076. * In FPHELP.PAS there were still context-variables defined as word instead
  3077. of THelpCtx
  3078. * StdStatusKeys() was missing from the statusdef for help windows
  3079. + Topic-title for index-table can be specified when adding a HTML-files
  3080. Revision 1.19 1999/02/22 11:51:39 peter
  3081. * browser updates from gabor
  3082. Revision 1.18 1999/02/22 11:29:38 pierre
  3083. + added col info in MessageItem
  3084. + grep uses HighLightExts and should work for linux
  3085. Revision 1.17 1999/02/22 02:15:22 peter
  3086. + default extension for save in the editor
  3087. + Separate Text to Find for the grep dialog
  3088. * fixed redir crash with tp7
  3089. Revision 1.16 1999/02/19 18:43:49 peter
  3090. + open dialog supports mask list
  3091. Revision 1.15 1999/02/17 15:04:02 pierre
  3092. + file(line) added in TProgramInfo message list
  3093. Revision 1.14 1999/02/16 12:45:18 pierre
  3094. * GDBWindow size and grow corrected
  3095. Revision 1.13 1999/02/15 09:36:06 pierre
  3096. * // comment ends at end of line !
  3097. GDB window changed !
  3098. now all is in a normal text editor, but pressing
  3099. Enter key will send part of line before cursor to GDB !
  3100. Revision 1.12 1999/02/11 19:07:25 pierre
  3101. * GDBWindow redesigned :
  3102. normal editor apart from
  3103. that any kbEnter will send the line (for begin to cursor)
  3104. to GDB command !
  3105. GDBWindow opened in Debugger Menu
  3106. still buggy :
  3107. -echo should not be present if at end of text
  3108. -GDBWindow becomes First after each step (I don't know why !)
  3109. Revision 1.11 1999/02/11 13:08:39 pierre
  3110. + TGDBWindow : direct gdb input/output
  3111. Revision 1.10 1999/02/10 09:42:52 pierre
  3112. + DoneReservedWords to avoid memory leaks
  3113. * TMessageItem Module field was not disposed
  3114. Revision 1.9 1999/02/05 12:12:02 pierre
  3115. + SourceDir that stores directories for sources that the
  3116. compiler should not know about
  3117. Automatically asked for addition when a new file that
  3118. needed filedialog to be found is in an unknown directory
  3119. Stored and retrieved from INIFile
  3120. + Breakpoints conditions added to INIFile
  3121. * Breakpoints insterted and removed at debin and end of debug session
  3122. Revision 1.8 1999/02/04 17:45:23 pierre
  3123. + BrowserAtCursor started
  3124. * bug in TryToOpenFile removed
  3125. Revision 1.7 1999/02/04 13:32:11 pierre
  3126. * Several things added (I cannot commit them independently !)
  3127. + added TBreakpoint and TBreakpointCollection
  3128. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  3129. + Breakpoint list in INIFile
  3130. * Select items now also depend of SwitchMode
  3131. * Reading of option '-g' was not possible !
  3132. + added search for -Fu args pathes in TryToOpen
  3133. + added code for automatic opening of FileDialog
  3134. if source not found
  3135. Revision 1.6 1999/01/21 11:54:27 peter
  3136. + tools menu
  3137. + speedsearch in symbolbrowser
  3138. * working run command
  3139. Revision 1.5 1999/01/14 21:42:25 peter
  3140. * source tracking from Gabor
  3141. Revision 1.4 1999/01/12 14:29:42 peter
  3142. + Implemented still missing 'switch' entries in Options menu
  3143. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  3144. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  3145. ASCII chars and inserted directly in the text.
  3146. + Added symbol browser
  3147. * splitted fp.pas to fpide.pas
  3148. Revision 1.3 1999/01/04 11:49:53 peter
  3149. * 'Use tab characters' now works correctly
  3150. + Syntax highlight now acts on File|Save As...
  3151. + Added a new class to syntax highlight: 'hex numbers'.
  3152. * There was something very wrong with the palette managment. Now fixed.
  3153. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  3154. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  3155. process revised
  3156. Revision 1.2 1998/12/28 15:47:54 peter
  3157. + Added user screen support, display & window
  3158. + Implemented Editor,Mouse Options dialog
  3159. + Added location of .INI and .CFG file
  3160. + Option (INI) file managment implemented (see bottom of Options Menu)
  3161. + Switches updated
  3162. + Run program
  3163. Revision 1.4 1998/12/22 10:39:53 peter
  3164. + options are now written/read
  3165. + find and replace routines
  3166. }