📄 jvunicodehleditor.pas
字号:
SetColor(Colors.Reserved)
else
if PrevToken = 'function' then
SetColor(Colors.Declaration)
else
F := False;
hlVB:
if IsVBKeyWord(Token) then
SetColor(Colors.Reserved)
else
if IsVBStatement(Token) then
SetColor(Colors.Statement)
else
if Cmp(PrevToken, 'function') or Cmp(PrevToken, 'sub') or
Cmp(PrevToken, 'class') then
SetColor(Colors.Declaration)
else
F := False;
hlHtml:
if not InTag then
begin
if Token = '<' then
begin
InTag := True;
SetColor(Colors.Reserved)
end;
F := True;
end
else
begin
if Token = '>' then
begin
InTag := False;
SetColor(Colors.Reserved)
end
else
if (Token = '/') and (PrevToken = '<') then
SetColor(Colors.Reserved)
else
if (NextSymbol = '=') and IsIdentifierW(Token) then
SetColor(Colors.Identifier)
else
if PrevToken = '=' then
SetColor(Colors.Strings)
else
if IsHtmlTag(Token) then
SetColor(Colors.Reserved)
else
if (PrevToken = '<') or ((PrevToken = '/') and (PrevToken2 = '<')) then
SetColor(Colors.Statement)
else
F := False;
end;
hlPerl:
if IsPerlKeyWord(Token) then
SetColor(Colors.Reserved)
else
if IsPerlStatement(Token) then
SetColor(Colors.Statement)
else
if CharInSetW(Token[1], ['$', '@', '%', '&']) then
SetColor(Colors.FunctionCall)
else
F := False;
hlCocoR:
if IsCocoKeyWord(Token) then
SetColor(Colors.Reserved)
else
if (Parser.PosBeg[0] = 0) and (Line > ProductionsLine) and
IsIdentifierW(Token) then
begin
NextToken := Parser.Token;
Parser.RollBack(1);
SetColor(Colors.Declaration)
end
else
F := False;
hlPhp:
if IsPhpKeyWord(Token) then
SetColor(Colors.Reserved)
else
F := False;
hlCSharp:
if IsCSharpKeyWord(Token) then
SetColor(Colors.Reserved)
else
F := False;
else
F := False;
end;
if F then
{Ok}
else
if IsPreproc(Token) then
SetColor(Colors.Preproc)
else
if IsComment(Token) then
SetColor(Colors.Comment)
else
if IsStringConstant(Token) then
SetColor(Colors.Strings)
else
if (Length(Token) = 1) and CharInSetW(Token[1], Symbols) then
SetColor(Colors.Symbol)
else
if IsIntConstantW(Token) or IsRealConstantW(Token) then
SetColor(Colors.Number)
else
if (FHighlighter in [hlCBuilder, hlJava, hlPython, hlPhp, hlNQC, hlCSharp]) and
(PrevToken = '0') and ((Token[1] = 'x') or (Token[1] = 'X')) then
SetColor(Colors.Number)
else
if FHighlighter = hlHtml then
SetColor(Colors.PlainText)
else
SetColor(Colors.Identifier);
if FHighlighter = hlHtml then
{ found special chars starting with '&' and ending with ';' }
TestHtmlSpecChars(Token);
PrevToken2 := PrevToken;
PrevToken := Token;
Token := Parser.Token;
end;
if Highlighter = hlCocoR then
HighlightGrammarName(S);
except
end;
end;
procedure TJvWideHLEditor.CheckInLong;
begin
if not FLongTokens then
begin
FLong := lgNone;
Exit;
end;
if FLineNum < Length(FLongDesc) then
begin
FLong := FLongDesc[FLineNum];
if FLong = lgUndefined then
begin
RescanLong(FLineNum); // scan the line
FLong := FLongDesc[FLineNum];
end;
end
else
RescanLong(-1);
end;
function TJvWideHLEditor.RescanLong(iLine: Integer): Boolean;
const
MaxScanLinesAtOnce = 5000;
var
P, F: PWideChar;
MaxLine, MaxScanLine: Integer;
S: WideString;
I, i1, L1: Integer;
begin
FLong := lgNone;
Result := False; // no Invalidate
if (not FSyntaxHighlighting) or
(not FLongTokens or (FHighlighter in [hlNone, hlIni])) or
(Lines.Count = 0) then
Exit;
if Lines.Count >= Length(FLongDesc) then
SetLength(FLongDesc, (Lines.Count div (64*1024) + 1) * (64*1024));
ProductionsLine := High(Integer);
MaxLine := Lines.Count - 1;
if MaxLine > High(FLongDesc) then
MaxLine := High(FLongDesc);
if iLine > MaxLine then
Exit;
MaxScanLine := MaxLine;
FLong := lgNone;
if iLine < 0 then
begin
FillChar(FLongDesc[0], SizeOf(FLongDesc[0]) * (1 + MaxLine), lgUndefined);
FLongDesc[0] := lgNone;
iLine := 0;
end
else
begin
FLong := FLongDesc[iLine];
if FLong = lgUndefined then
begin
if (iLine > 0) and (FLongDesc[iLine - 1] = lgUndefined) then
begin
iLine := 0; // scan all
FLong := lgNone;
end
else
begin
Dec(iLine);
FLong := FLongDesc[iLine];
MaxScanLine := Min(iLine + MaxScanLinesAtOnce, MaxLine);
end;
end
else
MaxScanLine := Min(iLine + MaxScanLinesAtOnce, MaxLine);
end;
while iLine < MaxScanLine do
begin
if (FHighlighter = hlSyntaxHighlighter) and (FSyntaxHighlighter <> nil) then
FSyntaxHighlighter.ScanLongTokens(Self, Lines, iLine, FLong)
else
begin
S := Lines[iLine];
P := Pointer(S);
F := P;
L1 := Length(S);
if (L1 = 0) then
begin
case Highlighter of
hlPascal:
if FLong in [lgString] then
FLong := lgNone;
hlCBuilder, hlPython, hlPerl, hlNQC:
if FLong in [lgPreproc] then
FLong := lgNone;
else
if FLong in [lgPreproc1, lgPreproc2, lgString] then
FLong := lgNone;
end;
end;
I := 1;
while I <= L1 do
begin
case FHighlighter of
hlPascal:
case FLong of
lgNone: // not in comment
case S[I] of
'/':
begin
if S[I + 1] = '/' then
Break;
end;
'{':
begin
P := StrScanW(F + I, WideChar('}'));
if P = nil then
begin
if S[I + 1] = '$' then
FLong := lgPreproc1
else
FLong := lgComment1;
Break;
end
else
I := P - F + 1;
end;
'(':
if {S[I + 1]} F[I] = '*' then
begin
if {S[I + 2]} F[I + 1] = '$' then
FLong := lgPreproc2
else
FLong := lgComment2;
P := StrScanW(F + I + 2, WideChar(')'));
if P = nil then
Break
else
begin
if P[-1] = '*' then
FLong := lgNone;
I := P - F + 1;
end;
end;
'''':
begin
P := StrScanW(F + I + 1, WideChar(''''));
if P <> nil then
begin
i1 := P - F;
if P[1] <> '''' then
I := i1
else
{ ?? }
end
else
I := L1 + 1;
end;
end;
lgPreproc1, lgComment1:
begin // {
P := StrScanW(F + I - 1, WideChar('}'));
if P <> nil then
begin
FLong := lgNone;
I := P - F + 1;
end
else
I := L1 + 1;
end;
lgPreproc2, lgComment2:
begin // (*
P := StrScanW(F + I, WideChar(')'));
if P = nil then
Break
else
begin
if P[-1] = '*' then
FLong := lgNone;
I := P - F + 1;
end;
end;
end;
hlCBuilder, hlSql, hlJava, hlPhp, hlNQC:
case FLong of
lgNone: // not in comment
case S[I] of
'/':
if {S[I + 1]} F[I] = '*' then
begin
FLong := lgComment2;
P := StrScanW(F + I + 2, WideChar('/'));
if P = nil then
Break
else
begin
if P[-1] = '*' then
FLong := lgNone;
I := P - F + 1;
end;
end;
'"':
begin
P := StrScanW(F + I + 1, WideChar('"'));
if P <> nil then
begin
i1 := P - F;
if P[1] <> '"' then
I := i1
else
{ ?? }
end
else
if FHighlighter in [hlCBuilder, hlJava, hlNQC] then
begin
if (LastNonSpaceChar(S) = '\') and (HasStringOpenEnd(Lines, iLine)) then
FLong := lgString;
I := L1 + 1;
end
else
I := L1 + 1;
end;
'#':
begin
if (GetTrimChar(S, 1) = '#') and (LastNonSpaceChar(S) = '\') then
begin
FLong := lgPreproc;
Break;
end;
end;
end;
lgComment2:
begin // /*
P := StrScanW(F + I, WideChar('/'));
if P = nil then
Break
else
begin
if P[-1] = '*' then
FLong := lgNone;
I := P - F + 1;
end;
end;
lgString:
begin
P := StrScanW(F + I + 1, WideChar('"'));
if P <> nil then
begin
i1 := P - F;
if P[1] <> '"' then
I := i1
else
{ ?? }
end
else
begin
if FHighlighter in [hlCBuilder, hlJava, hlNQC] then
begin
if (LastNonSpaceChar(S) <> '\') or (not HasStringOpenEnd(Lines, iLine)) then
FLong := lgNone;
end;
I := L1 + 1;
end;
end;
lgPreproc:
begin
if LastNonSpaceChar(S) <> '\' then
FLong := lgNone;
end;
end;
hlPython, hlPerl:
case FLong of
lgNone: // not in comment
case S[I] of
'#':
I := L1;
'"':
begin
P := StrScanW(F + I, WideChar('"'));
if P = nil then
begin
FLong := lgString;
Break;
end
else
I := P - F + 1;
end;
end;
lgString: // python and perl long string
begin
P := StrScanW(F + I - 1, WideChar('"'));
if P <> nil then
begin
FLong := lgNone;
I := P - F + 1;
end
else
I := L1 + 1;
end;
end;
hlHtml:
case FLong of
lgNone: // not in comment
case S[I] of
'<':
begin
P := StrScanW(F + I, WideChar('>'));
if P = nil then
begin
FLong := lgTag;
Break;
end
else
I := P - F + 1;
end;
end;
lgTag: // html tag
begin
P := StrScanW(F + I - 1, WideChar('>'));
if P <> nil then
begin
FLong := lgNone;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -