fpviews.pas 124 KB

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