On 09.10.2010 12:43, Bernd Kreuss wrote:

> The changes to the highlighter are just handful of lines, I quickly
> hacked something together yesterday evening to see how this mode would
> look like and it seems to work and I very much like how my programs
> appear in this mode.

Attached is a diff of my changes:

* do not highlight String
* do not highlight AnsiString
* do not highlight WideString
* highlight break
* highlight continue
* highlight exit
* highlight message only in a procedure defnition (partial fix to the
bug mentioned earlier, it does not eliminate all cases, judging from the
comments in the source a complete fix would need an improved parser in
the highlighter, but at least it now gets rid of highlighted "message"
anywhere *outside* the line where a procedure is defined.

the above patch is what I now use here locally and I like it much better
than the original one, but I don't think these radical changes would be
easily accepted by the core developers. It tries to highlight the ideas
and intentions in the programmer's mind and not so much the strict and
sometimes odd language definition.

Bernd
Index: components/synedit/synhighlighterpas.pp
===================================================================
--- components/synedit/synhighlighterpas.pp	(Revision 27606)
+++ components/synedit/synhighlighterpas.pp	(Arbeitskopie)
@@ -316,6 +316,7 @@
     function Func55: TtkTokenKind;
     function Func56: TtkTokenKind;
     function Func57: TtkTokenKind;
+    function Func58: TtkTokenKind;
     function Func59: TtkTokenKind;
     function Func60: TtkTokenKind;
     function Func61: TtkTokenKind;
@@ -657,6 +658,7 @@
   fIdentFuncTable[55] := @Func55;
   fIdentFuncTable[56] := @Func56;
   fIdentFuncTable[57] := @Func57;
+  fIdentFuncTable[58] := @Func58;
   fIdentFuncTable[59] := @Func59;
   fIdentFuncTable[60] := @Func60;
   fIdentFuncTable[61] := @Func61;
@@ -1048,7 +1050,10 @@
     else StartPascalCodeFoldBlock(cfbtBeginEnd);
     //debugln('TSynPasSyn.Func37 BEGIN ',dbgs(ord(TopPascalCodeFoldBlockType)),' LineNumber=',dbgs(fLineNumber),' ',dbgs(MinimumCodeFoldBlockLevel),' ',dbgs(CurrentCodeFoldBlockLevel));
   end else
-    Result := tkIdentifier;
+    if KeyComp('Break') then
+      Result := tkKey
+    else
+      Result := tkIdentifier;
 end;
 
 function TSynPasSyn.Func38: TtkTokenKind;
@@ -1184,6 +1189,11 @@
       if KeyComp('Xor') then Result := tkKey else Result := tkIdentifier;
 end;
 
+function TSynPasSyn.Func58: TtkTokenKind;
+begin
+  if KeyComp('Exit') then Result := tkKey else Result := tkIdentifier;
+end;
+
 function TSynPasSyn.Func59: TtkTokenKind;
 begin
   if KeyComp('Safecall') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
@@ -1283,9 +1293,11 @@
     else
       Result := tkIdentifier;
   end else
- if KeyComp('Dynamic') then Result := tkKey
- else
- if KeyComp('Message') then Result := tkKey else Result := tkIdentifier;
+  if KeyComp('Dynamic') then Result := tkKey
+  else
+    if KeyComp('Message') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
+      Result := tkKey
+        else Result := tkIdentifier;
 end;
 
 function TSynPasSyn.Func71: TtkTokenKind;
@@ -1428,7 +1440,7 @@
 
 function TSynPasSyn.Func87: TtkTokenKind;
 begin
-  if KeyComp('String') then Result := tkKey else Result := tkIdentifier;
+  {if KeyComp('String') then Result := tkKey else }Result := tkIdentifier;
 end;
 
 function TSynPasSyn.Func88: TtkTokenKind;
@@ -1629,7 +1641,10 @@
     if KeyComp('Platform') then
       Result := tkKey
     else
-      Result := tkIdentifier;
+      if KeyComp('Continue') then
+        Result := tkKey
+      else
+        Result := tkIdentifier;
 end;
 
 function TSynPasSyn.Func102: TtkTokenKind;
@@ -1739,7 +1754,7 @@
 
 function TSynPasSyn.Func128: TtkTokenKind;
 begin
-  if KeyComp('Widestring') then Result := tkKey else Result := tkIdentifier;
+  {if KeyComp('Widestring') then Result := tkKey else} Result := tkIdentifier;
 end;
 
 function TSynPasSyn.Func129: TtkTokenKind;
@@ -1759,9 +1774,9 @@
 
 function TSynPasSyn.Func130: TtkTokenKind;
 begin
-  if KeyComp('Ansistring') then
+  {if KeyComp('Ansistring') then
     Result := tkKey
-  else
+  else}
   if KeyComp('Enumerator') and (TopPascalCodeFoldBlockType in [cfbtClassSection]) then
     Result := tkKey
   else
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to