📄 synuniformatnativexml20.pas
字号:
SetVarAttr('Style', FontStyleToStr(Style));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportSchemes(ASchemes: TSynUniSchemes; ANode: IXMLNode): Boolean;
var
i, j: integer;
NewScheme: TSynScheme;
NewStyle: TSynAttributes;
begin
with ASchemes, ANode.ChildNodes do
begin
Clear();
for i := 0 to Count - 1 do
begin
NewScheme := AddScheme(VarToStr(Item[i].GetVarAttr('Name', '')));
ImportEditorProperties(NewScheme.EditorProperties, Item[i].EnsureChild('Editor'));
with Item[i].EnsureChild('Styles').ChildNodes do
for j := 0 to Count - 1 do
begin
NewStyle := NewScheme.AddStyle(VarToStr(Item[j].GetVarAttr('Name', '')),
clWindowText, clWindow, StrToFontStyle(''));
ImportAttributes(NewStyle, Item[j]);
end;
end;
//SetScheme(GetSchemeName('Default'));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportSchemes(ASchemes: TSynUniSchemes; ANode: IXMLNode): Boolean;
var
i, j: integer;
NewNode: IXMLNode;
begin
with ASchemes do begin
for i := 0 to Count - 1 do
with ANode.AppendElement('Scheme') do
begin
SetVarAttr('Name', Schemes[i].Name);
ExportEditorProperties(Schemes[i].EditorProperties, AppendElement('Editor'));
with AppendElement('Styles') do
for j := 0 to Schemes[i].Count - 1 do
begin
NewNode := AppendElement('Style');
NewNode.SetVarAttr('Name', Schemes[i].Styles[j].Name);
ExportAttributes(Schemes[i].Styles[j], NewNode);
end;
end;
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportKeyList(AKeyList: TSynKeyList; ANode: IXMLNode): Boolean;
begin
with AKeyList, ANode do
begin
Name := VarToStr(GetVarAttr('Name', ''));
Enabled := VarToBool(GetVarAttr('Enabled', ''), True);
Style := VarToStr(GetVarAttr('Style', ''));
KeyList.Text := VarToStr(GetVarAttr('Words', ''));
ImportAttributes(AKeyList.Attributes, EnsureChild('Attributes'));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportKeyList(AKeyList: TSynKeyList; ANode: IXMLNode): Boolean;
begin
with AKeyList, ANode do
begin
ANode.SetVarAttr('Name', Name);
ANode.SetVarAttr('Enabled', BoolToStr(Enabled, True));
ANode.SetVarAttr('Style', Style);
ANode.SetVarAttr('Words', KeyList.Text);
ExportAttributes(AKeyList.Attributes, AppendElement('Attributes'));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportSet(ASet: TSynSet; ANode: IXMLNode): Boolean;
begin
with ASet, ANode do
begin
Name := VarToStr(GetVarAttr('Name', ''));
Enabled := VarToBool(GetVarAttr('Enabled', ''), True);
Style := VarToStr(GetVarAttr('Style', ''));
CharSet := VarToSet(GetVarAttr('Symbols', ''));
Quantity := VarToInt(GetVarAttr('Quantity', ''));
ImportAttributes(ASet.Attributes, EnsureChild('Attributes'));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportSet(ASet: TSynSet; ANode: IXMLNode): Boolean;
begin
with ASet, ANode do
begin
SetVarAttr('Name', Name);
SetVarAttr('Enabled', BoolToStr(Enabled, True));
SetVarAttr('Style', Style);
SetVarAttr('Symbols', SetToStr(CharSet));
SetVarAttr('Quantity', IntToStr(Quantity));
ExportAttributes(ASet.Attributes, AppendElement('Attributes'));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportToken(AToken: TSynMultiToken; ANode: IXMLNode): Boolean;
begin
with AToken, ANode do
begin
Clear();
FinishOnEol := VarToBool(GetVarAttr('FinishOnEol', ''));
StartLine := StrToStartLine(VarToStr(GetVarAttr('StartLine', '')));
StartType := StrToStartType(VarToStr(GetVarAttr('PartOfTerm', '')));
BreakType := StrToBreakType(VarToStr(GetVarAttr('PartOfTerm', '')));
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportToken(AToken: TSynMultiToken; ANode: IXMLNode): Boolean;
begin
with AToken, ANode do
begin
if FinishOnEol then SetVarAttr('FinishOnEol', BoolToStr(FinishOnEol, True));
SetVarAttr('StartLine', StartLineToStr(StartLine));
if (StartType = stTerm) and (BreakType = btTerm) then
SetVarAttr('PartOfTerm', 'False')
else if (StartType = stAny) and (BreakType = btTerm) then
SetVarAttr('PartOfTerm', 'Left')
else if (StartType = stTerm) and (BreakType = btAny) then
SetVarAttr('PartOfTerm', 'Right');
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportRange(ARange: TSynRange; ANode: IXMLNode): Boolean;
var
i: integer;
NewRange: TSynRange;
NewKeyList: TSynKeyList;
NewSet: TSynSet;
begin
with ARange, ANode do begin
Clear;
Name := VarToStr(GetVarAttr('Name', ''));
Enabled := VarToBool(GetVarAttr('Enabled', ''), True);
CaseSensitive := VarToBool(GetVarAttr('CaseSensitive', ''));
Style := VarToStr(GetVarAttr('Style', ''));
Delimiters := VarToSet(EnsureChild('Delimiters').GetVarAttr('Value', ''));
ImportAttributes(ARange.Attributes, EnsureChild('Attributes'));
//TODO: if mainrules then exit, 躅? 箧?怵钿??蜞?疣犷蜞弪 :)
with EnsureChild('Properties') do
begin
CloseOnEol := VarToBool(GetVarAttr('CloseOnEol', ''));
CloseOnTerm := VarToBool(GetVarAttr('CloseOnTerm', ''));
AllowPreviousClose := VarToBool(GetVarAttr('AllowPredClose', ''));
end;
ImportToken(OpenToken, EnsureChild('OpenToken'));
ImportToken(CloseToken, EnsureChild('CloseToken'));
with EnsureChild('MultiTokens') do
for i := 0 to ChildNodes.Count-1 do
with ChildNodes[i] do
AddCoupleTokens(VarToStr(GetVarAttr('Open', '')), VarToStr(GetVarAttr('Close', '')));
{Sub rules}
with EnsureChild('SubRules').ChildNodes do
begin
for i := 0 to Count-1 do
begin
if Item[i].NodeName = 'Range' then
begin
NewRange := TSynRange.Create;
ImportRange(NewRange, Item[i]);
AddRange(NewRange);
end
else if Item[i].NodeName = 'KeyList' then
begin
NewKeyList := TSynKeyList.Create();
ImportKeyList(NewKeyList, Item[i]);
AddKeyList(NewKeyList);
end
else if Item[i].NodeName = 'Set' then
begin
NewSet := TSynSet.Create();
ImportSet(NewSet, Item[i]);
AddSet(NewSet);
end;
end;
end;
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportRange(ARange: TSynRange; ANode: IXMLNode): Boolean;
var
i: integer;
begin
with ARange, ANode do
begin
SetVarAttr('Name', Name);
if not Enabled then
SetVarAttr('Enabled', BoolToStr(Enabled, True));
if CaseSensitive then
SetVarAttr('CaseSensitive', BoolToStr(CaseSensitive, True));
SetVarAttr('Style', Style);
ExportAttributes(ARange.Attributes, AppendElement('Attributes'));
with AppendElement('Delimiters') do
SetVarAttr('Value', SetToStr(Delimiters));
if ANode.NodeName <> 'MainRules' then
begin
ExportToken(OpenToken, AppendElement('OpenToken'));
ExportToken(CloseToken, AppendElement('CloseToken'));
with AppendElement('Properties') do
begin
if CloseOnTerm then
SetVarAttr('CloseOnTerm', BoolToStr(CloseOnTerm, True));
if CloseOnEol then
SetVarAttr('CloseOnEol', BoolToStr(CloseOnEol, True));
if AllowPreviousClose then
SetVarAttr('AllowPredClose', BoolToStr(AllowPreviousClose, True));
end;
with AppendElement('MultiTokens') do
for i := 0 to OpenToken.SymbolCount-1 do
with AppendElement('Tokens') do
begin
if OpenToken.Symbols[i] <> '' then
SetVarAttr('Open', OpenToken.Symbols[i]);
if CloseToken.Symbols[i] <> '' then
SetVarAttr('Close', CloseToken.Symbols[i]);
end;
end;
with AppendElement('SubRules') do begin
for i := 0 to RangeCount -1 do
ExportRange(Ranges[i], AppendElement('Range'));
for i := 0 to KeyListCount -1 do
ExportKeyList(KeyLists[i], AppendElement('KeyList'));
for i := 0 to SetCount -1 do
ExportSet(Sets[i], AppendElement('Set'));
end;
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ImportCustomData(ACustomData: TStringList; ANode: IXMLNode): Boolean;
var
i: Integer;
Name, Value: string;
begin
with ACustomData, ANode do
begin
Clear();
for i := 0 to ChildNodes.Count-1 do
begin
Name := ChildNodes[i].GetAttr('Name', '');
Value := ChildNodes[i].GetAttr('Value', '');
ACustomData.Add(Name+'='+Value);
end;
end;
Result := True;
end;
//----------------------------------------------------------------------------
class function TSynUniFormatNativeXml20.ExportCustomData(ACustomData: TStringList; ANode: IXMLNode): Boolean;
var
i: Integer;
Name: string;
Node: IXmlElement;
begin
with ANode, ACustomData do
begin
for i := 0 to Count-1 do
begin
if Names[i] <> '' then //TODO: 礤 镱玮铍
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -