IDE: updating source editor when highlighter file extensions have changed

git-svn-id: trunk@10393 -
This commit is contained in:
mattias 2007-01-08 10:26:09 +00:00
parent 312ea10264
commit 0747802d17
3 changed files with 41 additions and 3 deletions

View File

@ -3666,7 +3666,9 @@ var EditorOptionsForm: TEditorOptionsForm;
Begin
EditorOptionsForm:=TEditorOptionsForm.Create(nil);
try
Project1.UpdateCustomHighlighter;
if EditorOptionsForm.ShowModal=mrOk then begin
Project1.UpdateSyntaxHighlighter;
SourceNotebook.ReloadEditorOptions;
ReloadMenuShortCuts;
end;

View File

@ -52,7 +52,7 @@ uses
LazarusIDEStrConsts, CompilerOptions, CodeToolManager, CodeCache,
EditorOptions, IDEProcs, RunParamsOpts, ProjectIntf, ProjectDefs,
FileReferenceList, EditDefineTree, DefineTemplates, PackageDefs, LazIDEIntf,
// for
// for .res files
W32VersionInfo;
type
@ -694,6 +694,10 @@ type
function LoadStateFile(IgnoreErrors: boolean): TModalResult;
function SaveStateFile(const CompilerFilename, CompilerParams: string
): TModalResult;
// source editor
procedure UpdateCustomHighlighter;
procedure UpdateSyntaxHighlighter;
public
property ActiveEditorIndexAtStart: integer read fActiveEditorIndexAtStart
write fActiveEditorIndexAtStart;
@ -3365,6 +3369,31 @@ begin
Result:=mrOk;
end;
procedure TProject.UpdateCustomHighlighter;
var
i: Integer;
AnUnitInfo: TUnitInfo;
begin
for i:=0 to UnitCount-1 do begin
AnUnitInfo:=Units[i];
AnUnitInfo.CustomHighlighter:=AnUnitInfo.SyntaxHighlighter
<>ExtensionToLazSyntaxHighlighter(ExtractFileExt(AnUnitInfo.Filename));
end;
end;
procedure TProject.UpdateSyntaxHighlighter;
var
AnUnitInfo: TUnitInfo;
i: Integer;
begin
for i:=0 to UnitCount-1 do begin
AnUnitInfo:=Units[i];
if not AnUnitInfo.CustomHighlighter then
AnUnitInfo.SyntaxHighlighter:=
ExtensionToLazSyntaxHighlighter(ExtractFileExt(AnUnitInfo.Filename));
end;
end;
procedure TProject.OnUnitNameChange(AnUnitInfo: TUnitInfo;
const OldUnitName, NewUnitName: string; CheckIfAllowed: boolean;
var Allowed: boolean);

View File

@ -5496,13 +5496,20 @@ Procedure TSourceNotebook.ReloadEditorOptions;
var
I: integer;
h: TLazSyntaxHighlighter;
ASrcEdit: TSourceEditor;
AnUnitInfo: TUnitInfo;
Begin
// this reloads the colors for the highlighter and other editor settings.
for h:=Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do
if Highlighters[h]<>nil then
EditorOpts.GetHighlighterSettings(Highlighters[h]);
for I := 0 to FSourceEditorList.Count-1 do
TSourceEditor(FSourceEditorList.Items[i]).RefreshEditorSettings;
for i := 0 to EditorCount-1 do begin
ASrcEdit:=Editors[i];
AnUnitInfo:=Project1.UnitWithEditorIndex(i);
if AnUnitInfo<>nil then
ASrcEdit.SyntaxHighlighterType:=AnUnitInfo.SyntaxHighlighter;
ASrcEdit.RefreshEditorSettings;
end;
// reload code templates
with CodeTemplateModul do begin