* Added new style: shInvalid

* Cosmetic changes
This commit is contained in:
sg 2000-02-20 10:59:46 +00:00
parent a56684bb8a
commit 92898b2bf8

View File

@ -13,11 +13,15 @@
} }
// viewer class for Pascal source // Syntax highlighting class for Pascal sources
{$MODE objfpc} {$MODE objfpc}
{$H+} {$H+}
{$IFDEF Debug}
{$ASSERTIONS On}
{$ENDIF}
unit sh_pas; unit sh_pas;
interface interface
@ -31,8 +35,8 @@ type
procedure KeyReturn; override; procedure KeyReturn; override;
public public
// Syntax highlighter style indices // Syntax highlighter style indices
shSymbol, shKeyword, shComment, shDirective, shNumbers, shCharacters, shInvalid, shSymbol, shKeyword, shComment, shDirective, shNumbers,
shStrings, shAssembler: Integer; shCharacters, shStrings, shAssembler: Integer;
end; end;
@ -42,8 +46,8 @@ uses Strings;
const const
LF_SH_Comment1 = LF_SH_Multiline1; LF_SH_Comment1 = LF_SH_Multiline1; { {} Comments}
LF_SH_Comment2 = LF_SH_Multiline2; { (* Comments} LF_SH_Comment2 = LF_SH_Multiline2; { (* *) Comments}
LF_SH_Asm = LF_SH_Multiline3; LF_SH_Asm = LF_SH_Multiline3;
MaxKeywordLength = 15; MaxKeywordLength = 15;
@ -95,11 +99,12 @@ end;
procedure TSHPasEdit.DoHighlighting(var flags: Byte; source, dest: PChar); procedure TSHPasEdit.DoHighlighting(var flags: Byte; source, dest: PChar);
var var
dp: Integer; {Destination postion - current offset in dest} dp: Integer; // Destination position - current offset in dest
LastSHPos: Integer; {Position of last highlighting character, or 0} LastSHPos: Integer; // Position of last highlighting character, or 0
procedure AddSH(sh: Byte); procedure AddSH(sh: Byte);
begin begin
ASSERT(sh > 0);
if (LastSHPos > 0) and (dp = LastSHPos + 1) then Dec(dp, 2); if (LastSHPos > 0) and (dp = LastSHPos + 1) then Dec(dp, 2);
dest[dp] := LF_Escape; Inc(dp); dest[dp] := LF_Escape; Inc(dp);
LastSHPos := dp; LastSHPos := dp;
@ -180,7 +185,7 @@ var
AddSH(shDefault); AddSH(shDefault);
break; break;
end else end else
if CheckForComment then LastChar := ' ' if CheckForComment then LastChar := ' '
else begin else begin
LastChar := source[0]; LastChar := source[0];
PutChar; PutChar;
@ -294,13 +299,17 @@ begin
dest[LastSHPos] := Chr(shCharacters); dest[LastSHPos] := Chr(shCharacters);
AddSH(shDefault); AddSH(shDefault);
end; end;
'_', 'A'..'Z', 'a'..'z': '_', 'A'..'Z', 'a'..'z': begin
if not CheckForKeyword then if not CheckForKeyword then
repeat repeat
PutChar PutChar
until not (source[0] in ['0'..'9', '_', 'A'..'Z', 'a'..'z']); until not (source[0] in ['0'..'9', '_', 'A'..'Z', 'a'..'z']);
else end;
' ': PutChar;
else begin
AddSH(shInvalid);
PutChar; // = found an invalid char! PutChar; // = found an invalid char!
end;
end; end;
end; end;
@ -313,7 +322,11 @@ end.
{ {
$Log$ $Log$
Revision 1.6 2000-02-19 19:06:47 sg Revision 1.7 2000-02-20 10:59:46 sg
* Added new style: shInvalid
* Cosmetic changes
Revision 1.6 2000/02/19 19:06:47 sg
* Added NIL keyword, removed READ and WRITE as keywords * Added NIL keyword, removed READ and WRITE as keywords
Revision 1.5 2000/01/07 01:24:34 peter Revision 1.5 2000/01/07 01:24:34 peter