⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synuniclasses.pas

📁 SynEditStudio delphi 代码编辑器
💻 PAS
📖 第 1 页 / 共 2 页
字号:
const
  { Symbols that are always delimiters }
  AbsoluteDelimiters: TCharSet = [#0, #9, #10, #13, #32];
  { End of line identifier }
  EOL = #13#10;

implementation

uses
  SynUniFormatNativeXml20,
{$IFDEF SYN_CLX}
  QSynUniRules;
{$ELSE}
  SynUniRules;
{$ENDIF}

//----------------------------------------------------------------------------
{* * * * * * * * * * * * * * * INTERFACE * * * * * * * * * * * * * * * * * * * }
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function FontStyleToStr(AFontStyle: TFontStyles): string;
begin
  Result := '';
  if fsBold in AFontStyle then Result := Result + 'B';
  if fsItalic in AFontStyle then Result := Result + 'I';
  if fsUnderline in AFontStyle then Result := Result + 'U';
  if fsStrikeOut in AFontStyle then Result := Result + 'S';
end;

//----------------------------------------------------------------------------
function SetToStr(ACharSet: TCharSet): string;
var
  b: byte;
begin
  Result := '';
  for b := 1 to 255 do
    if (chr(b) in ACharSet) and (not (chr(b) in AbsoluteDelimiters)) then
      Result := Result + chr(b);
end;

//----------------------------------------------------------------------------
function StrToFontStyle(AString: string): TFontStyles;
begin
  Result := [];
  if Pos('B', AString) > 0 then
    Include(Result, fsBold);
  if Pos('I', AString) > 0 then
    Include(Result, fsItalic);
  if Pos('U', AString) > 0 then
    Include(Result, fsUnderline);
  if Pos('S', AString) > 0 then
    Include(Result, fsStrikeOut);
end;

//----------------------------------------------------------------------------
function StrToSet(AString: string): TCharSet;
var
   i: Integer;
begin
  Result := [];
  for i := 1 to Length(AString) do
    Result := Result + [AString[i]];
end;

//----------------------------------------------------------------------------
function StartLineToStr(AStartLine: TStartLine): string;
begin
  if AStartLine = slFirst then
    Result := 'True'
  else if AStartLine = slFirstNonSpace then
    Result := 'NonSpace'
  else
    Result := '';
end;

//----------------------------------------------------------------------------
function StrToStartLine(AString: string): TStartLine;
begin
  Result := slNotFirst;
  if (AString = 'True') or (AString = 'First') then
    Result := slFirst
  else if AString = 'NonSpace' then
    Result := slFirstNonSpace
  else if (AString = 'False') or (AString = '') then
    Result := slNotFirst
  else
    //raise Exception.Create('Unknown StartLine identifier');
end;

//----------------------------------------------------------------------------
function StartTypeToStr(AStartType: TStartType): string;
begin

end;

//----------------------------------------------------------------------------
function StrToStartType(AString: string): TStartType;
begin
  if (AString = 'True') or (AString = 'Left') or (AString = '') then
    Result := stAny
  else if (AString = 'Right') or (AString = 'False') then
    Result := stTerm
  else
    Result := stUnspecified//raise Exception.Create('Unknown start types identifier');
end;

//----------------------------------------------------------------------------
function BreakTypeToStr(ABreakType: TBreakType): string;
begin

end;

//----------------------------------------------------------------------------
function StrToBreakType(AString: string): TBreakType;
begin
  if (AString = 'True') or (AString = 'Right') or (AString = '') then
    Result := btAny
  else if (AString = 'Left') or (AString = 'False') then
    Result := btTerm
  else
    Result := btUnspecified;//raise Exception.Create('Unknown break types identifier');
end;

//----------------------------------------------------------------------------
procedure ClearList(var List: TList);
var
  i: Integer;
begin
  if not Assigned(List) then
    Exit;
  for i := 0 to List.Count-1 do
    TObject(List[i]).Free();
  List.Clear();
end;

//----------------------------------------------------------------------------
procedure FreeList(var List: TList);
var
  i: Integer;
begin
  if not Assigned(List) then
    Exit;
  for i := 0 to List.Count - 1 do
    TObject(List[i]).Free();
  FreeAndNil(List);
end;

//----------------------------------------------------------------------------
{* * * * * * * * * * * * * * * TSynInfo * * * * * * * * * * * * * * * * * * * *}
//----------------------------------------------------------------------------
procedure TSynInfo.Clear;
begin
  General.Name := '';
  General.Extensions := '';
  General.Version := 0;
  General.Revision := 0;
  General.Sample := '';
  Author.Name := '';
  Author.Email := '';
  Author.Web := '';
  Author.Copyright := '';
  Author.Company := '';
end;

//----------------------------------------------------------------------------
procedure TSynInfo.LoadFromStream(AStream: TStream);
begin
  TSynUniFormatNativeXml20.ImportFromStream(Self, AStream);
end;

//----------------------------------------------------------------------------
procedure TSynInfo.LoadFromFile(AFileName: string);
begin
  TSynUniFormatNativeXml20.ImportFromFile(Self, AFileName);
end;

//----------------------------------------------------------------------------
procedure TSynInfo.SaveToStream(AStream: TStream);
begin
  TSynUniFormatNativeXml20.ExportToStream(Self, AStream);
end;

//----------------------------------------------------------------------------
procedure TSynInfo.SaveToFile(AFileName: string);
begin
  TSynUniFormatNativeXml20.ExportToFile(Self, AFileName);
end;

//----------------------------------------------------------------------------
{* * * * * * * * * * * * * TEditorProperties * * * * * * * * * * * * * * * * * }
//----------------------------------------------------------------------------
constructor TEditorProperties.Create();
begin
  inherited;
  Clear;
end;

//----------------------------------------------------------------------------
destructor TEditorProperties.Destroy();
begin
  inherited;
end;

//----------------------------------------------------------------------------
procedure TEditorProperties.Clear;
begin
  ActiveLineColor := clNone;
  SelectedForeground := clHighlightText;
  SelectedBackground := clHighlight;
end;

//----------------------------------------------------------------------------
{* * * * * * * * * * * * * * TSynAttributes * * * * * * * * * * * * * * * * * *}
//----------------------------------------------------------------------------
constructor TSynAttributes.Create(AName: String);
begin
  inherited Create(Name);
  //#fName := AName;
end;

//----------------------------------------------------------------------------
destructor TSynAttributes.Destroy();
begin
  //#fName := '';
  inherited;
end;

{$IFNDEF SYNEDIT11}
//----------------------------------------------------------------------------
procedure TSynAttributes.AssignColorAndStyle(AStyle: TSynAttributes);
begin
  inherited AssignColorAndStyle(AStyle);
  ParentForeground := AStyle.ParentForeground;
  ParentBackground := AStyle.ParentBackground;
end;
{$ENDIF}

//----------------------------------------------------------------------------
{* * * * * * * * * * * * * * TAbstractSynSymbol * * * * * * * * * * * * * * * *}
//----------------------------------------------------------------------------
constructor TAbstractSynToken.Create();
begin
  inherited;
  Attributes := nil;
  fIsRegexp  := False; 
  fOpenRule  := nil;
  StartLine  := slNotFirst;
  StartType  := stUnspecified;
  BreakType  := btUnspecified;
end;

//----------------------------------------------------------------------------
constructor TAbstractSynToken.Create(Attribs: TSynHighlighterAttributes);
begin
  Create();
  Attributes := Attribs;
end;

//----------------------------------------------------------------------------
constructor TAbstractSynToken.Create(ASynToken: TAbstractSynToken);
begin
  inherited Create();
  Attributes := ASynToken.Attributes;
  //# fOpenRule  := ASynSymbol.fOpenRule; //TODO: 袜?

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -