From 694d469e5ec65fcd309d4b14d1851775729663fc Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 8 Sep 2006 15:24:58 +0000 Subject: [PATCH] IDEIntf: added revert editor file function, h2pas gui: added tools for extern c and empty c macros git-svn-id: trunk@9839 - --- components/codetools/basiccodetools.pas | 2 +- components/h2pas/h2pasconvert.pas | 217 +++++++++++++++++++++-- components/h2pas/h2pasdlg.lfm | 4 +- components/h2pas/h2pasdlg.lrs | 10 +- components/h2pas/h2pasdlg.pas | 17 +- components/h2pas/idetextconvlistedit.lfm | 129 ++++++-------- components/h2pas/idetextconvlistedit.lrs | 97 +++++----- components/h2pas/idetextconvlistedit.pas | 2 + ide/buildmanager.pas | 5 +- ide/main.pp | 52 ++++-- ide/mainintf.pas | 1 - ide/msgview.pp | 24 +-- ide/sourceeditprocs.pas | 2 +- ideintf/idetextconverter.pas | 31 ++-- ideintf/lazideintf.pas | 2 + ideintf/objectinspector.pp | 82 +++++++-- ideintf/propedits.pp | 13 +- ideintf/texttools.pas | 21 ++- packager/packagesystem.pas | 16 +- packager/pkgmanager.pas | 2 +- 20 files changed, 504 insertions(+), 225 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 60fa2de7d0..f8ef2b1a7d 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -3291,7 +3291,7 @@ begin CurPos:=@Src[StartPos]; while (CurPosSrc) or (IsNonWordChar[PChar(CurPos-1)^])) + and ((not WholeWords) or (CurPos=Src) or (IsNonWordChar[PChar(CurPos-1)^])) then begin CmpSearch:=Search; CmpSrc:=CurPos; diff --git a/components/h2pas/h2pasconvert.pas b/components/h2pas/h2pasconvert.pas index 9960788363..d3dc601bbc 100644 --- a/components/h2pas/h2pasconvert.pas +++ b/components/h2pas/h2pasconvert.pas @@ -24,11 +24,31 @@ interface uses Classes, SysUtils, LCLProc, LResources, LazConfigStorage, XMLPropStorage, - Forms, Controls, Dialogs, FileUtil, FileProcs, - TextTools, IDEExternToolIntf, IDEDialogs, LazIDEIntf, IDEMsgIntf, - IDETextConverter; + Forms, Controls, Dialogs, FileUtil, FileProcs, AvgLvlTree, + // CodeTools + BasicCodeTools, + // IDEIntf + TextTools, IDEExternToolIntf, IDEDialogs, LazIDEIntf, + IDEMsgIntf, IDETextConverter; type + + { TRemoveCPlusPlusExternCTool } + + TRemoveCPlusPlusExternCTool = class(TCustomTextConverterTool) + public + class function ClassDescription: string; override; + function Execute(aText: TIDETextConverter): TModalResult; override; + end; + + { TRemoveEmptyCMacrosTool } + + TRemoveEmptyCMacrosTool = class(TCustomTextConverterTool) + public + class function ClassDescription: string; override; + function Execute(aText: TIDETextConverter): TModalResult; override; + end; + TH2PasProject = class; TH2PasConverter = class; @@ -120,7 +140,7 @@ type public constructor Create; destructor Destroy; override; - procedure Clear; + procedure Clear(AddDefaults: boolean); procedure Assign(Source: TPersistent); override; function IsEqual(AProject: TH2PasProject): boolean; procedure Load(Config: TConfigStorage); @@ -135,6 +155,7 @@ type function LongenFilename(const AFilename: string): string; function NormalizeFilename(const AFilename: string): string; function HasEnabledFiles: boolean; + procedure AddDefaultPreH2PasTools; public property CHeaderFileCount: integer read GetCHeaderFileCount; property CHeaderFiles[Index: integer]: TH2PasFile read GetCHeaderFiles; @@ -562,20 +583,19 @@ end; constructor TH2PasProject.Create; begin FCHeaderFiles:=TFPList.Create; - FPreH2PasTools:=TComponent.Create(nil); - Clear; + Clear(true); end; destructor TH2PasProject.Destroy; begin - Clear; + Clear(false); if (Converter<>nil) and (Converter.Project=Self) then Converter.Project:=nil; FreeAndNil(FCHeaderFiles); inherited Destroy; end; -procedure TH2PasProject.Clear; +procedure TH2PasProject.Clear(AddDefaults: boolean); begin // FFilename is kept FConstantsInsteadOfEnums:=true; @@ -600,6 +620,8 @@ begin CHeaderFiles[CHeaderFileCount-1].Free; FPreH2PasTools.Free; FPreH2PasTools:=TComponent.Create(nil); + if AddDefaults then + AddDefaultPreH2PasTools; FModified:=false; end; @@ -633,7 +655,7 @@ begin FVarParams:=Src.FVarParams; FWin32Header:=Src.FWin32Header; FOutputDirectory:=Src.FOutputDirectory; - Clear; + Clear(false); for i:=0 to Src.CHeaderFileCount-1 do begin NewCHeaderFile:=TH2PasFile.Create; NewCHeaderFile.Project:=Self; @@ -694,7 +716,7 @@ var NewCHeaderFile: TH2PasFile; NewComponent: TComponent; begin - Clear; + Clear(false); // FFilename is not saved FConstantsInsteadOfEnums:=Config.GetValue('ConstantsInsteadOfEnums/Value',true); @@ -924,6 +946,12 @@ begin Result:=false; end; +procedure TH2PasProject.AddDefaultPreH2PasTools; +begin + TRemoveCPlusPlusExternCTool.Create(FPreH2PasTools); + TRemoveEmptyCMacrosTool.Create(FPreH2PasTools); +end; + { TH2PasConverter } procedure TH2PasConverter.OnParseH2PasLine(Sender: TObject; @@ -1181,16 +1209,16 @@ begin OutputFilename:=AFile.GetOutputFilename; TempCHeaderFilename:=ChangeFileExt(OutputFilename,'.tmp.h'); - if not CopyFile(InputFilename,TempCHeaderFilename) then begin - Result:=IDEMessageDialog('Copying file failed', - 'Unable to copy file "'+InputFilename+'"'#13 - +'to "'+TempCHeaderFilename+'"', - mtError,[mbCancel,mbAbort],''); - exit; - end; - TextConverter:=TIDETextConverter.Create(nil); try + if not CopyFile(InputFilename,TempCHeaderFilename) then begin + Result:=IDEMessageDialog('Copying file failed', + 'Unable to copy file "'+InputFilename+'"'#13 + +'to "'+TempCHeaderFilename+'"', + mtError,[mbCancel,mbAbort],''); + exit; + end; + TextConverter.Filename:=TempCHeaderFilename; FLastUsedFilename:=TextConverter.Filename; TextConverter.LoadFromFile(InputFilename); @@ -1229,6 +1257,8 @@ begin finally TextConverter.Free; + if (LazarusIDE<>nil) then + LazarusIDE.DoRevertEditorFile(TempCHeaderFilename); end; Result:=mrOk; @@ -1275,6 +1305,157 @@ begin or ((Project<>nil) and (Project.CHeaderFileWithFilename(aFilename)<>nil)); end; +{ TRemoveCPlusPlusExternCTool } + +function TRemoveCPlusPlusExternCTool.ClassDescription: string; +begin + Result:='Remove C++ ''extern "C"'' lines'; +end; + +function TRemoveCPlusPlusExternCTool.Execute(aText: TIDETextConverter + ): TModalResult; +var + i: Integer; + Lines: TStrings; + Line: string; +begin + Result:=mrCancel; + if aText=nil then exit; + Lines:=aText.Strings; + i:=0; + while i<=Lines.Count-1 do begin + Line:=Trim(Lines[i]); + if Line='extern "C" {' then begin + Lines[i]:=''; + end + else if (i>0) and (Line='}') and (Lines[i-1]='#if defined(__cplusplus)') + then begin + Lines[i]:=''; + end; + inc(i); + end; + Result:=mrOk; +end; + +{ TRemoveEmptyCMacrosTool } + +function TRemoveEmptyCMacrosTool.ClassDescription: string; +begin + Result:='Remove empty C macros'; +end; + +function TRemoveEmptyCMacrosTool.Execute(aText: TIDETextConverter + ): TModalResult; +var + EmptyMacros: TAvgLvlTree;// tree of PChar + + procedure AddEmptyMacro(const MacroName: string); + var + TempStr: String; + Identifier: PChar; + begin + DebugLn(['AddEmptyMacro MacroName="',MacroName,'"']); + if EmptyMacros=nil then + EmptyMacros:=TAvgLvlTree.Create(TListSortCompare(@CompareIdentifiers)); + Identifier:=@MacroName[1]; + if EmptyMacros.Find(Identifier)<>nil then exit; + TempStr:=MacroName; // increase refcount + if TempStr<>'' then + Pointer(TempStr):=nil; + EmptyMacros.Add(Identifier); + end; + + procedure DeleteEmptyMacro(const MacroName: string); + var + OldMacroName: String; + Identifier: PChar; + Node: TAvgLvlTreeNode; + begin + DebugLn(['DeleteEmptyMacro MacroName="',MacroName,'"']); + if EmptyMacros=nil then exit; + Identifier:=@MacroName[1]; + Node:=EmptyMacros.Find(Identifier); + if Node=nil then exit; + OldMacroName:=''; + Pointer(OldMacroName):=Node.Data; + if OldMacroName<>'' then OldMacroName:=''; // decrease refcount + EmptyMacros.Delete(Node); + end; + + procedure FreeMacros; + var + CurMacroName: String; + Node: TAvgLvlTreeNode; + begin + if EmptyMacros=nil then exit; + CurMacroName:=''; + Node:=EmptyMacros.FindLowest; + while Node<>nil do begin + Pointer(CurMacroName):=Node.Data; + if CurMacroName<>'' then CurMacroName:=''; // decrease refcount + Node:=EmptyMacros.FindSuccessor(Node); + end; + EmptyMacros.Free; + end; + + procedure RemoveEmptyMacrosFromString(var s: string); + var + IdentEnd: Integer; + IdentStart: LongInt; + Identifier: PChar; + IdentLen: LongInt; + begin + if EmptyMacros=nil then exit; + IdentEnd:=1; + repeat + IdentStart:=FindNextIdentifier(s,IdentEnd,length(s)); + if IdentStart>length(s) then exit; + Identifier:=@s[IdentStart]; + IdentLen:=GetIdentLen(Identifier); + if EmptyMacros.Find(Identifier)<>nil then begin + // empty macro found -> remove + System.Delete(s,IdentStart,IdentLen); + IdentEnd:=IdentStart; + end else begin + IdentEnd:=IdentStart+IdentLen; + end; + until false; + end; + +var + MacroStart, MacroLen: integer; + Lines: TStrings; + i: Integer; + Line: string; + MacroName: String; +begin + Result:=mrCancel; + if aText=nil then exit; + Lines:=aText.Strings; + EmptyMacros:=nil; + try + i:=0; + while i<=Lines.Count-1 do begin + Line:=Lines[i]; + if REMatches(Line,'^#define\s+([a-zA-Z0-9_]+)\b(.*)$') then begin + REVarPos(1,MacroStart,MacroLen); + MacroName:=copy(Line,MacroStart,MacroLen); + if Trim(copy(Line,MacroStart+MacroLen,length(Line)))='' then + AddEmptyMacro(MacroName) + else + DeleteEmptyMacro(MacroName); + end; + if (Line<>'') and (Line[1]<>'#') then + RemoveEmptyMacrosFromString(Line); + Lines[i]:=Line; + inc(i); + end; + finally + FreeMacros; + end; + Result:=mrOk; +end; + end. diff --git a/components/h2pas/h2pasdlg.lfm b/components/h2pas/h2pasdlg.lfm index d457709f0c..43633fdb3a 100644 --- a/components/h2pas/h2pasdlg.lfm +++ b/components/h2pas/h2pasdlg.lfm @@ -16,10 +16,10 @@ object H2PasDialog: TH2PasDialog AnchorSideBottom.Control = OpenSettingsButton Height = 465 Width = 785 - ActivePage = FilesTabSheet + ActivePage = SettingsTabSheet Align = alTop Anchors = [akTop, akLeft, akRight, akBottom] - TabIndex = 0 + TabIndex = 3 TabOrder = 4 object FilesTabSheet: TTabSheet Caption = 'FilesTabSheet' diff --git a/components/h2pas/h2pasdlg.lrs b/components/h2pas/h2pasdlg.lrs index 56b7dc596a..ab19f1f4b6 100644 --- a/components/h2pas/h2pasdlg.lrs +++ b/components/h2pas/h2pasdlg.lrs @@ -7,11 +7,11 @@ LazarusResources.Add('TH2PasDialog','FORMDATA',[ +#7#14'FormCloseQuery'#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDes' +'troy'#9'OnKeyDown'#7#11'FormKeyDown'#8'Position'#7#15'poDesktopCenter'#0#12 +'TPageControl'#15'MainPageControl'#24'AnchorSideBottom.Control'#7#18'OpenSet' - +'tingsButton'#6'Height'#3#209#1#5'Width'#3#17#3#10'ActivePage'#7#13'FilesTab' - +'Sheet'#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'ak' - +'Bottom'#0#8'TabIndex'#2#0#8'TabOrder'#2#4#0#9'TTabSheet'#13'FilesTabSheet'#7 - +'Caption'#6#13'FilesTabSheet'#0#13'TCheckListBox'#24'CHeaderFilesCheckListBo' - +'x'#6'Height'#3#179#1#5'Width'#3#255#0#5'Align'#7#6'alLeft'#7'OnClick'#7#29 + +'tingsButton'#6'Height'#3#209#1#5'Width'#3#17#3#10'ActivePage'#7#16'Settings' + +'TabSheet'#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8 + +'akBottom'#0#8'TabIndex'#2#3#8'TabOrder'#2#4#0#9'TTabSheet'#13'FilesTabSheet' + +#7'Caption'#6#13'FilesTabSheet'#0#13'TCheckListBox'#24'CHeaderFilesCheckList' + +'Box'#6'Height'#3#179#1#5'Width'#3#255#0#5'Align'#7#6'alLeft'#7'OnClick'#7#29 +'CHeaderFilesCheckListBoxClick'#11'OnItemClick'#7'!CHeaderFilesCheckListBoxI' +'temClick'#8'TabOrder'#2#0#8'TopIndex'#2#255#0#0#7'TButton'#21'AddCHeaderFil' +'esButton'#22'AnchorSideLeft.Control'#7#21'CHeaderFilesSplitter1'#19'AnchorS' diff --git a/components/h2pas/h2pasdlg.pas b/components/h2pas/h2pasdlg.pas index 1171e91e7c..1b2d3992f1 100644 --- a/components/h2pas/h2pasdlg.pas +++ b/components/h2pas/h2pasdlg.pas @@ -176,13 +176,17 @@ var Key: TIDEShortCut; Cat: TIDECommandCategory; begin + // register IDE shortcut and menu item Key := IDEShortCut(VK_UNKNOWN,[],VK_UNKNOWN,[]); - Cat:=IDECommandList.FindCategoryByName(CommandCategoryToolMenuName); CmdH2PasTool := RegisterIDECommand(Cat , h2pH2Pas, h2pCreateUnitsFromCHeaderFiles, Key, nil, @ExecuteH2PasTool); RegisterIDEMenuCommand(itmSecondaryTools, h2pH2PasTool, h2pH2Pas, nil, nil, CmdH2PasTool); + + // register text converter tools + TextConverterToolClasses.RegisterClass(TRemoveCPlusPlusExternCTool); + TextConverterToolClasses.RegisterClass(TRemoveEmptyCMacrosTool); end; { TH2PasDialog } @@ -200,7 +204,7 @@ begin h2pasOptionsCheckGroup.Caption:='Options'; with h2pasOptionsCheckGroup.Items do begin Add('-d '+'Use external; for all procedures'); - Add('-D '+'Use external libname name "func_name" for functions'); + Add('-D '+'Use external libname name "func__name" for functions'); Add('-e '+'constants instead of enumeration type for C enums'); Add('-c '+'Compact outputmode, less spaces and empty lines'); Add('-i '+'Create an include file instead of a unit'); @@ -210,10 +214,10 @@ begin Add('-s '+'Strip comments'); Add('-S '+'Strip comments and info'); Add('-t '+'Prepend typedef types with T'); - Add('-T '+'Prepend typedef types with T, and remove _'); + Add('-T '+'Prepend typedef types with T, and remove __'); Add('-v '+'Replace pointer parameters by var'); Add('-w '+'Handle special win32 macros'); - Add('-x '+'Handle SYS_TRAP of the PalmOS header files'); + Add('-x '+'Handle SYS__TRAP of the PalmOS header files'); end; OutputExtLabel.Caption:='Output extension of new file'; OutputDirLabel.Caption:='Output directory'; @@ -386,7 +390,7 @@ end; procedure TH2PasDialog.NewSettingsButtonClick(Sender: TObject); begin Project.Filename:=''; - Project.Clear; + Project.Clear(true); UpdateAll; end; @@ -705,6 +709,7 @@ procedure TH2PasDialog.UpdateConvertPage; begin ClearMessages; PreH2PasEdit.ListOfTools:=Project.PreH2PasTools; + //DebugLn(['TH2PasDialog.UpdateConvertPage PreH2PasEdit.ListOfTools=',PreH2PasEdit.ListOfTools.COmponentCount]); end; procedure TH2PasDialog.UpdateSettingsPage; @@ -968,7 +973,7 @@ begin end; end else begin // new project - Project.Clear; + Project.Clear(true); Converter.CurrentProjectFilename:=NewFilename; Project.Filename:=NewFilename; end; diff --git a/components/h2pas/idetextconvlistedit.lfm b/components/h2pas/idetextconvlistedit.lfm index 2b1fe0ec2e..a70000d22a 100644 --- a/components/h2pas/idetextconvlistedit.lfm +++ b/components/h2pas/idetextconvlistedit.lfm @@ -1,33 +1,25 @@ object TextConvListEditor: TTextConvListEditor - ActiveControl = ToolsListBox - Caption = 'TextConvListEditor' - ClientHeight = 227 - ClientWidth = 519 - Constraints.MinHeight = 200 - Constraints.MinWidth = 400 - OnCreate = FormCreate - PixelsPerInch = 75 - HorzScrollBar.Page = 518 - VertScrollBar.Page = 226 Left = 290 Height = 227 Top = 202 Width = 519 + HorzScrollBar.Page = 518 + VertScrollBar.Page = 226 + ActiveControl = ToolsListBox + Caption = 'TextConvListEditor' + Constraints.MinHeight = 200 + Constraints.MinWidth = 400 + OnCreate = FormCreate object ToolsLabel: TLabel - Caption = 'ToolsLabel' - Color = clNone - ParentColor = False Left = 12 Height = 13 Top = 9 Width = 62 + Caption = 'ToolsLabel' + Color = clNone + ParentColor = False end object ToolsListBox: TListBox - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Top = 2 - OnSelectionChange = ToolsListBoxSelectionChange - TabOrder = 0 - TopIndex = -1 AnchorSideTop.Control = ToolsLabel AnchorSideTop.Side = asrBottom AnchorSideRight.Control = ToolsSplitter @@ -35,34 +27,25 @@ object TextConvListEditor: TTextConvListEditor Height = 120 Top = 24 Width = 232 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + OnSelectionChange = ToolsListBoxSelectionChange + TabOrder = 0 + TopIndex = -1 end object UpDownSplitter: TSplitter - Align = alNone - Anchors = [akTop, akLeft, akRight] - Beveled = True - Cursor = crVSplit - Height = 5 - Width = 519 - ResizeAnchor = akBottom AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Cursor = crVSplit Height = 5 Top = 144 Width = 519 + Align = alNone + Anchors = [akTop, akLeft, akRight] + Beveled = True + ResizeAnchor = akBottom end object ToolsPanel: TPanel - Anchors = [akTop, akLeft, akRight, akBottom] - BevelOuter = bvNone - ChildSizing.LeftRightSpacing = 6 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.HorizontalSpacing = 6 - ChildSizing.VerticalSpacing = 6 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 2 - ClientHeight = 144 - ClientWidth = 283 - TabOrder = 1 AnchorSideLeft.Control = ToolsSplitter AnchorSideLeft.Side = asrBottom AnchorSideRight.Control = Owner @@ -71,90 +54,96 @@ object TextConvListEditor: TTextConvListEditor Left = 236 Height = 144 Width = 283 + Anchors = [akTop, akLeft, akRight, akBottom] + BevelOuter = bvNone + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 6 + ChildSizing.VerticalSpacing = 6 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + TabOrder = 1 object AddToolButton: TButton + Left = 6 + Height = 26 + Top = 6 + Width = 120 BorderSpacing.InnerBorder = 4 Caption = 'AddToolButton' OnClick = AddToolButtonClick TabOrder = 0 - Left = 6 - Height = 26 - Top = 6 - Width = 120 end object DeleteToolButton: TButton + Left = 132 + Height = 26 + Top = 6 + Width = 137 BorderSpacing.InnerBorder = 4 Caption = 'DeleteToolButton' OnClick = DeleteToolButtonClick TabOrder = 1 - Left = 132 - Height = 26 - Top = 6 - Width = 137 end object MoveToolUpButton: TButton + Left = 6 + Height = 26 + Top = 38 + Width = 120 BorderSpacing.InnerBorder = 4 Caption = 'MoveToolUpButton' OnClick = MoveToolUpButtonClick TabOrder = 2 - Left = 6 - Height = 26 - Top = 38 - Width = 120 end object MoveToolDownButton: TButton + Left = 132 + Height = 26 + Top = 38 + Width = 137 BorderSpacing.InnerBorder = 4 Caption = 'MoveToolDownButton' OnClick = MoveToolDownButtonClick TabOrder = 3 - Left = 132 - Height = 26 - Top = 38 - Width = 137 end object CopyToolButton: TButton + Left = 6 + Height = 26 + Top = 70 + Width = 120 BorderSpacing.InnerBorder = 4 Caption = 'CopyToolButton' OnClick = CopyToolButtonClick TabOrder = 4 - Left = 6 - Height = 26 - Top = 70 - Width = 120 end object PasteButton: TButton - BorderSpacing.InnerBorder = 4 - Caption = 'PasteButton' - OnClick = PasteButtonClick - TabOrder = 5 Left = 132 Height = 26 Top = 70 Width = 137 + BorderSpacing.InnerBorder = 4 + Caption = 'PasteButton' + OnClick = PasteButtonClick + TabOrder = 5 end object CloneButton: TButton - BorderSpacing.InnerBorder = 4 - Caption = 'CloneButton' - OnClick = CloneButtonClick - TabOrder = 6 Left = 6 Height = 26 Top = 102 Width = 120 + BorderSpacing.InnerBorder = 4 + Caption = 'CloneButton' + OnClick = CloneButtonClick + TabOrder = 6 end end object ToolsSplitter: TSplitter - Align = alNone - Anchors = [akTop, akLeft, akBottom] - Beveled = True - Height = 144 - Width = 4 AnchorSideTop.Control = Owner AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = UpDownSplitter - Cursor = crHSplit Left = 232 Height = 144 Width = 4 + Align = alNone + Anchors = [akTop, akLeft, akBottom] + Beveled = True end end diff --git a/components/h2pas/idetextconvlistedit.lrs b/components/h2pas/idetextconvlistedit.lrs index 4844c61c77..b1e2130faf 100644 --- a/components/h2pas/idetextconvlistedit.lrs +++ b/components/h2pas/idetextconvlistedit.lrs @@ -1,56 +1,53 @@ { Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei } LazarusResources.Add('TTextConvListEditor','FORMDATA',[ - 'TPF0'#19'TTextConvListEditor'#18'TextConvListEditor'#13'ActiveControl'#7#12 - +'ToolsListBox'#7'Caption'#6#18'TextConvListEditor'#12'ClientHeight'#3#227#0 - +#11'ClientWidth'#3#7#2#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinW' - +'idth'#3#144#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'K'#18'HorzSc' - +'rollBar.Page'#3#6#2#18'VertScrollBar.Page'#3#226#0#4'Left'#3'"'#1#6'Height' - +#3#227#0#3'Top'#3#202#0#5'Width'#3#7#2#0#6'TLabel'#10'ToolsLabel'#7'Caption' - +#6#10'ToolsLabel'#5'Color'#7#6'clNone'#11'ParentColor'#8#4'Left'#2#12#6'Heig' - +'ht'#2#13#3'Top'#2#9#5'Width'#2'>'#0#0#8'TListBox'#12'ToolsListBox'#7'Anchor' - +'s'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#17'BorderSpacing.Top'#2#2 - +#17'OnSelectionChange'#7#27'ToolsListBoxSelectionChange'#8'TabOrder'#2#0#8'T' - +'opIndex'#2#255#21'AnchorSideTop.Control'#7#10'ToolsLabel'#18'AnchorSideTop.' - +'Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#13'ToolsSplitter'#24'Anc' - +'horSideBottom.Control'#7#14'UpDownSplitter'#6'Height'#2'x'#3'Top'#2#24#5'Wi' - +'dth'#3#232#0#0#0#9'TSplitter'#14'UpDownSplitter'#5'Align'#7#6'alNone'#7'Anc' - +'hors'#11#5'akTop'#6'akLeft'#7'akRight'#0#7'Beveled'#9#6'Cursor'#7#8'crVSpli' - +'t'#6'Height'#2#5#5'Width'#3#7#2#12'ResizeAnchor'#7#8'akBottom'#23'AnchorSid' - +'eRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#6'Cursor' - +#7#8'crVSplit'#6'Height'#2#5#3'Top'#3#144#0#5'Width'#3#7#2#0#0#6'TPanel'#10 - +'ToolsPanel'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#10'Be' - +'velOuter'#7#6'bvNone'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.T' - +'opBottomSpacing'#2#6#29'ChildSizing.HorizontalSpacing'#2#6#27'ChildSizing.V' - +'erticalSpacing'#2#6#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBott' - +'om'#27'ChildSizing.ControlsPerLine'#2#2#12'ClientHeight'#3#144#0#11'ClientW' - +'idth'#3#27#1#8'TabOrder'#2#1#22'AnchorSideLeft.Control'#7#13'ToolsSplitter' + 'TPF0'#19'TTextConvListEditor'#18'TextConvListEditor'#4'Left'#3'"'#1#6'Height' + +#3#227#0#3'Top'#3#202#0#5'Width'#3#7#2#18'HorzScrollBar.Page'#3#6#2#18'VertS' + +'crollBar.Page'#3#226#0#13'ActiveControl'#7#12'ToolsListBox'#7'Caption'#6#18 + +'TextConvListEditor'#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinWid' + +'th'#3#144#1#8'OnCreate'#7#10'FormCreate'#0#6'TLabel'#10'ToolsLabel'#4'Left' + +#2#12#6'Height'#2#13#3'Top'#2#9#5'Width'#2'>'#7'Caption'#6#10'ToolsLabel'#5 + +'Color'#7#6'clNone'#11'ParentColor'#8#0#0#8'TListBox'#12'ToolsListBox'#21'An' + +'chorSideTop.Control'#7#10'ToolsLabel'#18'AnchorSideTop.Side'#7#9'asrBottom' + +#23'AnchorSideRight.Control'#7#13'ToolsSplitter'#24'AnchorSideBottom.Control' + +#7#14'UpDownSplitter'#6'Height'#2'x'#3'Top'#2#24#5'Width'#3#232#0#7'Anchors' + +#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#17'BorderSpacing.Top'#2#2#17 + +'OnSelectionChange'#7#27'ToolsListBoxSelectionChange'#8'TabOrder'#2#0#8'TopI' + +'ndex'#2#255#0#0#9'TSplitter'#14'UpDownSplitter'#23'AnchorSideRight.Control' + +#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#6'Cursor'#7#8'crVSplit'#6 + +'Height'#2#5#3'Top'#3#144#0#5'Width'#3#7#2#5'Align'#7#6'alNone'#7'Anchors'#11 + +#5'akTop'#6'akLeft'#7'akRight'#0#7'Beveled'#9#12'ResizeAnchor'#7#8'akBottom' + +#0#0#6'TPanel'#10'ToolsPanel'#22'AnchorSideLeft.Control'#7#13'ToolsSplitter' +#19'AnchorSideLeft.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owne' +'r'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#14 - +'UpDownSplitter'#4'Left'#3#236#0#6'Height'#3#144#0#5'Width'#3#27#1#0#7'TButt' - +'on'#13'AddToolButton'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#13'Add' - +'ToolButton'#7'OnClick'#7#18'AddToolButtonClick'#8'TabOrder'#2#0#4'Left'#2#6 - +#6'Height'#2#26#3'Top'#2#6#5'Width'#2'x'#0#0#7'TButton'#16'DeleteToolButton' - +#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#16'DeleteToolButton'#7'OnCli' - +'ck'#7#21'DeleteToolButtonClick'#8'TabOrder'#2#1#4'Left'#3#132#0#6'Height'#2 - +#26#3'Top'#2#6#5'Width'#3#137#0#0#0#7'TButton'#16'MoveToolUpButton'#25'Borde' - +'rSpacing.InnerBorder'#2#4#7'Caption'#6#16'MoveToolUpButton'#7'OnClick'#7#21 - +'MoveToolUpButtonClick'#8'TabOrder'#2#2#4'Left'#2#6#6'Height'#2#26#3'Top'#2 - +'&'#5'Width'#2'x'#0#0#7'TButton'#18'MoveToolDownButton'#25'BorderSpacing.Inn' - +'erBorder'#2#4#7'Caption'#6#18'MoveToolDownButton'#7'OnClick'#7#23'MoveToolD' - +'ownButtonClick'#8'TabOrder'#2#3#4'Left'#3#132#0#6'Height'#2#26#3'Top'#2'&'#5 - +'Width'#3#137#0#0#0#7'TButton'#14'CopyToolButton'#25'BorderSpacing.InnerBord' - +'er'#2#4#7'Caption'#6#14'CopyToolButton'#7'OnClick'#7#19'CopyToolButtonClick' - +#8'TabOrder'#2#4#4'Left'#2#6#6'Height'#2#26#3'Top'#2'F'#5'Width'#2'x'#0#0#7 - +'TButton'#11'PasteButton'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#11 - +'PasteButton'#7'OnClick'#7#16'PasteButtonClick'#8'TabOrder'#2#5#4'Left'#3#132 - +#0#6'Height'#2#26#3'Top'#2'F'#5'Width'#3#137#0#0#0#7'TButton'#11'CloneButton' - +#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#11'CloneButton'#7'OnClick'#7 - +#16'CloneButtonClick'#8'TabOrder'#2#6#4'Left'#2#6#6'Height'#2#26#3'Top'#2'f' - +#5'Width'#2'x'#0#0#0#9'TSplitter'#13'ToolsSplitter'#5'Align'#7#6'alNone'#7'A' - +'nchors'#11#5'akTop'#6'akLeft'#8'akBottom'#0#7'Beveled'#9#6'Height'#3#144#0#5 - +'Width'#2#4#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control' - +#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Cont' - +'rol'#7#14'UpDownSplitter'#6'Cursor'#7#8'crHSplit'#4'Left'#3#232#0#6'Height' - +#3#144#0#5'Width'#2#4#0#0#0 + +'UpDownSplitter'#4'Left'#3#236#0#6'Height'#3#144#0#5'Width'#3#27#1#7'Anchors' + +#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#10'BevelOuter'#7#6'bvNone'#28 + +'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'C' + +'hildSizing.HorizontalSpacing'#2#6#27'ChildSizing.VerticalSpacing'#2#6#18'Ch' + +'ildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizing.Contro' + +'lsPerLine'#2#2#8'TabOrder'#2#1#0#7'TButton'#13'AddToolButton'#4'Left'#2#6#6 + +'Height'#2#26#3'Top'#2#6#5'Width'#2'x'#25'BorderSpacing.InnerBorder'#2#4#7'C' + +'aption'#6#13'AddToolButton'#7'OnClick'#7#18'AddToolButtonClick'#8'TabOrder' + +#2#0#0#0#7'TButton'#16'DeleteToolButton'#4'Left'#3#132#0#6'Height'#2#26#3'To' + +'p'#2#6#5'Width'#3#137#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#16'D' + +'eleteToolButton'#7'OnClick'#7#21'DeleteToolButtonClick'#8'TabOrder'#2#1#0#0 + +#7'TButton'#16'MoveToolUpButton'#4'Left'#2#6#6'Height'#2#26#3'Top'#2'&'#5'Wi' + +'dth'#2'x'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#16'MoveToolUpButto' + +'n'#7'OnClick'#7#21'MoveToolUpButtonClick'#8'TabOrder'#2#2#0#0#7'TButton'#18 + +'MoveToolDownButton'#4'Left'#3#132#0#6'Height'#2#26#3'Top'#2'&'#5'Width'#3 + +#137#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#18'MoveToolDownButton' + +#7'OnClick'#7#23'MoveToolDownButtonClick'#8'TabOrder'#2#3#0#0#7'TButton'#14 + +'CopyToolButton'#4'Left'#2#6#6'Height'#2#26#3'Top'#2'F'#5'Width'#2'x'#25'Bor' + +'derSpacing.InnerBorder'#2#4#7'Caption'#6#14'CopyToolButton'#7'OnClick'#7#19 + +'CopyToolButtonClick'#8'TabOrder'#2#4#0#0#7'TButton'#11'PasteButton'#4'Left' + +#3#132#0#6'Height'#2#26#3'Top'#2'F'#5'Width'#3#137#0#25'BorderSpacing.InnerB' + +'order'#2#4#7'Caption'#6#11'PasteButton'#7'OnClick'#7#16'PasteButtonClick'#8 + +'TabOrder'#2#5#0#0#7'TButton'#11'CloneButton'#4'Left'#2#6#6'Height'#2#26#3'T' + +'op'#2'f'#5'Width'#2'x'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#11'Cl' + +'oneButton'#7'OnClick'#7#16'CloneButtonClick'#8'TabOrder'#2#6#0#0#0#9'TSplit' + +'ter'#13'ToolsSplitter'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRi' + +'ght.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSi' + +'deBottom.Control'#7#14'UpDownSplitter'#4'Left'#3#232#0#6'Height'#3#144#0#5 + +'Width'#2#4#5'Align'#7#6'alNone'#7'Anchors'#11#5'akTop'#6'akLeft'#8'akBottom' + +#0#7'Beveled'#9#0#0#0 ]); diff --git a/components/h2pas/idetextconvlistedit.pas b/components/h2pas/idetextconvlistedit.pas index c9b58bb80f..86e01db348 100644 --- a/components/h2pas/idetextconvlistedit.pas +++ b/components/h2pas/idetextconvlistedit.pas @@ -168,6 +168,7 @@ begin if csDestroying in ComponentState then exit; UpdateButtons; Tool:=GetCurrentTool; + //DebugLn(['TTextConvListEditor.ToolsListBoxSelectionChange Tool=',dbgsName(Tool)]); PropertyGrid.TIObject:=Tool; end; @@ -318,6 +319,7 @@ begin Result:=nil; if FListOfTools=nil then exit; i:=ToolsListBox.ItemIndex; + //DebugLn(['TTextConvListEditor.GetCurrentTool ',dbgsName(Self),' ToolsListBox.ItemIndex=',ToolsListBox.ItemIndex,' FListOfTools.ComponentCount=',FListOfTools.ComponentCount]); if (i<0) or (i>=FListOfTools.ComponentCount) then exit; Result:=TCustomTextConverterTool(FListOfTools.Components[i]); end; diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index 06acf44035..8955bea095 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -40,6 +40,7 @@ uses CodeToolManager, DefineTemplates, // IDEIntf SrcEditorIntf, ProjectIntf, MacroIntf, IDEDialogs, IDEExternToolIntf, + LazIDEIntf, // IDE LazarusIDEStrConsts, DialogProcs, IDEProcs, CodeToolsOptions, InputHistory, MiscOptions, LazConf, EnvironmentOpts, TransferMacros, CompilerOptions, @@ -1122,7 +1123,9 @@ begin if SourceEditorWindow<>nil then SourceEditorWindow.ClearErrorLines; Result:=EnvironmentOptions.ExternalTools.Run(ExtTool,GlobalMacroList, - TheOutputFilter,CompOptions); + nil,CompOptions); + if LazarusIDE<>nil then + LazarusIDE.DoCheckFilesOnDisk; end; procedure TBuildManager.SetBuildTarget(const TargetOS, TargetCPU, diff --git a/ide/main.pp b/ide/main.pp index 7e17e795e5..04e76320bd 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -641,6 +641,7 @@ type function DoOpenFileAndJumpToPos(const AFilename: string; const CursorPosition: TPoint; TopLine: integer; PageIndex: integer; Flags: TOpenFlags): TModalResult; override; + function DoRevertEditorFile(const Filename: string): TModalResult; override; function DoSaveAll(Flags: TSaveFlags): TModalResult; procedure DoRestart; function DoOpenMainUnit(Flags: TOpenFlags): TModalResult; @@ -5383,6 +5384,11 @@ function TMainIDE.DoOpenFileInSourceEditor(AnUnitInfo: TUnitInfo; var NewSrcEdit: TSourceEditor; AFilename: string; NewSrcEditorCreated: boolean; + NewCaretXY: TPoint; + NewTopLine: LongInt; + NewLeftChar: LongInt; + NewErrorLine: LongInt; + NewExecutionLine: LongInt; begin AFilename:=AnUnitInfo.Filename; @@ -5405,9 +5411,19 @@ begin NewSrcEditorCreated:=true; MainIDEBar.itmFileClose.Enabled:=True; MainIDEBar.itmFileCloseAll.Enabled:=True; + NewCaretXY:=AnUnitInfo.CursorPos; + NewTopLine:=AnUnitInfo.TopLine; + NewLeftChar:=1; + NewErrorLine:=-1; + NewExecutionLine:=-1; end else begin // revert code in existing source editor NewSrcEdit:=SourceNotebook.FindSourceEditorWithPageIndex(PageIndex); + NewCaretXY:=NewSrcEdit.EditorComponent.CaretXY; + NewTopLine:=NewSrcEdit.EditorComponent.TopLine; + NewLeftChar:=NewSrcEdit.EditorComponent.LeftChar; + NewErrorLine:=NewSrcEdit.ErrorLine; + NewExecutionLine:=NewSrcEdit.ExecutionLine; NewSrcEdit.EditorComponent.BeginUpdate; NewSrcEdit.CodeBuffer:=AnUnitInfo.Source; NewSrcEdit.Modified:=false; @@ -5423,9 +5439,11 @@ begin DoRestoreBookMarks(AnUnitInfo,NewSrcEdit); DebugBoss.DoRestoreDebuggerMarks(AnUnitInfo); NewSrcEdit.SyntaxHighlighterType:=AnUnitInfo.SyntaxHighlighter; - NewSrcEdit.EditorComponent.CaretXY:=AnUnitInfo.CursorPos; - NewSrcEdit.EditorComponent.TopLine:=AnUnitInfo.TopLine; - NewSrcEdit.EditorComponent.LeftChar:=1; + NewSrcEdit.EditorComponent.CaretXY:=NewCaretXY; + NewSrcEdit.EditorComponent.TopLine:=NewTopLine; + NewSrcEdit.EditorComponent.LeftChar:=NewLeftChar; + NewSrcEdit.ErrorLine:=NewErrorLine; + NewSrcEdit.ExecutionLine:=NewExecutionLine; NewSrcEdit.ReadOnly:=AnUnitInfo.ReadOnly; // mark unit as loaded @@ -5904,9 +5922,7 @@ begin FilenameNoPath:=ExtractFilename(AFilename); // check to not open directories - if (not (ofRevert in Flags)) - and ((FilenameNoPath='') or (FilenameNoPath='.') or (FilenameNoPath='..')) - then + if ((FilenameNoPath='') or (FilenameNoPath='.') or (FilenameNoPath='..')) then exit; if ([ofAddToRecent,ofRevert,ofVirtualFile]*Flags=[ofAddToRecent]) @@ -6521,6 +6537,18 @@ begin end; end; +function TMainIDE.DoRevertEditorFile(const Filename: string): TModalResult; +var + AnUnitInfo: TUnitInfo; +begin + Result:=mrOk; + if (Project1<>nil) then begin + AnUnitInfo:=Project1.UnitInfoWithFilename(Filename,[]); + if AnUnitInfo.EditorIndex>=0 then + Result:=DoOpenEditorFile(Filename,AnUnitInfo.EditorIndex,[ofRevert]); + end; +end; + function TMainIDE.DoNewProject(ProjectDesc: TProjectDescriptor):TModalResult; var i:integer; Begin @@ -7450,7 +7478,6 @@ begin if Result<>mrOk then exit; // show messages - MessagesView.Clear; MessagesView.BeginBlock; try @@ -11588,14 +11615,9 @@ begin SourceNotebook.ClearErrorLines; ToolStatus:=itBuilder; - if CheckCompilerOptsDlg<>nil then begin - TheOutputFilter.OnAddFilteredLine:=@CheckCompilerOptsDlg.AddMsg; - TheOutputFilter.OnReadLine:=@CheckCompilerOptsDlg.AddProgress; - end else begin - MessagesView.Clear; - DoArrangeSourceEditorAndMessageView(false); - ConnectOutputFilter; - end; + MessagesView.Clear; + DoArrangeSourceEditorAndMessageView(false); + ConnectOutputFilter; end; procedure TMainIDE.OnExtToolFreeOutputFilter(OutputFilter: TOutputFilter; diff --git a/ide/mainintf.pas b/ide/mainintf.pas index 7c7afbf62b..adef95240c 100644 --- a/ide/mainintf.pas +++ b/ide/mainintf.pas @@ -155,7 +155,6 @@ type function DoSaveBuildIDEConfigs(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract; function DoBuildLazarus(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract; function DoSaveForBuild: TModalResult; virtual; abstract; - function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; virtual; abstract; function DoPublishModule(Options: TPublishModuleOptions; const SrcDirectory, DestDirectory: string ): TModalResult; virtual; abstract; diff --git a/ide/msgview.pp b/ide/msgview.pp index 89f560a09b..a1a51718bc 100644 --- a/ide/msgview.pp +++ b/ide/msgview.pp @@ -493,7 +493,6 @@ begin ImproveMessages(DestStartIndex); - {for i:=0 to SrcLines.Count-1 do begin SrcLine:=SrcLines[i]; DebugLn('TMessagesView.CollectLineParts i=',dbgs(i),' SrcLine=',MsgAsString(SrcLine)); @@ -509,16 +508,19 @@ var LastSeparator: integer; begin BeginBlock; - LastSeparator := VisibleItemCount - 1; - while (LastSeparator >= 0) and (VisibleItems[LastSeparator].Msg <> SeparatorLine) do - Dec(LastSeparator); - if LastSeparator >= 0 then - begin - while (VisibleItemCount > LastSeparator) do - DeleteLine(LinesCount - 1); - FLastLineIsProgress := False; + try + LastSeparator := VisibleItemCount - 1; + while (LastSeparator >= 0) and (VisibleItems[LastSeparator].Msg <> SeparatorLine) do + Dec(LastSeparator); + if LastSeparator >= 0 then + begin + while (VisibleItemCount > LastSeparator) do + DeleteLine(LinesCount - 1); + FLastLineIsProgress := False; + end; + finally + EndBlock; end; - EndBlock; end; procedure TMessagesView.ShowTopMessage; @@ -686,6 +688,7 @@ end; procedure TMessagesView.BeginBlock; begin Clear; + //if fBlockCount=0 then DumpStack; Inc(fBlockCount); end; @@ -694,6 +697,7 @@ begin if fBlockCount <= 0 then RaiseException('TMessagesView.EndBlock Internal Error'); Dec(fBlockCount); + //if fBlockCount=0 then DumpStack; end; procedure TMessagesView.ClearItems; diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 1ac70c8fa4..6649a4c370 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -452,7 +452,7 @@ begin Result:=''; end; -procedure SynREVarPos(Index: Integer; var MatchStart, MatchLength: integer); +procedure SynREVarPos(Index: Integer; out MatchStart, MatchLength: integer); begin if SynREEngine<>nil then begin MatchStart:=SynREEngine.MatchPos[Index]; diff --git a/ideintf/idetextconverter.pas b/ideintf/idetextconverter.pas index 0296830417..8524657f89 100644 --- a/ideintf/idetextconverter.pas +++ b/ideintf/idetextconverter.pas @@ -101,11 +101,11 @@ type procedure SetCaption(const AValue: string); procedure SetDescription(const AValue: string); public + class function ClassDescription: string; virtual; abstract;//the first line should be a short title + class function FirstLineOfClassDescription: string; constructor Create(TheOwner: TComponent); override; function Execute(aText: TIDETextConverter): TModalResult; virtual; abstract; procedure Assign(Source: TPersistent); override; - class function ClassDescription: string; virtual; abstract;//the first line should be a short title - class function FirstLineOfClassDescription: string; published property Caption: string read FCaption write SetCaption; property Description: string read FDescription write SetDescription; @@ -135,9 +135,9 @@ type procedure SetReplaceWith(const AValue: string); procedure SetSearchFor(const AValue: string); public + class function ClassDescription: string; override; function Execute(aText: TIDETextConverter): TModalResult; override; procedure Assign(Source: TPersistent); override; - class function ClassDescription: string; override; property SearchFor: string read FSearchFor write SetSearchFor; property ReplaceWith: string read FReplaceWith write SetReplaceWith; property Options: TTextReplaceToolOptions read FOptions write SetOptions; @@ -612,7 +612,10 @@ end; function TTextConverterToolClasses.GetCount: integer; begin - Result:=FItems.Count; + if Self<>nil then + Result:=FItems.Count + else + Result:=0; end; function TTextConverterToolClasses.GetItems(Index: integer @@ -636,6 +639,7 @@ end; procedure TTextConverterToolClasses.RegisterClass( AClass: TCustomTextConverterToolClass); begin + if Self=nil then exit; if FItems.IndexOf(AClass)<0 then FItems.Add(AClass); end; @@ -643,6 +647,7 @@ end; procedure TTextConverterToolClasses.UnregisterClass( AClass: TCustomTextConverterToolClass); begin + if Self=nil then exit; FItems.Remove(AClass); end; @@ -651,10 +656,11 @@ function TTextConverterToolClasses.FindByName(const aClassName: string var i: Integer; begin - for i:=0 to FItems.Count-1 do begin - Result:=Items[i]; - if CompareText(Result.ClassName,aClassName)=0 then exit; - end; + if Self<>nil then + for i:=0 to FItems.Count-1 do begin + Result:=Items[i]; + if CompareText(Result.ClassName,aClassName)=0 then exit; + end; Result:=nil; end; @@ -663,10 +669,11 @@ function TTextConverterToolClasses.FindByFirstLineOfClassDescription( var i: Integer; begin - for i:=0 to FItems.Count-1 do begin - Result:=Items[i]; - if Result.FirstLineOfClassDescription=Line then exit; - end; + if Self<>nil then + for i:=0 to FItems.Count-1 do begin + Result:=Items[i]; + if Result.FirstLineOfClassDescription=Line then exit; + end; Result:=nil; end; diff --git a/ideintf/lazideintf.pas b/ideintf/lazideintf.pas index a7221ff3c0..86b9385b85 100644 --- a/ideintf/lazideintf.pas +++ b/ideintf/lazideintf.pas @@ -158,6 +158,7 @@ type function DoOpenFileAndJumpToPos(const AFilename: string; const CursorPosition: TPoint; TopLine: integer; PageIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract; + function DoRevertEditorFile(const Filename: string): TModalResult; virtual; abstract; // project property ActiveProject: TLazProject read GetActiveProject; @@ -192,6 +193,7 @@ type FocusEditor: boolean): boolean; virtual; abstract; procedure DoJumpToNextError(DirectionDown: boolean); virtual; abstract; procedure DoShowMessagesView; virtual; abstract; + function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; virtual; abstract; // designer function GetDesignerWithProjectFile(AFile: TLazProjectFile; diff --git a/ideintf/objectinspector.pp b/ideintf/objectinspector.pp index 0e114deedd..382c1ef7b3 100644 --- a/ideintf/objectinspector.pp +++ b/ideintf/objectinspector.pp @@ -241,8 +241,12 @@ type end; //---------------------------------------------------------------------------- - TOIPropertyGridState = (pgsChangingItemIndex, pgsApplyingValue, - pgsUpdatingEditControl); + TOIPropertyGridState = ( + pgsChangingItemIndex, + pgsApplyingValue, + pgsUpdatingEditControl, + pgsBuildPropertyListNeeded + ); TOIPropertyGridStates = set of TOIPropertyGridState; { TOICustomPropertyGrid } @@ -285,6 +289,7 @@ type FPropertyEditorHook: TPropertyEditorHook; FRows: TList; FSelection: TPersistentSelectionList; + FNotificationComponents: TFPList; FSplitterX: integer; // current splitter position FStates: TOIPropertyGridStates; FTopY: integer; @@ -297,6 +302,7 @@ type procedure OnUserInput(Sender: TObject; Msg: Cardinal); procedure IncreaseChangeStep; + function GridIsUpdating: boolean; function GetRow(Index:integer):TOIPropertyGridRow; function GetRowCount:integer; @@ -324,6 +330,7 @@ type procedure SetSelection(const ASelection:TPersistentSelectionList); procedure SetPropertyEditorHook(NewPropertyEditorHook:TPropertyEditorHook); + procedure UpdateSelectionNotifications; procedure AddPropertyEditor(PropEditor: TPropertyEditor); procedure AddStringToComboBox(const s: string); @@ -334,7 +341,7 @@ type procedure SetRowValue; procedure DoCallEdit; procedure RefreshValueEdit; - Procedure ValueEditDblClick(Sender : TObject); + procedure ValueEditDblClick(Sender : TObject); procedure ValueControlMouseDown(Sender: TObject; Button:TMouseButton; Shift: TShiftState; X,Y:integer); procedure ValueControlMouseMove(Sender: TObject; Shift: TShiftState; @@ -366,6 +373,7 @@ type protected procedure CreateParams(var Params: TCreateParams); override; procedure CreateWnd; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:integer); override; procedure MouseMove(Shift:TShiftState; X,Y:integer); override; @@ -404,7 +412,7 @@ type function PropertyPath(Index: integer):string; function PropertyPath(Row: TOIPropertyGridRow):string; function TopMax: integer; - procedure BuildPropertyList; + procedure BuildPropertyList(OnlyIfNeeded: boolean = false); procedure Clear; procedure Paint; override; procedure PropEditLookupRootChange; @@ -709,6 +717,7 @@ begin FLayout := oilHorizontal; FSelection:=TPersistentSelectionList.Create; + FNotificationComponents:=TFPList.Create; FPropertyEditorHook:=APropertyEditorHook; FFilter:=TypeFilter; FItemIndex:=-1; @@ -885,6 +894,22 @@ begin UpdateScrollBar; end; +procedure TOICustomPropertyGrid.Notification(AComponent: TComponent; + Operation: TOperation); +var + i: LongInt; +begin + if Operation=opRemove then begin + FNotificationComponents.Remove(AComponent); + i:=FSelection.IndexOf(AComponent); + if i>=0 then begin + FSelection.Delete(i); + Include(FStates,pgsBuildPropertyListNeeded); + end; + end; + inherited Notification(AComponent, Operation); +end; + procedure TOICustomPropertyGrid.WMVScroll(var Msg: TLMScroll); begin case Msg.ScrollCode of @@ -913,6 +938,7 @@ begin for a:=0 to FRows.Count-1 do Rows[a].Free; FreeAndNil(FRows); FreeAndNil(FSelection); + FreeAndNil(FNotificationComponents); FreeAndNil(FValueFont); FreeAndNil(FDefaultValueFont); FreeAndNil(FNameFont); @@ -975,6 +1001,7 @@ begin ItemIndex:=-1; ClearRows; FSelection.Assign(ASelection); + UpdateSelectionNotifications; BuildPropertyList; CurRow:=GetRowByPath(OldSelectedRowPath); if CurRow<>nil then @@ -990,6 +1017,30 @@ begin SetSelection(FSelection); end; +procedure TOICustomPropertyGrid.UpdateSelectionNotifications; +var + i: Integer; + AComponent: TComponent; +begin + for i:=0 to FSelection.Count-1 do begin + if FSelection[i] is TComponent then begin + AComponent:=TComponent(FSelection[i]); + if FNotificationComponents.IndexOf(AComponent)<0 then begin + FNotificationComponents.Add(AComponent); + AComponent.FreeNotification(Self); + end; + end; + end; + for i:=FNotificationComponents.Count-1 downto 0 do begin + AComponent:=TComponent(FNotificationComponents[i]); + if FSelection.IndexOf(AComponent)<0 then begin + FNotificationComponents.Delete(i); + AComponent.RemoveFreeNotification(Self); + end; + end; + //DebugLn(['TOICustomPropertyGrid.UpdateSelectionNotifications FNotificationComponents=',FNotificationComponents.Count,' FSelection=',FSelection.Count]); +end; + function TOICustomPropertyGrid.PropertyPath(Index:integer):string; begin if (Index>=0) and (Index[]) + if GridIsUpdating or (FCurrentEdit=nil) or (FItemIndex<0) or (FItemIndex>=FRows.Count) @@ -1168,7 +1219,7 @@ var CurRow: TOIPropertyGridRow; NewValue: string; begin - if (FStates*[pgsChangingItemIndex,pgsApplyingValue]=[]) + if (not GridIsUpdating) and (FCurrentEdit<>nil) and (FItemIndex>=0) and (FItemIndex[]) - or (FItemIndex=NewIndex) then + if GridIsUpdating or (FItemIndex=NewIndex) then exit; // save old edit value @@ -1369,11 +1419,14 @@ begin Result:=FRows.Count; end; -procedure TOICustomPropertyGrid.BuildPropertyList; +procedure TOICustomPropertyGrid.BuildPropertyList(OnlyIfNeeded: boolean); var a:integer; CurRow:TOIPropertyGridRow; OldSelectedRowPath:string; begin + if OnlyIfNeeded and (not (pgsBuildPropertyListNeeded in FStates)) then exit; + Exclude(FStates,pgsBuildPropertyListNeeded); + OldSelectedRowPath:=PropertyPath(ItemIndex); // unselect ItemIndex:=-1; @@ -1588,7 +1641,7 @@ end; function TOICustomPropertyGrid.CanEditRowValue: boolean; begin - if (FStates*[pgsChangingItemIndex,pgsApplyingValue,pgsUpdatingEditControl]<>[]) + if GridIsUpdating or (FCurrentEdit=nil) or (FItemIndex<0) or (FItemIndex>=FRows.Count) @@ -2169,6 +2222,7 @@ procedure TOICustomPropertyGrid.DoPaint(PaintOnlyChangedValues:boolean); var a:integer; SpaceRect:TRect; begin + BuildPropertyList(true); if not PaintOnlyChangedValues then begin with Canvas do begin // draw properties @@ -2498,12 +2552,18 @@ begin FChangeStep:=-$7fffffff; end; +function TOICustomPropertyGrid.GridIsUpdating: boolean; +begin + Result:=(FStates*[pgsChangingItemIndex,pgsApplyingValue, + pgsBuildPropertyListNeeded]<>[]) +end; + procedure TOICustomPropertyGrid.ValueEditDblClick(Sender : TObject); var CurRow: TOIPropertyGridRow; TypeKind : TTypeKind; begin - if (FStates*[pgsChangingItemIndex,pgsApplyingValue]<>[]) + if GridIsUpdating or (FCurrentEdit=nil) or (FItemIndex<0) or (FItemIndex>=FRows.Count) diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index 93c4828592..112b597b3f 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -1037,7 +1037,7 @@ type TPersistentSelectionList = class protected FUpdateLock: integer; - FPersistentList: TList; + FPersistentList: TFPList; function GetItems(AIndex: integer): TPersistent; procedure SetItems(AIndex: integer; const APersistent: TPersistent); function GetCount: integer; @@ -1056,6 +1056,7 @@ type property Capacity:integer read GetCapacity write SetCapacity; function Add(APersistent: TPersistent): integer; function Remove(APersistent: TPersistent): integer; + procedure Delete(Index: Integer); procedure Assign(SourceSelectionList: TPersistentSelectionList); property Items[AIndex: integer]: TPersistent read GetItems write SetItems; default; end; @@ -4845,7 +4846,13 @@ end; function TPersistentSelectionList.Remove(APersistent: TPersistent): integer; begin Result:=IndexOf(APersistent); - if Result>=0 then FPersistentList.Remove(APersistent); + if Result>=0 then + FPersistentList.Delete(Result); +end; + +procedure TPersistentSelectionList.Delete(Index: Integer); +begin + FPersistentList.Delete(Index); end; procedure TPersistentSelectionList.Clear; @@ -4856,7 +4863,7 @@ end; constructor TPersistentSelectionList.Create; begin inherited Create; - FPersistentList:=TList.Create; + FPersistentList:=TFPList.Create; end; destructor TPersistentSelectionList.Destroy; diff --git a/ideintf/texttools.pas b/ideintf/texttools.pas index 027aac1a52..10477ed43e 100644 --- a/ideintf/texttools.pas +++ b/ideintf/texttools.pas @@ -37,8 +37,7 @@ type var ShowSortSelectionDialogFunc: TShowSortSelectionDialogFunc; SortTextFunc: TSortTextFunc; - - + { Regular expressions This is a simple interface to regular expressions. The syntax is similar @@ -72,7 +71,7 @@ var function REMatches(const TheText, RegExpr: string; const ModifierStr: string = ''): boolean; function REVar(Index: Integer): string; // 1 is the first -procedure REVarPos(Index: Integer; var MatchStart, MatchLength: integer); +procedure REVarPos(Index: Integer; out MatchStart, MatchLength: integer); function REVarCount: Integer; function REReplace(const TheText, FindRegExpr, ReplaceRegExpr: string; UseSubstutition: boolean; @@ -97,7 +96,7 @@ type ): boolean; TREVarFunction = function(Index: Integer): string; TREVarPosProcedure = procedure(Index: Integer; - var MatchStart, MatchLength: integer); + out MatchStart, MatchLength: integer); TREVarCountFunction = function: Integer; TREReplaceProcedure = function(const TheText, FindRegExpr, ReplaceRegExpr: string; UseSubstutition: boolean; @@ -105,12 +104,12 @@ type TRESplitFunction = procedure(const TheText, SeparatorRegExpr: string; Pieces: TStrings; const ModifierStr: string); var - REMatchesFunction: TREMatchesFunction; // initialized by the IDE ... - REVarFunction: TREVarFunction; - REVarPosProcedure: TREVarPosProcedure; - REVarCountFunction: TREVarCountFunction; - REReplaceProcedure: TREReplaceProcedure; - RESplitFunction: TRESplitFunction; + REMatchesFunction: TREMatchesFunction = nil; // initialized by the IDE ... + REVarFunction: TREVarFunction = nil; + REVarPosProcedure: TREVarPosProcedure = nil; + REVarCountFunction: TREVarCountFunction = nil; + REReplaceProcedure: TREReplaceProcedure = nil; + RESplitFunction: TRESplitFunction = nil; implementation @@ -125,7 +124,7 @@ begin Result:=REVarFunction(Index); end; -procedure REVarPos(Index: Integer; var MatchStart, MatchLength: integer); +procedure REVarPos(Index: Integer; out MatchStart, MatchLength: integer); begin REVarPosProcedure(Index,MatchStart,MatchLength); end; diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index 05014768a5..1f466f9831 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -2021,7 +2021,7 @@ var begin StateFile:=APackage.GetStateFilename; if not FileExists(StateFile) then begin - DebugLn('TLazPackageGraph.LoadPackageCompiledState Statefile not found: ',StateFile); + //DebugLn('TLazPackageGraph.LoadPackageCompiledState Statefile not found: ',StateFile); APackage.Flags:=APackage.Flags-[lpfStateFileLoaded]; Result:=mrOk; exit; @@ -2245,6 +2245,7 @@ var EffektiveCompilerParams: String; SrcFilename: String; CompilePolicies: TPackageUpdatePolicies; + BlockBegan: Boolean; begin Result:=mrCancel; @@ -2296,7 +2297,8 @@ begin // auto increase version // ToDo - if IDEMessagesWindow<>nil then + BlockBegan:=IDEMessagesWindow<>nil; + if BlockBegan then IDEMessagesWindow.BeginBlock; try Result:=PreparePackageOutputDirectory(APackage,pcfCleanCompile in Flags); @@ -2341,9 +2343,9 @@ begin end; // create external tool to run the compiler - DebugLn('TPkgManager.DoCompilePackage Compiler="',CompilerFilename,'"'); - DebugLn('TPkgManager.DoCompilePackage Params="',CompilerParams,'"'); - DebugLn('TPkgManager.DoCompilePackage WorkingDir="',APackage.Directory,'"'); + //DebugLn('TPkgManager.DoCompilePackage Compiler="',CompilerFilename,'"'); + //DebugLn('TPkgManager.DoCompilePackage Params="',CompilerParams,'"'); + //DebugLn('TPkgManager.DoCompilePackage WorkingDir="',APackage.Directory,'"'); if (not APackage.CompilerOptions.SkipCompiler) and (not (pcfDoNotCompilePackage in Flags)) then begin @@ -2409,8 +2411,8 @@ begin end; end; finally - if IDEMessagesWindow<>nil then - IDEMessagesWindow.BeginBlock; + if BlockBegan and (IDEMessagesWindow<>nil) then + IDEMessagesWindow.EndBlock; if Result<>mrOk then begin if (APackage.AutoInstall<>pitNope) and (APackage.Installed=pitNope) and (OnUninstallPackage<>nil) then begin diff --git a/packager/pkgmanager.pas b/packager/pkgmanager.pas index b5443476aa..d85911795d 100644 --- a/packager/pkgmanager.pas +++ b/packager/pkgmanager.pas @@ -2451,7 +2451,7 @@ begin Result:=MainIDE.PrepareForCompile; if Result<>mrOk then exit; - + // check graph for circles and broken dependencies if not (pcfDoNotCompileDependencies in Flags) then begin Result:=CheckPackageGraphForCompilation(APackage,nil,APackage.Directory);