📄 synuniformatultraedit.pas
字号:
if FileName <> '' then
begin
//'File was loaded.'
FileList := TStringList.Create;
FileList.LoadFromFile(FileName);
FileName := FileName;
FilePos := 0;
end
else begin
//'File was not assigned and not loaded. Exiting...'
Result := False;
Exit;
end
else begin
{ if (FileName = FileName) and (FilePos >= FileList.Count-1) or (FileName = '') then begin
//'Variables are deleted. Exiting...'
if Assigned(FileList) then begin
FileList.Free;
FileList := nil;
end;
FileName := '';
FilePos := 0;
Result := False;
Exit;
end;}
if FileName <> FileName then begin
//'New File was loaded.'
FileList.LoadFromFile(FileName);
FileName := FileName;
FilePos := 0;
end;
end;
MainRules.Clear;
isLoading := False;
qc1 := #0; qc2 := #0; Nc := 0; qn1 := -1; qn2 := -1;
for i := FilePos to FileList.Count-1 do begin
buf := FileList.Strings[i];
FilePos := i;
if buf = '' then continue;
if copy(buf, 1, 2) = '/L' then begin
if not isLoading then
isLoading := True
else begin // isLoading = True?
Info.Author.Remark := 'Created with UltraEdit Converter. (c) Vitalik';
Result := True;
Exit;
end;
Nc := 0; bn1 := -1; bn2 := -1; qn1 := -1; qn2 := -1; qc1 := #0; qc2 := #0;
for j := 1 to 8 do begin Cnames[j] := ''; Created[j] := -1; end;
if (buf[4] = '"') or (buf[5] = '"') then begin
cur := pos('"', copy(buf, pos('"',buf)+1, length(buf)-pos('"',buf))) + pos('"', buf);
Info.General.Name := copy(buf, pos('"',buf)+1, cur-pos('"',buf)-1);
end;
if Info.General.Name = '' then
Info.General.Name := ExtractFileName(FileName);
if GetAttribute('File Extensions = ', WHOLE_STRING) then begin
Info.General.Extensions := word;
end;
MainRules.AddSet('Numbers', ['0','1','2','3','4','5','6','7','8','9'], clRed);
if GetAttribute('Nocase', SINGLE_WORD) then
MainRules.CaseSensitive := False
else
MainRules.CaseSensitive := True;
if not GetAttribute('Noquote', SINGLE_WORD) then begin
if not GetAttribute('String Chars = ', STRING_CHARS) then
word := '"''';
qn1 := MainRules.RangeCount;
qc1 := word[1];
with MainRules.AddRange(qc1, qc1, 'String', clGray) do
CloseOnEol := True;
if length(word) > 1 then begin
qn2 := MainRules.RangeCount;
qc2 := word[2];
with MainRules.AddRange(qc2, qc2, 'String', clGray) do
CloseOnEol := True;
end;
if GetAttribute('Escape Char = ', ESCAPE_CHAR) then begin
with MainRules.Ranges[qn1].AddKeyList('Escape', clGray) do
KeyList.Text := word + word + #13#10 + word + qc1;
if qn2 > -1 then
with MainRules.Ranges[qn2].AddKeyList('Escape', clGray) do
KeyList.Text := word + word + #13#10 + word + qc2;
end;
end;
if GetAttribute('Line Comment = ', LINE_COMMENT) then begin
with MainRules.AddRange(word, '', 'Line Comment', clTeal) do
CloseOnEol := True;
end;
if GetAttribute('Line Comment Alt = ', LINE_COMMENT) then begin
with MainRules.AddRange(word, '', 'Line Comment Alt', clTeal) do
CloseOnEol := True;
end;
if GetAttribute('Line Comment Num = ', LINE_COMM_NUM) then begin
with MainRules.AddRange(word, '', 'Line Comment Num', clTeal) do
CloseOnEol := True;
end;
if GetAttribute('Block Comment On = ', BLOCK_COMMENT) then begin
bn1 := MainRules.RangeCount;
with MainRules.AddRange(word, '', 'Block Comment', clTeal) do
CloseOnEol := True;
end;
if GetAttribute('Block Comment Off = ', BLOCK_COMMENT) then begin
if bn1 = -1 then
MainRules.AddRange('', word, 'Block Comment', clTeal)
else begin
MainRules.Ranges[bn1].CloseToken.Symbols[0] := word;
MainRules.Ranges[bn1].CloseOnEol := False;
end;
end;
if GetAttribute('Block Comment On Alt = ', BLOCK_COMMENT) then begin
bn2 := MainRules.RangeCount;
with MainRules.AddRange(word, '', 'Block Comment Alt', clTeal) do
CloseOnEol := True;
end;
if GetAttribute('Block Comment Off Alt = ', BLOCK_COMMENT) then begin
if bn2 = -1 then
MainRules.AddRange('', word, 'Block Comment Alt', clTeal)
else begin
MainRules.Ranges[bn2].CloseToken.Symbols[0] := word;
MainRules.Ranges[bn2].CloseOnEol := False;
end;
end;
end else begin
if not isLoading then isLoading := True;
if copy(buf, 1, 13) = '/Delimiters =' then
MainRules.SetDelimiters(StrToSet(copy(buf, pos('=',buf)+1, length(buf)-pos('=',buf)+1)))
else
if copy(buf, 1, 2) = '/C' then begin
Nc := StrToInt(buf[3]);
if buf[4] = '"' then begin
cur := pos('"', copy(buf, 5, length(buf)-4)) + 4;
Cnames[Nc] := copy(buf, 5, cur-5);
if Created[Nc] > -1 then // already created
MainRules.KeyLists[Created[Nc]].Name := Cnames[Nc];
end
else
if Created[Nc] = -1 then // haven't created
Cnames[Nc] := 'Word list ' + IntToStr(Nc);
end else
if (buf[1] = '/') and (buf[2] <> '/') then // "/XXXXXXX = ...."
else begin
if (buf[1] = qc1) and (qn1 <> -1) then begin
MainRules.Ranges[qn1].Attributes.Foreground := colors[Nc];
MainRules.Ranges[qn1].Attributes.ParentForeground := False;
end;
if (buf[1] = qc2) and (qn2 <> -1) then begin
MainRules.Ranges[qn2].Attributes.Foreground := colors[Nc];
MainRules.Ranges[qn2].Attributes.ParentForeground := False;
end;
word := GetToken2;
if word = '**' then begin
repeat
word := GetToken2;
with MainRules.AddRange(word, '', Cnames[Nc], colors[Nc]) do begin
Delimiters := MainRules.Delimiters;
CloseOnTerm := True;
end;
until buf = '';
end else begin
if Created[Nc] = -1 then begin
Created[Nc] := MainRules.KeyListCount;
keyword := MainRules.AddKeyList(Cnames[Nc], colors[Nc]);
end else
keyword := MainRules.KeyLists[Created[Nc]];
if word = '//' then
word := GetToken2;
keyword.KeyList.Add(word);
while buf <> '' do begin
word := GetToken2;
keyword.KeyList.Add(word);
end;
end;
end;
end;
end;
Info.Author.Copyright := 'Created with UltraEdit Converter. (c) Vitalik';
{ Fill schemes }
SynUniSyn.ActiveScheme := SynUniSyn.Schemes.AddScheme('Default');
RefreshScheme(MainRules);
//Result := True;
(* if n = 1 then begin // The One
Name := ChangeFileExt(FileName, '.hgl');
{ TrySaveFile();}
end else begin // The Last
Name := ChangeFileExt(Info.General.Name, '.hgl');
for j := 0 to 8 do
while Pos(badsymb[j], Name) > 0 do
Name[Pos(badsymb[j], Name)] := ' ';
{ TrySaveFile();}
end;*)
end;
Result := True;
end;
//------------------------------------------------------------------------------
class function TSynUniFormatUltraEdit.ImportFromStream(AObject: TObject; Stream: TStream): boolean;
var
FileList: TStringList;
begin
FileList := TStringList.Create;
FileList.LoadFromStream(Stream);
Result := Import(TSynUniSyn(AObject), FileList);
FreeAndNil(FileList);
end;
//------------------------------------------------------------------------------
class function TSynUniFormatUltraEdit.ImportFromFile(AObject: TObject; FileName: string): boolean;
var
FileList: TStringList;
begin
FileList := TStringList.Create;
FileList.LoadFromFile(FileName);
Result := Import(TSynUniSyn(AObject), FileList);
FreeAndNil(FileList);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -