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