[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 1/2] kedit: Leerzeichen am Ende der Zeile markieren
+ kedit: Mit Syntaxhighlighting werden die ueberschuessigen Leerzeichen
am Ende der Zeile mit rotem Hintergrund markiert.
---
src/modules/pas/kedit/kedit_tui.pas | 2 ++
src/modules/pas/kedit/syntax.pas | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/src/modules/pas/kedit/kedit_tui.pas b/src/modules/pas/kedit/kedit_tui.pas
index 8067ed1..13c7781 100644
--- a/src/modules/pas/kedit/kedit_tui.pas
+++ b/src/modules/pas/kedit/kedit_tui.pas
@@ -307,6 +307,7 @@ begin
repeat
syntax_chg := highlighter.Next;
TextColor(SyntaxColor(syntax_chg.color));
+ TextBackground(SyntaxBgColor(syntax_chg.color));
if syntax_chg.posY = 0 then begin
toCol := length(state^.text^[i]);
@@ -328,6 +329,7 @@ begin
until syntax_chg.posY = 0;
syntax_state := highlighter.GetState;
+ TextBackground(0);
if toCol < state^.scrollx + 80 then begin
if toCol < state^.scrollx then begin
WriteLn(#27'[K');
diff --git a/src/modules/pas/kedit/syntax.pas b/src/modules/pas/kedit/syntax.pas
index 4a0fe87..b6c6a8d 100644
--- a/src/modules/pas/kedit/syntax.pas
+++ b/src/modules/pas/kedit/syntax.pas
@@ -4,7 +4,9 @@ unit syntax;
interface
type
- TSyntaxColor = (syn_keyword, syn_string, syn_string_special, syn_comment, syn_type, syn_compiler, syn_number, syn_label, syn_other);
+ TSyntaxColor = (syn_keyword, syn_string, syn_string_special, syn_comment,
+ syn_type, syn_compiler, syn_number, syn_label, syn_other,
+ syn_trailing_space);
TSyntaxChange = record
posY: integer;
@@ -35,6 +37,7 @@ type
function SyntaxColor(c: TSyntaxColor): byte;
+function SyntaxBgColor(c: TSyntaxColor): byte;
implementation
@@ -67,6 +70,15 @@ begin
exit(8);
end;
+function SyntaxBgColor(c: TSyntaxColor): byte;
+begin
+ case c of
+ syn_trailing_space: exit(4);
+ end;
+
+ exit(0);
+end;
+
function Matches(s: String; pos: integer; pattern: String): boolean;
begin
Matches := (Copy(s, pos, length(pattern)) = pattern);
@@ -202,6 +214,18 @@ begin
end;
end;
+function MatchesTrailingSpace(s: String; pos: integer): boolean;
+var
+ i: integer;
+begin
+ for i := pos to length(s) do begin
+ if (s[i] <> ' ') then begin
+ exit(false);
+ end;
+ end;
+ exit(true);
+end;
+
constructor TSyntax.create;
begin
f_state := 0;
@@ -286,6 +310,14 @@ begin
f_state := 4;
exit;
end;
+ ' ':
+ begin
+ if MatchesTrailingSpace(line, pos) then begin
+ Next := Highlight(syn_trailing_space);
+ pos := length(line) + 1;
+ exit;
+ end;
+ end;
else
begin
--
1.6.0.2