View Issue Details

IDProjectCategoryView StatusLast Update
0003154JEDI VCL00 JVCL Componentspublic2005-08-28 09:31
ReportereswarprAssigned Toobones 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.10 
Summary0003154: JvHLEditor - Parser features for HTML and SQL
DescriptionI am trying to get the TJvHLEditor component to hilight my SQL comments starting with "--". I guess this was not available in version 3.00 and also multi-line HTML comment which goes like <!-- Comment -->. I have put in the fix for the -- comments, but since I am not a "developer" to JVCL yet, I don't know how to upload the fix which pretty much covers the JvHLEditor.pas and JvParser.pas. How do I do this?
TagsNo tags attached.

Activities

obones

2005-08-17 05:08

administrator   ~0007806

HT is for HTML, hence, the SQL comments are not to be taken into account.
The multiline <!-- comments should, however, be taken into account.
If you can get the latter to work, please upload a diff file (diff -u 3) to this server and we'll look into it.

eswarpr

2005-08-17 05:20

reporter   ~0007807

Last edited: 2005-08-17 05:22

Thanks. I will try to get the <!-- comments to work in it. For the SQL comments, I thought JvHLEditor has more than one "mode" which includes hlSql hilighter that comes default with the JvHLEditor component. In that case shouldn't it be taken into account? One keyword missing by the parser for SQL is "replace" as in "create or replace". I have entered in that too. But even then, is it OK if my fix comes with it?

PS: I am new to using CVS diff, since I don't use UNIX or LINUX at home. Any pointers to a "diff" port for win32 would be greatly appreciated.

obones

2005-08-18 00:48

administrator   ~0007808

Last edited: 2005-08-18 00:49

Woops, sorry, I misread the report, it's JvHLEditor, not the JvHTLabel.
So yes, please bring in the change for SQL as well.

As to diff, there is a port of a bunch of unix tools for Win32, it's called unxutils on sourceforge:

http://unxutils.sourceforge.net/

Beware to not put the echo program in this package inside a directory accessible by PATH as it behaves differently from the regular echo and would be used instead of this default one. Same goes for make, by the way.

2005-08-18 04:37

 

jvhleditor_diff.txt (5,948 bytes)
--- jvhleditor.pas	Thu Aug 18 11:35:52 2005
+++ 3.0\jvhleditor.pas	Thu Feb 24 13:26:10 2005
@@ -311,7 +311,7 @@
     case FHighlighter of
       hlPascal:
         Parser.Style := psPascal;
-      hlCBuilder, hlJava, hlNQC, hlCSharp:
+      hlCBuilder, hlSql, hlJava, hlNQC, hlCSharp:
         Parser.Style := psCpp;
       hlPython:
         Parser.Style := psPython;
@@ -327,8 +327,6 @@
         Parser.Style := psCocoR;
       hlPhp:
         Parser.Style := psPhp;
-      hlSql:
-        Parser.Style := psSql;
     end;
     RescanLong(0);
     Invalidate;
@@ -379,7 +377,6 @@
     ' int monitor repeat return signed start stop sub switch task true' +
     ' until void while ';
 
-    (* 17/08/05 - Eswar: REPLACE keyword added to the list *)
   SQLKeyWords =
     ' active as add asc after ascending all at alter auto' +
     ' and autoddl any avg based between basename blob' +
@@ -405,8 +402,8 @@
     ' open output_type option overflow page post_event pagelength  precision' +
     ' pages  prepare page_size procedure parameter  protected password  primary' +
     ' plan  privileges position  public quit' +
-    ' raw_partitions  retain rdb db_key  return read replace returning_values real  returns' +
-    ' record_version revoke references  right release  rollback reserv runtime replace' +
+    ' raw_partitions  retain rdb db_key  return read  returning_values real  returns' +
+    ' record_version revoke references  right release  rollback reserv runtime' +
     ' reserving schema  sql segment  sqlcode select  sqlerror set  sqlwarning' +
     ' shadow  stability shared  starting shell  starts show  statement' +
     ' singular  static size  statistics smallint  sub_type snapshot  sum' +
@@ -638,17 +635,9 @@
         Result := ((LS > 0) and (St[1] = '{')) or
           ((LS > 1) and (((St[1] = '(') and (St[2] = '*')) or
           ((St[1] = '/') and (St[2] = '/'))));
