From 751a6f677eb8ea9f5602e8d304818a609a8d63da Mon Sep 17 00:00:00 2001 From: lazarus Date: Thu, 29 Mar 2001 12:38:59 +0000 Subject: [PATCH] MG: new environment opts, ptApplication bugfixes git-svn-id: trunk@246 - --- designer/objectinspector.pp | 5 +- ide/codetools.pp | 2 + ide/compiler.pp | 6 +- ide/editoroptions.pp | 391 ++++++++++++++++++------------------ ide/environmentopts.pp | 304 ++++++++++++++++++++++++++-- ide/main.pp | 57 ++++-- ide/project.pp | 50 +++-- 7 files changed, 566 insertions(+), 249 deletions(-) diff --git a/designer/objectinspector.pp b/designer/objectinspector.pp index 0ffc4ac1f2..1cbb942529 100644 --- a/designer/objectinspector.pp +++ b/designer/objectinspector.pp @@ -1467,16 +1467,15 @@ begin MaxY:=ClientHeight-20; // combobox at top (filled with available components) - AvailCompsComboBox.SetBounds(0,0,MaxX-4,20); + AvailCompsComboBox.SetBounds(0,0,MaxX,20); // notebook NewTop:=AvailCompsComboBox.Top+AvailCompsComboBox.Height+2; - NoteBook.SetBounds(0,NewTop,MaxX-4,MaxY-NewTop); + NoteBook.SetBounds(0,NewTop,MaxX,MaxY-NewTop); end; procedure TObjectInspector.SetPropertyEditorHook(NewValue:TPropertyEditorHook); begin -//XXX writeln('OI: SetPropertyEditorHook'); if FPropertyEditorHook<>NewValue then begin FPropertyEditorHook:=NewValue; FPropertyEditorHook.OnChangeLookupRoot:=@PropEditLookupRootChange; diff --git a/ide/codetools.pp b/ide/codetools.pp index 313ad7eb8c..05a230583e 100644 --- a/ide/codetools.pp +++ b/ide/codetools.pp @@ -918,7 +918,9 @@ begin Result:=true; exit; end; + if Source='' then exit; // search "LazarusResources.Add(''," + FindPosition:=1; repeat Atom:=ReadNextPascalAtom(Source,FindPosition,FindAtomStart); until (Atom='') or (Atom=','); diff --git a/ide/compiler.pp b/ide/compiler.pp index 0f76c4120d..1d081ecbeb 100644 --- a/ide/compiler.pp +++ b/ide/compiler.pp @@ -173,7 +173,8 @@ begin OutputLine:='unable to execute "'+CmdLine+'"'; end; OutputLine:='Error: '+OutputLine; - ProcessOutputLine; + if Assigned(OnOutputString) then + OnOutputString(OutputLine); exit; end; {$ENDIF linux} @@ -280,6 +281,9 @@ end. { $Log$ + Revision 1.10 2001/03/29 12:38:58 lazarus + MG: new environment opts, ptApplication bugfixes + Revision 1.9 2001/03/26 14:52:30 lazarus MG: TSourceLog + compiling bugfixes diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index 4ac08cf28b..fc1b7d48b5 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -565,7 +565,7 @@ begin // set defaults // General options - fSyntaxExtensions:='pp;inc;lfm;lrs;pas;dpr;dfm;dpk'; + fSyntaxExtensions:='pp;pas;inc;lpr;lrs;dpr;dpk'; // Display options fEditorFont:='courier'; @@ -610,108 +610,112 @@ procedure TEditorOptions.Load; var SynEditOpt:TSynEditorOption; SynEditOptName:ansistring; begin - // general options - for SynEditOpt:=Low(TSynEditorOption) to High(TSynEditorOption) do begin - case SynEditOpt of - eoAltSetsColumnMode:SynEditOptName:='AltSetsColumnMode'; - eoAutoIndent:SynEditOptName:='AutoIndent'; - eoDragDropEditing:SynEditOptName:='DragDropEditing'; - eoDropFiles:SynEditOptName:='DropFiles'; - eoHalfPageScroll:SynEditOptName:='HalfPageScroll'; - eoKeepCaretX:SynEditOptName:='KeepCaretX'; - eoNoCaret:SynEditOptName:='NoCaret'; - eoNoSelection:SynEditOptName:='NoSelection'; - eoScrollByOneLess:SynEditOptName:='ScrollByOneLess'; - eoScrollPastEof:SynEditOptName:='ScrollPastEof'; - eoScrollPastEol:SynEditOptName:='ScrollPastEol'; - eoShowScrollHint:SynEditOptName:='ShowScrollHint'; - eoSmartTabs:SynEditOptName:='SmartTabs'; - eoTabsToSpaces:SynEditOptName:='TabsToSpaces'; - eoTrimTrailingSpaces:SynEditOptName:='TrimTrailingSpaces'; - else - SynEditOptName:=''; - end; - if SynEditOptName<>'' then begin - if XMLConfig.GetValue('EditorOptions/General/Editor/'+SynEditOptName, - SynEditOpt in SYNEDIT_DEFAULT_OPTIONS) then - Include(fSynEditOptions,SynEditOpt) + try + // general options + for SynEditOpt:=Low(TSynEditorOption) to High(TSynEditorOption) do begin + case SynEditOpt of + eoAltSetsColumnMode:SynEditOptName:='AltSetsColumnMode'; + eoAutoIndent:SynEditOptName:='AutoIndent'; + eoDragDropEditing:SynEditOptName:='DragDropEditing'; + eoDropFiles:SynEditOptName:='DropFiles'; + eoHalfPageScroll:SynEditOptName:='HalfPageScroll'; + eoKeepCaretX:SynEditOptName:='KeepCaretX'; + eoNoCaret:SynEditOptName:='NoCaret'; + eoNoSelection:SynEditOptName:='NoSelection'; + eoScrollByOneLess:SynEditOptName:='ScrollByOneLess'; + eoScrollPastEof:SynEditOptName:='ScrollPastEof'; + eoScrollPastEol:SynEditOptName:='ScrollPastEol'; + eoShowScrollHint:SynEditOptName:='ShowScrollHint'; + eoSmartTabs:SynEditOptName:='SmartTabs'; + eoTabsToSpaces:SynEditOptName:='TabsToSpaces'; + eoTrimTrailingSpaces:SynEditOptName:='TrimTrailingSpaces'; else - Exclude(fSynEditOptions,SynEditOpt); + SynEditOptName:=''; + end; + if SynEditOptName<>'' then begin + if XMLConfig.GetValue('EditorOptions/General/Editor/'+SynEditOptName, + SynEditOpt in SYNEDIT_DEFAULT_OPTIONS) then + Include(fSynEditOptions,SynEditOpt) + else + Exclude(fSynEditOptions,SynEditOpt); + end; end; + + fUndoAfterSave:= + XMLConfig.GetValue('EditorOptions/General/Editor/UndoAfterSave',true); + fDoubleClickLine:= + XMLConfig.GetValue('EditorOptions/General/Editor/DoubleClickLine',false); + fFindTextAtCursor:= + XMLConfig.GetValue('EditorOptions/General/Editor/FindTextAtCursor',true); + fUseSyntaxHighlight:= + XMLConfig.GetValue('EditorOptions/General/Editor/UseSyntaxHighlight',true); + fCreateBackupFiles:= + XMLConfig.GetValue('EditorOptions/General/Editor/CreateBackupFiles',true); + fBlockIndent:= + XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndent',2); + fUndoLimit:= + XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit',32767); + fTabWidths:= + XMLConfig.GetValue('EditorOptions/General/Editor/TabWidths',8); + fSyntaxExtensions:= + XMLConfig.GetValue('EditorOptions/General/Editor/SyntaxExtensions' + ,'pp;inc;lfc;pas;dpr;dpk'); + + // Display options + fVisibleRightMargin:= + XMLConfig.GetValue('EditorOptions/Display/VisibleRightMargin',true); + fVisibleGutter:= + XMLConfig.GetValue('EditorOptions/Display/VisibleGutter',true); + fShowLineNumbers:= + XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers',false); + fGutterColor:= + XMLConfig.GetValue('EditorOptions/Display/GutterColor',clBtnFace); + fGutterWidth:= + XMLConfig.GetValue('EditorOptions/Display/GutterWidth',30); + fRightMargin:= + XMLConfig.GetValue('EditorOptions/Display/RightMargin',80); + fRightMarginColor:= + XMLConfig.GetValue('EditorOptions/Display/VisibleRightMarginColor' + ,clBtnFace); + fEditorFont:= + XMLConfig.GetValue('EditorOptions/Display/EditorFont','courier'); + fEditorFontHeight:= + XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',12); + fExtraLineSpacing:= + XMLConfig.GetValue('EditorOptions/Display/ExtraLineSpacing',1); + + // Key Mappings options + fKeyMappingScheme:= + XMLConfig.GetValue('EditorOptions/KeyMapping/Scheme',fKeyMappingScheme); + fKeyMap.LoadFromXMLConfig(XMLConfig + ,'EditorOptions/KeyMapping/'+fKeyMappingScheme+'/'); + + // Color options + fColorScheme:= + XMLConfig.GetValue('EditorOptions/Color/ColorScheme','Default'); + ReadAttribute(fTextBlockElement); + ReadAttribute(fExecutionPointElement); + ReadAttribute(fEnabledBreakPointElement); + ReadAttribute(fDisabledBreakPointElement); + ReadAttribute(fErrorLineElement); + + // Code Tools options + fAutoCodeCompletion:= + XMLConfig.GetValue('EditorOptions/CodeTools/AutoCodeCompletion',true); + fAutoCodeParameters:= + XMLConfig.GetValue('EditorOptions/CodeTools/AutoCodeParameters',true); + fAutoToolTipExprEval:= + XMLConfig.GetValue('EditorOptions/CodeTools/AutoToolTipExprEval',true); + fAutoToolTipSymbTools:= + XMLConfig.GetValue('EditorOptions/CodeTools/AutoToolTipSymbTools',true); + fAutoDelayInMSec:= + XMLConfig.GetValue('EditorOptions/CodeTools/AutoDelayInMSec',1000); + fCodeTemplateFileName:= + XMLConfig.GetValue('EditorOptions/CodeTools/CodeTemplateFileName' + ,SetDirSeparators(GetPrimaryConfigPath+'/lazarus.dci')); + except + writeln('[TEditorOptions.Load] ERROR'); end; - - fUndoAfterSave:= - XMLConfig.GetValue('EditorOptions/General/Editor/UndoAfterSave',true); - fDoubleClickLine:= - XMLConfig.GetValue('EditorOptions/General/Editor/DoubleClickLine',false); - fFindTextAtCursor:= - XMLConfig.GetValue('EditorOptions/General/Editor/FindTextAtCursor',true); - fUseSyntaxHighlight:= - XMLConfig.GetValue('EditorOptions/General/Editor/UseSyntaxHighlight',true); - fCreateBackupFiles:= - XMLConfig.GetValue('EditorOptions/General/Editor/CreateBackupFiles',true); - fBlockIndent:= - XMLConfig.GetValue('EditorOptions/General/Editor/BlockIndent',2); - fUndoLimit:= - XMLConfig.GetValue('EditorOptions/General/Editor/UndoLimit',32767); - fTabWidths:= - XMLConfig.GetValue('EditorOptions/General/Editor/TabWidths',8); - fSyntaxExtensions:= - XMLConfig.GetValue('EditorOptions/General/Editor/SyntaxExtensions' - ,'pp;inc;lfm;lfc;pas;dpr;dfm;dpk'); - - // Display options - fVisibleRightMargin:= - XMLConfig.GetValue('EditorOptions/Display/VisibleRightMargin',true); - fVisibleGutter:= - XMLConfig.GetValue('EditorOptions/Display/VisibleGutter',true); - fShowLineNumbers:= - XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers',false); - fGutterColor:= - XMLConfig.GetValue('EditorOptions/Display/GutterColor',clBtnFace); - fGutterWidth:= - XMLConfig.GetValue('EditorOptions/Display/GutterWidth',30); - fRightMargin:= - XMLConfig.GetValue('EditorOptions/Display/RightMargin',80); - fRightMarginColor:= - XMLConfig.GetValue('EditorOptions/Display/VisibleRightMarginColor' - ,clBtnFace); - fEditorFont:= - XMLConfig.GetValue('EditorOptions/Display/EditorFont','courier'); - fEditorFontHeight:= - XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',12); - fExtraLineSpacing:= - XMLConfig.GetValue('EditorOptions/Display/ExtraLineSpacing',1); - - // Key Mappings options - fKeyMappingScheme:= - XMLConfig.GetValue('EditorOptions/KeyMapping/Scheme',fKeyMappingScheme); - fKeyMap.LoadFromXMLConfig(XMLConfig - ,'EditorOptions/KeyMapping/'+fKeyMappingScheme+'/'); - - // Color options - fColorScheme:= - XMLConfig.GetValue('EditorOptions/Color/ColorScheme','Default'); - ReadAttribute(fTextBlockElement); - ReadAttribute(fExecutionPointElement); - ReadAttribute(fEnabledBreakPointElement); - ReadAttribute(fDisabledBreakPointElement); - ReadAttribute(fErrorLineElement); - - // Code Tools options - fAutoCodeCompletion:= - XMLConfig.GetValue('EditorOptions/CodeTools/AutoCodeCompletion',true); - fAutoCodeParameters:= - XMLConfig.GetValue('EditorOptions/CodeTools/AutoCodeParameters',true); - fAutoToolTipExprEval:= - XMLConfig.GetValue('EditorOptions/CodeTools/AutoToolTipExprEval',true); - fAutoToolTipSymbTools:= - XMLConfig.GetValue('EditorOptions/CodeTools/AutoToolTipSymbTools',true); - fAutoDelayInMSec:= - XMLConfig.GetValue('EditorOptions/CodeTools/AutoDelayInMSec',1000); - fCodeTemplateFileName:= - XMLConfig.GetValue('EditorOptions/CodeTools/CodeTemplateFileName' - ,SetDirSeparators(GetPrimaryConfigPath+'/lazarus.dci')); end; procedure TEditorOptions.Save; @@ -719,95 +723,99 @@ procedure TEditorOptions.Save; var SynEditOpt:TSynEditorOption; SynEditOptName:ansistring; begin - // general options - for SynEditOpt:=Low(TSynEditorOption) to High(TSynEditorOption) do begin - case SynEditOpt of - eoAltSetsColumnMode:SynEditOptName:='AltSetsColumnMode'; - eoAutoIndent:SynEditOptName:='AutoIndent'; - eoDragDropEditing:SynEditOptName:='DragDropEditing'; - eoDropFiles:SynEditOptName:='DropFiles'; - eoHalfPageScroll:SynEditOptName:='HalfPageScroll'; - eoKeepCaretX:SynEditOptName:='KeepCaretX'; - eoNoCaret:SynEditOptName:='NoCaret'; - eoNoSelection:SynEditOptName:='NoSelection'; - eoScrollByOneLess:SynEditOptName:='ScrollByOneLess'; - eoScrollPastEof:SynEditOptName:='ScrollPastEof'; - eoScrollPastEol:SynEditOptName:='ScrollPastEol'; - eoShowScrollHint:SynEditOptName:='ShowScrollHint'; - eoSmartTabs:SynEditOptName:='SmartTabs'; - eoTabsToSpaces:SynEditOptName:='TabsToSpaces'; - eoTrimTrailingSpaces:SynEditOptName:='TrimTrailingSpaces'; - else - SynEditOptName:=''; - end; - if SynEditOptName<>'' then begin - XMLConfig.SetValue('EditorOptions/General/Editor/'+SynEditOptName, - SynEditOpt in fSynEditOptions); + try + // general options + for SynEditOpt:=Low(TSynEditorOption) to High(TSynEditorOption) do begin + case SynEditOpt of + eoAltSetsColumnMode:SynEditOptName:='AltSetsColumnMode'; + eoAutoIndent:SynEditOptName:='AutoIndent'; + eoDragDropEditing:SynEditOptName:='DragDropEditing'; + eoDropFiles:SynEditOptName:='DropFiles'; + eoHalfPageScroll:SynEditOptName:='HalfPageScroll'; + eoKeepCaretX:SynEditOptName:='KeepCaretX'; + eoNoCaret:SynEditOptName:='NoCaret'; + eoNoSelection:SynEditOptName:='NoSelection'; + eoScrollByOneLess:SynEditOptName:='ScrollByOneLess'; + eoScrollPastEof:SynEditOptName:='ScrollPastEof'; + eoScrollPastEol:SynEditOptName:='ScrollPastEol'; + eoShowScrollHint:SynEditOptName:='ShowScrollHint'; + eoSmartTabs:SynEditOptName:='SmartTabs'; + eoTabsToSpaces:SynEditOptName:='TabsToSpaces'; + eoTrimTrailingSpaces:SynEditOptName:='TrimTrailingSpaces'; + else + SynEditOptName:=''; + end; + if SynEditOptName<>'' then begin + XMLConfig.SetValue('EditorOptions/General/Editor/'+SynEditOptName, + SynEditOpt in fSynEditOptions); + end; end; + + XMLConfig.SetValue('EditorOptions/General/Editor/UndoAfterSave' + ,fUndoAfterSave); + XMLConfig.SetValue('EditorOptions/General/Editor/DoubleClickLine' + ,fDoubleClickLine); + XMLConfig.SetValue('EditorOptions/General/Editor/FindTextAtCursor' + ,fFindTextAtCursor); + XMLConfig.SetValue('EditorOptions/General/Editor/UseSyntaxHighlight' + ,fUseSyntaxHighlight); + XMLConfig.SetValue('EditorOptions/General/Editor/CreateBackupFiles' + ,fCreateBackupFiles); + XMLConfig.SetValue('EditorOptions/General/Editor/BlockIndent' + ,fBlockIndent); + XMLConfig.SetValue('EditorOptions/General/Editor/UndoLimit' + ,fUndoLimit); + XMLConfig.SetValue('EditorOptions/General/Editor/TabWidths' + ,fTabWidths); + XMLConfig.SetValue('EditorOptions/General/Editor/SyntaxExtensions' + ,fSyntaxExtensions); + + // Display options + XMLConfig.SetValue('EditorOptions/Display/VisibleRightMargin' + ,fVisibleRightMargin); + XMLConfig.SetValue('EditorOptions/Display/VisibleGutter',fVisibleGutter); + XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers',fShowLineNumbers); + XMLConfig.GetValue('EditorOptions/Display/GutterColor',fGutterColor); + XMLConfig.SetValue('EditorOptions/Display/GutterWidth',fGutterWidth); + XMLConfig.SetValue('EditorOptions/Display/RightMargin',fRightMargin); + XMLConfig.SetValue('EditorOptions/Display/RightMarginColor',fRightMarginColor); + XMLConfig.SetValue('EditorOptions/Display/EditorFont',fEditorFont); + XMLConfig.SetValue('EditorOptions/Display/EditorFontHeight' + ,fEditorFontHeight); + XMLConfig.SetValue('EditorOptions/Display/ExtraLineSpacing' + ,fExtraLineSpacing); + + // Key Mappings options + XMLConfig.SetValue('EditorOptions/KeyMapping/Scheme',fKeyMappingScheme); + fKeyMap.SaveToXMLConfig( + XMLConfig,'EditorOptions/KeyMapping/'+fKeyMappingScheme+'/'); + + // Color options + XMLConfig.SetValue('EditorOptions/Color/ColorScheme',fColorScheme); + WriteAttribute(fTextBlockElement); + WriteAttribute(fExecutionPointElement); + WriteAttribute(fEnabledBreakPointElement); + WriteAttribute(fDisabledBreakPointElement); + WriteAttribute(fErrorLineElement); + + // Code Tools options + XMLConfig.SetValue('EditorOptions/CodeTools/AutoCodeCompletion' + ,fAutoCodeCompletion); + XMLConfig.SetValue('EditorOptions/CodeTools/AutoCodeParameters' + ,fAutoCodeParameters); + XMLConfig.SetValue('EditorOptions/CodeTools/AutoToolTipExprEval' + ,fAutoToolTipExprEval); + XMLConfig.SetValue('EditorOptions/CodeTools/AutoToolTipSymbTools' + ,fAutoToolTipSymbTools); + XMLConfig.SetValue('EditorOptions/CodeTools/AutoDelayInMSec' + ,fAutoDelayInMSec); + XMLConfig.SetValue('EditorOptions/CodeTools/CodeTemplateFileName' + ,fCodeTemplateFileName); + + XMLConfig.Flush; + except + writeln('[TEditorOptions.Save] ERROR: unable to write xml file'); end; - - XMLConfig.SetValue('EditorOptions/General/Editor/UndoAfterSave' - ,fUndoAfterSave); - XMLConfig.SetValue('EditorOptions/General/Editor/DoubleClickLine' - ,fDoubleClickLine); - XMLConfig.SetValue('EditorOptions/General/Editor/FindTextAtCursor' - ,fFindTextAtCursor); - XMLConfig.SetValue('EditorOptions/General/Editor/UseSyntaxHighlight' - ,fUseSyntaxHighlight); - XMLConfig.SetValue('EditorOptions/General/Editor/CreateBackupFiles' - ,fCreateBackupFiles); - XMLConfig.SetValue('EditorOptions/General/Editor/BlockIndent' - ,fBlockIndent); - XMLConfig.SetValue('EditorOptions/General/Editor/UndoLimit' - ,fUndoLimit); - XMLConfig.SetValue('EditorOptions/General/Editor/TabWidths' - ,fTabWidths); - XMLConfig.SetValue('EditorOptions/General/Editor/SyntaxExtensions' - ,fSyntaxExtensions); - - // Display options - XMLConfig.SetValue('EditorOptions/Display/VisibleRightMargin' - ,fVisibleRightMargin); - XMLConfig.SetValue('EditorOptions/Display/VisibleGutter',fVisibleGutter); - XMLConfig.GetValue('EditorOptions/Display/ShowLineNumbers',fShowLineNumbers); - XMLConfig.GetValue('EditorOptions/Display/GutterColor',fGutterColor); - XMLConfig.SetValue('EditorOptions/Display/GutterWidth',fGutterWidth); - XMLConfig.SetValue('EditorOptions/Display/RightMargin',fRightMargin); - XMLConfig.SetValue('EditorOptions/Display/RightMarginColor',fRightMarginColor); - XMLConfig.SetValue('EditorOptions/Display/EditorFont',fEditorFont); - XMLConfig.SetValue('EditorOptions/Display/EditorFontHeight' - ,fEditorFontHeight); - XMLConfig.SetValue('EditorOptions/Display/ExtraLineSpacing' - ,fExtraLineSpacing); - - // Key Mappings options - XMLConfig.SetValue('EditorOptions/KeyMapping/Scheme',fKeyMappingScheme); - fKeyMap.SaveToXMLConfig( - XMLConfig,'EditorOptions/KeyMapping/'+fKeyMappingScheme+'/'); - - // Color options - XMLConfig.SetValue('EditorOptions/Color/ColorScheme',fColorScheme); - WriteAttribute(fTextBlockElement); - WriteAttribute(fExecutionPointElement); - WriteAttribute(fEnabledBreakPointElement); - WriteAttribute(fDisabledBreakPointElement); - WriteAttribute(fErrorLineElement); - - // Code Tools options - XMLConfig.SetValue('EditorOptions/CodeTools/AutoCodeCompletion' - ,fAutoCodeCompletion); - XMLConfig.SetValue('EditorOptions/CodeTools/AutoCodeParameters' - ,fAutoCodeParameters); - XMLConfig.SetValue('EditorOptions/CodeTools/AutoToolTipExprEval' - ,fAutoToolTipExprEval); - XMLConfig.SetValue('EditorOptions/CodeTools/AutoToolTipSymbTools' - ,fAutoToolTipSymbTools); - XMLConfig.SetValue('EditorOptions/CodeTools/AutoDelayInMSec' - ,fAutoDelayInMSec); - XMLConfig.SetValue('EditorOptions/CodeTools/CodeTemplateFileName' - ,fCodeTemplateFileName); - - XMLConfig.Flush; end; procedure TEditorOptions.ReadAttribute(Attri:TSynHighlightElement); @@ -1059,7 +1067,7 @@ begin Parent:=Self; Top:=0; Left:=0; - Width:=Self.Width-4; + Width:=Self.Width; Height:=Self.Height-50; Pages.Strings[0]:='General'; Pages.Add('Display'); @@ -2219,10 +2227,11 @@ begin Parent:=MainNoteBook.Page[0]; Top:=TabWidthsComboBox.Top+TabWidthsComboBox.Height+5; Left:=TabWidthsComboBox.Left; - Width:=200; + Width:=300; Items.BeginUpdate; - Items.Add('pp;pas;inc;lfm;lrs;dpr;dpm;dpk'); - Items.Add('pp;pas;inc;dpr;dpm;dpk'); + Items.Add('pp;pas;inc;lpr;lfm;lrs;dpr;dfm;dpk'); + Items.Add('pp;pas;inc;lpr;lrs;dpr;dpk'); + Items.Add('pp;pas;inc;lpr;lrs'); Items.Add('pp;pas;inc'); Items.EndUpdate; SetComboBoxText(SyntaxExtensionsComboBox,EditorOpts.SyntaxExtensions); diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index fa2794b16b..2d0b4c753f 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -70,14 +70,22 @@ type // object inspector FObjectInspectorOptions: TOIOptions; + // compiler + lazarus files + FLazarusDirectory: string; + FCompilerFilename: string; + FFPCSourceDirectory: string; + + // recent files and directories + FRecentOpenFiles: TStringList; + FMaxRecentOpenFiles: integer; + FRecentProjectFiles: TStringList; + FMaxRecentProjectFiles: integer; + FLastOpenDialogDir: string; + // backup FBackupInfoProjectFiles: TBackupInfo; FBackupInfoOtherFiles: TBackupInfo; - // recent files and directories - // ToDo - FLastOpenDialogDir: string; - procedure SetFileName(NewFilename: string); public constructor Create; @@ -125,15 +133,31 @@ type property ObjectInspectorOptions: TOIOptions read FObjectInspectorOptions write FObjectInspectorOptions; + // files + property LazarusDirectory: string + read FLazarusDirectory write FLazarusDirectory; + property CompilerFilename: string + read FCompilerFilename write FCompilerFilename; + property FPCSourceDirectory: string + read FFPCSourceDirectory write FFPCSourceDirectory; + + // recent files and directories + property RecentOpenFiles: TStringList + read FRecentOpenFiles write FRecentOpenFiles; + property MaxRecentOpenFiles: integer + read FMaxRecentOpenFiles write FMaxRecentOpenFiles; + property RecentProjectFiles: TStringList + read FRecentProjectFiles write FRecentProjectFiles; + property MaxRecentProjectFiles: integer + read FMaxRecentProjectFiles write FMaxRecentProjectFiles; + property LastOpenDialogDir: string + read FLastOpenDialogDir write FLastOpenDialogDir; + // backup property BackupInfoProjectFiles: TBackupInfo read FBackupInfoProjectFiles write FBackupInfoProjectFiles; property BackupInfoOtherFiles: TBackupInfo read FBackupInfoOtherFiles write FBackupInfoOtherFiles; - - // recent files and directories - property LastOpenDialogDir: string - read FLastOpenDialogDir write FLastOpenDialogDir; end; //---------------------------------------------------------------------------- @@ -150,6 +174,7 @@ type FOnSaveEnvironmentSettings: TOnSaveEnvironmentSettings; procedure SetupDesktopPage; procedure SetupBackupPage; + procedure SetupFilesPage; procedure SetComboBoxText(AComboBox:TComboBox; AText:AnsiString); published @@ -207,6 +232,18 @@ type BakOtherSubDirLabel: TLabel; BakOtherSubDirComboBox: TComboBox; + // Files + MaxRecentOpenFilesLabel: TLabel; + MaxRecentOpenFilesComboBox: TComboBox; + MaxRecentProjectFilesLabel: TLabel; + MaxRecentProjectFilesComboBox: TComboBox; + LazarusDirLabel: TLabel; + LazarusDirComboBox: TComboBox; + CompilerPathLabel: TLabel; + CompilerPathComboBox: TComboBox; + FPCSourceDirLabel: TLabel; + FPCSourceDirComboBox: TComboBox; + // buttons at bottom OkButton: TButton; CancelButton: TButton; @@ -275,6 +312,18 @@ begin // object inspector FObjectInspectorOptions:=TOIOptions.Create; + // files + FLazarusDirectory:=''; + FCompilerFilename:=''; + FFPCSourceDirectory:=''; + + // recent files and directories + FRecentOpenFiles:=TStringList.Create; + FMaxRecentOpenFiles:=10; + FRecentProjectFiles:=TStringList.Create; + FMaxRecentProjectFiles:=5; + FLastOpenDialogDir:=''; + // backup with FBackupInfoProjectFiles do begin BackupType:=bakSameName; @@ -288,13 +337,12 @@ begin MaxCounter:=3; // for bakCounter SubDirectory:=''; end; - - // recent files and directories - FLastOpenDialogDir:=''; end; destructor TEnvironmentOptions.Destroy; begin + FRecentOpenFiles.Free; + FRecentProjectFiles.Free; FObjectInspectorOptions.Free; inherited Destroy; end; @@ -358,6 +406,18 @@ var XMLConfig: TXMLConfig; end; end; + procedure LoadRecentList(List: TStringList; Path: string); + var i,Count: integer; + s: string; + begin + Count:=XMLConfig.GetValue(Path+'Count',0); + List.Clear; + for i:=1 to Count do begin + s:=XMLConfig.GetValue(Path+'Item'+IntToStr(i)+'/Value',''); + if s<>'' then List.Add(s); + end; + end; + begin try XMLConfig:=TXMLConfig.Create(FFileName); @@ -408,6 +468,14 @@ begin 'EnvironmentOptions/FormEditor/GridSizeY',FGridSizeY); if not OnlyDesktop then begin + // files + FLazarusDirectory:=XMLConfig.GetValue( + 'EnvironmentOptions/LazarusDirectory/Value',FLazarusDirectory); + FCompilerFilename:=XMLConfig.GetValue( + 'EnvironmentOptions/CompilerFilename/Value',FCompilerFilename); + FFPCSourceDirectory:=XMLConfig.GetValue( + 'EnvironmentOptions/FPCSourceDirectory/Value',FFPCSourceDirectory); + // backup LoadBackupInfo(FBackupInfoProjectFiles ,'EnvironmentOptions/BackupProjectFiles/'); @@ -416,6 +484,12 @@ begin end; // recent files and directories + FMaxRecentOpenFiles:=XMLConfig.GetValue( + 'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles); + LoadRecentList(FRecentOpenFiles,'EnvironmentOptions/Recent/OpenFiles/'); + FMaxRecentProjectFiles:=XMLConfig.GetValue( + 'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles); + LoadRecentList(FRecentProjectFiles,'EnvironmentOptions/Recent/ProjectFiles/'); FLastOpenDialogDir:=XMLConfig.GetValue( 'EnvironmentOptions/Recent/LastOpenDialogDir/Value',FLastOpenDialogDir); @@ -461,6 +535,14 @@ var XMLConfig: TXMLConfig; end; end; + procedure SaveRecentList(List: TStringList; Path: string); + var i: integer; + begin + XMLConfig.SetValue(Path+'Count',List.Count); + for i:=0 to List.Count-1 do + XMLConfig.SetValue(Path+'Item'+IntToStr(i+1)+'/Value',List[i]); + end; + begin try XMLConfig:=TXMLConfig.Create(FFileName); @@ -504,6 +586,14 @@ begin XMLConfig.SetValue('EnvironmentOptions/FormEditor/GridSizeY',FGridSizeY); if not OnlyDesktop then begin + // files + XMLConfig.SetValue( + 'EnvironmentOptions/LazarusDirectory/Value',FLazarusDirectory); + XMLConfig.SetValue( + 'EnvironmentOptions/CompilerFilename/Value',FCompilerFilename); + XMLConfig.SetValue( + 'EnvironmentOptions/FPCSourceDirectory/Value',FFPCSourceDirectory); + // backup SaveBackupInfo(FBackupInfoProjectFiles ,'EnvironmentOptions/BackupProjectFiles/'); @@ -512,6 +602,12 @@ begin end; // recent files and directories + XMLConfig.SetValue( + 'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles); + SaveRecentList(FRecentOpenFiles,'EnvironmentOptions/Recent/OpenFiles/'); + XMLConfig.SetValue( + 'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles); + SaveRecentList(FRecentProjectFiles,'EnvironmentOptions/Recent/ProjectFiles/'); XMLConfig.SetValue('EnvironmentOptions/Recent/LastOpenDialogDir/Value' ,FLastOpenDialogDir); @@ -544,12 +640,14 @@ begin with NoteBook do begin Name:='NoteBook'; Parent:=Self; - SetBounds(0,0,Self.ClientWidth-4,Self.ClientHeight-50); + SetBounds(0,0,Self.ClientWidth,Self.ClientHeight-50); Pages[0]:='Desktop'; + Pages.Add('Files'); Pages.Add('Backup'); end; SetupDesktopPage; + SetupFilesPage; SetupBackupPage; NoteBook.Show; @@ -910,7 +1008,7 @@ begin BackupHelpLabel:=TLabel.Create(Self); with BackupHelpLabel do begin Name:='BackupHelpLabel'; - Parent:=NoteBook.Page[1]; + Parent:=NoteBook.Page[2]; Left:=5; Top:=2; Width:=MaxX-Left*2; @@ -922,7 +1020,7 @@ begin BackupProjectGroupBox:=TGroupBox.Create(Self); with BackupProjectGroupBox do begin Name:='BackupProjectGroupBox'; - Parent:=NoteBook.Page[1]; + Parent:=NoteBook.Page[2]; Left:=4; Top:=BackupHelpLabel.Top+BackupHelpLabel.Height+4; Width:=(MaxX div 2) - 11; @@ -1048,7 +1146,7 @@ begin BackupOtherGroupBox:=TGroupBox.Create(Self); with BackupOtherGroupBox do begin Name:='BackupOtherGroupBox'; - Parent:=NoteBook.Page[1]; + Parent:=NoteBook.Page[2]; Left:=BackupProjectGroupBox.Left+BackupProjectGroupBox.Width+10; Top:=BackupHelpLabel.Top+BackupHelpLabel.Height+4; Width:=(MaxX div 2) - 11; @@ -1172,6 +1270,162 @@ begin end; end; +procedure TEnvironmentOptionsDialog.SetupFilesPage; +var MaxX:integer; +begin + MaxX:=ClientWidth-5; + + MaxRecentOpenFilesLabel:=TLabel.Create(Self); + with MaxRecentOpenFilesLabel do begin + Name:='MaxRecentOpenFilesLabel'; + Parent:=NoteBook.Page[1]; + Left:=4; + Top:=4; + Width:=150; + Height:=23; + Caption:='Max recent files'; + Show; + end; + + MaxRecentOpenFilesComboBox:=TComboBox.Create(Self); + with MaxRecentOpenFilesComboBox do begin + Name:='MaxRecentOpenFilesComboBox'; + Parent:=NoteBook.Page[1]; + Left:=MaxRecentOpenFilesLabel.Left+MaxRecentOpenFilesLabel.Width+2; + Top:=MaxRecentOpenFilesLabel.Top; + Width:=60; + Height:=25; + with Items do begin + BeginUpdate; + Add('5'); + Add('10'); + Add('15'); + Add('20'); + Add('25'); + Add('30'); + EndUpdate; + end; + Show; + end; + + MaxRecentProjectFilesLabel:=TLabel.Create(Self); + with MaxRecentProjectFilesLabel do begin + Name:='MaxRecentProjectFilesLabel'; + Parent:=NoteBook.Page[1]; + Left:=MaxRecentOpenFilesLabel.Left; + Top:=MaxRecentOpenFilesLabel.Top+MaxRecentOpenFilesLabel.Height+3; + Width:=MaxRecentOpenFilesLabel.Width; + Height:=MaxRecentOpenFilesLabel.Height; + Caption:='Max recent project files'; + Show; + end; + + MaxRecentProjectFilesComboBox:=TComboBox.Create(Self); + with MaxRecentProjectFilesComboBox do begin + Name:='MaxRecentProjectFilesComboBox'; + Parent:=NoteBook.Page[1]; + Left:=MaxRecentProjectFilesLabel.Left+MaxRecentProjectFilesLabel.Width+2; + Top:=MaxRecentProjectFilesLabel.Top; + Width:=60; + Height:=25; + with Items do begin + BeginUpdate; + Add('5'); + Add('10'); + Add('15'); + Add('20'); + Add('25'); + Add('30'); + EndUpdate; + end; + Show; + end; + + LazarusDirLabel:=TLabel.Create(Self); + with LazarusDirLabel do begin + Name:='LazarusDirLabel'; + Parent:=NoteBook.Page[1]; + Left:=4; + Top:=MaxRecentProjectFilesLabel.Top+MaxRecentProjectFilesLabel.Height+5; + Width:=MaxX-10; + Height:=23; + Caption:='Lazarus directory (default for all projects)'; + Show; + end; + + LazarusDirComboBox:=TComboBox.Create(Self); + with LazarusDirComboBox do begin + Name:='LazarusDirComboBox'; + Parent:=NoteBook.Page[1]; + Left:=LazarusDirLabel.Left; + Top:=LazarusDirLabel.Top+LazarusDirLabel.Height+2; + Width:=LazarusDirLabel.Width; + Height:=25; + with Items do begin + BeginUpdate; + Add(''); + EndUpdate; + end; + Show; + end; + + CompilerPathLabel:=TLabel.Create(Self); + with CompilerPathLabel do begin + Name:='CompilerPathLabel'; + Parent:=NoteBook.Page[1]; + Left:=LazarusDirLabel.Left; + Top:=LazarusDirComboBox.Top+LazarusDirComboBox.Height; + Width:=LazarusDirLabel.Width; + Height:=25; + Caption:='Compiler path (ppc386)'; + Show; + end; + + CompilerPathComboBox:=TComboBox.Create(Self); + with CompilerPathComboBox do begin + Name:='CompilerPathComboBox'; + Parent:=NoteBook.Page[1]; + Left:=LazarusDirLabel.Left; + Top:=CompilerPathLabel.Top+CompilerPathLabel.Height+2; + Width:=LazarusDirLabel.Width; + Height:=25; + with Items do begin + BeginUpdate; + Add('/usr/bin/ppc386'); + EndUpdate; + end; + Show; + end; + + FPCSourceDirLabel:=TLabel.Create(Self); + with FPCSourceDirLabel do begin + Name:='FPCSourceDirLabel'; + Parent:=NoteBook.Page[1]; + Left:=LazarusDirLabel.Left; + Top:=CompilerPathComboBox.Top+CompilerPathComboBox.Height; + Width:=LazarusDirLabel.Width; + Height:=23; + Caption:='FPC source directory'; + Show; + end; + + FPCSourceDirComboBox:=TComboBox.Create(Self); + with FPCSourceDirComboBox do begin + Name:='FPCSourceDirComboBox'; + Parent:=NoteBook.Page[1]; + Left:=LazarusDirLabel.Left; + Top:=FPCSourceDirLabel.Top+FPCSourceDirLabel.Height+2; + Width:=LazarusDirLabel.Width; + Height:=25; + with Items do begin + BeginUpdate; + Add(''); + EndUpdate; + end; + Show; + end; +end; + procedure TEnvironmentOptionsDialog.BakTypeRadioGroupClick(Sender: TObject); var i: integer; begin @@ -1291,6 +1545,15 @@ begin SetComboBoxText(GridSizeXComboBox,IntToStr(GridSizeX)); SetComboBoxText(GridSizeYComboBox,IntToStr(GridSizeY)); + // files + SetComboBoxText(LazarusDirComboBox,LazarusDirectory); + SetComboBoxText(CompilerPathComboBox,CompilerFilename); + SetComboBoxText(FPCSourceDirComboBox,FPCSourceDirectory); + + // recent files and directories + SetComboBoxText(MaxRecentOpenFilesComboBox,IntToStr(MaxRecentOpenFiles)); + SetComboBoxText(MaxRecentProjectFilesComboBox,IntToStr(MaxRecentProjectFiles)); + // backup with BackupInfoProjectFiles do begin case BackupType of @@ -1361,6 +1624,17 @@ begin GridSizeX:=StrToIntDef(GridSizeXComboBox.Text,GridSizeX); GridSizeY:=StrToIntDef(GridSizeYComboBox.Text,GridSizeY); + // files + LazarusDirectory:=LazarusDirComboBox.Text; + CompilerFilename:=CompilerPathComboBox.Text; + FPCSourceDirectory:=FPCSourceDirComboBox.Text; + + // recent files and directories + MaxRecentOpenFiles:=StrToIntDef( + MaxRecentOpenFilesComboBox.Text,MaxRecentOpenFiles); + MaxRecentProjectFiles:=StrToIntDef( + MaxRecentProjectFilesComboBox.Text,MaxRecentProjectFiles); + // backup with BackupInfoProjectFiles do begin case BakProjTypeRadioGroup.ItemIndex of diff --git a/ide/main.pp b/ide/main.pp index 765ada1567..1b6016aefa 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1602,6 +1602,7 @@ writeln('TMainIDE.DoNewEditorUnit 1'); SetDefaultsForForm(TempForm); NewUnitInfo.FormName:=TempForm.Name; + Project.AddCreateFormToProjectFile(TempForm.Name,TempForm.ClassName); end; // create source code @@ -1649,7 +1650,7 @@ var ActiveSrcEdit:TSourceEditor; ResourceCode: TSourceLog; FileStream:TFileStream; begin -writeln('TMainIDE.DoSaveCurUnit 1'); +writeln('TMainIDE.DoSaveEditorUnit 1'); Result:=mrCancel; if ToolStatus<>itNone then begin Result:=mrAbort; @@ -1657,6 +1658,12 @@ writeln('TMainIDE.DoSaveCurUnit 1'); end; GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo); if ActiveUnitInfo=nil then exit; + if (Project.MainUnit>=0) and (Project.Units[Project.MainUnit]=ActiveUnitInfo) + and (ActiveUnitInfo.Filename='') then begin + Result:=DoSaveProject(false); + exit; + end; + ActiveUnitInfo.ReadOnly:=ActiveSrcEdit.ReadOnly; if ActiveUnitInfo.ReadOnly then begin Result:=mrOk; @@ -1667,15 +1674,6 @@ writeln('TMainIDE.DoSaveCurUnit 1'); ActiveUnitInfo.Modified:=true; end; - if ActiveUnitInfo.Filename='' then begin - if (Project.MainUnit>=0) - and (Project.Units[Project.MainUnit]=ActiveUnitInfo) then begin - // new project has no name yet -> save project - Result:=DoSaveProject(true); - exit; - end; - end; - // load old resource file ResourceFileName:=Project.SearchResourceFilename(ActiveUnitInfo); ResourceCode:=TSourceLog.Create(''); @@ -1739,6 +1737,8 @@ writeln('TMainIDE.DoSaveCurUnit 1'); ActiveUnitInfo.Filename,SourceNoteBook.NoteBook.PageIndex); SourceNoteBook.NoteBook.Pages[SourceNoteBook.NoteBook.PageIndex]:= NewPageName; + ResourceFilename:=ChangeFileExt(ActiveUnitInfo.Filename + ,ResourceFileExt); SaveAllParts:=true; end else begin // user cancels @@ -1759,7 +1759,6 @@ writeln('TMainIDE.DoSaveCurUnit 1'); if ActiveUnitInfo.HasResources then begin LFMFilename:=ChangeFileExt(ActiveUnitInfo.Filename,'.lfm'); - ResourceFileName:=Project.SearchResourceFilename(ActiveUnitInfo); // save lrs - lazarus resource file and lfm - lazarus form text file @@ -1768,6 +1767,7 @@ writeln('TMainIDE.DoSaveCurUnit 1'); try repeat try + BinCompStream.Position:=0; Driver:=TBinaryObjectWriter.Create(BinCompStream,4096); try Writer:=TWriter.Create(Driver); @@ -1819,6 +1819,7 @@ writeln('TMainIDE.DoSaveCurUnit 1'); BinCompStream.Position:=0; ObjectBinaryToText(BinCompStream,TxtCompStream); TxtCompStream.Position:=0; + // save lfm file Result:=DoSaveStreamToFile(TxtCompStream,LFMFilename ,ActiveUnitInfo.IsPartOfProject); if Result<>mrOk then exit; @@ -1838,9 +1839,11 @@ writeln('TMainIDE.DoSaveCurUnit 1'); finally BinCompStream.Free; end; - +writeln('saving lrs A ',ResourceFileName); // save resource file - DoBackupFile(ResourceFileName,ActiveUnitInfo.IsPartOfProject); + Result:=DoBackupFile(ResourceFileName,ActiveUnitInfo.IsPartOfProject); + if Result=mrAbort then exit; +writeln('saving lrs B'); repeat try FileStream:=TFileStream.Create(ResourceFileName,fmCreate); @@ -2162,9 +2165,11 @@ var UnitList: TList; i, ProgramNameStart, ProgramNameEnd:integer; MainUnitName: string; MainUnitInfo, AnUnitInfo: TUnitInfo; + MainUnitIndex: integer; Begin UnitList:= TList.Create; try + MainUnitIndex:=-1; for i:=0 to Project.UnitCount-1 do begin if Project.Units[i].IsPartOfProject then begin if OnlyForms then begin @@ -2186,9 +2191,11 @@ Begin MainUnitName:=FindProgramNameInSource(MainUnitInfo.Source.Source ,ProgramNameStart,ProgramNameEnd); end; - if MainUnitName<>'' then + if MainUnitName<>'' then begin + MainUnitIndex:=UnitList.Count; UnitList.Add(TViewUnitsEntry.Create( MainUnitName,i,false)); + end; end; end; end; @@ -2201,7 +2208,11 @@ Begin if AnUnitInfo.Loaded then SourceNoteBook.NoteBook.PageIndex:=AnUnitInfo.EditorIndex else begin - if DoOpenEditorFile(AnUnitInfo.Filename,false)=mrAbort then exit; + if MainUnitIndex=i then + Result:=DoOpenMainUnit(false) + else + Result:=DoOpenEditorFile(AnUnitInfo.Filename,false); + if Result=mrAbort then exit; end; end; end; @@ -2566,6 +2577,7 @@ writeln('[TMainIDE.DoCreateProjectForProgram] END'); end; function TMainIDE.DoBuildProject: TModalResult; +var ActiveSrcEdit: TSourceEditor; begin Result:=mrCancel; if ToolStatus<>itNone then begin @@ -2581,6 +2593,8 @@ begin Application.MessageBox('Create a project first!','Error',mb_ok); Exit; end; + ActiveSrcEdit:=SourceNotebook.GetActiveSE; + if ActiveSrcEdit<>nil then ActiveSrcEdit.ErrorLine:=-1; ToolStatus:=itBuilder; MessagesView.Clear; @@ -2647,8 +2661,7 @@ begin if ActiveSourceEditor=nil then ActiveUnitInfo:=nil else - ActiveUnitInfo:=Project.UnitWithEditorIndex( - SourceNoteBook.NoteBook.PageIndex); + ActiveUnitInfo:=Project.UnitWithEditorIndex(PageIndex); end; end; @@ -2657,13 +2670,16 @@ function TMainIDE.DoSaveStreamToFile(AStream:TStream; // save to file with backup and user interaction var fs:TFileStream; AText,ACaption:string; + OldPos: integer; begin Result:=DoBackupFile(Filename,IsPartOfProject); if Result<>mrOk then exit; + OldPos:=AStream.Position; repeat try fs:=TFileStream.Create(Filename,fmCreate); try + AStream.Position:=OldPos; fs.CopyFrom(AStream,AStream.Size-AStream.Position); finally fs.Free; @@ -2690,6 +2706,7 @@ begin try FileStream:=TFileStream.Create(AFilename,fmOpenRead); try + FileStream.Position:=0; MemStream.CopyFrom(FileStream,FileStream.Size); MemStream.Position:=0; finally @@ -2727,7 +2744,8 @@ begin exit; FilePath:=ExtractFilePath(Filename); FileExt:=ExtractFileExt(Filename); - FileNameOnly:=copy(Filename,1,length(Filename)-length(FileExt)); + FileNameOnly:=ExtractFilename(Filename); + FileNameOnly:=copy(FilenameOnly,1,length(FilenameOnly)-length(FileExt)); if BackupInfo.SubDirectory<>'' then begin SubDir:=FilePath+BackupInfo.SubDirectory; repeat @@ -3183,6 +3201,9 @@ end. { ============================================================================= $Log$ + Revision 1.84 2001/03/29 12:38:59 lazarus + MG: new environment opts, ptApplication bugfixes + Revision 1.83 2001/03/28 14:08:45 lazarus MG: added backup code and fixed removing controls diff --git a/ide/project.pp b/ide/project.pp index d68b155945..e3110e4710 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -241,7 +241,7 @@ type function UnitIsUsed(AUnitName:string):boolean; function GetResourceFilename(AnUnitInfo: TUnitInfo; Index:integer):string; function SearchIncludeFile(AnUnitInfo: TUnitInfo; Filename:string):string; - function SearchFile(Filename,SearchPaths:string):string; + function SearchFile(Filename,SearchPaths,InitialDir:string):string; function SearchResourceFilename(AnUnitInfo: TUnitInfo):string; property ActiveEditorIndexAtStart: integer @@ -672,7 +672,7 @@ begin end; procedure TUnitInfo.SetUnitName(NewUnitName:string); -var OldIncludeFilename,NewIncludeFilename:string; +var NewIncludeFilename:string; IncludeStart,IncludeEnd:integer; Allowed:boolean; begin @@ -686,10 +686,7 @@ begin if FindIncludeDirective(Source.Source,'initialization',1 ,IncludeStart,IncludeEnd) then begin - OldIncludeFilename:=copy(Source.Source,IncludeStart - ,IncludeEnd-IncludeStart); - NewIncludeFilename:= - ExtractFilePath(OldIncludeFilename)+NewUnitName+ResourceFileExt; + NewIncludeFilename:=NewUnitName+ResourceFileExt; Source.Replace(IncludeStart,IncludeEnd-IncludeStart, '{$I '+NewIncludeFilename+'}'); end; @@ -1194,26 +1191,34 @@ begin Result:=ExtractFilePath(AnUnitInfo.Filename)+Filename; if FileExists(Result) then exit; // search in all include paths - Result:=SearchFile(Filename,CompilerOptions.IncludeFiles); + Result:=SearchFile(Filename,CompilerOptions.IncludeFiles + ,ExtractFilePath(AnUnitInfo.Filename)); end; -function TProject.SearchFile(Filename,SearchPaths:string):string; +function TProject.SearchFile(Filename,SearchPaths,InitialDir:string):string; var StartPos,EndPos:integer; - CurPath:string; + CurPath: string; + OldDir: string; begin - StartPos:=1; - while StartPos<=length(SearchPaths) do begin - EndPos:=Startpos; - while (EndPos<=length(SearchPaths)) and (SearchPaths[EndPos]<>';') do - inc(EndPos); - CurPath:=copy(SearchPaths,Startpos,EndPos-StartPos); - if CurPath<>'' then begin - if CurPath[length(CurPath)]<>OSDirSeparator then - CurPath:=CurPath+OSDirSeparator; - Result:=CurPath+Filename; - if FileExists(Result) then exit; + OldDir:=GetCurrentDir; + SetCurrentDir(ExtractFilePath(InitialDir)); + try + StartPos:=1; + while StartPos<=length(SearchPaths) do begin + EndPos:=Startpos; + while (EndPos<=length(SearchPaths)) and (SearchPaths[EndPos]<>';') do + inc(EndPos); + CurPath:=copy(SearchPaths,Startpos,EndPos-StartPos); + if CurPath<>'' then begin + if CurPath[length(CurPath)]<>OSDirSeparator then + CurPath:=CurPath+OSDirSeparator; + Result:=CurPath+Filename; + if FileExists(Result) then exit; + end; + StartPos:=EndPos+1; end; - StartPos:=EndPos+1; + finally + SetCurrentDir(OldDir); end; Result:=''; end; @@ -1392,6 +1397,9 @@ end. { $Log$ + Revision 1.18 2001/03/29 12:38:59 lazarus + MG: new environment opts, ptApplication bugfixes + Revision 1.17 2001/03/26 14:52:30 lazarus MG: TSourceLog + compiling bugfixes