[tyndur-devel] [PATCH 2/3] kedit: Syntax-Highlighting [2]
Kevin Wolf ·
On Thu, Sep 24, 2009 at 02:11:54AM +0200, Alexander Hartmut Kluth wrote: > * kedit: syntax.pas: Definition der Klasse TSyntax samt Methoden > + kedit: syntax_c.pas: C-Syntax > > Signed-off-by: Alexander Hartmut Kluth <hartmut at tyndur.org> > --- > src/modules/pas/kedit/syntax.pas | 195 ++---------------------------------- > src/modules/pas/kedit/syntax_c.pas | 197 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 206 insertions(+), 186 deletions(-) > create mode 100644 src/modules/pas/kedit/syntax_c.pas > > diff --git a/src/modules/pas/kedit/syntax.pas b/src/modules/pas/kedit/syntax.pas > index b382265..0f9950e 100644 > --- a/src/modules/pas/kedit/syntax.pas > +++ b/src/modules/pas/kedit/syntax.pas > @@ -29,30 +29,18 @@ type > property GetState: integer read f_state; > end; > > - TSyntax_C = class(TSyntax) > - public > - procedure StartLine(s: String; state: integer); override; > - function Next: TSyntaxChange; override; > - end; > - > > function SyntaxColor(c: TSyntaxColor): byte; > function SyntaxBgColor(c: TSyntaxColor): byte; > +function Matches(s: String; pos: integer; pattern: String): boolean; > +function MatchesNumber(s: string; pos: integer): integer; > +function MatchesKeyword(s: string; pos: integer; p: Array of String): integer; > +function MatchesLabel(s: string; pos: integer): integer; > +function MatchesType(s: string; pos: integer): integer; > +function MatchesTrailingSpace(s: string; pos: integer): boolean; > > > implementation > - > -const > - Keywords_C: Array [1..15] of String = ( > - 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'default', 'goto', > - 'break', 'continue', 'return', 'sizeof', 'typedef', 'asm' > - ); > - Types_C: Array [1..17] of String = ( > - 'void', 'char', 'short', 'int', 'long', 'signed', 'unsigned', 'float', 'double', > - 'static', 'inline', 'extern', 'enum', 'struct', 'union', 'volatile', 'const' > - ); > - > - > function SyntaxColor(c: TSyntaxColor): byte; > begin > case c of > @@ -70,6 +58,7 @@ begin > exit(8); > end; > > + > function SyntaxBgColor(c: TSyntaxColor): byte; > begin > case c of > @@ -79,11 +68,13 @@ begin > exit(0); > end; > > + > function Matches(s: String; pos: integer; pattern: String): boolean; > begin > Matches := (Copy(s, pos, length(pattern)) = pattern); > end; > > + > function MatchesNumber(s: String; pos: integer): integer; > var > i: integer; > @@ -261,172 +252,4 @@ begin > color := c; > end; Die zusätzlichen Leerzeilen haben mit dem Patch nicht viel zu tun. Nimm die noch raus, dann sollte das passen. Bessere Patchüberschrift wäre auch noch nett, z.B. "kedit: Syntaxhighlighting-Unit aufsplitten"