2
0

fpviews.pas 126 KB

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