mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 06:38:13 +02:00
IDE: Project/SourceEdit, reimplement user-set custom highlighter. Only calculate default if needed.
This commit is contained in:
parent
046947520c
commit
2a690eac26
@ -41,7 +41,9 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
IdeHighlighterNoneID = TIdeSyntaxHighlighterID(0);
|
IdeHighlighterUnknownId = TIdeSyntaxHighlighterID(-2); // Name not in list
|
||||||
|
IdeHighlighterNotSpecifiedId = TIdeSyntaxHighlighterID(-1); // No Name given
|
||||||
|
IdeHighlighterNoneID = TIdeSyntaxHighlighterID(0);
|
||||||
IdeHighlighterStartId = TIdeSyntaxHighlighterID(1); // first regulor Highlighter in IdeSyntaxHighlighters (lowest index)
|
IdeHighlighterStartId = TIdeSyntaxHighlighterID(1); // first regulor Highlighter in IdeSyntaxHighlighters (lowest index)
|
||||||
|
|
||||||
LazSyntaxHighlighterNames: array[TLazSyntaxHighlighter] of String =
|
LazSyntaxHighlighterNames: array[TLazSyntaxHighlighter] of String =
|
||||||
|
@ -1580,8 +1580,6 @@ begin
|
|||||||
// add .lpr file to project as main unit
|
// add .lpr file to project as main unit
|
||||||
MainUnitInfo:=TUnitInfo.Create(fMainUnitConverter.fPascalBuffer);
|
MainUnitInfo:=TUnitInfo.Create(fMainUnitConverter.fPascalBuffer);
|
||||||
Assert(Assigned(IDEEditorOptions), 'TConvertDelphiProject.CreateMainSourceFile: IDEEditorOptions is Nil.');
|
Assert(Assigned(IDEEditorOptions), 'TConvertDelphiProject.CreateMainSourceFile: IDEEditorOptions is Nil.');
|
||||||
MainUnitInfo.DefaultSyntaxHighlighter:=
|
|
||||||
IdeSyntaxHighlighters.GetIdForFileExtension(fMainUnitConverter.LazFileExt);
|
|
||||||
MainUnitInfo.IsPartOfProject:=true;
|
MainUnitInfo.IsPartOfProject:=true;
|
||||||
LazProject.AddFile(MainUnitInfo,false);
|
LazProject.AddFile(MainUnitInfo,false);
|
||||||
LazProject.MainFileID:=0;
|
LazProject.MainFileID:=0;
|
||||||
|
@ -3231,9 +3231,13 @@ end;
|
|||||||
|
|
||||||
function TEditOptLangList.GetIdForName(AName: String): TIdeSyntaxHighlighterID;
|
function TEditOptLangList.GetIdForName(AName: String): TIdeSyntaxHighlighterID;
|
||||||
begin
|
begin
|
||||||
|
if AName = '' then
|
||||||
|
exit(IdeHighlighterNotSpecifiedId);
|
||||||
Result := Count - 1;
|
Result := Count - 1;
|
||||||
while (Result >= 0) and (CompareText(AName, Names[Result]) <> 0) do
|
while (Result >= 0) and (CompareText(AName, Names[Result]) <> 0) do
|
||||||
dec(Result);
|
dec(Result);
|
||||||
|
if Result < 0 then
|
||||||
|
Result := IdeHighlighterUnknownId;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEditOptLangList.GetCaptions(AnID: TIdeSyntaxHighlighterID): String;
|
function TEditOptLangList.GetCaptions(AnID: TIdeSyntaxHighlighterID): String;
|
||||||
@ -3256,6 +3260,9 @@ var
|
|||||||
h: TEditOptLanguageInfo;
|
h: TEditOptLanguageInfo;
|
||||||
i: SizeInt;
|
i: SizeInt;
|
||||||
begin
|
begin
|
||||||
|
if AnID = IdeHighlighterNotSpecifiedId then // IdeHighlighterNoneID
|
||||||
|
Result := ''
|
||||||
|
else
|
||||||
if AnID <= 0 then // IdeHighlighterNoneID
|
if AnID <= 0 then // IdeHighlighterNoneID
|
||||||
Result := LazSyntaxHighlighterNames{%H-}[lshNone]
|
Result := LazSyntaxHighlighterNames{%H-}[lshNone]
|
||||||
else begin
|
else begin
|
||||||
|
17
ide/main.pp
17
ide/main.pp
@ -452,7 +452,6 @@ type
|
|||||||
procedure EnvironmentOptionsBeforeRead(Sender: TObject);
|
procedure EnvironmentOptionsBeforeRead(Sender: TObject);
|
||||||
procedure EnvironmentOptionsBeforeWrite(Sender: TObject; Restore: boolean);
|
procedure EnvironmentOptionsBeforeWrite(Sender: TObject; Restore: boolean);
|
||||||
procedure EnvironmentOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
procedure EnvironmentOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
||||||
procedure EditorOptionsBeforeRead(Sender: TObject);
|
|
||||||
procedure EditorOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
procedure EditorOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
||||||
procedure CodetoolsOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
procedure CodetoolsOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
||||||
procedure CodeExplorerOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
procedure CodeExplorerOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
||||||
@ -1381,7 +1380,6 @@ begin
|
|||||||
|
|
||||||
EditorOpts := TEditorOptions.Create;
|
EditorOpts := TEditorOptions.Create;
|
||||||
IDEEditorOptions := EditorOpts;
|
IDEEditorOptions := EditorOpts;
|
||||||
EditorOpts.OnBeforeRead := @EditorOptionsBeforeRead;
|
|
||||||
EditorOpts.OnAfterWrite := @EditorOptionsAfterWrite;
|
EditorOpts.OnAfterWrite := @EditorOptionsAfterWrite;
|
||||||
SetupIDECommands;
|
SetupIDECommands;
|
||||||
// Only after EditorOpts.KeyMap.DefineCommandCategories; in SetupIDECommands
|
// Only after EditorOpts.KeyMap.DefineCommandCategories; in SetupIDECommands
|
||||||
@ -5226,19 +5224,11 @@ begin
|
|||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.EditorOptionsBeforeRead(Sender: TObject);
|
|
||||||
begin
|
|
||||||
// update editor options?
|
|
||||||
if Project1=nil then exit;
|
|
||||||
Project1.UpdateAllCustomHighlighter;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainIDE.EditorOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
procedure TMainIDE.EditorOptionsAfterWrite(Sender: TObject; Restore: boolean);
|
||||||
begin
|
begin
|
||||||
if Restore then exit;
|
if Restore then exit;
|
||||||
if Project1<>nil then
|
|
||||||
Project1.UpdateAllSyntaxHighlighter;
|
|
||||||
SourceEditorManager.BeginGlobalUpdate;
|
SourceEditorManager.BeginGlobalUpdate;
|
||||||
|
SourceEditorManager.UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
try
|
try
|
||||||
UpdateHighlighters(True);
|
UpdateHighlighters(True);
|
||||||
SourceEditorManager.ReloadEditorOptions;
|
SourceEditorManager.ReloadEditorOptions;
|
||||||
@ -5313,8 +5303,8 @@ begin
|
|||||||
Project1.WriteProject([pwfSkipSeparateSessionInfo,pwfIgnoreModified],
|
Project1.WriteProject([pwfSkipSeparateSessionInfo,pwfIgnoreModified],
|
||||||
aFilename,EnvironmentOptions.BuildMatrixOptions);
|
aFilename,EnvironmentOptions.BuildMatrixOptions);
|
||||||
end;
|
end;
|
||||||
Project1.UpdateAllSyntaxHighlighter;
|
|
||||||
SourceEditorManager.BeginGlobalUpdate;
|
SourceEditorManager.BeginGlobalUpdate;
|
||||||
|
SourceEditorManager.UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
try
|
try
|
||||||
UpdateHighlighters(True);
|
UpdateHighlighters(True);
|
||||||
SourceEditorManager.ReloadEditorOptions;
|
SourceEditorManager.ReloadEditorOptions;
|
||||||
@ -6080,7 +6070,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
DlgResult:=ShowUnitInfoDlg(ShortUnitName,
|
DlgResult:=ShowUnitInfoDlg(ShortUnitName,
|
||||||
IdeSyntaxHighlighters.Captions[ActiveUnitInfo.DefaultSyntaxHighlighter],
|
|
||||||
ActiveUnitInfo.IsPartOfProject,
|
ActiveUnitInfo.IsPartOfProject,
|
||||||
SizeInBytes,UnitSizeWithIncludeFiles,UnitSizeParsed,
|
SizeInBytes,UnitSizeWithIncludeFiles,UnitSizeParsed,
|
||||||
LineCount,UnitLineCountWithIncludes,UnitLineCountParsed,
|
LineCount,UnitLineCountWithIncludes,UnitLineCountParsed,
|
||||||
@ -11511,7 +11500,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if AnUpdates * [sepuNewShared, sepuChangedHighlighter] <> [] then begin
|
if AnUpdates * [sepuNewShared, sepuChangedHighlighter] <> [] then begin
|
||||||
p.SyntaxHighlighter := SrcEdit.SyntaxHighlighterId;
|
p.CustomSyntaxHighlighter := SrcEdit.SyntaxHighlighterId;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p.PageIndex := SrcEdit.PageIndex;
|
p.PageIndex := SrcEdit.PageIndex;
|
||||||
|
@ -1766,7 +1766,7 @@ begin
|
|||||||
ASrcEdit := SourceEditorManager.SourceEditors[i];
|
ASrcEdit := SourceEditorManager.SourceEditors[i];
|
||||||
AnEditorInfo:=Project1.EditorInfoWithEditorComponent(ASrcEdit);
|
AnEditorInfo:=Project1.EditorInfoWithEditorComponent(ASrcEdit);
|
||||||
if AnEditorInfo <> nil then
|
if AnEditorInfo <> nil then
|
||||||
ASrcEdit.SyntaxHighlighterId := AnEditorInfo.SyntaxHighlighter;
|
ASrcEdit.SyntaxHighlighterId := AnEditorInfo.CustomSyntaxHighlighter;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
@ -172,7 +172,6 @@ type
|
|||||||
uifBuildFileIfActive,
|
uifBuildFileIfActive,
|
||||||
uifComponentUsedByDesigner,
|
uifComponentUsedByDesigner,
|
||||||
uifComponentIndirectlyUsedByDesigner,
|
uifComponentIndirectlyUsedByDesigner,
|
||||||
uifCustomDefaultHighlighter,
|
|
||||||
uifDisableI18NForLFM,
|
uifDisableI18NForLFM,
|
||||||
uifFileReadOnly,
|
uifFileReadOnly,
|
||||||
uifHasErrorInLFM,
|
uifHasErrorInLFM,
|
||||||
@ -204,15 +203,13 @@ type
|
|||||||
FTopLine: integer;
|
FTopLine: integer;
|
||||||
FCursorPos: TPoint; // physical (screen) position
|
FCursorPos: TPoint; // physical (screen) position
|
||||||
FFoldState: String;
|
FFoldState: String;
|
||||||
// Todo: FCustomHighlighter is only ever set to false, and not stored in XML
|
FCustomSyntaxHighlighter: TIdeSyntaxHighlighterID;
|
||||||
FCustomHighlighter: boolean; // do not change highlighter on file extension change
|
|
||||||
FSyntaxHighlighter: TIdeSyntaxHighlighterID;
|
|
||||||
procedure SetCursorPos(const AValue: TPoint);
|
procedure SetCursorPos(const AValue: TPoint);
|
||||||
procedure SetFoldState(AValue: String);
|
procedure SetFoldState(AValue: String);
|
||||||
procedure SetIsLocked(const AValue: Boolean);
|
procedure SetIsLocked(const AValue: Boolean);
|
||||||
procedure SetPageIndex(const AValue: Integer);
|
procedure SetPageIndex(const AValue: Integer);
|
||||||
procedure SetIsVisibleTab(const AValue: Boolean);
|
procedure SetIsVisibleTab(const AValue: Boolean);
|
||||||
procedure SetSyntaxHighlighter(AValue: TIdeSyntaxHighlighterID);
|
procedure SetCustomSyntaxHighlighter(AValue: TIdeSyntaxHighlighterID);
|
||||||
procedure SetTopLine(const AValue: Integer);
|
procedure SetTopLine(const AValue: Integer);
|
||||||
procedure SetWindowIndex(const AValue: Integer);
|
procedure SetWindowIndex(const AValue: Integer);
|
||||||
protected
|
protected
|
||||||
@ -233,8 +230,7 @@ type
|
|||||||
property CursorPos: TPoint read FCursorPos write SetCursorPos;
|
property CursorPos: TPoint read FCursorPos write SetCursorPos;
|
||||||
property FoldState: String read FFoldState write SetFoldState;
|
property FoldState: String read FFoldState write SetFoldState;
|
||||||
property IsLocked: Boolean read FIsLocked write SetIsLocked;
|
property IsLocked: Boolean read FIsLocked write SetIsLocked;
|
||||||
property CustomHighlighter: Boolean read FCustomHighlighter write FCustomHighlighter; // SetCustomHighlighter
|
property CustomSyntaxHighlighter: TIdeSyntaxHighlighterID read FCustomSyntaxHighlighter write SetCustomSyntaxHighlighter; // User-set HL to override default
|
||||||
property SyntaxHighlighter: TIdeSyntaxHighlighterID read FSyntaxHighlighter write SetSyntaxHighlighter; // SetSyntaxHighlighter
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUnitEditorInfoList }
|
{ TUnitEditorInfoList }
|
||||||
@ -275,7 +271,6 @@ type
|
|||||||
private
|
private
|
||||||
FComponentTypesToClasses: TStringToPointerTree;
|
FComponentTypesToClasses: TStringToPointerTree;
|
||||||
FComponentVarsToClasses: TStringToPointerTree;
|
FComponentVarsToClasses: TStringToPointerTree;
|
||||||
FDefaultSyntaxHighlighter: TIdeSyntaxHighlighterID;
|
|
||||||
FEditorInfoList: TUnitEditorInfoList;
|
FEditorInfoList: TUnitEditorInfoList;
|
||||||
fAutoRevertLockCount: integer;// =0 means, codetools can auto update from disk
|
fAutoRevertLockCount: integer;// =0 means, codetools can auto update from disk
|
||||||
fBookmarks: TFileBookmarks;
|
fBookmarks: TFileBookmarks;
|
||||||
@ -314,7 +309,6 @@ type
|
|||||||
function ComponentLFMOnDiskHasChanged: boolean;
|
function ComponentLFMOnDiskHasChanged: boolean;
|
||||||
function GetAutoReferenceSourceDir: boolean;
|
function GetAutoReferenceSourceDir: boolean;
|
||||||
function GetBuildFileIfActive: boolean;
|
function GetBuildFileIfActive: boolean;
|
||||||
function GetCustomDefaultHighlighter: boolean;
|
|
||||||
function GetDisableI18NForLFM: boolean;
|
function GetDisableI18NForLFM: boolean;
|
||||||
function GetEditorInfo(Index: Integer): TUnitEditorInfo;
|
function GetEditorInfo(Index: Integer): TUnitEditorInfo;
|
||||||
function GetFileReadOnly: Boolean;
|
function GetFileReadOnly: Boolean;
|
||||||
@ -332,8 +326,6 @@ type
|
|||||||
function GetUserReadOnly: Boolean;
|
function GetUserReadOnly: Boolean;
|
||||||
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
procedure SetBuildFileIfActive(const AValue: boolean);
|
procedure SetBuildFileIfActive(const AValue: boolean);
|
||||||
procedure SetCustomDefaultHighlighter(AValue: boolean);
|
|
||||||
procedure SetDefaultSyntaxHighlighter(const AValue: TIdeSyntaxHighlighterID);
|
|
||||||
procedure SetDisableI18NForLFM(const AValue: boolean);
|
procedure SetDisableI18NForLFM(const AValue: boolean);
|
||||||
procedure SetFileReadOnly(const AValue: Boolean);
|
procedure SetFileReadOnly(const AValue: Boolean);
|
||||||
procedure SetComponent(const AValue: TComponent);
|
procedure SetComponent(const AValue: TComponent);
|
||||||
@ -359,7 +351,6 @@ type
|
|||||||
procedure SetInternalFilename(const NewFilename: string);
|
procedure SetInternalFilename(const NewFilename: string);
|
||||||
procedure SetUnitName(const AValue: string); override;
|
procedure SetUnitName(const AValue: string); override;
|
||||||
|
|
||||||
procedure UpdateHasCustomHighlighter(aDefaultHighlighter: TIdeSyntaxHighlighterID);
|
|
||||||
procedure UpdatePageIndex;
|
procedure UpdatePageIndex;
|
||||||
public
|
public
|
||||||
constructor Create(ACodeBuffer: TCodeBuffer);
|
constructor Create(ACodeBuffer: TCodeBuffer);
|
||||||
@ -430,8 +421,6 @@ type
|
|||||||
property OpenEditorInfo[Index: Integer]: TUnitEditorInfo read GetOpenEditorInfo;
|
property OpenEditorInfo[Index: Integer]: TUnitEditorInfo read GetOpenEditorInfo;
|
||||||
function GetClosedOrNewEditorInfo: TUnitEditorInfo;
|
function GetClosedOrNewEditorInfo: TUnitEditorInfo;
|
||||||
procedure SetLastUsedEditor(AEditor:TSourceEditorInterface);
|
procedure SetLastUsedEditor(AEditor:TSourceEditorInterface);
|
||||||
// Highlighter
|
|
||||||
procedure UpdateDefaultHighlighter(aDefaultHighlighter: TIdeSyntaxHighlighterID);
|
|
||||||
public
|
public
|
||||||
{ Properties }
|
{ Properties }
|
||||||
property UnitResourceFileformat: TUnitResourcefileFormatClass read GetUnitResourceFileformat;
|
property UnitResourceFileformat: TUnitResourcefileFormatClass read GetUnitResourceFileformat;
|
||||||
@ -457,8 +446,6 @@ type
|
|||||||
read FComponentLastLRSStreamSize write FComponentLastLRSStreamSize;
|
read FComponentLastLRSStreamSize write FComponentLastLRSStreamSize;
|
||||||
property ComponentLastLFMStreamSize: TStreamSeekType
|
property ComponentLastLFMStreamSize: TStreamSeekType
|
||||||
read FComponentLastLFMStreamSize write FComponentLastLFMStreamSize;
|
read FComponentLastLFMStreamSize write FComponentLastLFMStreamSize;
|
||||||
property CustomDefaultHighlighter: boolean
|
|
||||||
read GetCustomDefaultHighlighter write SetCustomDefaultHighlighter;
|
|
||||||
property Directives: TStrings read FDirectives write FDirectives;
|
property Directives: TStrings read FDirectives write FDirectives;
|
||||||
property DisableI18NForLFM: boolean read GetDisableI18NForLFM write SetDisableI18NForLFM;
|
property DisableI18NForLFM: boolean read GetDisableI18NForLFM write SetDisableI18NForLFM;
|
||||||
property FileReadOnly: Boolean read GetFileReadOnly write SetFileReadOnly;
|
property FileReadOnly: Boolean read GetFileReadOnly write SetFileReadOnly;
|
||||||
@ -482,8 +469,6 @@ type
|
|||||||
property RunFileIfActive: boolean read GetRunFileIfActive write SetRunFileIfActive;
|
property RunFileIfActive: boolean read GetRunFileIfActive write SetRunFileIfActive;
|
||||||
property Source: TCodeBuffer read fSource write SetSource;
|
property Source: TCodeBuffer read fSource write SetSource;
|
||||||
property SourceLFM: TCodeBuffer read FSourceLFM write SetSourceLFM;
|
property SourceLFM: TCodeBuffer read FSourceLFM write SetSourceLFM;
|
||||||
property DefaultSyntaxHighlighter: TIdeSyntaxHighlighterID
|
|
||||||
read FDefaultSyntaxHighlighter write SetDefaultSyntaxHighlighter;
|
|
||||||
property UserReadOnly: Boolean read GetUserReadOnly write SetUserReadOnly;
|
property UserReadOnly: Boolean read GetUserReadOnly write SetUserReadOnly;
|
||||||
property AutoReferenceSourceDir: boolean read GetAutoReferenceSourceDir
|
property AutoReferenceSourceDir: boolean read GetAutoReferenceSourceDir
|
||||||
write SetAutoReferenceSourceDir;
|
write SetAutoReferenceSourceDir;
|
||||||
@ -1113,10 +1098,6 @@ type
|
|||||||
function SaveStateFile(const CompilerFilename: string; CompilerParams: TStrings;
|
function SaveStateFile(const CompilerFilename: string; CompilerParams: TStrings;
|
||||||
Complete: boolean): TModalResult;
|
Complete: boolean): TModalResult;
|
||||||
|
|
||||||
// source editor
|
|
||||||
procedure UpdateAllCustomHighlighter;
|
|
||||||
procedure UpdateAllSyntaxHighlighter;
|
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
function GetPOOutDirectory: string;
|
function GetPOOutDirectory: string;
|
||||||
|
|
||||||
@ -1212,7 +1193,6 @@ const
|
|||||||
var
|
var
|
||||||
Project1: TProject absolute LazProject1;// the main project
|
Project1: TProject absolute LazProject1;// the main project
|
||||||
|
|
||||||
function FilenameToLazSyntaxHighlighter(Filename: String): TIdeSyntaxHighlighterID;
|
|
||||||
function AddCompileReasonsDiff(const PropertyName: string;
|
function AddCompileReasonsDiff(const PropertyName: string;
|
||||||
const Old, New: TCompileReasons; Tool: TCompilerDiffTool = nil): boolean;
|
const Old, New: TCompileReasons; Tool: TCompilerDiffTool = nil): boolean;
|
||||||
function dbgs(aType: TUnitCompDependencyType): string; overload;
|
function dbgs(aType: TUnitCompDependencyType): string; overload;
|
||||||
@ -1227,14 +1207,6 @@ const
|
|||||||
ProjOptionsPath = 'ProjectOptions/';
|
ProjOptionsPath = 'ProjectOptions/';
|
||||||
|
|
||||||
|
|
||||||
function FilenameToLazSyntaxHighlighter(Filename: String): TIdeSyntaxHighlighterID;
|
|
||||||
var
|
|
||||||
CompilerMode: TCompilerMode;
|
|
||||||
begin
|
|
||||||
CompilerMode:=CodeToolBoss.GetCompilerModeForDirectory(ExtractFilePath(Filename));
|
|
||||||
Result := IdeSyntaxHighlighters.GetIdForFileExtension(ExtractFileExt(Filename), CompilerMode in [cmDELPHI,cmTP]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function AddCompileReasonsDiff(const PropertyName: string;
|
function AddCompileReasonsDiff(const PropertyName: string;
|
||||||
const Old, New: TCompileReasons; Tool: TCompilerDiffTool): boolean;
|
const Old, New: TCompileReasons; Tool: TCompilerDiffTool): boolean;
|
||||||
begin
|
begin
|
||||||
@ -1347,11 +1319,10 @@ begin
|
|||||||
FUnitInfo.SessionModified := True;
|
FUnitInfo.SessionModified := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitEditorInfo.SetSyntaxHighlighter(AValue: TIdeSyntaxHighlighterID);
|
procedure TUnitEditorInfo.SetCustomSyntaxHighlighter(AValue: TIdeSyntaxHighlighterID);
|
||||||
begin
|
begin
|
||||||
if FSyntaxHighlighter = AValue then Exit;
|
if FCustomSyntaxHighlighter = AValue then Exit;
|
||||||
FSyntaxHighlighter := AValue;
|
FCustomSyntaxHighlighter := AValue;
|
||||||
FCustomHighlighter := FSyntaxHighlighter <> FUnitInfo.DefaultSyntaxHighlighter;
|
|
||||||
FUnitInfo.SessionModified := True;
|
FUnitInfo.SessionModified := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1378,8 +1349,7 @@ begin
|
|||||||
FCursorPos.X := -1;
|
FCursorPos.X := -1;
|
||||||
FCursorPos.Y := -1;
|
FCursorPos.Y := -1;
|
||||||
FFoldState := '';
|
FFoldState := '';
|
||||||
FSyntaxHighlighter := FUnitInfo.DefaultSyntaxHighlighter;
|
FCustomSyntaxHighlighter := IdeHighlighterNotSpecifiedId;
|
||||||
FCustomHighlighter := FUnitInfo.CustomDefaultHighlighter;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TUnitEditorInfo.Create(aUnitInfo: TUnitInfo);
|
constructor TUnitEditorInfo.Create(aUnitInfo: TUnitInfo);
|
||||||
@ -1411,9 +1381,11 @@ begin
|
|||||||
FFoldState := XMLConfig.GetValue(Path+'FoldState/Value', '');
|
FFoldState := XMLConfig.GetValue(Path+'FoldState/Value', '');
|
||||||
FIsLocked := XMLConfig.GetValue(Path+'IsLocked/Value', False);
|
FIsLocked := XMLConfig.GetValue(Path+'IsLocked/Value', False);
|
||||||
if IdeSyntaxHighlighters <> nil then
|
if IdeSyntaxHighlighters <> nil then
|
||||||
FSyntaxHighlighter := IdeSyntaxHighlighters.GetIdForName(
|
FCustomSyntaxHighlighter := IdeSyntaxHighlighters.GetIdForName(
|
||||||
XMLConfig.GetValue(Path+'SyntaxHighlighter/Value',
|
XMLConfig.GetValue(Path+'SyntaxHighlighter/Value',
|
||||||
IdeSyntaxHighlighters.Names[UnitInfo.DefaultSyntaxHighlighter]));
|
IdeSyntaxHighlighters.Names[IdeHighlighterNotSpecifiedId]))
|
||||||
|
else
|
||||||
|
FCustomSyntaxHighlighter := IdeHighlighterUnknownId;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitEditorInfo.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure TUnitEditorInfo.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
@ -1430,10 +1402,11 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'FoldState/Value', FoldState, '')
|
XMLConfig.SetDeleteValue(Path+'FoldState/Value', FoldState, '')
|
||||||
else
|
else
|
||||||
XMLConfig.DeletePath(Path+'FoldState');
|
XMLConfig.DeletePath(Path+'FoldState');
|
||||||
if IdeSyntaxHighlighters <> nil then
|
if (FCustomSyntaxHighlighter <> IdeHighlighterUnknownId) and // Don't overwrite, if the value is currently not registerd
|
||||||
|
(IdeSyntaxHighlighters <> nil)
|
||||||
|
then
|
||||||
XMLConfig.SetDeleteValue(Path+'SyntaxHighlighter/Value',
|
XMLConfig.SetDeleteValue(Path+'SyntaxHighlighter/Value',
|
||||||
IdeSyntaxHighlighters.Names[fSyntaxHighlighter],
|
IdeSyntaxHighlighters.Names[FCustomSyntaxHighlighter], '');
|
||||||
IdeSyntaxHighlighters.Names[UnitInfo.DefaultSyntaxHighlighter]);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUnitEditorInfoList }
|
{ TUnitEditorInfoList }
|
||||||
@ -1784,9 +1757,7 @@ begin
|
|||||||
fComponentName := '';
|
fComponentName := '';
|
||||||
fComponentResourceName := '';
|
fComponentResourceName := '';
|
||||||
FComponentState := wsNormal;
|
FComponentState := wsNormal;
|
||||||
FDefaultSyntaxHighlighter := IdeHighlighterNoneID;
|
|
||||||
DisableI18NForLFM:=false;
|
DisableI18NForLFM:=false;
|
||||||
CustomDefaultHighlighter := False;
|
|
||||||
FEditorInfoList.ClearEachInfo;
|
FEditorInfoList.ClearEachInfo;
|
||||||
fFilename := '';
|
fFilename := '';
|
||||||
FileReadOnly := false;
|
FileReadOnly := false;
|
||||||
@ -1922,10 +1893,6 @@ begin
|
|||||||
RunFileIfActive,false);
|
RunFileIfActive,false);
|
||||||
// save custom session data
|
// save custom session data
|
||||||
SaveStringToStringTree(XMLConfig,CustomSessionData,Path+'CustomSessionData/');
|
SaveStringToStringTree(XMLConfig,CustomSessionData,Path+'CustomSessionData/');
|
||||||
if IdeSyntaxHighlighters <> nil then
|
|
||||||
XMLConfig.SetDeleteValue(Path+'DefaultSyntaxHighlighter/Value',
|
|
||||||
IdeSyntaxHighlighters.Names[FDefaultSyntaxHighlighter],
|
|
||||||
IdeSyntaxHighlighters.Names[IdeSyntaxHighlighters.GetIdForLazSyntaxHighlighter(lshFreePascal)]);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1978,10 +1945,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// session data
|
// session data
|
||||||
if IdeSyntaxHighlighters <> nil then
|
|
||||||
FDefaultSyntaxHighlighter := IdeSyntaxHighlighters.GetIdForName(
|
|
||||||
XMLConfig.GetValue(Path+'DefaultSyntaxHighlighter/Value',
|
|
||||||
IdeSyntaxHighlighters.Names[IdeSyntaxHighlighters.GetIdForLazSyntaxHighlighter(lshFreePascal)]));
|
|
||||||
FEditorInfoList.Clear;
|
FEditorInfoList.Clear;
|
||||||
FEditorInfoList.NewEditorInfo;
|
FEditorInfoList.NewEditorInfo;
|
||||||
FEditorInfoList[0].LoadFromXMLConfig(XMLConfig, Path);
|
FEditorInfoList[0].LoadFromXMLConfig(XMLConfig, Path);
|
||||||
@ -2064,22 +2027,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
fFileName:=NewFilename;
|
fFileName:=NewFilename;
|
||||||
if IDEEditorOptions<>nil then
|
|
||||||
UpdateDefaultHighlighter(FilenameToLazSyntaxHighlighter(FFilename));
|
|
||||||
UpdateSourceDirectoryReference;
|
UpdateSourceDirectoryReference;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.UpdateHasCustomHighlighter(
|
|
||||||
aDefaultHighlighter: TIdeSyntaxHighlighterID);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
CustomDefaultHighlighter := FDefaultSyntaxHighlighter <> aDefaultHighlighter;
|
|
||||||
for i := 0 to FEditorInfoList.Count - 1 do
|
|
||||||
FEditorInfoList[i].CustomHighlighter :=
|
|
||||||
FEditorInfoList[i].SyntaxHighlighter <> aDefaultHighlighter;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUnitInfo.UpdatePageIndex;
|
procedure TUnitInfo.UpdatePageIndex;
|
||||||
var
|
var
|
||||||
HasPageIndex: Boolean;
|
HasPageIndex: Boolean;
|
||||||
@ -2117,20 +2067,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.UpdateDefaultHighlighter(
|
|
||||||
aDefaultHighlighter: TIdeSyntaxHighlighterID);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
//debugln(['TUnitInfo.UpdateDefaultHighlighter ',Filename,' ',ord(aDefaultHighlighter)]);
|
|
||||||
if not CustomDefaultHighlighter then
|
|
||||||
DefaultSyntaxHighlighter := aDefaultHighlighter
|
|
||||||
else
|
|
||||||
for i := 0 to FEditorInfoList.Count - 1 do
|
|
||||||
if not FEditorInfoList[i].CustomHighlighter then
|
|
||||||
FEditorInfoList[i].SyntaxHighlighter := aDefaultHighlighter;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TUnitInfo.GetFileName: string;
|
function TUnitInfo.GetFileName: string;
|
||||||
begin
|
begin
|
||||||
if fSource<>nil then
|
if fSource<>nil then
|
||||||
@ -2238,11 +2174,6 @@ begin
|
|||||||
Result:=uifBuildFileIfActive in FFlags;
|
Result:=uifBuildFileIfActive in FFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TUnitInfo.GetCustomDefaultHighlighter: boolean;
|
|
||||||
begin
|
|
||||||
Result:=uifCustomDefaultHighlighter in FFlags;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TUnitInfo.GetDisableI18NForLFM: boolean;
|
function TUnitInfo.GetDisableI18NForLFM: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=uifDisableI18NForLFM in FFlags;
|
Result:=uifDisableI18NForLFM in FFlags;
|
||||||
@ -2649,26 +2580,6 @@ begin
|
|||||||
SessionModified:=true;
|
SessionModified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.SetCustomDefaultHighlighter(AValue: boolean);
|
|
||||||
begin
|
|
||||||
if AValue then
|
|
||||||
Include(FFlags, uifCustomDefaultHighlighter)
|
|
||||||
else
|
|
||||||
Exclude(FFlags, uifCustomDefaultHighlighter);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUnitInfo.SetDefaultSyntaxHighlighter(
|
|
||||||
const AValue: TIdeSyntaxHighlighterID);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
if FDefaultSyntaxHighlighter = AValue then exit;
|
|
||||||
FDefaultSyntaxHighlighter := AValue;
|
|
||||||
for i := 0 to FEditorInfoList.Count - 1 do
|
|
||||||
if not FEditorInfoList[i].CustomHighlighter then
|
|
||||||
FEditorInfoList[i].SyntaxHighlighter := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUnitInfo.SetDisableI18NForLFM(const AValue: boolean);
|
procedure TUnitInfo.SetDisableI18NForLFM(const AValue: boolean);
|
||||||
begin
|
begin
|
||||||
if DisableI18NForLFM=AValue then exit;
|
if DisableI18NForLFM=AValue then exit;
|
||||||
@ -3996,8 +3907,6 @@ var
|
|||||||
begin
|
begin
|
||||||
NewBuf:=CodeToolBoss.CreateFile(Filename);
|
NewBuf:=CodeToolBoss.CreateFile(Filename);
|
||||||
AnUnitInfo:=TUnitInfo.Create(NewBuf);
|
AnUnitInfo:=TUnitInfo.Create(NewBuf);
|
||||||
if IDEEditorOptions<>nil then
|
|
||||||
AnUnitInfo.DefaultSyntaxHighlighter := FilenameToLazSyntaxHighlighter(NewBuf.Filename);
|
|
||||||
Result:=AnUnitInfo;
|
Result:=AnUnitInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5517,24 +5426,6 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProject.UpdateAllCustomHighlighter;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
if IDEEditorOptions=nil then exit;
|
|
||||||
for i:=0 to UnitCount-1 do
|
|
||||||
Units[i].UpdateHasCustomHighlighter(FilenameToLazSyntaxHighlighter(Units[i].Filename));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TProject.UpdateAllSyntaxHighlighter;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
if IDEEditorOptions=nil then exit;
|
|
||||||
for i:=0 to UnitCount-1 do
|
|
||||||
Units[i].UpdateDefaultHighlighter(FilenameToLazSyntaxHighlighter(Units[i].Filename));
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TProject.GetPOOutDirectory: string;
|
function TProject.GetPOOutDirectory: string;
|
||||||
begin
|
begin
|
||||||
Result:=POOutputDirectory;
|
Result:=POOutputDirectory;
|
||||||
|
@ -267,7 +267,8 @@ type
|
|||||||
|
|
||||||
FPopUpMenu: TPopupMenu;
|
FPopUpMenu: TPopupMenu;
|
||||||
FMouseActionPopUpMenu: TPopupMenu;
|
FMouseActionPopUpMenu: TPopupMenu;
|
||||||
FSyntaxHighlighterId: TIdeSyntaxHighlighterID;
|
FSyntaxHighlighterId, FDefaultSyntaxHighlighterId: TIdeSyntaxHighlighterID;
|
||||||
|
FDefaultSyntaxHighlighterIdFilename: string;
|
||||||
FErrorLine: integer;
|
FErrorLine: integer;
|
||||||
FErrorColumn: integer;
|
FErrorColumn: integer;
|
||||||
FLineInfoNotification: TIDELineInfoNotification;
|
FLineInfoNotification: TIDELineInfoNotification;
|
||||||
@ -571,6 +572,7 @@ type
|
|||||||
property SourceNotebook: TSourceNotebook read FSourceNoteBook;
|
property SourceNotebook: TSourceNotebook read FSourceNoteBook;
|
||||||
property SyntaxHighlighterId: TIdeSyntaxHighlighterID
|
property SyntaxHighlighterId: TIdeSyntaxHighlighterID
|
||||||
read fSyntaxHighlighterId write SetSyntaxHighlighterId;
|
read fSyntaxHighlighterId write SetSyntaxHighlighterId;
|
||||||
|
procedure UpdateDefaultDefaultSyntaxHighlighterId(AForce: boolean = False);
|
||||||
property SyncroLockCount: Integer read FSyncroLockCount;
|
property SyncroLockCount: Integer read FSyncroLockCount;
|
||||||
function SharedEditorCount: Integer;
|
function SharedEditorCount: Integer;
|
||||||
property SharedEditors[Index: Integer]: TSourceEditor read GetSharedEditors;
|
property SharedEditors[Index: Integer]: TSourceEditor read GetSharedEditors;
|
||||||
@ -775,6 +777,7 @@ type
|
|||||||
procedure IncrementalSearch(ANext, ABackward: Boolean);
|
procedure IncrementalSearch(ANext, ABackward: Boolean);
|
||||||
procedure UpdatePageNames;
|
procedure UpdatePageNames;
|
||||||
procedure UpdateProjectFiles(ACurrentEditor: TSourceEditor = nil);
|
procedure UpdateProjectFiles(ACurrentEditor: TSourceEditor = nil);
|
||||||
|
procedure UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
|
|
||||||
property NoteBookPage[Index: Integer]: TTabSheet read GetNoteBookPage;
|
property NoteBookPage[Index: Integer]: TTabSheet read GetNoteBookPage;
|
||||||
procedure NoteBookInsertPage(Index: Integer; const S: string);
|
procedure NoteBookInsertPage(Index: Integer; const S: string);
|
||||||
@ -1174,6 +1177,7 @@ type
|
|||||||
procedure SetWindowByIDAndPage(AWindowID, APageIndex: integer);
|
procedure SetWindowByIDAndPage(AWindowID, APageIndex: integer);
|
||||||
function SourceEditorIntfWithFilename(const Filename: string): TSourceEditor; reintroduce;
|
function SourceEditorIntfWithFilename(const Filename: string): TSourceEditor; reintroduce;
|
||||||
function FindSourceEditorWithEditorComponent(EditorComp: TComponent): TSourceEditor; // With SynEdit
|
function FindSourceEditorWithEditorComponent(EditorComp: TComponent): TSourceEditor; // With SynEdit
|
||||||
|
procedure UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
protected
|
protected
|
||||||
procedure NewEditorCreated(AEditor: TSourceEditor);
|
procedure NewEditorCreated(AEditor: TSourceEditor);
|
||||||
procedure EditorRemoved(AEditor: TSourceEditor);
|
procedure EditorRemoved(AEditor: TSourceEditor);
|
||||||
@ -1504,6 +1508,7 @@ procedure RegisterStandardSourceEditorMenuItems;
|
|||||||
function dbgSourceNoteBook(snb: TSourceNotebook): string;
|
function dbgSourceNoteBook(snb: TSourceNotebook): string;
|
||||||
function CompareSrcEditIntfWithFilename(SrcEdit1, SrcEdit2: Pointer): integer;
|
function CompareSrcEditIntfWithFilename(SrcEdit1, SrcEdit2: Pointer): integer;
|
||||||
function CompareFilenameWithSrcEditIntf(FilenameStr, SrcEdit: Pointer): integer;
|
function CompareFilenameWithSrcEditIntf(FilenameStr, SrcEdit: Pointer): integer;
|
||||||
|
function FilenameToLazSyntaxHighlighter(Filename: String): TIdeSyntaxHighlighterID;
|
||||||
|
|
||||||
var
|
var
|
||||||
EnglishGPLNotice: string;
|
EnglishGPLNotice: string;
|
||||||
@ -1955,6 +1960,17 @@ begin
|
|||||||
Result:=CompareFilenames(AnsiString(FileNameStr),SE1.FileName);
|
Result:=CompareFilenames(AnsiString(FileNameStr),SE1.FileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FilenameToLazSyntaxHighlighter(Filename: String): TIdeSyntaxHighlighterID;
|
||||||
|
var
|
||||||
|
CompilerMode: TCompilerMode;
|
||||||
|
begin
|
||||||
|
if LazStartsStr(EditorMacroVirtualDrive, FileName) then
|
||||||
|
exit(IdeSyntaxHighlighters.GetIdForLazSyntaxHighlighter(lshFreePascal));
|
||||||
|
|
||||||
|
CompilerMode:=CodeToolBoss.GetCompilerModeForDirectory(ExtractFilePath(Filename));
|
||||||
|
Result := IdeSyntaxHighlighters.GetIdForFileExtension(ExtractFileExt(Filename), CompilerMode in [cmDELPHI,cmTP]);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TToolButton_GotoBookmarks }
|
{ TToolButton_GotoBookmarks }
|
||||||
|
|
||||||
procedure TToolButton_GotoBookmarks.RefreshMenu;
|
procedure TToolButton_GotoBookmarks.RefreshMenu;
|
||||||
@ -3640,6 +3656,7 @@ Begin
|
|||||||
FSourceNoteBook:=nil;
|
FSourceNoteBook:=nil;
|
||||||
|
|
||||||
FSyntaxHighlighterId:=IdeHighlighterNoneID;
|
FSyntaxHighlighterId:=IdeHighlighterNoneID;
|
||||||
|
FDefaultSyntaxHighlighterId := IdeHighlighterNotSpecifiedId;
|
||||||
FErrorLine:=-1;
|
FErrorLine:=-1;
|
||||||
FErrorColumn:=-1;
|
FErrorColumn:=-1;
|
||||||
FSyncroLockCount := 0;
|
FSyncroLockCount := 0;
|
||||||
@ -5047,6 +5064,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.UpdateDefaultDefaultSyntaxHighlighterId(AForce: boolean);
|
||||||
|
var
|
||||||
|
s: String;
|
||||||
|
begin
|
||||||
|
s := FileName;
|
||||||
|
if s <> FDefaultSyntaxHighlighterIdFilename then
|
||||||
|
FDefaultSyntaxHighlighterId := IdeHighlighterNotSpecifiedId;
|
||||||
|
FDefaultSyntaxHighlighterIdFilename := s;
|
||||||
|
|
||||||
|
if (not AForce) and (FSyntaxHighlighterId >= 0) then begin
|
||||||
|
FDefaultSyntaxHighlighterId := IdeHighlighterNotSpecifiedId;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
FDefaultSyntaxHighlighterId := FilenameToLazSyntaxHighlighter(Filename);
|
||||||
|
if FDefaultSyntaxHighlighterId = IdeHighlighterUnknownId then
|
||||||
|
FDefaultSyntaxHighlighterId := IdeHighlighterNoneID;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.SetSyntaxHighlighterId(
|
procedure TSourceEditor.SetSyntaxHighlighterId(
|
||||||
AHighlighterId: TIdeSyntaxHighlighterID);
|
AHighlighterId: TIdeSyntaxHighlighterID);
|
||||||
var
|
var
|
||||||
@ -5058,7 +5094,13 @@ begin
|
|||||||
OldHlIsPas := FEditor.Highlighter is TSynPasSyn;
|
OldHlIsPas := FEditor.Highlighter is TSynPasSyn;
|
||||||
HlIsPas := False;
|
HlIsPas := False;
|
||||||
if EditorOpts.UseSyntaxHighlight then begin
|
if EditorOpts.UseSyntaxHighlight then begin
|
||||||
FEditor.Highlighter:=EditorOpts.HighlighterList.SharedSynInstances[AHighlighterId];
|
if AHighlighterId < 0 then begin
|
||||||
|
if FDefaultSyntaxHighlighterId = IdeHighlighterNotSpecifiedId then
|
||||||
|
UpdateDefaultDefaultSyntaxHighlighterId(True);
|
||||||
|
FEditor.Highlighter:=EditorOpts.HighlighterList.SharedSynInstances[FDefaultSyntaxHighlighterId];
|
||||||
|
end
|
||||||
|
else
|
||||||
|
FEditor.Highlighter:=EditorOpts.HighlighterList.SharedSynInstances[AHighlighterId];
|
||||||
HlIsPas := FEditor.Highlighter is TSynPasSyn;
|
HlIsPas := FEditor.Highlighter is TSynPasSyn;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -7212,8 +7254,8 @@ begin
|
|||||||
if Sender is TIDEMenuItem then begin
|
if Sender is TIDEMenuItem then begin
|
||||||
IDEMenuItem:=TIDEMenuItem(Sender);
|
IDEMenuItem:=TIDEMenuItem(Sender);
|
||||||
i:=IDEMenuItem.Tag;
|
i:=IDEMenuItem.Tag;
|
||||||
if (i>=0) and (i<EditorOpts.HighlighterList.Count) then begin
|
if (i>=-1) and (i<EditorOpts.HighlighterList.Count) then begin
|
||||||
SrcEdit.SyntaxHighlighterId:=i;
|
SrcEdit.SyntaxHighlighterId :=i;
|
||||||
SrcEdit.UpdateProjectFile([sepuChangedHighlighter]);
|
SrcEdit.UpdateProjectFile([sepuChangedHighlighter]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -7668,22 +7710,34 @@ var
|
|||||||
CurCaption: String;
|
CurCaption: String;
|
||||||
IDEMenuItem: TIDEMenuItem;
|
IDEMenuItem: TIDEMenuItem;
|
||||||
begin
|
begin
|
||||||
|
assert(IdeHighlighterNotSpecifiedId=-1, 'TSourceNotebook.UpdateHighlightMenuItems: IdeHighlighterNotSpecifiedId=-1');
|
||||||
|
if SrcEdit.FDefaultSyntaxHighlighterId = IdeHighlighterNotSpecifiedId then
|
||||||
|
SrcEdit.UpdateDefaultDefaultSyntaxHighlighterId(True);
|
||||||
|
|
||||||
SrcEditSubMenuHighlighter.ChildrenAsSubMenu:=true;
|
SrcEditSubMenuHighlighter.ChildrenAsSubMenu:=true;
|
||||||
for i := 0 to EditorOpts.HighlighterList.Count - 1 do begin
|
for i := -1 to EditorOpts.HighlighterList.Count - 1 do begin
|
||||||
if EditorOpts.HighlighterList.SharedSynInstances[i] is TNonSrcIDEHighlighter then
|
if (i >= 0) and (EditorOpts.HighlighterList.SharedSynInstances[i] is TNonSrcIDEHighlighter) then
|
||||||
continue;
|
continue;
|
||||||
CurName:='Highlighter'+IntToStr(i);
|
CurName:='Highlighter'+IntToStr(i);
|
||||||
CurCaption:= EditorOpts.HighlighterList.Captions[i];
|
if i = IdeHighlighterNotSpecifiedId then begin
|
||||||
if SrcEditSubMenuHighlighter.Count=i then begin
|
if SrcEdit.FDefaultSyntaxHighlighterId <> IdeHighlighterNotSpecifiedId then
|
||||||
|
CurCaption:= Format('%s (%s)', [lisDefault, EditorOpts.HighlighterList.Captions[SrcEdit.FDefaultSyntaxHighlighterId]])
|
||||||
|
else
|
||||||
|
CurCaption:= lisDefault;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
CurCaption:= EditorOpts.HighlighterList.Captions[i];
|
||||||
|
|
||||||
|
if SrcEditSubMenuHighlighter.Count=i+1 then begin
|
||||||
// add new item
|
// add new item
|
||||||
IDEMenuItem:=RegisterIDEMenuCommand(SrcEditSubMenuHighlighter,
|
IDEMenuItem:=RegisterIDEMenuCommand(SrcEditSubMenuHighlighter,
|
||||||
CurName,CurCaption,@HighlighterClicked);
|
CurName,CurCaption,@HighlighterClicked);
|
||||||
end else begin
|
end else begin
|
||||||
IDEMenuItem:=SrcEditSubMenuHighlighter[i];
|
IDEMenuItem:=SrcEditSubMenuHighlighter[i+1];
|
||||||
IDEMenuItem.Caption:=CurCaption;
|
|
||||||
IDEMenuItem.Tag:=i;
|
|
||||||
IDEMenuItem.OnClick:=@HighlighterClicked;
|
IDEMenuItem.OnClick:=@HighlighterClicked;
|
||||||
end;
|
end;
|
||||||
|
IDEMenuItem.Caption:=CurCaption;
|
||||||
|
IDEMenuItem.Tag:=i;
|
||||||
if IDEMenuItem is TIDEMenuCommand then
|
if IDEMenuItem is TIDEMenuCommand then
|
||||||
TIDEMenuCommand(IDEMenuItem).Checked:=(SrcEdit<>nil)
|
TIDEMenuCommand(IDEMenuItem).Checked:=(SrcEdit<>nil)
|
||||||
and (SrcEdit.FSyntaxHighlighterId=i);
|
and (SrcEdit.FSyntaxHighlighterId=i);
|
||||||
@ -7750,6 +7804,14 @@ begin
|
|||||||
Editors[i].UpdateProjectFile;
|
Editors[i].UpdateProjectFile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := 0 to EditorCount - 1 do
|
||||||
|
Editors[i].UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.UpdateEncodingMenuItems(SrcEdit: TSourceEditor);
|
procedure TSourceNotebook.UpdateEncodingMenuItems(SrcEdit: TSourceEditor);
|
||||||
var
|
var
|
||||||
List: TStringList;
|
List: TStringList;
|
||||||
@ -10987,6 +11049,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorManager.UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := FSourceWindowList.Count - 1 downto 0 do
|
||||||
|
SourceWindows[i].UpdateDefaultDefaultSyntaxHighlighterId;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.NewEditorCreated(AEditor: TSourceEditor);
|
procedure TSourceEditorManager.NewEditorCreated(AEditor: TSourceEditor);
|
||||||
begin
|
begin
|
||||||
if FDefaultCompletionForm <> nil then
|
if FDefaultCompletionForm <> nil then
|
||||||
|
@ -620,12 +620,6 @@ begin
|
|||||||
else
|
else
|
||||||
SrcNotebook := SourceEditorManager.SourceWindows[FWindowIndex];
|
SrcNotebook := SourceEditorManager.SourceWindows[FWindowIndex];
|
||||||
|
|
||||||
// get syntax highlighter type
|
|
||||||
if (uifInternalFile in AnUnitInfo.Flags) then
|
|
||||||
AnUnitInfo.UpdateDefaultHighlighter(IdeSyntaxHighlighters.GetIdForLazSyntaxHighlighter(lshFreePascal))
|
|
||||||
else
|
|
||||||
AnUnitInfo.UpdateDefaultHighlighter(FilenameToLazSyntaxHighlighter(AFilename));
|
|
||||||
|
|
||||||
SrcNotebook.IncUpdateLock;
|
SrcNotebook.IncUpdateLock;
|
||||||
try
|
try
|
||||||
//DebugLn(['TFileOpener.OpenFileInSourceEditor Revert=',ofRevert in Flags,' ',AnUnitInfo.Filename,' PageIndex=',PageIndex]);
|
//DebugLn(['TFileOpener.OpenFileInSourceEditor Revert=',ofRevert in Flags,' ',AnUnitInfo.Filename,' PageIndex=',PageIndex]);
|
||||||
@ -673,7 +667,7 @@ begin
|
|||||||
|
|
||||||
// restore source editor settings
|
// restore source editor settings
|
||||||
DebugBossMgr.DoRestoreDebuggerMarks(AnUnitInfo);
|
DebugBossMgr.DoRestoreDebuggerMarks(AnUnitInfo);
|
||||||
NewSrcEdit.SyntaxHighlighterId := AnEditorInfo.SyntaxHighlighter;
|
NewSrcEdit.SyntaxHighlighterId := AnEditorInfo.CustomSyntaxHighlighter;
|
||||||
NewSrcEdit.EditorComponent.AfterLoadFromFile;
|
NewSrcEdit.EditorComponent.AfterLoadFromFile;
|
||||||
try
|
try
|
||||||
NewSrcEdit.EditorComponent.FoldState := FoldState;
|
NewSrcEdit.EditorComponent.FoldState := FoldState;
|
||||||
@ -925,7 +919,6 @@ begin
|
|||||||
if MacroListViewer.MacroByFullName(FFileName) <> nil then
|
if MacroListViewer.MacroByFullName(FFileName) <> nil then
|
||||||
NewBuf.Source := MacroListViewer.MacroByFullName(FFileName).GetAsSource;
|
NewBuf.Source := MacroListViewer.MacroByFullName(FFileName).GetAsSource;
|
||||||
FNewUnitInfo:=TUnitInfo.Create(NewBuf);
|
FNewUnitInfo:=TUnitInfo.Create(NewBuf);
|
||||||
FNewUnitInfo.DefaultSyntaxHighlighter := IdeSyntaxHighlighters.GetIdForLazSyntaxHighlighter(lshFreePascal);
|
|
||||||
Project1.AddFile(FNewUnitInfo,false);
|
Project1.AddFile(FNewUnitInfo,false);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
@ -2495,7 +2488,7 @@ begin
|
|||||||
CreateSrcEditPageName(NewUnitInfo.Unit_Name, NewUnitInfo.Filename, AShareEditor),
|
CreateSrcEditPageName(NewUnitInfo.Unit_Name, NewUnitInfo.Filename, AShareEditor),
|
||||||
NewUnitInfo.Source, True, AShareEditor);
|
NewUnitInfo.Source, True, AShareEditor);
|
||||||
MainIDEBar.itmFileClose.Enabled:=True;
|
MainIDEBar.itmFileClose.Enabled:=True;
|
||||||
NewSrcEdit.SyntaxHighlighterId:=NewUnitInfo.EditorInfo[0].SyntaxHighlighter;
|
NewSrcEdit.SyntaxHighlighterId:=NewUnitInfo.EditorInfo[0].CustomSyntaxHighlighter;
|
||||||
NewUnitInfo.GetClosedOrNewEditorInfo.EditorComponent := NewSrcEdit;
|
NewUnitInfo.GetClosedOrNewEditorInfo.EditorComponent := NewSrcEdit;
|
||||||
NewSrcEdit.EditorComponent.CaretXY := Point(1,1);
|
NewSrcEdit.EditorComponent.CaretXY := Point(1,1);
|
||||||
|
|
||||||
@ -5757,7 +5750,6 @@ var
|
|||||||
NewSource: TCodeBuffer;
|
NewSource: TCodeBuffer;
|
||||||
NewFilePath, OldFilePath: String;
|
NewFilePath, OldFilePath: String;
|
||||||
OldFilename, OldLFMFilename, NewLFMFilename, S: String;
|
OldFilename, OldLFMFilename, NewLFMFilename, S: String;
|
||||||
NewHighlighter: TIdeSyntaxHighlighterID;
|
|
||||||
AmbiguousFiles: TStringList;
|
AmbiguousFiles: TStringList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
DirRelation: TSPFileMaskRelation;
|
DirRelation: TSPFileMaskRelation;
|
||||||
@ -5899,15 +5891,10 @@ begin
|
|||||||
DebugLn(['RenameUnit CodeToolBoss.RenameMainInclude failed: AnUnitInfo.Source="',AnUnitInfo.Source,'" ResourceCode="',ExtractFilename(LRSCode.Filename),'"']);
|
DebugLn(['RenameUnit CodeToolBoss.RenameMainInclude failed: AnUnitInfo.Source="',AnUnitInfo.Source,'" ResourceCode="',ExtractFilename(LRSCode.Filename),'"']);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// change syntax highlighter
|
|
||||||
NewHighlighter:=FilenameToLazSyntaxHighlighter(NewFilename);
|
|
||||||
AnUnitInfo.UpdateDefaultHighlighter(NewHighlighter);
|
|
||||||
for i := 0 to AnUnitInfo.EditorInfoCount - 1 do
|
for i := 0 to AnUnitInfo.EditorInfoCount - 1 do
|
||||||
if (AnUnitInfo.EditorInfo[i].EditorComponent <> nil) and
|
if (AnUnitInfo.EditorInfo[i].EditorComponent <> nil) then
|
||||||
(not AnUnitInfo.EditorInfo[i].CustomHighlighter)
|
|
||||||
then
|
|
||||||
TSourceEditor(AnUnitInfo.EditorInfo[i].EditorComponent).SyntaxHighlighterId :=
|
TSourceEditor(AnUnitInfo.EditorInfo[i].EditorComponent).SyntaxHighlighterId :=
|
||||||
AnUnitInfo.EditorInfo[i].SyntaxHighlighter;
|
AnUnitInfo.EditorInfo[i].CustomSyntaxHighlighter;
|
||||||
|
|
||||||
// save file
|
// save file
|
||||||
if not NewSource.IsVirtual then begin
|
if not NewSource.IsVirtual then begin
|
||||||
|
@ -63,7 +63,7 @@ type
|
|||||||
function GetIncludedBy: string;
|
function GetIncludedBy: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ShowUnitInfoDlg(const AnUnitName, AType: string;
|
function ShowUnitInfoDlg(const AnUnitName: string;
|
||||||
IsPartOfProject: boolean; SizeInBytes, UnitSizeWithIncludeFiles, UnitSizeParsed,
|
IsPartOfProject: boolean; SizeInBytes, UnitSizeWithIncludeFiles, UnitSizeParsed,
|
||||||
LineCount, UnitLineCountWithIncludes, UnitLineCountParsed: integer;
|
LineCount, UnitLineCountWithIncludes, UnitLineCountParsed: integer;
|
||||||
const FilePath: string; const IncludedBy: string; out ClearIncludedBy: boolean;
|
const FilePath: string; const IncludedBy: string; out ClearIncludedBy: boolean;
|
||||||
@ -73,7 +73,7 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
function ShowUnitInfoDlg(const AnUnitName, AType: string;
|
function ShowUnitInfoDlg(const AnUnitName: string;
|
||||||
IsPartOfProject: boolean; SizeInBytes, UnitSizeWithIncludeFiles,
|
IsPartOfProject: boolean; SizeInBytes, UnitSizeWithIncludeFiles,
|
||||||
UnitSizeParsed, LineCount, UnitLineCountWithIncludes,
|
UnitSizeParsed, LineCount, UnitLineCountWithIncludes,
|
||||||
UnitLineCountParsed: integer; const FilePath: string;
|
UnitLineCountParsed: integer; const FilePath: string;
|
||||||
@ -91,7 +91,6 @@ begin
|
|||||||
FFilePath:=FilePath;
|
FFilePath:=FilePath;
|
||||||
|
|
||||||
ListValues.Items[0].SubItems[0]:=AnUnitName;
|
ListValues.Items[0].SubItems[0]:=AnUnitName;
|
||||||
ListValues.Items[1].SubItems[0]:=AType;
|
|
||||||
|
|
||||||
if IsPartOfProject then s:=lisUIDyes else s:=lisUIDno;
|
if IsPartOfProject then s:=lisUIDyes else s:=lisUIDno;
|
||||||
ListValues.Items[2].SubItems[0]:=s;
|
ListValues.Items[2].SubItems[0]:=s;
|
||||||
@ -153,7 +152,7 @@ begin
|
|||||||
with ListValues do
|
with ListValues do
|
||||||
begin
|
begin
|
||||||
with Items.Add do begin Caption:= lisUIDName; SubItems.Add(''); end;
|
with Items.Add do begin Caption:= lisUIDName; SubItems.Add(''); end;
|
||||||
with Items.Add do begin Caption:= lisUIDType; SubItems.Add(''); end;
|
with Items.Add do begin Caption:= ''{lisUIDType}; SubItems.Add(''); end;
|
||||||
with Items.Add do begin Caption:= lisUIDinProject; SubItems.Add(''); end;
|
with Items.Add do begin Caption:= lisUIDinProject; SubItems.Add(''); end;
|
||||||
with Items.Add do begin Caption:= lisUIDSize; SubItems.Add(''); end;
|
with Items.Add do begin Caption:= lisUIDSize; SubItems.Add(''); end;
|
||||||
with Items.Add do begin Caption:= lisUIDLines; SubItems.Add(''); end;
|
with Items.Add do begin Caption:= lisUIDLines; SubItems.Add(''); end;
|
||||||
|
@ -2614,9 +2614,7 @@ var
|
|||||||
NewProjFile.ComponentResourceName:=OldProjFile.ComponentResourceName;
|
NewProjFile.ComponentResourceName:=OldProjFile.ComponentResourceName;
|
||||||
NewProjFile.BuildFileIfActive:=OldProjFile.BuildFileIfActive;
|
NewProjFile.BuildFileIfActive:=OldProjFile.BuildFileIfActive;
|
||||||
NewProjFile.RunFileIfActive:=OldProjFile.RunFileIfActive;
|
NewProjFile.RunFileIfActive:=OldProjFile.RunFileIfActive;
|
||||||
NewProjFile.DefaultSyntaxHighlighter:=OldProjFile.DefaultSyntaxHighlighter;
|
|
||||||
NewProjFile.DisableI18NForLFM:=OldProjFile.DisableI18NForLFM;
|
NewProjFile.DisableI18NForLFM:=OldProjFile.DisableI18NForLFM;
|
||||||
NewProjFile.CustomDefaultHighlighter:=OldProjFile.CustomDefaultHighlighter;
|
|
||||||
end;
|
end;
|
||||||
if (not SrcIsTarget)
|
if (not SrcIsTarget)
|
||||||
and (pfMainUnitHasUsesSectionForAllUnits in TargetProject.Flags) then
|
and (pfMainUnitHasUsesSectionForAllUnits in TargetProject.Flags) then
|
||||||
|
Loading…
Reference in New Issue
Block a user