fpviews.pas 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541
  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. PA : Array[1..2] of pointer;
  1091. LoadFile: boolean;
  1092. begin
  1093. inherited Init(Bounds,AFileName,SearchFreeWindowNo);
  1094. Options:=Options or ofTileAble;
  1095. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1096. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1097. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1098. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1099. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1100. New(Indicator, Init(R));
  1101. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1102. Insert(Indicator);
  1103. GetExtent(R); R.Grow(-1,-1);
  1104. LoadFile:=AFileName<>'';
  1105. if not LoadFile then
  1106. begin SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas'); Inc(NonameCount); end;
  1107. New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
  1108. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1109. if LoadFile then
  1110. begin
  1111. if Editor^.LoadFile=false then
  1112. ErrorBox(#3'Error reading file.',nil)
  1113. else if Editor^.Modified then
  1114. begin
  1115. PA[1]:=@AFileName;
  1116. longint(PA[2]):=Editor^.ChangedLine;
  1117. EditorDialog(edChangedOnloading,@PA);
  1118. end;
  1119. end;
  1120. Insert(Editor);
  1121. If assigned(BreakpointsCollection) then
  1122. BreakpointsCollection^.ShowBreakpoints(@Self);
  1123. UpdateTitle;
  1124. end;
  1125. procedure TSourceWindow.UpdateTitle;
  1126. var Name: string;
  1127. begin
  1128. if Editor^.FileName<>'' then
  1129. begin Name:=SmartPath(Editor^.FileName); SetTitle(Name); end;
  1130. end;
  1131. procedure TSourceWindow.SetTitle(ATitle: string);
  1132. begin
  1133. if Title<>nil then DisposeStr(Title);
  1134. Title:=NewStr(ATitle);
  1135. Frame^.DrawView;
  1136. end;
  1137. procedure TSourceWindow.HandleEvent(var Event: TEvent);
  1138. var DontClear: boolean;
  1139. begin
  1140. case Event.What of
  1141. evBroadcast :
  1142. case Event.Command of
  1143. cmUpdate :
  1144. Update;
  1145. cmUpdateTitle :
  1146. UpdateTitle;
  1147. cmSearchWindow :
  1148. if @Self<>ClipboardWindow then
  1149. ClearEvent(Event);
  1150. end;
  1151. evCommand :
  1152. begin
  1153. DontClear:=false;
  1154. case Event.Command of
  1155. cmSave :
  1156. if Editor^.IsClipboard=false then
  1157. Editor^.Save;
  1158. cmSaveAs :
  1159. if Editor^.IsClipboard=false then
  1160. Editor^.SaveAs;
  1161. else DontClear:=true;
  1162. end;
  1163. if DontClear=false then ClearEvent(Event);
  1164. end;
  1165. end;
  1166. inherited HandleEvent(Event);
  1167. end;
  1168. procedure TSourceWindow.SetState(AState: Word; Enable: Boolean);
  1169. var OldState: word;
  1170. begin
  1171. OldState:=State;
  1172. inherited SetState(AState,Enable);
  1173. if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
  1174. UpdateCommands;
  1175. end;
  1176. procedure TSourceWindow.UpdateCommands;
  1177. var Active: boolean;
  1178. begin
  1179. Active:=GetState(sfActive);
  1180. if Editor^.IsClipboard=false then
  1181. begin
  1182. SetCmdState(SourceCmds+CompileCmds,Active);
  1183. SetCmdState(EditorCmds,Active);
  1184. end;
  1185. if Active=false then
  1186. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  1187. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  1188. end;
  1189. procedure TSourceWindow.Update;
  1190. begin
  1191. ReDraw;
  1192. end;
  1193. procedure TSourceWindow.SelectInDebugSession;
  1194. var
  1195. F,PrevCurrent : PView;
  1196. begin
  1197. DeskTop^.Lock;
  1198. PrevCurrent:=Desktop^.Current;
  1199. F:=PrevCurrent;
  1200. While assigned(F) and
  1201. ((F^.HelpCtx = hcGDBWindow) or
  1202. (F^.HelpCtx = hcWatches) or {hcStack,}
  1203. (F^.HelpCtx = hcRegisters)) do
  1204. F:=F^.NextView;
  1205. if F<>@Self then
  1206. Select;
  1207. if PrevCurrent<>F then
  1208. Begin
  1209. Desktop^.InsertBefore(@self,F);
  1210. PrevCurrent^.Select;
  1211. End;
  1212. DeskTop^.Unlock;
  1213. end;
  1214. function TSourceWindow.GetPalette: PPalette;
  1215. const P: string[length(CSourceWindow)] = CSourceWindow;
  1216. begin
  1217. GetPalette:=@P;
  1218. end;
  1219. constructor TSourceWindow.Load(var S: TStream);
  1220. begin
  1221. Title:=S.ReadStr;
  1222. PushStatus('Loading '+GetStr(Title));
  1223. inherited Load(S);
  1224. GetSubViewPtr(S,Indicator);
  1225. GetSubViewPtr(S,Editor);
  1226. If assigned(BreakpointsCollection) then
  1227. BreakpointsCollection^.ShowBreakpoints(@Self);
  1228. PopStatus;
  1229. end;
  1230. procedure TSourceWindow.Store(var S: TStream);
  1231. begin
  1232. S.WriteStr(Title);
  1233. PushStatus('Storing '+GetStr(Title));
  1234. inherited Store(S);
  1235. PutSubViewPtr(S,Indicator);
  1236. PutSubViewPtr(S,Editor);
  1237. PopStatus;
  1238. end;
  1239. destructor TSourceWindow.Done;
  1240. begin
  1241. PushStatus('Closing '+GetStr(Title));
  1242. if not IDEApp.IsClosing then
  1243. Message(Application,evBroadcast,cmSourceWndClosing,@Self);
  1244. inherited Done;
  1245. { if not IDEApp.IsClosing then
  1246. Message(Application,evBroadcast,cmUpdate,@Self);}
  1247. PopStatus;
  1248. end;
  1249. function TGDBSourceEditor.Valid(Command: Word): Boolean;
  1250. var OK: boolean;
  1251. begin
  1252. OK:=TCodeEditor.Valid(Command);
  1253. { do NOT ask for save !!
  1254. if OK and ((Command=cmClose) or (Command=cmQuit)) then
  1255. if IsClipboard=false then
  1256. OK:=SaveAsk; }
  1257. Valid:=OK;
  1258. end;
  1259. procedure TGDBSourceEditor.AddLine(const S: string);
  1260. begin
  1261. if Silent or (IgnoreStringAtEnd and (S=LastCommand)) then exit;
  1262. inherited AddLine(S);
  1263. LimitsChanged;
  1264. end;
  1265. procedure TGDBSourceEditor.AddErrorLine(const S: string);
  1266. begin
  1267. if Silent then exit;
  1268. inherited AddLine(S);
  1269. { display like breakpoints in red }
  1270. Lines^.At(GetLineCount-1)^.IsBreakpoint:=true;
  1271. LimitsChanged;
  1272. end;
  1273. function TGDBSourceEditor.InsertLine: Sw_integer;
  1274. Var
  1275. S : string;
  1276. begin
  1277. if IsReadOnly then begin InsertLine:=-1; Exit; end;
  1278. if CurPos.Y<GetLineCount then S:=GetDisplayText(CurPos.Y) else S:='';
  1279. s:=Copy(S,1,CurPos.X);
  1280. if assigned(Debugger) then
  1281. if S<>'' then
  1282. begin
  1283. LastCommand:=S;
  1284. { should be true only if we are at the end ! }
  1285. IgnoreStringAtEnd:=(CurPos.Y=GetLineCount-1) and
  1286. (CurPos.X=length(GetDisplayText(GetLineCount-1)));
  1287. Debugger^.Command(S);
  1288. IgnoreStringAtEnd:=false;
  1289. end
  1290. else if AutoRepeat then
  1291. Debugger^.Command(LastCommand);
  1292. InsertLine:=inherited InsertLine;
  1293. end;
  1294. constructor TGDBWindow.Init(var Bounds: TRect);
  1295. var HSB,VSB: PScrollBar;
  1296. R: TRect;
  1297. begin
  1298. inherited Init(Bounds,'GDB window',0);
  1299. Options:=Options or ofTileAble;
  1300. AutoNumber:=true;
  1301. HelpCtx:=hcGDBWindow;
  1302. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1303. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1304. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1305. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1306. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1307. New(Indicator, Init(R));
  1308. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1309. Insert(Indicator);
  1310. GetExtent(R); R.Grow(-1,-1);
  1311. New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
  1312. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1313. if ExistsFile(GDBOutputFile) then
  1314. begin
  1315. if Editor^.LoadFile=false then
  1316. ErrorBox(#3'Error reading file'#13#3+GDBOutputFile,nil);
  1317. end
  1318. else
  1319. { Empty files are buggy !! }
  1320. Editor^.AddLine('');
  1321. Insert(Editor);
  1322. if assigned(Debugger) then
  1323. Debugger^.Command('set width '+IntToStr(Size.X-1));
  1324. Editor^.silent:=false;
  1325. Editor^.AutoRepeat:=true;
  1326. end;
  1327. destructor TGDBWindow.Done;
  1328. begin
  1329. if @Self=GDBWindow then
  1330. GDBWindow:=nil;
  1331. inherited Done;
  1332. end;
  1333. constructor TGDBWindow.Load(var S: TStream);
  1334. begin
  1335. inherited Load(S);
  1336. GetSubViewPtr(S,Indicator);
  1337. GetSubViewPtr(S,Editor);
  1338. end;
  1339. procedure TGDBWindow.Store(var S: TStream);
  1340. begin
  1341. inherited Store(S);
  1342. PutSubViewPtr(S,Indicator);
  1343. PutSubViewPtr(S,Editor);
  1344. end;
  1345. function TGDBWindow.GetPalette: PPalette;
  1346. const P: string[length(CSourceWindow)] = CSourceWindow;
  1347. begin
  1348. GetPalette:=@P;
  1349. end;
  1350. procedure TGDBWindow.WriteOutputText(Buf : pchar);
  1351. begin
  1352. {selected normal color ?}
  1353. WriteText(Buf,false);
  1354. end;
  1355. procedure TGDBWindow.WriteErrorText(Buf : pchar);
  1356. begin
  1357. {selected normal color ?}
  1358. WriteText(Buf,true);
  1359. end;
  1360. procedure TGDBWindow.WriteString(Const S : string);
  1361. begin
  1362. Editor^.AddLine(S);
  1363. end;
  1364. procedure TGDBWindow.WriteErrorString(Const S : string);
  1365. begin
  1366. Editor^.AddErrorLine(S);
  1367. end;
  1368. procedure TGDBWindow.WriteText(Buf : pchar;IsError : boolean);
  1369. var p,pe : pchar;
  1370. s : string;
  1371. begin
  1372. p:=buf;
  1373. DeskTop^.Lock;
  1374. While assigned(p) do
  1375. begin
  1376. pe:=strscan(p,#10);
  1377. if pe<>nil then
  1378. pe^:=#0;
  1379. s:=strpas(p);
  1380. If IsError then
  1381. Editor^.AddErrorLine(S)
  1382. else
  1383. Editor^.AddLine(S);
  1384. { restore for dispose }
  1385. if pe<>nil then
  1386. pe^:=#10;
  1387. if pe=nil then
  1388. p:=nil
  1389. else
  1390. begin
  1391. p:=pe;
  1392. inc(p);
  1393. end;
  1394. end;
  1395. DeskTop^.Unlock;
  1396. Editor^.Draw;
  1397. end;
  1398. constructor TClipboardWindow.Init;
  1399. var R: TRect;
  1400. HSB,VSB: PScrollBar;
  1401. begin
  1402. Desktop^.GetExtent(R);
  1403. inherited Init(R, '');
  1404. SetTitle('Clipboard');
  1405. HelpCtx:=hcClipboardWindow;
  1406. Number:=wnNoNumber;
  1407. AutoNumber:=true;
  1408. GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
  1409. New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  1410. GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
  1411. New(VSB, Init(R)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1412. GetExtent(R); R.A.X:=3; R.B.X:=14; R.A.Y:=R.B.Y-1;
  1413. New(Indicator, Init(R));
  1414. Indicator^.GrowMode:=gfGrowLoY+gfGrowHiY;
  1415. Insert(Indicator);
  1416. GetExtent(R); R.Grow(-1,-1);
  1417. New(Editor, Init(R, HSB, VSB, Indicator, ''));
  1418. Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1419. Insert(Editor);
  1420. Hide;
  1421. Clipboard:=Editor;
  1422. end;
  1423. procedure TClipboardWindow.Close;
  1424. begin
  1425. Hide;
  1426. end;
  1427. constructor TClipboardWindow.Load(var S: TStream);
  1428. begin
  1429. inherited Load(S);
  1430. Clipboard:=Editor;
  1431. end;
  1432. procedure TClipboardWindow.Store(var S: TStream);
  1433. begin
  1434. inherited Store(S);
  1435. end;
  1436. destructor TClipboardWindow.Done;
  1437. begin
  1438. inherited Done;
  1439. Clipboard:=nil;
  1440. ClipboardWindow:=nil;
  1441. end;
  1442. constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  1443. begin
  1444. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  1445. GrowMode:=gfGrowHiX+gfGrowHiY;
  1446. New(ModuleNames, Init(50,100));
  1447. NoSelection:=true;
  1448. end;
  1449. function TMessageListBox.GetLocalMenu: PMenu;
  1450. var M: PMenu;
  1451. begin
  1452. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  1453. M:=NewMenu(
  1454. NewItem('~C~lear','',kbNoKey,cmMsgClear,hcMsgClear,
  1455. NewLine(
  1456. NewItem('~G~oto source','',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  1457. NewItem('~T~rack source','',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
  1458. nil)))));
  1459. GetLocalMenu:=M;
  1460. end;
  1461. procedure TMessageListBox.HandleEvent(var Event: TEvent);
  1462. var DontClear: boolean;
  1463. begin
  1464. case Event.What of
  1465. evKeyDown :
  1466. begin
  1467. DontClear:=false;
  1468. case Event.KeyCode of
  1469. kbEnter :
  1470. Message(@Self,evCommand,cmMsgGotoSource,nil);
  1471. else
  1472. DontClear:=true;
  1473. end;
  1474. if not DontClear then
  1475. ClearEvent(Event);
  1476. end;
  1477. evBroadcast :
  1478. case Event.Command of
  1479. cmListItemSelected :
  1480. if Event.InfoPtr=@Self then
  1481. Message(@Self,evCommand,cmMsgTrackSource,nil);
  1482. end;
  1483. evCommand :
  1484. begin
  1485. DontClear:=false;
  1486. case Event.Command of
  1487. cmMsgGotoSource :
  1488. if Range>0 then
  1489. GotoSource;
  1490. cmMsgTrackSource :
  1491. if Range>0 then
  1492. TrackSource;
  1493. cmMsgClear :
  1494. Clear;
  1495. else
  1496. DontClear:=true;
  1497. end;
  1498. if not DontClear then
  1499. ClearEvent(Event);
  1500. end;
  1501. end;
  1502. inherited HandleEvent(Event);
  1503. end;
  1504. procedure TMessageListBox.AddItem(P: PMessageItem);
  1505. var W : integer;
  1506. begin
  1507. if List=nil then New(List, Init(500,500));
  1508. W:=length(P^.GetText(255));
  1509. if W>MaxWidth then
  1510. begin
  1511. MaxWidth:=W;
  1512. if HScrollBar<>nil then
  1513. HScrollBar^.SetRange(0,MaxWidth);
  1514. end;
  1515. List^.Insert(P);
  1516. SetRange(List^.Count);
  1517. if Focused=List^.Count-1-1 then
  1518. FocusItem(List^.Count-1);
  1519. DrawView;
  1520. end;
  1521. function TMessageListBox.AddModuleName(const Name: string): PString;
  1522. var P: PString;
  1523. begin
  1524. if ModuleNames<>nil then
  1525. P:=ModuleNames^.Add(Name)
  1526. else
  1527. P:=nil;
  1528. AddModuleName:=P;
  1529. end;
  1530. function TMessageListBox.GetText(Item,MaxLen: Sw_Integer): String;
  1531. var P: PMessageItem;
  1532. S: string;
  1533. begin
  1534. P:=List^.At(Item);
  1535. S:=P^.GetText(MaxLen);
  1536. GetText:=copy(S,1,MaxLen);
  1537. end;
  1538. procedure TMessageListBox.Clear;
  1539. begin
  1540. if assigned(List) then
  1541. Dispose(List, Done);
  1542. List:=nil;
  1543. MaxWidth:=0;
  1544. if assigned(ModuleNames) then
  1545. ModuleNames^.FreeAll;
  1546. SetRange(0); DrawView;
  1547. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1548. end;
  1549. procedure TMessageListBox.TrackSource;
  1550. var W: PSourceWindow;
  1551. P: PMessageItem;
  1552. R: TRect;
  1553. Row,Col: sw_integer;
  1554. begin
  1555. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1556. if Range=0 then Exit;
  1557. P:=List^.At(Focused);
  1558. if P^.Row=0 then Exit;
  1559. Desktop^.Lock;
  1560. GetNextEditorBounds(R);
  1561. {$ifdef OLDCOMP}
  1562. if Assigned(Owner) and (Owner=pointer(ProgramInfoWindow)) then
  1563. {$endif}
  1564. R.B.Y:=Owner^.Origin.Y;
  1565. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  1566. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  1567. W:=EditorWindowFile(P^.GetModuleName);
  1568. if assigned(W) then
  1569. begin
  1570. W^.GetExtent(R);
  1571. {$ifdef OLDCOMP}
  1572. if Assigned(Owner) and (Owner=pointer(ProgramInfoWindow)) then
  1573. {$endif}
  1574. R.B.Y:=Owner^.Origin.Y;
  1575. W^.ChangeBounds(R);
  1576. W^.Editor^.SetCurPtr(Col,Row);
  1577. end
  1578. else
  1579. W:=TryToOpenFile(@R,P^.GetModuleName,Col,Row,true);
  1580. if W<>nil then
  1581. begin
  1582. W^.Select;
  1583. W^.Editor^.TrackCursor(true);
  1584. W^.Editor^.SetHighlightRow(Row);
  1585. end;
  1586. if Assigned(Owner) then
  1587. Owner^.Select;
  1588. Desktop^.UnLock;
  1589. end;
  1590. procedure TMessageListBox.GotoSource;
  1591. var W: PSourceWindow;
  1592. P: PMessageItem;
  1593. R:TRect;
  1594. Row,Col: sw_integer;
  1595. begin
  1596. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1597. if Range=0 then Exit;
  1598. P:=List^.At(Focused);
  1599. if P^.Row=0 then Exit;
  1600. Desktop^.Lock;
  1601. if P^.Row>0 then Row:=P^.Row-1 else Row:=0;
  1602. if P^.Col>0 then Col:=P^.Col-1 else Col:=0;
  1603. W:=TryToOpenFile(nil,P^.GetModuleName,Col,Row,true);
  1604. if assigned(W) then
  1605. begin
  1606. { Message(Owner,evCommand,cmClose,nil);
  1607. This calls close on StackWindow
  1608. rendering P invalid
  1609. so postpone it PM }
  1610. W^.GetExtent(R);
  1611. if (P^.TClass<>0) then
  1612. W^.Editor^.SetErrorMessage(P^.GetText(R.B.X-R.A.X));
  1613. W^.Select;
  1614. Message(Owner,evCommand,cmClose,nil);
  1615. end;
  1616. Desktop^.UnLock;
  1617. end;
  1618. procedure TMessageListBox.Draw;
  1619. var
  1620. I, J, Item: Sw_Integer;
  1621. NormalColor, SelectedColor, FocusedColor, Color: Word;
  1622. ColWidth, CurCol, Indent: Integer;
  1623. B: TDrawBuffer;
  1624. Text: String;
  1625. SCOff: Byte;
  1626. TC: byte;
  1627. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  1628. begin
  1629. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  1630. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  1631. begin
  1632. NormalColor := GetColor(1);
  1633. FocusedColor := GetColor(3);
  1634. SelectedColor := GetColor(4);
  1635. end else
  1636. begin
  1637. NormalColor := GetColor(2);
  1638. SelectedColor := GetColor(4);
  1639. end;
  1640. if Transparent then
  1641. begin MT(NormalColor); MT(SelectedColor); end;
  1642. if NoSelection then
  1643. SelectedColor:=NormalColor;
  1644. if HScrollBar <> nil then Indent := HScrollBar^.Value
  1645. else Indent := 0;
  1646. ColWidth := Size.X div NumCols + 1;
  1647. for I := 0 to Size.Y - 1 do
  1648. begin
  1649. for J := 0 to NumCols-1 do
  1650. begin
  1651. Item := J*Size.Y + I + TopItem;
  1652. CurCol := J*ColWidth;
  1653. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  1654. (Focused = Item) and (Range > 0) then
  1655. begin
  1656. Color := FocusedColor;
  1657. SetCursor(CurCol+1,I);
  1658. SCOff := 0;
  1659. end
  1660. else if (Item < Range) and IsSelected(Item) then
  1661. begin
  1662. Color := SelectedColor;
  1663. SCOff := 2;
  1664. end
  1665. else
  1666. begin
  1667. Color := NormalColor;
  1668. SCOff := 4;
  1669. end;
  1670. MoveChar(B[CurCol], ' ', Color, ColWidth);
  1671. if Item < Range then
  1672. begin
  1673. Text := GetText(Item, ColWidth + Indent);
  1674. Text := Copy(Text,Indent,ColWidth);
  1675. MoveStr(B[CurCol+1], Text, Color);
  1676. if ShowMarkers then
  1677. begin
  1678. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  1679. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  1680. end;
  1681. end;
  1682. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  1683. end;
  1684. WriteLine(0, I, Size.X, 1, B);
  1685. end;
  1686. end;
  1687. constructor TMessageListBox.Load(var S: TStream);
  1688. begin
  1689. inherited Load(S);
  1690. New(ModuleNames, Init(50,100));
  1691. NoSelection:=true;
  1692. end;
  1693. procedure TMessageListBox.Store(var S: TStream);
  1694. var OL: PCollection;
  1695. ORV: sw_integer;
  1696. begin
  1697. OL:=List; ORV:=Range;
  1698. New(List, Init(1,1)); Range:=0;
  1699. inherited Store(S);
  1700. Dispose(List, Done);
  1701. List:=OL; Range:=ORV;
  1702. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  1703. collection? Pasting here a modified version of TListBox.Store+
  1704. TAdvancedListBox.Store isn't a better solution, since by eventually
  1705. changing the obj-hierarchy you'll always have to modify this, too - BG }
  1706. end;
  1707. destructor TMessageListBox.Done;
  1708. begin
  1709. inherited Done;
  1710. if List<>nil then Dispose(List, Done);
  1711. if ModuleNames<>nil then Dispose(ModuleNames, Done);
  1712. end;
  1713. constructor TMessageItem.Init(AClass: longint; const AText: string; AModule: PString; ARow, ACol: sw_integer);
  1714. begin
  1715. inherited Init;
  1716. TClass:=AClass;
  1717. Text:=NewStr(AText);
  1718. Module:=AModule;
  1719. Row:=ARow; Col:=ACol;
  1720. end;
  1721. function TMessageItem.GetText(MaxLen: Sw_integer): string;
  1722. var S: string;
  1723. begin
  1724. if Text=nil then S:='' else S:=Text^;
  1725. if (Module<>nil) then
  1726. S:=NameAndExtOf(Module^)+'('+IntToStr(Row)+') '+S;
  1727. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  1728. GetText:=S;
  1729. end;
  1730. procedure TMessageItem.Selected;
  1731. begin
  1732. end;
  1733. function TMessageItem.GetModuleName: string;
  1734. begin
  1735. GetModuleName:=GetStr(Module);
  1736. end;
  1737. destructor TMessageItem.Done;
  1738. begin
  1739. inherited Done;
  1740. if Text<>nil then DisposeStr(Text);
  1741. { if Module<>nil then DisposeStr(Module);}
  1742. end;
  1743. {$ifdef OLDCOMP}
  1744. function TCompilerMessage.GetText(MaxLen: Integer): String;
  1745. var ClassS: string[20];
  1746. S: string;
  1747. begin
  1748. if TClass=
  1749. V_Fatal then ClassS:='Fatal' else if TClass =
  1750. V_Error then ClassS:='Error' else if TClass =
  1751. V_Normal then ClassS:='' else if TClass =
  1752. V_Warning then ClassS:='Warning' else if TClass =
  1753. V_Note then ClassS:='Note' else if TClass =
  1754. V_Hint then ClassS:='Hint' else if TClass =
  1755. V_Macro then ClassS:='Macro' else if TClass =
  1756. V_Procedure then ClassS:='Procedure' else if TClass =
  1757. V_Conditional then ClassS:='Conditional' else if TClass =
  1758. V_Info then ClassS:='Info' else if TClass =
  1759. V_Status then ClassS:='Status' else if TClass =
  1760. V_Used then ClassS:='Used' else if TClass =
  1761. V_Tried then ClassS:='Tried' else if TClass =
  1762. V_Debug then ClassS:='Debug'
  1763. else
  1764. ClassS:='???';
  1765. if ClassS<>'' then
  1766. ClassS:=RExpand(ClassS,0)+': ';
  1767. S:=ClassS;
  1768. if (Module<>nil) {and (ID<>0)} then
  1769. S:=S+NameAndExtOf(Module^)+'('+IntToStr(Row)+') ';
  1770. if Text<>nil then S:=S+Text^;
  1771. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  1772. GetText:=S;
  1773. end;
  1774. {$endif}
  1775. constructor TProgramInfoWindow.Init;
  1776. var R,R2: TRect;
  1777. HSB,VSB: PScrollBar;
  1778. ST: PStaticText;
  1779. C: word;
  1780. const White = 15;
  1781. begin
  1782. Desktop^.GetExtent(R); R.A.Y:=R.B.Y-13;
  1783. inherited Init(R, 'Program Information', wnNoNumber);
  1784. HelpCtx:=hcInfoWindow;
  1785. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+3;
  1786. C:=((Desktop^.GetColor(32+6) and $f0) or White)*256+Desktop^.GetColor(32+6);
  1787. New(InfoST, Init(R,'', C)); InfoST^.GrowMode:=gfGrowHiX;
  1788. InfoST^.DontWrap:=true;
  1789. Insert(InfoST);
  1790. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,3); R.B.Y:=R.A.Y+1;
  1791. New(ST, Init(R, CharStr('Ä', MaxViewWidth))); ST^.GrowMode:=gfGrowHiX; Insert(ST);
  1792. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,4);
  1793. R2.Copy(R); Inc(R2.B.Y); R2.A.Y:=R2.B.Y-1;
  1794. New(HSB, Init(R2)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX; Insert(HSB);
  1795. R2.Copy(R); Inc(R2.B.X); R2.A.X:=R2.B.X-1;
  1796. New(VSB, Init(R2)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1797. New(LogLB, Init(R,HSB,VSB));
  1798. LogLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1799. LogLB^.Transparent:=true;
  1800. Insert(LogLB);
  1801. Update;
  1802. end;
  1803. constructor TProgramInfoWindow.Load(var S : TStream);
  1804. begin
  1805. inherited Load(S);
  1806. GetSubViewPtr(S,InfoST);
  1807. GetSubViewPtr(S,LogLB);
  1808. end;
  1809. procedure TProgramInfoWindow.Store(var S : TStream);
  1810. begin
  1811. inherited Store(S);
  1812. PutSubViewPtr(S,InfoST);
  1813. PutSubViewPtr(S,LogLB);
  1814. end;
  1815. procedure TProgramInfoWindow.AddMessage(AClass: longint; Msg, Module: string; Line, Column: longint);
  1816. begin
  1817. if AClass>=V_Info then Line:=0;
  1818. LogLB^.AddItem(New(PCompilerMessage, Init(AClass, Msg, LogLB^.AddModuleName(Module), Line, Column)));
  1819. end;
  1820. procedure TProgramInfoWindow.ClearMessages;
  1821. begin
  1822. LogLB^.Clear;
  1823. ReDraw;
  1824. end;
  1825. procedure TProgramInfoWindow.SizeLimits(var Min, Max: TPoint);
  1826. begin
  1827. inherited SizeLimits(Min,Max);
  1828. Min.X:=30; Min.Y:=9;
  1829. end;
  1830. procedure TProgramInfoWindow.Close;
  1831. begin
  1832. Hide;
  1833. end;
  1834. procedure TProgramInfoWindow.HandleEvent(var Event: TEvent);
  1835. begin
  1836. case Event.What of
  1837. evBroadcast :
  1838. case Event.Command of
  1839. cmUpdate :
  1840. Update;
  1841. end;
  1842. end;
  1843. inherited HandleEvent(Event);
  1844. end;
  1845. procedure TProgramInfoWindow.Update;
  1846. begin
  1847. InfoST^.SetText(
  1848. {#13+ }
  1849. ' Current module : '+MainFile+#13+
  1850. ' Last exit code : '+IntToStr(LastExitCode)+#13+
  1851. ' Available memory : '+IntToStrL(MemAvail div 1024,5)+'K'+#13+
  1852. ''
  1853. );
  1854. end;
  1855. destructor TProgramInfoWindow.Done;
  1856. begin
  1857. inherited Done;
  1858. ProgramInfoWindow:=nil;
  1859. end;
  1860. constructor TTab.Init(var Bounds: TRect; ATabDef: PTabDef);
  1861. begin
  1862. inherited Init(Bounds);
  1863. Options:=Options or ofSelectable or ofFirstClick or ofPreProcess or ofPostProcess;
  1864. GrowMode:=gfGrowHiX+gfGrowHiY+gfGrowRel;
  1865. TabDefs:=ATabDef;
  1866. ActiveDef:=-1;
  1867. SelectTab(0);
  1868. ReDraw;
  1869. end;
  1870. function TTab.TabCount: integer;
  1871. var i: integer;
  1872. P: PTabDef;
  1873. begin
  1874. I:=0; P:=TabDefs;
  1875. while (P<>nil) do
  1876. begin
  1877. Inc(I);
  1878. P:=P^.Next;
  1879. end;
  1880. TabCount:=I;
  1881. end;
  1882. function TTab.AtTab(Index: integer): PTabDef;
  1883. var i: integer;
  1884. P: PTabDef;
  1885. begin
  1886. i:=0; P:=TabDefs;
  1887. while (I<Index) do
  1888. begin
  1889. if P=nil then RunError($AA);
  1890. P:=P^.Next;
  1891. Inc(i);
  1892. end;
  1893. AtTab:=P;
  1894. end;
  1895. procedure TTab.SelectTab(Index: integer);
  1896. var P: PTabItem;
  1897. V: PView;
  1898. begin
  1899. if ActiveDef<>Index then
  1900. begin
  1901. if Owner<>nil then Owner^.Lock;
  1902. Lock;
  1903. { --- Update --- }
  1904. if TabDefs<>nil then
  1905. begin
  1906. DefCount:=1;
  1907. while AtTab(DefCount-1)^.Next<>nil do Inc(DefCount);
  1908. end
  1909. else DefCount:=0;
  1910. if ActiveDef<>-1 then
  1911. begin
  1912. P:=AtTab(ActiveDef)^.Items;
  1913. while P<>nil do
  1914. begin
  1915. if P^.View<>nil then Delete(P^.View);
  1916. P:=P^.Next;
  1917. end;
  1918. end;
  1919. ActiveDef:=Index;
  1920. P:=AtTab(ActiveDef)^.Items;
  1921. while P<>nil do
  1922. begin
  1923. if P^.View<>nil then Insert(P^.View);
  1924. P:=P^.Next;
  1925. end;
  1926. V:=AtTab(ActiveDef)^.DefItem;
  1927. if V<>nil then V^.Select;
  1928. ReDraw;
  1929. { --- Update --- }
  1930. UnLock;
  1931. if Owner<>nil then Owner^.UnLock;
  1932. DrawView;
  1933. end;
  1934. end;
  1935. procedure TTab.ChangeBounds(var Bounds: TRect);
  1936. var D: TPoint;
  1937. procedure DoCalcChange(P: PView); {$ifndef FPC}far;{$endif}
  1938. var
  1939. R: TRect;
  1940. begin
  1941. if P^.Owner=nil then Exit; { it think this is a bug in TV }
  1942. P^.CalcBounds(R, D);
  1943. P^.ChangeBounds(R);
  1944. end;
  1945. var
  1946. P: PTabItem;
  1947. I: integer;
  1948. begin
  1949. D.X := Bounds.B.X - Bounds.A.X - Size.X;
  1950. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y;
  1951. inherited ChangeBounds(Bounds);
  1952. for I:=0 to TabCount-1 do
  1953. if I<>ActiveDef then
  1954. begin
  1955. P:=AtTab(I)^.Items;
  1956. while P<>nil do
  1957. begin
  1958. if P^.View<>nil then DoCalcChange(P^.View);
  1959. P:=P^.Next;
  1960. end;
  1961. end;
  1962. end;
  1963. procedure TTab.SelectNextTab(Forwards: boolean);
  1964. var Index: integer;
  1965. begin
  1966. Index:=ActiveDef;
  1967. if Index=-1 then Exit;
  1968. if Forwards then Inc(Index) else Dec(Index);
  1969. if Index<0 then Index:=DefCount-1 else
  1970. if Index>DefCount-1 then Index:=0;
  1971. SelectTab(Index);
  1972. end;
  1973. procedure TTab.HandleEvent(var Event: TEvent);
  1974. var Index : integer;
  1975. I : integer;
  1976. X : integer;
  1977. Len : byte;
  1978. P : TPoint;
  1979. V : PView;
  1980. CallOrig: boolean;
  1981. LastV : PView;
  1982. FirstV: PView;
  1983. function FirstSelectable: PView;
  1984. var
  1985. FV : PView;
  1986. begin
  1987. FV := First;
  1988. while (FV<>nil) and ((FV^.Options and ofSelectable)=0) and (FV<>Last) do
  1989. FV:=FV^.Next;
  1990. if FV<>nil then
  1991. if (FV^.Options and ofSelectable)=0 then FV:=nil;
  1992. FirstSelectable:=FV;
  1993. end;
  1994. function LastSelectable: PView;
  1995. var
  1996. LV : PView;
  1997. begin
  1998. LV := Last;
  1999. while (LV<>nil) and ((LV^.Options and ofSelectable)=0) and (LV<>First) do
  2000. LV:=LV^.Prev;
  2001. if LV<>nil then
  2002. if (LV^.Options and ofSelectable)=0 then LV:=nil;
  2003. LastSelectable:=LV;
  2004. end;
  2005. begin
  2006. if (Event.What and evMouseDown)<>0 then
  2007. begin
  2008. MakeLocal(Event.Where,P);
  2009. if P.Y<3 then
  2010. begin
  2011. Index:=-1; X:=1;
  2012. for i:=0 to DefCount-1 do
  2013. begin
  2014. Len:=CStrLen(AtTab(i)^.Name^);
  2015. if (P.X>=X) and (P.X<=X+Len+1) then Index:=i;
  2016. X:=X+Len+3;
  2017. end;
  2018. if Index<>-1 then
  2019. SelectTab(Index);
  2020. end;
  2021. end;
  2022. if Event.What=evKeyDown then
  2023. begin
  2024. Index:=-1;
  2025. case Event.KeyCode of
  2026. kbCtrlTab :
  2027. begin
  2028. SelectNextTab((Event.KeyShift and kbShift)=0);
  2029. ClearEvent(Event);
  2030. end;
  2031. kbTab,kbShiftTab :
  2032. if GetState(sfSelected) then
  2033. begin
  2034. if Current<>nil then
  2035. begin
  2036. LastV:=LastSelectable; FirstV:=FirstSelectable;
  2037. if ((Current=LastV) or (Current=PLabel(LastV)^.Link)) and (Event.KeyCode=kbShiftTab) then
  2038. begin
  2039. if Owner<>nil then Owner^.SelectNext(true);
  2040. end else
  2041. if ((Current=FirstV) or (Current=PLabel(FirstV)^.Link)) and (Event.KeyCode=kbTab) then
  2042. begin
  2043. Lock;
  2044. if Owner<>nil then Owner^.SelectNext(false);
  2045. UnLock;
  2046. end else
  2047. SelectNext(Event.KeyCode=kbShiftTab);
  2048. ClearEvent(Event);
  2049. end;
  2050. end;
  2051. else
  2052. for I:=0 to DefCount-1 do
  2053. begin
  2054. if Upcase(GetAltChar(Event.KeyCode))=AtTab(I)^.ShortCut
  2055. then begin
  2056. Index:=I;
  2057. ClearEvent(Event);
  2058. Break;
  2059. end;
  2060. end;
  2061. end;
  2062. if Index<>-1 then
  2063. begin
  2064. Select;
  2065. SelectTab(Index);
  2066. V:=AtTab(ActiveDef)^.DefItem;
  2067. if V<>nil then V^.Focus;
  2068. end;
  2069. end;
  2070. CallOrig:=true;
  2071. if Event.What=evKeyDown then
  2072. begin
  2073. if ((Owner<>nil) and (Owner^.Phase=phPostProcess) and (GetAltChar(Event.KeyCode)<>#0)) or GetState(sfFocused)
  2074. then
  2075. else CallOrig:=false;
  2076. end;
  2077. if CallOrig then inherited HandleEvent(Event);
  2078. end;
  2079. function TTab.GetPalette: PPalette;
  2080. begin
  2081. GetPalette:=nil;
  2082. end;
  2083. procedure TTab.Draw;
  2084. var B : TDrawBuffer;
  2085. i : integer;
  2086. C1,C2,C3,C : word;
  2087. HeaderLen : integer;
  2088. X,X2 : integer;
  2089. Name : PString;
  2090. ActiveKPos : integer;
  2091. ActiveVPos : integer;
  2092. FC : char;
  2093. ClipR : TRect;
  2094. procedure SWriteBuf(X,Y,W,H: integer; var Buf);
  2095. var i: integer;
  2096. begin
  2097. if Y+H>Size.Y then H:=Size.Y-Y;
  2098. if X+W>Size.X then W:=Size.X-X;
  2099. if Buffer=nil then WriteBuf(X,Y,W,H,Buf)
  2100. else for i:=1 to H do
  2101. Move(Buf,Buffer^[X+(Y+i-1)*Size.X],W*2);
  2102. end;
  2103. procedure ClearBuf;
  2104. begin
  2105. MoveChar(B,' ',C1,Size.X);
  2106. end;
  2107. begin
  2108. if InDraw then Exit;
  2109. InDraw:=true;
  2110. { - Start of TGroup.Draw - }
  2111. if Buffer = nil then
  2112. begin
  2113. GetBuffer;
  2114. end;
  2115. { - Start of TGroup.Draw - }
  2116. C1:=GetColor(1); C2:=(GetColor(7) and $f0 or $08)+GetColor(9)*256; C3:=GetColor(8)+GetColor({9}8)*256;
  2117. HeaderLen:=0; for i:=0 to DefCount-1 do HeaderLen:=HeaderLen+CStrLen(AtTab(i)^.Name^)+3; Dec(HeaderLen);
  2118. if HeaderLen>Size.X-2 then HeaderLen:=Size.X-2;
  2119. { --- 1. sor --- }
  2120. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[HeaderLen+1],'³',C1,1);
  2121. X:=1;
  2122. for i:=0 to DefCount-1 do
  2123. begin
  2124. Name:=AtTab(i)^.Name; X2:=CStrLen(Name^);
  2125. if i=ActiveDef
  2126. then begin
  2127. ActiveKPos:=X-1;
  2128. ActiveVPos:=X+X2+2;
  2129. if GetState(sfFocused) then C:=C3 else C:=C2;
  2130. end
  2131. else C:=C2;
  2132. MoveCStr(B[X],' '+Name^+' ',C); X:=X+X2+3;
  2133. MoveChar(B[X-1],'³',C1,1);
  2134. end;
  2135. SWriteBuf(0,1,Size.X,1,B);
  2136. { --- 0. sor --- }
  2137. ClearBuf; MoveChar(B[0],'Ú',C1,1);
  2138. X:=1;
  2139. for i:=0 to DefCount-1 do
  2140. begin
  2141. if I<ActiveDef then FC:='Ú'
  2142. else FC:='¿';
  2143. X2:=CStrLen(AtTab(i)^.Name^)+2;
  2144. MoveChar(B[X+X2],{'Â'}FC,C1,1);
  2145. if i=DefCount-1 then X2:=X2+1;
  2146. if X2>0 then
  2147. MoveChar(B[X],'Ä',C1,X2);
  2148. X:=X+X2+1;
  2149. end;
  2150. MoveChar(B[HeaderLen+1],'¿',C1,1);
  2151. MoveChar(B[ActiveKPos],'Ú',C1,1); MoveChar(B[ActiveVPos],'¿',C1,1);
  2152. SWriteBuf(0,0,Size.X,1,B);
  2153. { --- 2. sor --- }
  2154. MoveChar(B[1],'Ä',C1,Max(HeaderLen,0)); MoveChar(B[HeaderLen+2],'Ä',C1,Max(Size.X-HeaderLen-3,0));
  2155. MoveChar(B[Size.X-1],'¿',C1,1);
  2156. MoveChar(B[ActiveKPos],'Ù',C1,1);
  2157. if ActiveDef=0 then MoveChar(B[0],'³',C1,1)
  2158. else MoveChar(B[0],{'Ã'}'Ú',C1,1);
  2159. MoveChar(B[HeaderLen+1],'Ä'{'Á'},C1,1); MoveChar(B[ActiveVPos],'À',C1,1);
  2160. MoveChar(B[ActiveKPos+1],' ',C1,Max(ActiveVPos-ActiveKPos-1,0));
  2161. SWriteBuf(0,2,Size.X,1,B);
  2162. { --- marad‚k sor --- }
  2163. ClearBuf; MoveChar(B[0],'³',C1,1); MoveChar(B[Size.X-1],'³',C1,1);
  2164. SWriteBuf(0,3,Size.X,Size.Y-4,B);
  2165. { --- Size.X . sor --- }
  2166. MoveChar(B[0],'À',C1,1); MoveChar(B[1],'Ä',C1,Max(Size.X-2,0)); MoveChar(B[Size.X-1],'Ù',C1,1);
  2167. SWriteBuf(0,Size.Y-1,Size.X,1,B);
  2168. { - End of TGroup.Draw - }
  2169. if Buffer <> nil then
  2170. begin
  2171. Lock;
  2172. Redraw;
  2173. UnLock;
  2174. end;
  2175. if Buffer <> nil then WriteBuf(0, 0, Size.X, Size.Y, Buffer^) else
  2176. begin
  2177. GetClipRect(ClipR);
  2178. Redraw;
  2179. GetExtent(ClipR);
  2180. end;
  2181. { - End of TGroup.Draw - }
  2182. InDraw:=false;
  2183. end;
  2184. function TTab.Valid(Command: Word): Boolean;
  2185. var PT : PTabDef;
  2186. PI : PTabItem;
  2187. OK : boolean;
  2188. begin
  2189. OK:=true;
  2190. PT:=TabDefs;
  2191. while (PT<>nil) and (OK=true) do
  2192. begin
  2193. PI:=PT^.Items;
  2194. while (PI<>nil) and (OK=true) do
  2195. begin
  2196. if PI^.View<>nil then OK:=OK and PI^.View^.Valid(Command);
  2197. PI:=PI^.Next;
  2198. end;
  2199. PT:=PT^.Next;
  2200. end;
  2201. Valid:=OK;
  2202. end;
  2203. procedure TTab.SetState(AState: Word; Enable: Boolean);
  2204. begin
  2205. inherited SetState(AState,Enable);
  2206. if (AState and sfFocused)<>0 then DrawView;
  2207. end;
  2208. destructor TTab.Done;
  2209. var P,X: PTabDef;
  2210. procedure DeleteViews(P: PView); {$ifndef FPC}far;{$endif}
  2211. begin
  2212. if P<>nil then Delete(P);
  2213. end;
  2214. begin
  2215. ForEach(@DeleteViews);
  2216. inherited Done;
  2217. P:=TabDefs;
  2218. while P<>nil do
  2219. begin
  2220. X:=P^.Next;
  2221. DisposeTabDef(P);
  2222. P:=X;
  2223. end;
  2224. end;
  2225. constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  2226. AScreen: PScreen);
  2227. begin
  2228. inherited Init(Bounds,AHScrollBar,AVScrollBar);
  2229. Screen:=AScreen;
  2230. if Screen=nil then
  2231. Fail;
  2232. SetState(sfCursorVis,true);
  2233. Update;
  2234. end;
  2235. procedure TScreenView.Update;
  2236. begin
  2237. SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
  2238. DrawView;
  2239. end;
  2240. procedure TScreenView.HandleEvent(var Event: TEvent);
  2241. begin
  2242. case Event.What of
  2243. evBroadcast :
  2244. case Event.Command of
  2245. cmUpdate : Update;
  2246. end;
  2247. end;
  2248. inherited HandleEvent(Event);
  2249. end;
  2250. procedure TScreenView.Draw;
  2251. var B: TDrawBuffer;
  2252. X,Y: integer;
  2253. Text,Attr: string;
  2254. P: TPoint;
  2255. begin
  2256. Screen^.GetCursorPos(P);
  2257. for Y:=Delta.Y to Delta.Y+Size.Y-1 do
  2258. begin
  2259. if Y<Screen^.GetHeight then
  2260. Screen^.GetLine(Y,Text,Attr)
  2261. else
  2262. begin Text:=''; Attr:=''; end;
  2263. Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
  2264. MoveChar(B,' ',0,Size.X);
  2265. for X:=1 to length(Text) do
  2266. MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
  2267. WriteLine(0,Y-Delta.Y,Size.X,1,B);
  2268. end;
  2269. SetCursor(P.X-Delta.X,P.Y-Delta.Y);
  2270. end;
  2271. constructor TScreenWindow.Init(AScreen: PScreen; ANumber: integer);
  2272. var R: TRect;
  2273. VSB,HSB: PScrollBar;
  2274. begin
  2275. Desktop^.GetExtent(R);
  2276. inherited Init(R, 'User screen', ANumber);
  2277. Options:=Options or ofTileAble;
  2278. GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
  2279. New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
  2280. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2281. GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
  2282. New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
  2283. HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
  2284. GetExtent(R); R.Grow(-1,-1);
  2285. New(ScreenView, Init(R, HSB, VSB, AScreen));
  2286. ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2287. Insert(ScreenView);
  2288. UserScreenWindow:=@Self;
  2289. end;
  2290. destructor TScreenWindow.Done;
  2291. begin
  2292. inherited Done;
  2293. UserScreenWindow:=nil;
  2294. end;
  2295. const InTranslate : boolean = false;
  2296. procedure TranslateMouseClick(View: PView; var Event: TEvent);
  2297. procedure TranslateAction(Action: integer);
  2298. var E: TEvent;
  2299. begin
  2300. if Action<>acNone then
  2301. begin
  2302. E:=Event;
  2303. E.What:=evMouseDown; E.Buttons:=mbLeftButton;
  2304. View^.HandleEvent(E);
  2305. Event.What:=evCommand;
  2306. Event.Command:=ActionCommands[Action];
  2307. end;
  2308. end;
  2309. begin
  2310. if InTranslate then Exit;
  2311. InTranslate:=true;
  2312. case Event.What of
  2313. evMouseDown :
  2314. if (GetShiftState and kbAlt)<>0 then
  2315. TranslateAction(AltMouseAction) else
  2316. if (GetShiftState and kbCtrl)<>0 then
  2317. TranslateAction(CtrlMouseAction);
  2318. end;
  2319. InTranslate:=false;
  2320. end;
  2321. function GetNextEditorBounds(var Bounds: TRect): boolean;
  2322. var P: PView;
  2323. begin
  2324. P:=Desktop^.Current;
  2325. while P<>nil do
  2326. begin
  2327. if P^.HelpCtx=hcSourceWindow then Break;
  2328. P:=P^.NextView;
  2329. if P=Desktop^.Current then
  2330. begin
  2331. P:=nil;
  2332. break;
  2333. end;
  2334. end;
  2335. if P=nil then Desktop^.GetExtent(Bounds) else
  2336. begin
  2337. P^.GetBounds(Bounds);
  2338. Inc(Bounds.A.X); Inc(Bounds.A.Y);
  2339. end;
  2340. GetNextEditorBounds:=P<>nil;
  2341. end;
  2342. function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
  2343. var R: TRect;
  2344. W: PSourceWindow;
  2345. begin
  2346. if Assigned(Bounds) then R.Copy(Bounds^) else
  2347. GetNextEditorBounds(R);
  2348. PushStatus('Opening source file... ('+SmartPath(FileName)+')');
  2349. New(W, Init(R, FileName));
  2350. if W<>nil then
  2351. begin
  2352. if (CurX<>0) or (CurY<>0) then
  2353. with W^.Editor^ do
  2354. begin
  2355. SetCurPtr(CurX,CurY);
  2356. TrackCursor(true);
  2357. end;
  2358. W^.HelpCtx:=hcSourceWindow;
  2359. Desktop^.Insert(W);
  2360. Message(Application,evBroadcast,cmUpdate,nil);
  2361. end;
  2362. PopStatus;
  2363. OpenEditorWindow:=W;
  2364. end;
  2365. function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
  2366. var
  2367. V: PView;
  2368. W: PWindow;
  2369. I: integer;
  2370. D,DS : DirStr;
  2371. N,NS : NameStr;
  2372. E,ES : ExtStr;
  2373. Found : boolean;
  2374. SName : string;
  2375. function IsSearchedFile(W : PSourceWindow) : boolean;
  2376. var Found: boolean;
  2377. begin
  2378. Found:=false;
  2379. if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
  2380. begin
  2381. if (D='') then
  2382. SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
  2383. else
  2384. SName:=PSourceWindow(W)^.Editor^.FileName;
  2385. FSplit(SName,DS,NS,ES);
  2386. SName:=UpcaseStr(NS+ES);
  2387. if (E<>'') or (not tryexts) then
  2388. begin
  2389. if D<>'' then
  2390. Found:=UpCaseStr(DS)+SName=UpcaseStr(D+N+E)
  2391. else
  2392. Found:=SName=UpcaseStr(N+E);
  2393. end
  2394. else
  2395. begin
  2396. Found:=SName=UpcaseStr(N+'.pp');
  2397. if Found=false then
  2398. Found:=SName=UpcaseStr(N+'.pas');
  2399. end;
  2400. end;
  2401. IsSearchedFile:=found;
  2402. end;
  2403. function IsSearchedSource(P: PView) : boolean; {$ifndef FPC}far;{$endif}
  2404. begin
  2405. if assigned(P) and
  2406. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  2407. IsSearchedSource:=IsSearchedFile(PSourceWindow(P))
  2408. else
  2409. IsSearchedSource:=false;
  2410. end;
  2411. begin
  2412. FSplit(FileName,D,N,E);
  2413. SearchOnDesktop:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
  2414. end;
  2415. function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts:boolean): PSourceWindow;
  2416. var D : DirStr;
  2417. N : NameStr;
  2418. E : ExtStr;
  2419. DrStr : String;
  2420. function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
  2421. var OK: boolean;
  2422. begin
  2423. NewDir:=CompleteDir(NewDir);
  2424. OK:=ExistsFile(NewDir+NewName+NewExt);
  2425. if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
  2426. CheckDir:=OK;
  2427. end;
  2428. function CheckExt(NewExt: ExtStr): boolean;
  2429. var OK: boolean;
  2430. begin
  2431. OK:=false;
  2432. if D<>'' then OK:=CheckDir(D,N,NewExt) else
  2433. if CheckDir('.'+DirSep,N,NewExt) then OK:=true;
  2434. CheckExt:=OK;
  2435. end;
  2436. function TryToOpen(const DD : dirstr): PSourceWindow;
  2437. var Found: boolean;
  2438. W : PSourceWindow;
  2439. begin
  2440. D:=CompleteDir(DD);
  2441. Found:=true;
  2442. if (E<>'') or (not tryexts) then
  2443. Found:=CheckExt(E)
  2444. else
  2445. if CheckExt('.pp') then
  2446. Found:=true
  2447. else
  2448. if CheckExt('.pas') then
  2449. Found:=true
  2450. else
  2451. if CheckExt('.inc') then
  2452. Found:=true
  2453. else
  2454. Found:=false;
  2455. if Found=false then
  2456. W:=nil
  2457. else
  2458. begin
  2459. FileName:=FExpand(D+N+E);
  2460. W:=OpenEditorWindow(Bounds,FileName,CurX,CurY);
  2461. end;
  2462. TryToOpen:=W;
  2463. end;
  2464. var
  2465. W : PSourceWindow;
  2466. begin
  2467. W:=SearchOnDesktop(FileName,tryexts);
  2468. if W<>nil then
  2469. begin
  2470. NewEditorOpened:=false;
  2471. { if assigned(Bounds) then
  2472. W^.ChangeBounds(Bounds^);}
  2473. W^.Editor^.SetCurPtr(CurX,CurY);
  2474. end
  2475. else
  2476. begin
  2477. FSplit(FileName,D,N,E);
  2478. DrStr:=GetSourceDirectories;
  2479. While pos(';',DrStr)>0 do
  2480. Begin
  2481. W:=TryToOpen(Copy(DrStr,1,pos(';',DrStr)-1));
  2482. if assigned(W) then
  2483. break;
  2484. DrStr:=Copy(DrStr,pos(';',DrStr)+1,255);
  2485. End;
  2486. if not assigned(W) then
  2487. W:=TryToOpen(DrStr);
  2488. NewEditorOpened:=W<>nil;
  2489. if assigned(W) then
  2490. W^.Editor^.SetCurPtr(CurX,CurY);
  2491. end;
  2492. TryToOpenFile:=W;
  2493. end;
  2494. function StartEditor(Editor: PCodeEditor; FileName: string): boolean;
  2495. var OK: boolean;
  2496. E: PFileEditor;
  2497. R: TRect;
  2498. begin
  2499. R.Assign(0,0,0,0);
  2500. New(E, Init(R,nil,nil,nil,FileName));
  2501. OK:=E<>nil;
  2502. if OK then OK:=E^.LoadFile;
  2503. if OK then
  2504. begin
  2505. E^.SelectAll(true);
  2506. Editor^.InsertFrom(E);
  2507. Editor^.SetCurPtr(0,0);
  2508. Editor^.SelectAll(false);
  2509. Dispose(E, Done);
  2510. end;
  2511. StartEditor:=OK;
  2512. end;
  2513. constructor TTextScroller.Init(var Bounds: TRect; ASpeed: integer; AText: PUnsortedStringCollection);
  2514. begin
  2515. inherited Init(Bounds,'');
  2516. EventMask:=EventMask or evIdle;
  2517. Speed:=ASpeed; Lines:=AText;
  2518. end;
  2519. function TTextScroller.GetLineCount: integer;
  2520. var Count: integer;
  2521. begin
  2522. if Lines=nil then Count:=0 else
  2523. Count:=Lines^.Count;
  2524. GetLineCount:=Count;
  2525. end;
  2526. function TTextScroller.GetLine(I: integer): string;
  2527. var S: string;
  2528. begin
  2529. if I<Lines^.Count then
  2530. S:=GetStr(Lines^.At(I))
  2531. else
  2532. S:='';
  2533. GetLine:=S;
  2534. end;
  2535. procedure TTextScroller.HandleEvent(var Event: TEvent);
  2536. begin
  2537. case Event.What of
  2538. evIdle :
  2539. Update;
  2540. end;
  2541. inherited HandleEvent(Event);
  2542. end;
  2543. procedure TTextScroller.Update;
  2544. begin
  2545. if abs(GetDosTicks-LastTT)<Speed then Exit;
  2546. Scroll;
  2547. LastTT:=GetDosTicks;
  2548. end;
  2549. procedure TTextScroller.Reset;
  2550. begin
  2551. TopLine:=0;
  2552. LastTT:=GetDosTicks;
  2553. DrawView;
  2554. end;
  2555. procedure TTextScroller.Scroll;
  2556. begin
  2557. Inc(TopLine);
  2558. if TopLine>=GetLineCount then
  2559. Reset;
  2560. DrawView;
  2561. end;
  2562. procedure TTextScroller.Draw;
  2563. var B: TDrawBuffer;
  2564. C: word;
  2565. Count,Y: integer;
  2566. S: string;
  2567. begin
  2568. C:=GetColor(1);
  2569. Count:=GetLineCount;
  2570. for Y:=0 to Size.Y-1 do
  2571. begin
  2572. if Count=0 then S:='' else
  2573. S:=GetLine((TopLine+Y) mod Count);
  2574. if copy(S,1,1)=^C then
  2575. S:=CharStr(' ',Max(0,(Size.X-(length(S)-1)) div 2))+copy(S,2,255);
  2576. MoveChar(B,' ',C,Size.X);
  2577. MoveStr(B,S,C);
  2578. WriteLine(0,Y,Size.X,1,B);
  2579. end;
  2580. end;
  2581. destructor TTextScroller.Done;
  2582. begin
  2583. inherited Done;
  2584. if Lines<>nil then Dispose(Lines, Done);
  2585. end;
  2586. constructor TFPAboutDialog.Init;
  2587. var R,R2: TRect;
  2588. C: PUnsortedStringCollection;
  2589. I: integer;
  2590. OSStr: string;
  2591. procedure AddLine(S: string);
  2592. begin
  2593. C^.Insert(NewStr(S));
  2594. end;
  2595. begin
  2596. OSStr:='';
  2597. {$ifdef go32v2}
  2598. OSStr:='Dos';
  2599. {$endif}
  2600. {$ifdef tp}
  2601. OSStr:='Dos';
  2602. {$endif}
  2603. {$ifdef linux}
  2604. OSStr:='Linux';
  2605. {$endif}
  2606. {$ifdef win32}
  2607. OSStr:='Win32';
  2608. {$endif}
  2609. {$ifdef os2}
  2610. OSStr:='OS/2';
  2611. {$endif}
  2612. R.Assign(0,0,38,13);
  2613. inherited Init(R, 'About');
  2614. GetExtent(R); R.Grow(-3,-2);
  2615. R2.Copy(R); R2.B.Y:=R2.A.Y+1;
  2616. Insert(New(PStaticText, Init(R2, ^C'FreePascal IDE for '+OSStr)));
  2617. R2.Move(0,1);
  2618. Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr
  2619. {$ifdef FPC}+' '+{$i %date%}{$endif}
  2620. )));
  2621. R2.Move(0,1);
  2622. Insert(New(PStaticText, Init(R2, ^C'(Compiler Version '+Version_String+')')));
  2623. {$ifndef NODEBUG}
  2624. if pos('Fake',GDBVersion)=0 then
  2625. begin
  2626. R2.Move(0,1);
  2627. Insert(New(PStaticText, Init(R2, ^C'(Debugger '+GDBVersion+')')));
  2628. R2.Move(0,1);
  2629. end
  2630. else
  2631. {$endif NODEBUG}
  2632. R2.Move(0,2);
  2633. Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-2000 by')));
  2634. R2.Move(0,2);
  2635. Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
  2636. R2.Move(0,1);
  2637. Insert(New(PStaticText, Init(R2, ^C'Pierre Muller')));
  2638. R2.Move(0,1);
  2639. Insert(New(PStaticText, Init(R2, ^C'and')));
  2640. R2.Move(0,1);
  2641. Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
  2642. New(C, Init(50,10));
  2643. for I:=1 to 7 do
  2644. AddLine('');
  2645. AddLine(^C'< Original concept >');
  2646. AddLine(^C'Borland International, Inc.');
  2647. AddLine('');
  2648. AddLine(^C'< Compiler development >');
  2649. AddLine(^C'Carl-Eric Codere');
  2650. AddLine(^C'Daniel Mantione');
  2651. AddLine(^C'Florian Kl„mpfl');
  2652. AddLine(^C'Jonas Maebe');
  2653. AddLine(^C'Mich„el Van Canneyt');
  2654. AddLine(^C'Peter Vreman');
  2655. AddLine(^C'Pierre Muller');
  2656. AddLine('');
  2657. AddLine(^C'< IDE development >');
  2658. AddLine(^C'B‚rczi G bor');
  2659. AddLine(^C'Peter Vreman');
  2660. AddLine(^C'Pierre Muller');
  2661. AddLine('');
  2662. GetExtent(R);
  2663. R.Grow(-1,-1); Inc(R.A.Y,3);
  2664. New(Scroller, Init(R, 10, C));
  2665. Scroller^.Hide;
  2666. Insert(Scroller);
  2667. R.Move(0,-1); R.B.Y:=R.A.Y+1;
  2668. New(TitleST, Init(R, ^C'Team'));
  2669. TitleST^.Hide;
  2670. Insert(TitleST);
  2671. InsertOK(@Self);
  2672. end;
  2673. procedure TFPAboutDialog.ToggleInfo;
  2674. begin
  2675. if Scroller=nil then Exit;
  2676. if Scroller^.GetState(sfVisible) then
  2677. begin
  2678. Scroller^.Hide;
  2679. TitleST^.Hide;
  2680. end
  2681. else
  2682. begin
  2683. Scroller^.Reset;
  2684. Scroller^.Show;
  2685. TitleST^.Show;
  2686. end;
  2687. end;
  2688. procedure TFPAboutDialog.HandleEvent(var Event: TEvent);
  2689. begin
  2690. case Event.What of
  2691. evKeyDown :
  2692. case Event.KeyCode of
  2693. kbAltI : { just like in BP }
  2694. begin
  2695. ToggleInfo;
  2696. ClearEvent(Event);
  2697. end;
  2698. end;
  2699. end;
  2700. inherited HandleEvent(Event);
  2701. end;
  2702. constructor TFPASCIIChart.Init;
  2703. begin
  2704. inherited Init;
  2705. HelpCtx:=hcASCIITableWindow;
  2706. Number:=SearchFreeWindowNo;
  2707. ASCIIChart:=@Self;
  2708. end;
  2709. procedure TFPASCIIChart.Store(var S: TStream);
  2710. begin
  2711. inherited Store(S);
  2712. end;
  2713. constructor TFPASCIIChart.Load(var S: TStream);
  2714. begin
  2715. inherited Load(S);
  2716. end;
  2717. procedure TFPASCIIChart.HandleEvent(var Event: TEvent);
  2718. var W: PSourceWindow;
  2719. begin
  2720. case Event.What of
  2721. evKeyDown :
  2722. case Event.KeyCode of
  2723. kbEsc :
  2724. begin
  2725. Close;
  2726. ClearEvent(Event);
  2727. end;
  2728. end;
  2729. evCommand :
  2730. case Event.Command of
  2731. cmTransfer :
  2732. begin
  2733. W:=FirstEditorWindow;
  2734. if Assigned(W) and Assigned(Report) then
  2735. Message(W,evCommand,cmAddChar,pointer(ord(Report^.AsciiChar)));
  2736. ClearEvent(Event);
  2737. end;
  2738. end;
  2739. end;
  2740. inherited HandleEvent(Event);
  2741. end;
  2742. destructor TFPASCIIChart.Done;
  2743. begin
  2744. ASCIIChart:=nil;
  2745. inherited Done;
  2746. end;
  2747. function TVideoModeListBox.GetText(Item: pointer; MaxLen: sw_integer): string;
  2748. var P: PVideoModeList;
  2749. S: string;
  2750. begin
  2751. P:=Item;
  2752. S:=IntToStr(P^.Col)+'x'+IntToStr(P^.Row)+' ';
  2753. if P^.Color then
  2754. S:=S+'color'
  2755. else
  2756. S:=S+'mono';
  2757. GetText:=copy(S,1,MaxLen);
  2758. end;
  2759. constructor TFPDesktop.Load(var S: TStream);
  2760. begin
  2761. inherited Load(S);
  2762. end;
  2763. procedure TFPDesktop.Store(var S: TStream);
  2764. begin
  2765. inherited Store(S);
  2766. end;
  2767. constructor TFPToolTip.Init(var Bounds: TRect; const AText: string; AAlign: TAlign);
  2768. begin
  2769. inherited Init(Bounds);
  2770. SetAlign(AAlign);
  2771. SetText(AText);
  2772. end;
  2773. procedure TFPToolTip.Draw;
  2774. var C: word;
  2775. procedure DrawLine(Y: integer; S: string);
  2776. var B: TDrawBuffer;
  2777. begin
  2778. S:=copy(S,1,Size.X-2);
  2779. case Align of
  2780. alLeft : S:=' '+S;
  2781. alRight : S:=LExpand(' '+S,Size.X);
  2782. alCenter : S:=Center(S,Size.X);
  2783. end;
  2784. MoveChar(B,' ',C,Size.X);
  2785. MoveStr(B,S,C);
  2786. WriteLine(0,Y,Size.X,1,B);
  2787. end;
  2788. var S: string;
  2789. Y: integer;
  2790. begin
  2791. C:=GetColor(1);
  2792. S:=GetText;
  2793. for Y:=0 to Size.Y-1 do
  2794. DrawLine(Y,S);
  2795. end;
  2796. function TFPToolTip.GetText: string;
  2797. begin
  2798. GetText:=GetStr(Text);
  2799. end;
  2800. procedure TFPToolTip.SetText(const AText: string);
  2801. begin
  2802. if AText<>GetText then
  2803. begin
  2804. if Assigned(Text) then DisposeStr(Text);
  2805. Text:=NewStr(AText);
  2806. DrawView;
  2807. end;
  2808. end;
  2809. function TFPToolTip.GetAlign: TAlign;
  2810. begin
  2811. GetAlign:=Align;
  2812. end;
  2813. procedure TFPToolTip.SetAlign(AAlign: TAlign);
  2814. begin
  2815. if AAlign<>Align then
  2816. begin
  2817. Align:=AAlign;
  2818. DrawView;
  2819. end;
  2820. end;
  2821. destructor TFPToolTip.Done;
  2822. begin
  2823. if Assigned(Text) then DisposeStr(Text); Text:=nil;
  2824. inherited Done;
  2825. end;
  2826. function TFPToolTip.GetPalette: PPalette;
  2827. const S: string[length(CFPToolTip)] = CFPToolTip;
  2828. begin
  2829. GetPalette:=@S;
  2830. end;
  2831. constructor TFPCodeMemo.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
  2832. PScrollBar; AIndicator: PIndicator; ABufSize:Sw_Word);
  2833. begin
  2834. inherited Init(Bounds,AHScrollBar,AVScrollBar,AIndicator,ABufSize);
  2835. SetFlags(Flags and not (efPersistentBlocks) or efSyntaxHighlight);
  2836. end;
  2837. function TFPCodeMemo.GetPalette: PPalette;
  2838. const P: string[length(CFPCodeMemo)] = CFPCodeMemo;
  2839. begin
  2840. GetPalette:=@P;
  2841. end;
  2842. function TFPCodeMemo.GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer;
  2843. var Count: integer;
  2844. begin
  2845. case SpecClass of
  2846. ssCommentPrefix : Count:=3;
  2847. ssCommentSingleLinePrefix : Count:=1;
  2848. ssCommentSuffix : Count:=2;
  2849. ssStringPrefix : Count:=1;
  2850. ssStringSuffix : Count:=1;
  2851. ssAsmPrefix : Count:=1;
  2852. ssAsmSuffix : Count:=1;
  2853. ssDirectivePrefix : Count:=1;
  2854. ssDirectiveSuffix : Count:=1;
  2855. end;
  2856. GetSpecSymbolCount:=Count;
  2857. end;
  2858. function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
  2859. var S: string[20];
  2860. begin
  2861. case SpecClass of
  2862. ssCommentPrefix :
  2863. case Index of
  2864. 0 : S:='{';
  2865. 1 : S:='(*';
  2866. 2 : S:='//';
  2867. end;
  2868. ssCommentSingleLinePrefix :
  2869. case Index of
  2870. 0 : S:='//';
  2871. end;
  2872. ssCommentSuffix :
  2873. case Index of
  2874. 0 : S:='}';
  2875. 1 : S:='*)';
  2876. end;
  2877. ssStringPrefix :
  2878. S:='''';
  2879. ssStringSuffix :
  2880. S:='''';
  2881. ssAsmPrefix :
  2882. S:='asm';
  2883. ssAsmSuffix :
  2884. S:='end';
  2885. ssDirectivePrefix :
  2886. S:='{$';
  2887. ssDirectiveSuffix :
  2888. S:='}';
  2889. end;
  2890. GetSpecSymbol:=S;
  2891. end;
  2892. function TFPCodeMemo.IsReservedWord(const S: string): boolean;
  2893. begin
  2894. IsReservedWord:=IsFPReservedWord(S);
  2895. end;
  2896. {$ifdef VESA}
  2897. function VESASetVideoModeProc(const VideoMode: TVideoMode; Params: Longint): Boolean; {$ifndef FPC}far;{$endif}
  2898. begin
  2899. VESASetVideoModeProc:=VESASetMode(Params);
  2900. end;
  2901. procedure InitVESAScreenModes;
  2902. var ML: TVESAModeList;
  2903. MI: TVESAModeInfoBlock;
  2904. I: integer;
  2905. begin
  2906. if VESAInit=false then Exit;
  2907. if VESAGetModeList(ML)=false then Exit;
  2908. for I:=1 to ML.Count do
  2909. begin
  2910. if VESAGetModeInfo(ML.Modes[I],MI) then
  2911. with MI do
  2912. if (Attributes and vesa_vma_GraphicsMode)=0 then
  2913. RegisterVideoMode(XResolution,YResolution,
  2914. (Attributes and vesa_vma_ColorMode)<>0,{$ifdef FPC}@{$endif}VESASetVideoModeProc,ML.Modes[I]);
  2915. end;
  2916. end;
  2917. {$endif}
  2918. procedure NoDebugger;
  2919. begin
  2920. InformationBox('No debugger support available.',nil);
  2921. end;
  2922. procedure RegisterFPViews;
  2923. begin
  2924. RegisterType(RSourceEditor);
  2925. RegisterType(RSourceWindow);
  2926. RegisterType(RFPHelpViewer);
  2927. RegisterType(RFPHelpWindow);
  2928. RegisterType(RClipboardWindow);
  2929. RegisterType(RMessageListBox);
  2930. RegisterType(RFPDesktop);
  2931. RegisterType(RGDBSourceEditor);
  2932. RegisterType(RGDBWindow);
  2933. RegisterType(RFPASCIIChart);
  2934. RegisterType(RProgramInfoWindow);
  2935. end;
  2936. END.
  2937. {
  2938. $Log$
  2939. Revision 1.64 2000-03-14 13:59:41 pierre
  2940. + add a warning if Changed on loading
  2941. Revision 1.63 2000/03/13 20:39:25 pierre
  2942. * one more try to get the menu update to work correctly
  2943. * breakpoint in red at loading
  2944. Revision 1.62 2000/03/07 21:50:38 pierre
  2945. * UpdateCommands changed again, still not correct :(
  2946. Revision 1.61 2000/03/01 22:32:48 pierre
  2947. * hopfully the bug on wrong Menu config fixed
  2948. Revision 1.60 2000/02/07 23:40:38 pierre
  2949. * avoid closing the StackWindow too early
  2950. Revision 1.59 2000/02/07 10:36:43 michael
  2951. + Something went wrong when unzipping
  2952. Revision 1.58 2000/02/06 23:42:47 pierre
  2953. + Use ErrorLine on GotoSource
  2954. Revision 1.57 2000/02/04 00:03:30 pierre
  2955. + SelectInDebugSession lets CPU and watches in front
  2956. Revision 1.56 2000/02/02 22:51:49 pierre
  2957. * use desktop^.current for GetNextEditorBounds
  2958. Revision 1.55 2000/02/01 10:58:41 pierre
  2959. * avoid Search sometimes disabled for Editor Windows
  2960. Revision 1.54 2000/01/10 14:59:50 pierre
  2961. * TProgramInfo was not registered
  2962. Revision 1.53 2000/01/07 14:02:52 pierre
  2963. + date string added
  2964. Revision 1.52 2000/01/03 11:38:34 michael
  2965. Changes from Gabor
  2966. Revision 1.51 1999/12/20 14:23:17 pierre
  2967. * MyApp renamed IDEApp
  2968. * TDebugController.ResetDebuggerRows added to
  2969. get resetting of debugger rows
  2970. Revision 1.50 1999/12/16 16:55:52 pierre
  2971. * fix of web bug 756
  2972. Revision 1.49 1999/11/25 00:25:43 pierre
  2973. * add Status when loading/saving files
  2974. Revision 1.48 1999/11/22 16:02:12 pierre
  2975. * TryToOpenFile failed tofind a sourcewindow if it has no number
  2976. Revision 1.47 1999/11/18 13:39:24 pierre
  2977. * Better info for Undo debugging
  2978. Revision 1.46 1999/11/10 00:44:12 pierre
  2979. * Grouped Undo action signaled in 'Dump Undo'
  2980. Revision 1.45 1999/10/29 14:50:07 pierre
  2981. * About dialog changes
  2982. Revision 1.44 1999/10/27 12:10:42 pierre
  2983. + With DebugUndo added 3 menu items
  2984. "Dump Undo" "Undo All" and "Redo All"
  2985. for Undo checks
  2986. Revision 1.43 1999/10/25 16:55:13 pierre
  2987. * adapted to a small weditor change
  2988. Revision 1.42 1999/09/16 14:34:59 pierre
  2989. + TBreakpoint and TWatch registering
  2990. + WatchesCollection and BreakpointsCollection stored in desk file
  2991. * Syntax highlighting was broken
  2992. Revision 1.41 1999/09/13 16:24:43 peter
  2993. + clock
  2994. * backspace unident like tp7
  2995. Revision 1.40 1999/09/09 16:30:37 pierre
  2996. * ModuleNames was not created in TMessageListBox.Load
  2997. Revision 1.39 1999/09/03 12:54:07 pierre
  2998. * adapted to modified tokens unit
  2999. * TryToOpen works better
  3000. Revision 1.38 1999/08/31 16:18:33 pierre
  3001. + TGDBWindow.Load and Store + Registration
  3002. Revision 1.37 1999/08/16 18:25:26 peter
  3003. * Adjusting the selection when the editor didn't contain any line.
  3004. * Reserved word recognition redesigned, but this didn't affect the overall
  3005. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  3006. The syntax scanner loop is a bit slow but the main problem is the
  3007. recognition of special symbols. Switching off symbol processing boosts
  3008. the performance up to ca. 200%...
  3009. * The editor didn't allow copying (for ex to clipboard) of a single character
  3010. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  3011. * Compiler Messages window (actually the whole desktop) did not act on any
  3012. keypress when compilation failed and thus the window remained visible
  3013. + Message windows are now closed upon pressing Esc
  3014. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  3015. only when neccessary
  3016. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  3017. + LineSelect (Ctrl+K+L) implemented
  3018. * The IDE had problems closing help windows before saving the desktop
  3019. Revision 1.36 1999/08/03 20:22:39 peter
  3020. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  3021. + Desktop saving should work now
  3022. - History saved
  3023. - Clipboard content saved
  3024. - Desktop saved
  3025. - Symbol info saved
  3026. * syntax-highlight bug fixed, which compared special keywords case sensitive
  3027. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  3028. * with 'whole words only' set, the editor didn't found occourences of the
  3029. searched text, if the text appeared previously in the same line, but didn't
  3030. satisfied the 'whole-word' condition
  3031. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  3032. (ie. the beginning of the selection)
  3033. * when started typing in a new line, but not at the start (X=0) of it,
  3034. the editor inserted the text one character more to left as it should...
  3035. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  3036. * Shift shouldn't cause so much trouble in TCodeEditor now...
  3037. * Syntax highlight had problems recognizing a special symbol if it was
  3038. prefixed by another symbol character in the source text
  3039. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  3040. Revision 1.35 1999/07/12 13:14:22 pierre
  3041. * LineEnd bug corrected, now goes end of text even if selected
  3042. + Until Return for debugger
  3043. + Code for Quit inside GDB Window
  3044. Revision 1.34 1999/06/30 23:58:20 pierre
  3045. + BreakpointsList Window implemented
  3046. with Edit/New/Delete functions
  3047. + Individual breakpoint dialog with support for all types
  3048. ignorecount and conditions
  3049. (commands are not yet implemented, don't know if this wolud be useful)
  3050. awatch and rwatch have problems because GDB does not annotate them
  3051. I fixed v4.16 for this
  3052. Revision 1.33 1999/06/28 19:32:28 peter
  3053. * fixes from gabor
  3054. Revision 1.32 1999/06/21 23:37:08 pierre
  3055. * VESASetVideoModeProc return value was not set
  3056. Revision 1.31 1999/06/02 11:19:13 pierre
  3057. * @ is now required for FPC for procedure address passing in functions
  3058. Revision 1.30 1999/05/22 13:44:33 peter
  3059. * fixed couple of bugs
  3060. Revision 1.29 1999/04/15 08:58:08 peter
  3061. * syntax highlight fixes
  3062. * browser updates
  3063. Revision 1.28 1999/04/07 21:55:56 peter
  3064. + object support for browser
  3065. * html help fixes
  3066. * more desktop saving things
  3067. * NODEBUG directive to exclude debugger
  3068. Revision 1.27 1999/04/01 10:27:06 pierre
  3069. + file(line) in start of message added
  3070. Revision 1.26 1999/03/23 16:16:41 peter
  3071. * linux fixes
  3072. Revision 1.25 1999/03/23 15:11:37 peter
  3073. * desktop saving things
  3074. * vesa mode
  3075. * preferences dialog
  3076. Revision 1.24 1999/03/21 22:51:37 florian
  3077. + functional screen mode switching added
  3078. Revision 1.23 1999/03/19 16:04:33 peter
  3079. * new compiler dialog
  3080. Revision 1.22 1999/03/16 00:44:45 peter
  3081. * forgotten in last commit :(
  3082. Revision 1.21 1999/03/08 14:58:16 peter
  3083. + prompt with dialogs for tools
  3084. Revision 1.20 1999/03/01 15:42:08 peter
  3085. + Added dummy entries for functions not yet implemented
  3086. * MenuBar didn't update itself automatically on command-set changes
  3087. * Fixed Debugging/Profiling options dialog
  3088. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is set
  3089. * efBackSpaceUnindents works correctly
  3090. + 'Messages' window implemented
  3091. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  3092. + Added TP message-filter support (for ex. you can call GREP thru
  3093. GREP2MSG and view the result in the messages window - just like in TP)
  3094. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  3095. so topic search didn't work...
  3096. * In FPHELP.PAS there were still context-variables defined as word instead
  3097. of THelpCtx
  3098. * StdStatusKeys() was missing from the statusdef for help windows
  3099. + Topic-title for index-table can be specified when adding a HTML-files
  3100. Revision 1.19 1999/02/22 11:51:39 peter
  3101. * browser updates from gabor
  3102. Revision 1.18 1999/02/22 11:29:38 pierre
  3103. + added col info in MessageItem
  3104. + grep uses HighLightExts and should work for linux
  3105. Revision 1.17 1999/02/22 02:15:22 peter
  3106. + default extension for save in the editor
  3107. + Separate Text to Find for the grep dialog
  3108. * fixed redir crash with tp7
  3109. Revision 1.16 1999/02/19 18:43:49 peter
  3110. + open dialog supports mask list
  3111. Revision 1.15 1999/02/17 15:04:02 pierre
  3112. + file(line) added in TProgramInfo message list
  3113. Revision 1.14 1999/02/16 12:45:18 pierre
  3114. * GDBWindow size and grow corrected
  3115. Revision 1.13 1999/02/15 09:36:06 pierre
  3116. * // comment ends at end of line !
  3117. GDB window changed !
  3118. now all is in a normal text editor, but pressing
  3119. Enter key will send part of line before cursor to GDB !
  3120. Revision 1.12 1999/02/11 19:07:25 pierre
  3121. * GDBWindow redesigned :
  3122. normal editor apart from
  3123. that any kbEnter will send the line (for begin to cursor)
  3124. to GDB command !
  3125. GDBWindow opened in Debugger Menu
  3126. still buggy :
  3127. -echo should not be present if at end of text
  3128. -GDBWindow becomes First after each step (I don't know why !)
  3129. Revision 1.11 1999/02/11 13:08:39 pierre
  3130. + TGDBWindow : direct gdb input/output
  3131. Revision 1.10 1999/02/10 09:42:52 pierre
  3132. + DoneReservedWords to avoid memory leaks
  3133. * TMessageItem Module field was not disposed
  3134. Revision 1.9 1999/02/05 12:12:02 pierre
  3135. + SourceDir that stores directories for sources that the
  3136. compiler should not know about
  3137. Automatically asked for addition when a new file that
  3138. needed filedialog to be found is in an unknown directory
  3139. Stored and retrieved from INIFile
  3140. + Breakpoints conditions added to INIFile
  3141. * Breakpoints insterted and removed at debin and end of debug session
  3142. Revision 1.8 1999/02/04 17:45:23 pierre
  3143. + BrowserAtCursor started
  3144. * bug in TryToOpenFile removed
  3145. Revision 1.7 1999/02/04 13:32:11 pierre
  3146. * Several things added (I cannot commit them independently !)
  3147. + added TBreakpoint and TBreakpointCollection
  3148. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  3149. + Breakpoint list in INIFile
  3150. * Select items now also depend of SwitchMode
  3151. * Reading of option '-g' was not possible !
  3152. + added search for -Fu args pathes in TryToOpen
  3153. + added code for automatic opening of FileDialog
  3154. if source not found
  3155. Revision 1.6 1999/01/21 11:54:27 peter
  3156. + tools menu
  3157. + speedsearch in symbolbrowser
  3158. * working run command
  3159. Revision 1.5 1999/01/14 21:42:25 peter
  3160. * source tracking from Gabor
  3161. Revision 1.4 1999/01/12 14:29:42 peter
  3162. + Implemented still missing 'switch' entries in Options menu
  3163. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  3164. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  3165. ASCII chars and inserted directly in the text.
  3166. + Added symbol browser
  3167. * splitted fp.pas to fpide.pas
  3168. Revision 1.3 1999/01/04 11:49:53 peter
  3169. * 'Use tab characters' now works correctly
  3170. + Syntax highlight now acts on File|Save As...
  3171. + Added a new class to syntax highlight: 'hex numbers'.
  3172. * There was something very wrong with the palette managment. Now fixed.
  3173. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  3174. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  3175. process revised
  3176. Revision 1.2 1998/12/28 15:47:54 peter
  3177. + Added user screen support, display & window
  3178. + Implemented Editor,Mouse Options dialog
  3179. + Added location of .INI and .CFG file
  3180. + Option (INI) file managment implemented (see bottom of Options Menu)
  3181. + Switches updated
  3182. + Run program
  3183. Revision 1.4 1998/12/22 10:39:53 peter
  3184. + options are now written/read
  3185. + find and replace routines
  3186. }