-      hlCBuilder, hlJava, hlPhp, hlNQC, hlCSharp:
+      hlCBuilder, hlSql, hlJava, hlPhp, hlNQC, hlCSharp:
         Result := (LS > 1) and (St[1] = '/') and
           ((St[2] = '*') or (St[2] = '/'));
-      (* 17/08 - Eswar: Support for SQL comment line beginning with -- *)
-      hlSql:
-        Result := (LS > 1) and ((St[1] = '-') and
-          (St[2] = '-'));
-      (* 17/08 - Eswar: HTML multi line comment support *)
-      hlHtml:
-        Result := (LS > 3) and (St[1] = '<') and (St[2] = '!')
-          and (St[3] = '-') and (St[4] = '-');
       hlVB:
         Result := (LS > 0) and (St[1] = '''');
       hlPython, hlPerl:
@@ -858,11 +847,11 @@
       C := Colors.Comment
     else
       C := Colors.PlainText;
-    if (FLong <> 0) {Eswar: and (FHighlighter <> hlHtml)} then
+    if (FLong <> 0) and (FHighlighter <> hlHtml) then
     begin
       Parser.pcPos := Parser.pcProgram + FindLongEnd + 1;
       case Highlighter of
-        hlCBuilder, hlPython, hlPerl, hlNQC, hlCSharp, hlHtml:
+        hlCBuilder, hlPython, hlPerl, hlNQC, hlCSharp:
           case FLong of
             lgString:
               C := Colors.Strings;
@@ -988,34 +977,15 @@
           hlHtml:
             if not InTag then
             begin
-              (* 18/08 - Eswar: Check for the comment starting
-                 with <!-- and force the hilighter to check for
-                 the comments *)
-              if Token = '<!--' then
-              begin
-                InTag := True;
-                SetColor(Colors.Comment);
-                F := False;
-              end
-              else
               if Token = '<' then
               begin
                 InTag := True;
-                SetColor(Colors.Reserved);
-                F := True;
-              end
-              else
-                F := False;
+                SetColor(Colors.Reserved)
+              end;
+              F := True;
             end
             else
             begin
-              if Token = '-->' then
-              begin
-                InTag := False;
-                SetColor(Colors.Reserved);
-                F := False;
-              end
-              else
               if Token = '>' then
               begin
                 InTag := False;
@@ -1424,28 +1394,13 @@
                       P := StrScan(F + I, Char('>'));
                       if P = nil then
                       begin
-                        (* 17/08 - Eswar: Multiline comments in HTML *)
-                        if S[2] = '!' then
-                          FLong := lgComment1
-                        else
-                          FLong := lgTag;
+                        FLong := lgTag;
                         Break;
                       end
                       else
                         I := P - F + 1;
                     end;
                 end;
-              (* 17/08 - Eswar: Multiline comments in HTML *)
-              lgComment1:
-                begin
-                  P := StrScan(F + I - 1, Char('>'));
-                  if P = nil then
-                    Break
-                  else
-                    if (P[-2] = '-') and (P[-1] = '-') then
-                      FLong := lgNone;
-                  I := P - F + 1;
-                end;
               lgTag: // html tag
                 begin
                   P := StrScan(F + I - 1, Char('>'));
@@ -1646,16 +1601,6 @@
       end;
     hlHtml:
       case FLong of
-        (* 18/08 - Eswar: HTML multiline comments *)
-        lgComment1:
-          begin
-            P := StrScan(P, Char('>'));
-            if P <> nil then
-              // check if the previous characters are
-              // --
-              if (P[-1] = '-') and (P[-2] = '-') then
-                Result := P - PChar(FLine);
-          end;
         lgTag:
           begin
             P := StrScan(P, Char('>'));
jvhleditor_diff.txt (5,948 bytes)

2005-08-18 04:38

 

jvunicodehleditor_diff.txt (5,477 bytes)
--- JvUnicodeHLEditor.pas	Thu Aug 18 11:52:44 2005
+++ 3.0\JvUnicodeHLEditor.pas	Thu Feb 24 13:26:12 2005
@@ -255,10 +255,8 @@
     case FHighlighter of
       hlPascal:
         Parser.Style := psPascal;
-      hlCBuilder, hlJava, hlNQC, hlCSharp:
+      hlCBuilder, hlSql, hlJava, hlNQC, hlCSharp:
         Parser.Style := psCpp;
-      hlSql:
-        Parser.Style := psSql;
       hlPython:
         Parser.Style := psPython;
       hlVB:
@@ -323,7 +321,6 @@
     ' int monitor repeat return signed start stop sub switch task true' +
     ' until void while ';
 
-  (* 18/08 - Eswar: Support for REPLACE keyword *)
   SQLKeyWords =
     ' active as add asc after ascending all at alter auto' +
     ' and autoddl any avg based between basename blob' +
@@ -349,7 +346,7 @@
     ' open output_type option overflow page post_event pagelength  precision' +
     ' pages  prepare page_size procedure parameter  protected password  primary' +
     ' plan  privileges position  public quit' +
-    ' raw_partitions  retain rdb db_key  return read replace returning_values real  returns' +
+    ' raw_partitions  retain rdb db_key  return read  returning_values real  returns' +
     ' record_version revoke references  right release  rollback reserv runtime' +
     ' reserving schema  sql segment  sqlcode select  sqlerror set  sqlwarning' +
     ' shadow  stability shared  starting shell  starts show  statement' +
@@ -583,17 +580,9 @@
         Result := ((LS > 0) and (St[1] = '{')) or
           ((LS > 1) and (((St[1] = '(') and (St[2] = '*')) or
           ((St[1] = '/') and (St[2] = '/'))));
-      hlCBuilder, hlJava, hlPhp, hlNQC:
+      hlCBuilder, hlSql, hlJava, hlPhp, hlNQC:
         Result := (LS > 1) and (St[1] = '/') and
           ((St[2] = '*') or (St[2] = '/'));
-      (* 17/08 - Eswar: Support for SQL comment line beginning with -- *)
-      hlSql:
-        Result := (LS > 1) and ((St[1] = '-') and
-          (St[2] = '-'));
-      (* 17/08 - Eswar: HTML multi line comment support *)
-      hlHtml:
-        Result := (LS > 3) and (St[1] = '<') and (St[2] = '!')
-          and (St[3] = '-') and (St[4] = '-');
       hlVB:
         Result := (LS > 0) and (St[1] = '''');
       hlPython, hlPerl:
@@ -802,7 +791,7 @@
       C := Colors.Comment
     else
       C := Colors.PlainText;
-    if (FLong <> 0) {18/08 - Eswar: and (FHighlighter <> hlHtml)} then
+    if (FLong <> 0) and (FHighlighter <> hlHtml) then
     begin
       Parser.pcPos := Parser.pcProgram + FindLongEnd + 1;
       case Highlighter of
@@ -932,34 +921,15 @@
           hlHtml:
             if not InTag then
             begin
-              (* 18/08 - Eswar: Check for the comment starting
-                 with <!-- and force the hilighter to check for
-                 the comments *)
-              if Token = '<!--' then
-              begin
-                InTag := True;
-                SetColor(Colors.Comment);
-                F := False;
-              end
-              else
               if Token = '<' then
               begin
                 InTag := True;
-                SetColor(Colors.Reserved);
-                F := True;
-              end
-              else
-                F := False;
+                SetColor(Colors.Reserved)
+              end;
+              F := True;
             end
             else
             begin
-              if Token = '-->' then
-              begin
-                InTag := False;
-                SetColor(Colors.Reserved);
-                F := False;
-              end
-              else
               if Token = '>' then
               begin
                 InTag := False;
@@ -1368,29 +1338,13 @@
                       P := StrScanW(F + I, WideChar('>'));
                       if P = nil then
                       begin
-                        (* 17/08 - Eswar: Multiline comments in HTML *)
-                        if S[2] = '!' then
-                          FLong := lgComment1
-                        else
-                          FLong := lgTag;
-                          
+                        FLong := lgTag;
                         Break;
                       end
                       else
                         I := P - F + 1;
                     end;
                 end;
-              (* 17/08 - Eswar: Multiline comments in HTML *)
-              lgComment1:
-                begin
-                  P := StrScanW(F + I - 1, WideChar('>'));
-                  if P = nil then
-                    Break
-                  else
-                    if (P[-2] = '-') and (P[-1] = '-') then
-                      FLong := lgNone;
-                  I := P - F + 1;
-                end;
               lgTag: // html tag
                 begin
                   P := StrScanW(F + I - 1, WideChar('>'));
@@ -1591,16 +1545,6 @@
       end;
     hlHtml:
       case FLong of
-        (* 18/08 - Eswar: HTML multiline comments *)
-        lgComment1:
-          begin
-            P := StrScanW(P, WideChar('>'));
-            if P <> nil then
-              // check if the previous characters are
-              // --
-              if (P[-1] = '-') and (P[-2] = '-') then
-                Result := P - PWideChar(FLine);
-          end;
         lgTag:
           begin
             P := StrScanW(P, WideChar('>'));

2005-08-18 04:38

 

jvhlparser_diff.txt (2,807 bytes)
--- jvhlparser.pas	Wed Aug 17 14:33:12 2005
+++ 3.0\jvhlparser.pas	Thu Feb 17 11:20:36 2005
@@ -54,7 +54,7 @@
   ieBadRemark = 1;
 
 type
-  TIParserStyle = (psNone, psPascal, psCpp, psPython, psVB, psHtml, psPerl, psCocoR, psPhp, psSql);
+  TIParserStyle = (psNone, psPascal, psCpp, psPython, psVB, psHtml, psPerl, psCocoR, psPhp);
 
   TJvIParser = class(TObject)
   protected
@@ -293,39 +293,6 @@
             F := StrEnd(P + 1);
           P := F;
         end;
-      (* 17/08 - Eswar: Support for the SQL -- comments *)
-      '-':
-        if (FStyle = psSql) and (P[1] = '-') then
-        begin
-          F := StrScan(P + 1, Cr);
-          if F = nil then
-            F := StrEnd(P + 1);
-          P := F;
-        end;
-      (* 17/08 - Eswar: Support for multiline comments for HTML *)
-      '<':
-        if (FStyle = psHtml) and (P[1] = '!') then
-        begin
-          // we need the next 2 chars to be --
-          if (P[2] = #0) or (P[3] = #0) then
-            Exit; // line end
-          if (P[2] <> '-') and (P[3] <> '-') then
-            Exit;
-          F := P + 3;
-          while True do
-          begin
-            F := StrScan(F, '-');
-            if F = nil then //IParserError(ieBadRemark, P - FpcProgram);
-              Exit;
-            if (F[1] = '-') and (F[2] = '>') then
-            begin
-              Inc(F, 2);
-              Break;
-            end;
-            Inc(F);
-          end;
-          P := F + 1;
-        end;
     end;
     SkipComments := False;
   end;
@@ -689,39 +656,6 @@
           if F = nil then
             F := StrEndW(P + 1);
           P := F;
-        end;
-      (* 17/08 - Eswar: Support for the SQL -- comments *)
-      '-':
-        if (FStyle = psSql) and (P[1] = '-') then
-        begin
-          F := StrScanW(P + 1, WideChar(Cr));
-          if F = nil then
-            F := StrEndW(P + 1);
-          P := F;
-        end;
-      (* 17/08 - Eswar: Support for multiline comments for HTML *)
-      '<':
-        if (FStyle = psHtml) and (P[1] = '!') then
-        begin
-          // we need the next 2 chars to be --
-          if (P[2] = #0) or (P[3] = #0) then
-            Exit; // line end
-          if (P[2] <> '-') and (P[3] <> '-') then
-            Exit;
-          F := P + 3;
-          while True do
-          begin
-            F := StrScanW(F, WideChar('-'));
-            if F = nil then //IParserError(ieBadRemark, P - FpcProgram);
-              Exit;
-            if (F[1] = '-') and (F[2] = '>') then
-            begin
-              Inc(F, 2);
-              Break;
-            end;
-            Inc(F);
-          end;
-          P := F + 1;
         end;
     end;
     SkipComments := False;
jvhlparser_diff.txt (2,807 bytes)

eswarpr

2005-08-18 04:41

reporter   ~0007809

There are 3 files that I have changed JvHLEditor.pas, JvHLParser.pas, and JvUnicodeHLEditor.pas and have added support for the -- SQL comment, the SQL replace keyword and <!-- --> comment for HTML hilighter. I have uploaded them as output files of the diff -u3 command on the files. This is the first time I am uploading my code to sourceforge.net bug tracker. Let me know if this is the correct way to do it, or please suggest changes.

obones

2005-08-18 09:03

administrator   ~0007811

The files were uploaded just fine, but the diff is in reverse.
The order in which you specify on the command lines is important as it indicates you are going from one file to the other.
Basically, those updated here, have '-' (minus) in front of the lines you added, where it should have been '+' (plus). Could you try to do this again?
I mean, I could do it myself, but then, you wouldn't learn much from this exchange ;-)

2005-08-19 02:56

 

jvhleditor_diff_new.txt (5,948 bytes)
--- 3.0\JvHLEditor.pas	Thu Feb 24 13:26:10 2005
+++ JvHLEditor.pas	Thu Aug 18 11:35:52 2005
@@ -311,7 +311,7 @@
     case FHighlighter of
       hlPascal:
         Parser.Style := psPascal;
-      hlCBuilder, hlSql, hlJava, hlNQC, hlCSharp:
+      hlCBuilder, hlJava, hlNQC, hlCSharp:
         Parser.Style := psCpp;
       hlPython:
         Parser.Style := psPython;
@@ -327,6 +327,8 @@
         Parser.Style := psCocoR;
       hlPhp:
         Parser.Style := psPhp;
+      hlSql:
+        Parser.Style := psSql;
     end;
     RescanLong(0);
     Invalidate;
@@ -377,6 +379,7 @@
     ' int monitor repeat return signed start stop sub switch task true' +
     ' until void while ';
 
+    (* 17/08/05 - Eswar: REPLACE keyword added to the list *)
   SQLKeyWords =
     ' active as add asc after ascending all at alter auto' +
     ' and autoddl any avg based between basename blob' +
@@ -402,8 +405,8 @@
     ' open output_type option overflow page post_event pagelength  precision' +
     ' pages  prepare page_size procedure parameter  protected password  primary' +
     ' plan  privileges position  public quit' +
-    ' raw_partitions  retain rdb db_key  return read  returning_values real  returns' +
-    ' record_version revoke references  right release  rollback reserv runtime' +
+    ' raw_partitions  retain rdb db_key  return read replace returning_values real  returns' +
+    ' record_version revoke references  right release  rollback reserv runtime replace' +
     ' reserving schema  sql segment  sqlcode select  sqlerror set  sqlwarning' +
     ' shadow  stability shared  starting shell  starts show  statement' +
     ' singular  static size  statistics smallint  sub_type snapshot  sum' +
@@ -635,9 +638,17 @@
         Result := ((LS > 0) and (St[1] = '{')) or
           ((LS > 1) and (((St[1] = '(') and (St[2] = '*')) or
           ((St[1] = '/') and (St[2] = '/'))));
-      hlCBuilder, hlSql, hlJava, hlPhp, hlNQC, hlCSharp:
+      hlCBuilder, hlJava, hlPhp, hlNQC, hlCSharp:
         Result := (LS > 1) and (St[1] = '/') and
           ((St[2] = '*') or (St[2] = '/'));
+      (* 17/08 - Eswar: Support for SQL comment line beginning with -- *)
+      hlSql:
+        Result := (LS > 1) and ((St[1] = '-') and
+          (St[2] = '-'));
+      (* 17/08 - Eswar: HTML multi line comment support *)
+      hlHtml:
+        Result := (LS > 3) and (St[1] = '<') and (St[2] = '!')
+          and (St[3] = '-') and (St[4] = '-');
       hlVB:
         Result := (LS > 0) and (St[1] = '''');
       hlPython, hlPerl:
@@ -847,11 +858,11 @@
       C := Colors.Comment
     else
       C := Colors.PlainText;
-    if (FLong <> 0) and (FHighlighter <> hlHtml) then
+    if (FLong <> 0) {Eswar: and (FHighlighter <> hlHtml)} then
     begin
       Parser.pcPos := Parser.pcProgram + FindLongEnd + 1;
       case Highlighter of
-        hlCBuilder, hlPython, hlPerl, hlNQC, hlCSharp:
+        hlCBuilder, hlPython, hlPerl, hlNQC, hlCSharp, hlHtml:
           case FLong of
             lgString:
               C := Colors.Strings;
@@ -977,15 +988,34 @@
           hlHtml:
             if not InTag then
             begin
+              (* 18/08 - Eswar: Check for the comment starting
+                 with <!-- and force the hilighter to check for
+                 the comments *)
+              if Token = '<!--' then
+              begin
+                InTag := True;
+                SetColor(Colors.Comment);
+                F := False;
+              end
+              else
               if Token = '<' then
               begin
                 InTag := True;
-                SetColor(Colors.Reserved)
-              end;
-              F := True;
+                SetColor(Colors.Reserved);
+                F := True;
+              end
+              else
+                F := False;
             end
             else
             begin
+              if Token = '-->' then
+              begin
+                InTag := False;
+                SetColor(Colors.Reserved);
+                F := False;
+              end
+              else
               if Token = '>' then
               begin
                 InTag := False;
@@ -1394,13 +1424,28 @@
                       P := StrScan(F + I, Char('>'));
                       if P = nil then
                       begin
-                        FLong := lgTag;
+                        (* 17/08 - Eswar: Multiline comments in HTML *)
+                        if S[2] = '!' then
+                          FLong := lgComment1
+                        else
+                          FLong := lgTag;
                         Break;
                       end
                       else
                         I := P - F + 1;
                     end;
                 end;
+              (* 17/08 - Eswar: Multiline comments in HTML *)
+              lgComment1:
+                begin
+                  P := StrScan(F + I - 1, Char('>'));
+                  if P = nil then
+                    Break
+                  else
+                    if (P[-2] = '-') and (P[-1] = '-') then
+                      FLong := lgNone;
+                  I := P - F + 1;
+                end;
               lgTag: // html tag
                 begin
                   P := StrScan(F + I - 1, Char('>'));
@@ -1601,6 +1646,16 @@
       end;
     hlHtml:
       case FLong of
+        (* 18/08 - Eswar: HTML multiline comments *)
+        lgComment1:
+          begin
+            P := StrScan(P, Char('>'));
+            if P <> nil then
+              // check if the previous characters are
+              // --
+              if (P[-1] = '-') and (P[-2] = '-') then
+                Result := P - PChar(FLine);
+          end;
         lgTag:
           begin
             P := StrScan(P, Char('>'));
jvhleditor_diff_new.txt (5,948 bytes)

2005-08-19 02:56

 

jvhlparser_diff_new.txt (2,807 bytes)
--- 3.0\JvHLParser.pas	Thu Feb 17 11:20:36 2005
+++ JvHLParser.pas	Wed Aug 17 14:33:12 2005
@@ -54,7 +54,7 @@
   ieBadRemark = 1;
 
 type
-  TIParserStyle = (psNone, psPascal, psCpp, psPython, psVB, psHtml, psPerl, psCocoR, psPhp);
+  TIParserStyle = (psNone, psPascal, psCpp, psPython, psVB, psHtml, psPerl, psCocoR, psPhp, psSql);
 
   TJvIParser = class(TObject)
   protected
@@ -293,6 +293,39 @@
             F := StrEnd(P + 1);
           P := F;
         end;
+      (* 17/08 - Eswar: Support for the SQL -- comments *)
+      '-':
+        if (FStyle = psSql) and (P[1] = '-') then
+        begin
+          F := StrScan(P + 1, Cr);
+          if F = nil then
+            F := StrEnd(P + 1);
+          P := F;
+        end;
+      (* 17/08 - Eswar: Support for multiline comments for HTML *)
+      '<':
+        if (FStyle = psHtml) and (P[1] = '!') then
+        begin
+          // we need the next 2 chars to be --
+          if (P[2] = #0) or (P[3] = #0) then
+            Exit; // line end
+          if (P[2] <> '-') and (P[3] <> '-') then
+            Exit;
+          F := P + 3;
+          while True do
+          begin
+            F := StrScan(F, '-');
+            if F = nil then //IParserError(ieBadRemark, P - FpcProgram);
+              Exit;
+            if (F[1] = '-') and (F[2] = '>') then
+            begin
+              Inc(F, 2);
+              Break;
+            end;
+            Inc(F);
+          end;
+          P := F + 1;
+        end;
     end;
     SkipComments := False;
   end;
@@ -656,6 +689,39 @@
           if F = nil then
             F := StrEndW(P + 1);
           P := F;
+        end;
+      (* 17/08 - Eswar: Support for the SQL -- comments *)
+      '-':
+        if (FStyle = psSql) and (P[1] = '-') then
+        begin
+          F := StrScanW(P + 1, WideChar(Cr));
+          if F = nil then
+            F := StrEndW(P + 1);
+          P := F;
+        end;
+      (* 17/08 - Eswar: Support for multiline comments for HTML *)
+      '<':
+        if (FStyle = psHtml) and (P[1] = '!') then
+        begin
+          // we need the next 2 chars to be --
+          if (P[2] = #0) or (P[3] = #0) then
+            Exit; // line end
+          if (P[2] <> '-') and (P[3] <> '-') then
+            Exit;
+          F := P + 3;
+          while True do
+          begin
+            F := StrScanW(F, WideChar('-'));
+            if F = nil then //IParserError(ieBadRemark, P - FpcProgram);
+              Exit;
+            if (F[1] = '-') and (F[2] = '>') then
+            begin
+              Inc(F, 2);
+              Break;
+            end;
+            Inc(F);
+          end;
+          P := F + 1;
         end;
     end;
     SkipComments := False;
jvhlparser_diff_new.txt (2,807 bytes)

2005-08-19 02:56

 

jvunicodehleditor_diff_new.txt (5,477 bytes)
--- 3.0\JvUnicodeHLEditor.pas	Thu Feb 24 13:26:12 2005
+++ JvUnicodeHLEditor.pas	Thu Aug 18 11:52:44 2005
@@ -255,8 +255,10 @@
     case FHighlighter of
       hlPascal:
         Parser.Style := psPascal;
-      hlCBuilder, hlSql, hlJava, hlNQC, hlCSharp:
+      hlCBuilder, hlJava, hlNQC, hlCSharp:
         Parser.Style := psCpp;
+      hlSql:
+        Parser.Style := psSql;
       hlPython:
         Parser.Style := psPython;
       hlVB:
@@ -321,6 +323,7 @@
     ' int monitor repeat return signed start stop sub switch task true' +
     ' until void while ';
 
+  (* 18/08 - Eswar: Support for REPLACE keyword *)
   SQLKeyWords =
     ' active as add asc after ascending all at alter auto' +
     ' and autoddl any avg based between basename blob' +
@@ -346,7 +349,7 @@
     ' open output_type option overflow page post_event pagelength  precision' +
     ' pages  prepare page_size procedure parameter  protected password  primary' +
     ' plan  privileges position  public quit' +
-    ' raw_partitions  retain rdb db_key  return read  returning_values real  returns' +
+    ' raw_partitions  retain rdb db_key  return read replace returning_values real  returns' +
     ' record_version revoke references  right release  rollback reserv runtime' +
     ' reserving schema  sql segment  sqlcode select  sqlerror set  sqlwarning' +
     ' shadow  stability shared  starting shell  starts show  statement' +
@@ -580,9 +583,17 @@
         Result := ((LS > 0) and (St[1] = '{')) or
           ((LS > 1) and (((St[1] = '(') and (St[2] = '*')) or
           ((St[1] = '/') and (St[2] = '/'))));
-      hlCBuilder, hlSql, hlJava, hlPhp, hlNQC:
+      hlCBuilder, hlJava, hlPhp, hlNQC:
         Result := (LS > 1) and (St[1] = '/') and
           ((St[2] = '*') or (St[2] = '/'));
+      (* 17/08 - Eswar: Support for SQL comment line beginning with -- *)
+      hlSql:
+        Result := (LS > 1) and ((St[1] = '-') and
+          (St[2] = '-'));
+      (* 17/08 - Eswar: HTML multi line comment support *)
+      hlHtml:
+        Result := (LS > 3) and (St[1] = '<') and (St[2] = '!')
+          and (St[3] = '-') and (St[4] = '-');
       hlVB:
         Result := (LS > 0) and (St[1] = '''');
       hlPython, hlPerl:
@@ -791,7 +802,7 @@
       C := Colors.Comment
     else
       C := Colors.PlainText;
-    if (FLong <> 0) and (FHighlighter <> hlHtml) then
+    if (FLong <> 0) {18/08 - Eswar: and (FHighlighter <> hlHtml)} then
     begin
       Parser.pcPos := Parser.pcProgram + FindLongEnd + 1;
       case Highlighter of
@@ -921,15 +932,34 @@
           hlHtml:
             if not InTag then
             begin
+              (* 18/08 - Eswar: Check for the comment starting
+                 with <!-- and force the hilighter to check for
+                 the comments *)
+              if Token = '<!--' then
+              begin
+                InTag := True;
+                SetColor(Colors.Comment);
+                F := False;
+              end
+              else
               if Token = '<' then
               begin
                 InTag := True;
-                SetColor(Colors.Reserved)
-              end;
-              F := True;
+                SetColor(Colors.Reserved);
+                F := True;
+              end
+              else
+                F := False;
             end
             else
             begin
+              if Token = '-->' then
+              begin
+                InTag := False;
+                SetColor(Colors.Reserved);
+                F := False;
+              end
+              else
               if Token = '>' then
               begin
                 InTag := False;
@@ -1338,13 +1368,29 @@
                       P := StrScanW(F + I, WideChar('>'));
                       if P = nil then
                       begin
-                        FLong := lgTag;
+                        (* 17/08 - Eswar: Multiline comments in HTML *)
+                        if S[2] = '!' then
+                          FLong := lgComment1
+                        else
+                          FLong := lgTag;
+                          
                         Break;
                       end
                       else
                         I := P - F + 1;
                     end;
                 end;
+              (* 17/08 - Eswar: Multiline comments in HTML *)
+              lgComment1:
+                begin
+                  P := StrScanW(F + I - 1, WideChar('>'));
+                  if P = nil then
+                    Break
+                  else
+                    if (P[-2] = '-') and (P[-1] = '-') then
+                      FLong := lgNone;
+                  I := P - F + 1;
+                end;
               lgTag: // html tag
                 begin
                   P := StrScanW(F + I - 1, WideChar('>'));
@@ -1545,6 +1591,16 @@
       end;
     hlHtml:
       case FLong of
+        (* 18/08 - Eswar: HTML multiline comments *)
+        lgComment1:
+          begin
+            P := StrScanW(P, WideChar('>'));
+            if P <> nil then
+              // check if the previous characters are
+              // --
+              if (P[-1] = '-') and (P[-2] = '-') then
+                Result := P - PWideChar(FLine);
+          end;
         lgTag:
           begin
             P := StrScanW(P, WideChar('>'));

eswarpr

2005-08-19 02:57

reporter   ~0007814

Thanks. I have uploaded the new versions as *_diff_new.txt files. Let me know if I did right.

obones

2005-08-19 03:26

administrator   ~0007815

Yes, they are fine, I'll put that in CVS when I get a bit of spare time

obones

2005-08-28 09:31

administrator   ~0007871

This is now in CVS.
As you will have noticed, the "eswar" comments got adapted as we generally don't do "in source" acknowledgment. Your name has however been added to the contributors list for those units.

Issue History

Date Modified Username Field Change
2005-08-17 04:19 eswarpr New Issue
2005-08-17 05:08 obones Note Added: 0007806
2005-08-17 05:08 obones Status new => feedback
2005-08-17 05:20 eswarpr Note Added: 0007807
2005-08-17 05:22 eswarpr Note Edited: 0007807
2005-08-18 00:48 obones Note Added: 0007808
2005-08-18 00:49 obones Note Edited: 0007808
2005-08-18 04:37 eswarpr File Added: jvhleditor_diff.txt
2005-08-18 04:38 eswarpr File Added: jvunicodehleditor_diff.txt
2005-08-18 04:38 eswarpr File Added: jvhlparser_diff.txt
2005-08-18 04:41 eswarpr Note Added: 0007809
2005-08-18 09:03 obones Note Added: 0007811
2005-08-19 02:56 eswarpr File Added: jvhleditor_diff_new.txt
2005-08-19 02:56 eswarpr File Added: jvhlparser_diff_new.txt
2005-08-19 02:56 eswarpr File Added: jvunicodehleditor_diff_new.txt
2005-08-19 02:57 eswarpr Note Added: 0007814
2005-08-19 03:26 obones Note Added: 0007815
2005-08-28 09:31 obones Status feedback => resolved
2005-08-28 09:31 obones Resolution open => fixed
2005-08-28 09:31 obones Assigned To => obones
2005-08-28 09:31 obones Note Added: 0007871