mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 09:55:54 +02:00
IDE: updating source editor when highlighter file extensions have changed
git-svn-id: trunk@10393 -
This commit is contained in:
parent
312ea10264
commit
0747802d17
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user