📄 jclborlandtools.pas
字号:
OptionsFile.Free;
end;
Result := Execute(StrDoubleQuote(StrTrimQuotes(PackageName)));
finally
SetCurrentDir(SaveDir);
end;
end;
procedure TJclDCC.SetDefaultOptions;
begin
Options.Clear;
AddPathOption('U', Installation.LibFolderName);
if Installation.RadToolKind = brCppBuilder then
AddPathOption('U', Installation.LibFolderName + PathAddSeparator('obj'));
end;
function TJclDCC.SupportsLibSuffix: Boolean;
begin
{$IFDEF KYLIX}
Result := True;
{$ELSE}
Result := Installation.VersionNumber >= 6;
{$ENDIF KYLIX}
end;
//=== { TJclBorlandMake } ====================================================
function TJclBorlandMake.GetExeName: string;
begin
Result := MakeExeName;
end;
//=== { TJclBpr2Mak } ========================================================
function TJclBpr2Mak.GetExeName: string;
begin
Result := Bpr2MakExeName;
end;
//=== { TJclBorRADToolPalette } ==============================================
constructor TJclBorRADToolPalette.Create(AInstallation: TJclBorRADToolInstallation);
begin
inherited Create(AInstallation);
FKey := PaletteKeyName;
FTabNames := TStringList.Create;
FTabNames.Sorted := True;
ReadTabNames;
end;
destructor TJclBorRADToolPalette.Destroy;
begin
FreeAndNil(FTabNames);
inherited Destroy;
end;
procedure TJclBorRADToolPalette.ComponentsOnTabToStrings(Index: Integer; Strings: TStrings;
IncludeUnitName: Boolean; IncludeHiddenComponents: Boolean);
var
TempList: TStringList;
procedure ProcessList(Hidden: Boolean);
var
D, I: Integer;
List, S: string;
begin
if Hidden then
List := HiddenComponentsOnTab[Index]
else
List := ComponentsOnTab[Index];
List := StrEnsureSuffix(';', List);
while Length(List) > 1 do
begin
D := Pos(';', List);
S := Trim(Copy(List, 1, D - 1));
if not IncludeUnitName then
Delete(S, 1, Pos('.', S));
if Hidden then
begin
I := TempList.IndexOf(S);
if I = -1 then
TempList.AddObject(S, Pointer(True))
else
TempList.Objects[I] := Pointer(True);
end
else
TempList.Add(S);
Delete(List, 1, D);
end;
end;
begin
TempList := TStringList.Create;
try
TempList.Duplicates := dupError;
ProcessList(False);
TempList.Sorted := True;
if IncludeHiddenComponents then
ProcessList(True);
Strings.AddStrings(TempList);
finally
TempList.Free;
end;
end;
function TJclBorRADToolPalette.DeleteTabName(const TabName: string): Boolean;
var
I: Integer;
begin
I := FTabNames.IndexOf(TabName);
Result := I >= 0;
if Result then
begin
Installation.ConfigData.DeleteKey(Key, FTabNames[I]);
Installation.ConfigData.DeleteKey(Key, FTabNames[I] + PaletteHiddenTag);
FTabNames.Delete(I);
end;
end;
function TJclBorRADToolPalette.GetComponentsOnTab(Index: Integer): string;
begin
Result := Installation.ConfigData.ReadString(Key, FTabNames[Index], '');
end;
function TJclBorRADToolPalette.GetHiddenComponentsOnTab(Index: Integer): string;
begin
Result := Installation.ConfigData.ReadString(Key, FTabNames[Index] + PaletteHiddenTag, '');
end;
function TJclBorRADToolPalette.GetTabNameCount: Integer;
begin
Result := FTabNames.Count;
end;
function TJclBorRADToolPalette.GetTabNames(Index: Integer): string;
begin
Result := FTabNames[Index];
end;
procedure TJclBorRADToolPalette.ReadTabNames;
var
TempList: TStringList;
I: Integer;
S: string;
begin
if Installation.ConfigData.SectionExists(Key) then
begin
TempList := TStringList.Create;
try
Installation.ConfigData.ReadSection(Key, TempList);
for I := 0 to TempList.Count - 1 do
begin
S := TempList[I];
if Pos(PaletteHiddenTag, S) = 0 then
FTabNames.Add(S);
end;
finally
TempList.Free;
end;
end;
end;
function TJclBorRADToolPalette.TabNameExists(const TabName: string): Boolean;
begin
Result := FTabNames.IndexOf(TabName) <> -1;
end;
//=== { TJclBorRADToolRepository } ===========================================
constructor TJclBorRADToolRepository.Create(AInstallation: TJclBorRADToolInstallation);
begin
inherited Create(AInstallation);
{$IFDEF KYLIX}
FFileName := AInstallation.ConfigFileName('dro');
{$ELSE}
FFileName := AInstallation.BinFolderName + BorRADToolRepositoryFileName;
{$ENDIF KYLIX}
FPages := TStringList.Create;
IniFile.ReadSection(BorRADToolRepositoryPagesSection, FPages);
CloseIniFile;
end;
destructor TJclBorRADToolRepository.Destroy;
begin
FreeAndNil(FPages);
FreeAndNil(FIniFile);
inherited Destroy;
end;
procedure TJclBorRADToolRepository.AddObject(const FileName, ObjectType, PageName, ObjectName,
IconFileName, Description, Author, Designer: string; const Ancestor: string);
var
SectionName: string;
begin
GetIniFile;
SectionName := AnsiUpperCase(PathRemoveExtension(FileName));
FIniFile.EraseSection(FileName);
FIniFile.EraseSection(SectionName);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectType, ObjectType);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectName, ObjectName);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectPage, PageName);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectIcon, IconFileName);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectDescr, Description);
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectAuthor, Author);
if Ancestor <> '' then
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectAncestor, Ancestor);
if Installation.VersionNumber >= 6 then
FIniFile.WriteString(SectionName, BorRADToolRepositoryObjectDesigner, Designer);
FIniFile.WriteBool(SectionName, BorRADToolRepositoryObjectNewForm, False);
FIniFile.WriteBool(SectionName, BorRADToolRepositoryObjectMainForm, False);
CloseIniFile;
end;
procedure TJclBorRADToolRepository.CloseIniFile;
begin
FreeAndNil(FIniFile);
end;
function TJclBorRADToolRepository.FindPage(const Name: string; OptionalIndex: Integer): string;
var
I: Integer;
begin
I := Pages.IndexOf(Name);
if I >= 0 then
Result := Pages[I]
else
begin
if OptionalIndex < Pages.Count then
Result := Pages[OptionalIndex]
else
Result := '';
end;
end;
function TJclBorRADToolRepository.GetIniFile: TIniFile;
begin
if not Assigned(FIniFile) then
FIniFile := TIniFile.Create(FileName);
Result := FIniFile;
end;
function TJclBorRADToolRepository.GetPages: TStrings;
begin
Result := FPages;
end;
procedure TJclBorRADToolRepository.RemoveObjects(const PartialPath, FileName, ObjectType: string);
var
Sections: TStringList;
I: Integer;
SectionName, FileNamePart, PathPart, DialogFileName: string;
begin
Sections := TStringList.Create;
try
GetIniFile;
FIniFile.ReadSections(Sections);
for I := 0 to Sections.Count - 1 do
begin
SectionName := Sections[I];
if FIniFile.ReadString(SectionName, BorRADToolRepositoryObjectType, '') = ObjectType then
begin
FileNamePart := PathExtractFileNameNoExt(SectionName);
PathPart := StrRight(PathAddSeparator(ExtractFilePath(SectionName)), Length(PartialPath));
DialogFileName := PathExtractFileNameNoExt(FileName);
if StrSame(FileNamePart, DialogFileName) and StrSame(PathPart, PartialPath) then
FIniFile.EraseSection(SectionName);
end;
end;
finally
Sections.Free;
end;
end;
//=== { TJclBorRADToolInstallation } =========================================
constructor TJclBorRADToolInstallation.Create;
begin
inherited Create;
{$IFDEF KYLIX}
FConfigData := TMemIniFile.Create(AConfigDataLocation);
FMake := TJclCommandLineTool.Create('make');
{$ELSE}
FConfigData := TRegistryIniFile.Create(AConfigDataLocation);
FMake := TJclBorlandMake.Create(Self);
// Set option "-l+", which enables use of long command lines. Should be
// default, but there have been reports indicating that's not always the case.
FMake.Options.Add('-l+');
{$ENDIF KYLIX}
FGlobals := TStringList.Create;
ReadInformation;
FIdeTools := TJclBorRADToolIdeTool.Create(Self);
{$IFNDEF KYLIX}
FOpenHelp := TJclBorlandOpenHelp.Create(Self);
{$ENDIF ~KYLIX}
end;
destructor TJclBorRADToolInstallation.Destroy;
begin
FreeAndNil(FRepository);
FreeAndNil(FDCC);
FreeAndNil(FIdePackages);
FreeAndNil(FIdeTools);
{$IFDEF MSWINDOWS}
FreeAndNil(FOpenHelp);
{$ENDIF MSWINDOWS}
FreeAndNil(FPalette);
FreeAndNil(FGlobals);
{$IFDEF KYLIX}
FConfigData.UpdateFile; // TMemIniFile.Destroy doesn't call UpdateFile
{$ENDIF KYLIX}
FreeAndNil(FConfigData);
inherited Destroy;
end;
function TJclBorRADToolInstallation.AddToDebugDCUPath(const Path: string): Boolean;
var
TempDebugDCUPath: TJclBorRADToolPath;
begin
TempDebugDCUPath := DebugDCUPath;
Result := AddMissingPathItems(TempDebugDCUPath, Path);
DebugDCUPath := TempDebugDCUPath;
end;
function TJclBorRADToolInstallation.AddToLibrarySearchPath(const Path: string): Boolean;
var
TempLibraryPath: TJclBorRADToolPath;
begin
TempLibraryPath := LibrarySearchPath;
Result := AddMissingPathItems(TempLibraryPath, Path);
LibrarySearchPath := TempLibraryPath;
end;
function TJclBorRADToolInstallation.AddToLibraryBrowsingPath(const Path: string): Boolean;
var
TempLibraryPath: TJclBorRADToolPath;
begin
TempLibraryPath := LibraryBrowsingPath;
Result := AddMissingPathItems(TempLibraryPath, Path);
LibraryBrowsingPath := TempLibraryPath;
end;
function TJclBorRADToolInstallation.AnyInstanceRunning: Boolean;
var
Processes: TStringList;
I: Integer;
begin
Result := False;
Processes := TStringList.Create;
try
if RunningProcessesList(Processes) then
begin
for I := 0 to Processes.Count - 1 do
if AnsiSameText(IdeExeFileName, Processes[I]) then
begin
Result := True;
Break;
end;
end;
finally
Processes.Free;
end;
end;
{$IFDEF KYLIX}
function TJclBorRADToolInstallation.ConfigFileName(const Extension: string): string;
begin
Result := '';
end;
{$ENDIF KYLIX}
class procedure TJclBorRADToolInstallation.ExtractPaths(const Path: TJclBorRADToolPath; List: TStrings);
begin
StrToStrings(Path, PathSep, List);
end;
function TJclBorRADToolInstallation.AddMissingPathItems(var Path: string; const NewPath: string): Boolean;
var
PathItems, NewItems: TStringList;
Folder: string;
I: Integer;
Missing: Boolean;
begin
Result := False;
PathItems := nil;
NewItems := nil;
try
PathItems := TStringList.Create;
NewItems := TStringList.Create;
ExtractPaths(Path, PathItems);
ExtractPaths(NewPath, NewItems);
for I := 0 to NewItems.Count - 1 do
begin
Folder := NewItems[I];
Missing := FindFolderInPath(Folder, PathItems) = -1;
if Missing then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -