Hi,
below I have another fix needed for the Lazarus version of UniHighlighter (see my other posts today on fixing it to not make all chars uppercase)
 
That fix is because the original UniHighlighter from which it was ported didn't work with any ANSI chars below the A-Z/a-z range.
 
at the code below (which is for Delphi):
    CaseFunct:[EMAIL PROTECTED]
instead of
    CaseFunct:=AnsiUpCase
 
etc.
 
has to be used, since {$MODE DELPHI} isn't used in the current version of the Lazarus port of Unihighlighter
 
I've also made GreekUpCase and GreekUpperCase for those interested in ignoring Greek punctuation marks (if anyone interested contact me in private to send you those two AnsiUpCase/AnsiUpperCase alternatives)
 
btw, it would be nice if Delphi (and Lazarus) had an AnsiUpCase function (could use my implementation below or any better one)
 
thanks for seeing into adding this to Lazarus,
don't have time to file bug for it (too busy with some other project),
George
 

From: George Birbilis [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 11, 2006 5:44 PM
To: 'Vitaly Nevzorov'
Cc: 'Manolis Tzagarakis'
Subject: RE: SynUni (update on fix for TSynRange.SetCaseSensitive)
Importance: High

Hi again Vitaly,
 
I forgot to fix the upper casing for single characters too. I had fixed it only for strings, but seems UniHighlighter (or SynEdit) first checks if the first char of a word matches, then checks the whole word for a match (for more speed I suppose, since char parameters can be passed using a register)
 
Here's the full fix for UniHighlighter.pas to not only work with ANSI English chars, but use the Windows locale rules for uppercasing (used at char and token comparisons as it seems):
 
1) add AnsiUpCase function above CaseNone and StringCaseNone (those are unchanged)
 
function AnsiUpCase(c:char):char; //Birb
begin
  Result:=AnsiUpperCase(c)[1];
end;
 
function CaseNone(c:char):char;
begin
  Result:=c;
end;
 
function StringCaseNone(const s:string):string;
begin
  Result:=s;
end;
 
2) add this new version of TSynRange.SetCaseSensitive that uses AnsiUpCase (for chars) instead of UpCase (and uses AnsiUpperCase instead of UpperCase [for strings])
 
procedure TSynRange.SetCaseSensitive(const Value: boolean);
begin
 FCaseSensitive:=Value;
 if not Value then
 begin
   CaseFunct:=AnsiUpCase; //Birb: not using UpCase cause it's only for English
   StringCaseFunct:=AnsiUpperCase; //Birb: not using UpperCase cause it's only for English
 end
 else
 begin
   CaseFunct:=CaseNone;
   StringCaseFunct:=StringCaseNone;
 end;
end;
 
cheers,
George
 
P.S.  in my case I need Greek punctuation marks to be ignored when comparing which the Windows locale string rules that AnsiUpperCase (and my AnsiUpCase) use doesn't do, but can easily write my own GreekUpCase and GreekUpperCase to use. I also suggest that you also add two events at the VCL component or at least two "function pointer" properties so that one can set their own uppercasing functions at runtime without having to patch UniHighlighter.pas
 

----------------
George Birbilis ([EMAIL PROTECTED])
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
* QuickTime, QTVR, ActiveX, VCL, .NET
http://www.kagi.com/birbilis
* Robotics
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup

 


From: Vitaly Nevzorov 
Sent: Wednesday, July 05, 2006 6:54 PM
To: George Birbilis
Subject: Re: SynUni

Thanks a lot!
 
With the best regards Vitaly Nevzorov.
http://www.nevzorov.org
http://www.delphist.com
http://www.drkb.ru


----- Original Message ----
From: George Birbilis <[EMAIL PROTECTED]>
Sent: Wednesday, July 5, 2006 6:51:38 AM
Subject: SynUni

I need to change SynUni (Uni Highlighter for SynEdit) to work with a Greek
programming language (taught at highschool in Greece) and it seems it only
supports English when selecting to use ignore-case

I suggest the following change (see //Birb: comment), not sure though at
which Delphi version the AnsiUpperCase function was introduced.

----------

procedure TSynRange.SetCaseSensitive(const Value: boolean);
begin
FCaseSensitive:=Value;
if not Value then
begin
   CaseFunct:=UpCase;
   StringCaseFunct:=AnsiUpperCase; //Birb: not using UpperCase cause it's
only for English
end
else
begin
   CaseFunct:=CaseNone;
   StringCaseFunct:=StringCaseNone;
end;
end;

------------------

Anyway, I may need to write my own function for ignoring punctuation marks
too at comparisons, so instead of having to change SetCaseSensitive to point
to my routine it would be best I think to have some way to callback a user's
event handler from the TSynUni component and either

* pass them either two strings to compare and have an "out" boolean param
for the result (or "var" param for old Delphi versions),

* or pass them a var param with the string value to make uppercase, in which
case they could make it uppercase in a special way that removes punctution
marks, so that both punctuated and unpunctuated strings compare the same

Cheers,
George

P.S. btw, are you interested for feedback regarding UniEdit bugs/problems?
It's a very useful tool but has various GUI issues

----------------
George Birbilis ([EMAIL PROTECTED])
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
* QuickTime, QTVR, ActiveX, VCL, .NET
http://www.kagi.com/birbilis
* Robotics
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup



avast! Antivirus: Outbound message clean.

Virus Database (VPS): 0629-1, 19/07/2006
Tested on: 21/7/2006 5:53:00 ìì
avast! - copyright (c) 1988-2006 ALWIL Software.


Reply via email to