Re: [lazarus] New synedit patch

2008-01-27 Thread Felipe Monteiro de Carvalho
On Jan 27, 2008 10:43 PM, zaher dirkey <[EMAIL PROTECTED]> wrote:
> How we can test it?, i use compile from SVN i will use Arabic language in my
> units (strings).

You need to recompile with unicode enabled:

http://wiki.lazarus.freepascal.org/LCL_Unicode_Support#Compiling_LCL-Win32_with_Unicode

Then you can write unicode text to the code editor and the object
inspector. Legacy code needs to be converted to utf-8

> Is we can use it also for WinCE?

Not yet. I hope to implement it in the next month(s).

-- 
Felipe Monteiro de Carvalho

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Ales Katona

zaher dirkey  wrote / napísal(a):
How we can test it?, i use compile from SVN i will use Arabic language 
in my units (strings).

Is we can use it also for WinCE?

On Jan 27, 2008 6:20 PM, Felipe Monteiro de Carvalho 
<[EMAIL PROTECTED] 
> wrote:


Ok, so we are now reduced to zero known regressions introduced by
unicode win32 Lazarus.

Just thougth I could use this opportunity to encourage people to
test it =)

thanks,
--
Felipe Monteiro de Carvalho

_
To unsubscribe: mail [EMAIL PROTECTED]
 with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives




--
Zaher Dirkey 


Just doubleclick a word with special (non latin1) chars, and see if it's 
properly selected. Or try other functions like SynEdit.NextWordPos etc.


Ales

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread zaher dirkey
How we can test it?, i use compile from SVN i will use Arabic language in my
units (strings).
Is we can use it also for WinCE?

On Jan 27, 2008 6:20 PM, Felipe Monteiro de Carvalho <
[EMAIL PROTECTED]> wrote:

> Ok, so we are now reduced to zero known regressions introduced by
> unicode win32 Lazarus.
>
> Just thougth I could use this opportunity to encourage people to test it
> =)
>
> thanks,
> --
> Felipe Monteiro de Carvalho
>
> _
> To unsubscribe: mail [EMAIL PROTECTED] with
>"unsubscribe" as the Subject
>   archives at http://www.lazarus.freepascal.org/mailarchives
>



-- 
Zaher Dirkey


Re: [lazarus] New synedit patch

2008-01-27 Thread Felipe Monteiro de Carvalho
Ok, so we are now reduced to zero known regressions introduced by
unicode win32 Lazarus.

Just thougth I could use this opportunity to encourage people to test it =)

thanks,
-- 
Felipe Monteiro de Carvalho

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Ales Katona

Felipe Monteiro de Carvalho  wrote / napísal(a):

On Jan 27, 2008 3:48 PM, Paul Ishenin <[EMAIL PROTECTED]> wrote:
  

Felipe Monteiro de Carvalho wrote:


If you double click "Text" it goes between "t" and "1"

  

Sorry, where is "1" in word "Text" :) ?



It's on the word on the left of it: Edit1.Text

The idea is that you click one word and the caret goes to the other
word on the left.

  
If you apply my last patch (see a few mails earlier, synedit3.patch), 
you'll fix this :)


Ales

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Felipe Monteiro de Carvalho
Thanks applied. I did some testing and it looks perfect now =)

thanks again,
-- 
Felipe Monteiro de Carvalho

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Felipe Monteiro de Carvalho
On Jan 27, 2008 3:48 PM, Paul Ishenin <[EMAIL PROTECTED]> wrote:
> Felipe Monteiro de Carvalho wrote:
> > If you double click "Text" it goes between "t" and "1"
> >
> Sorry, where is "1" in word "Text" :) ?

It's on the word on the left of it: Edit1.Text

The idea is that you click one word and the caret goes to the other
word on the left.

-- 
Felipe Monteiro de Carvalho

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Ales Katona

Felipe Monteiro de Carvalho  wrote / napísal(a):

Thanks, applied as it's much better then the current behavior.

However, it still isn't perfect. On:

  Caption := 'éé';
  Edit1.Text := 'éé';

If you double click "Caption" the cursor ends up 1 char before "C"

If you double click "Text" it goes between "t" and "1"

thanks,
  

This patch fixed the oversight :)

Ales
Index: components/synedit/synedit.pp
===
--- components/synedit/synedit.pp	(revision 13892)
+++ components/synedit/synedit.pp	(working copy)
@@ -6516,6 +6516,7 @@
   CaretXY := Runner;
   {$IFDEF SYN_LAZARUS}
   if UseUTF8 then begin
+Delete(TempString, fBlockEnd.X, Length(TempString));
 CaretX := CaretX - Max(0, (Length(TempString) - UTF8Length(TempString)));
   end;
   {$ENDIF}


Re: [lazarus] New synedit patch

2008-01-27 Thread Paul Ishenin

Felipe Monteiro de Carvalho wrote:

If you double click "Text" it goes between "t" and "1"
  

Sorry, where is "1" in word "Text" :) ?

Best regards,
Paul Ishenin.

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Ales Katona

Felipe Monteiro de Carvalho  wrote / napísal(a):

Thanks, applied as it's much better then the current behavior.

However, it still isn't perfect. On:

  Caption := 'éé';
  Edit1.Text := 'éé';

If you double click "Caption" the cursor ends up 1 char before "C"

If you double click "Text" it goes between "t" and "1"

thanks,
  
You're right, this is a logical problem on my end. I need to know how 
many utf8 chars are BEFORE the current word, not on the whole line. I'll 
try to fix this.


Ales

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New synedit patch

2008-01-27 Thread Felipe Monteiro de Carvalho
Thanks, applied as it's much better then the current behavior.

However, it still isn't perfect. On:

  Caption := 'éé';
  Edit1.Text := 'éé';

If you double click "Caption" the cursor ends up 1 char before "C"

If you double click "Text" it goes between "t" and "1"

thanks,
-- 
Felipe Monteiro de Carvalho

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] New synedit patch

2008-01-27 Thread Ales Katona
This is a revised version of my synedit patch which adds support for 
"doubleclick" selection of utf-8 text as well as puts all the changes in 
{$IFDEF SYN_LAZARUS}.


To sum it up:
1. it inverts parsing logic to use Highlighter.WordBlockChars + 
TSynWhiteChars (or TSynWordBlockChars + TSynWhiteChars if there's no 
highlighter), thus allowing utf-8 words to be parsed as long as the 
block chars don't contain chars > 127.


2. it fixes the doubleclick selection by said logic + fixing final caret 
position based on true length of given line if UseUTF8 is true.


Ales
Index: components/synedit/synedittypes.pp
===
--- components/synedit/synedittypes.pp	(revision 13890)
+++ components/synedit/synedittypes.pp	(working copy)
@@ -44,6 +44,7 @@
 const
   TSynSpecialChars = ['À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ'];
   TSynValidStringChars = ['_', '0'..'9', 'A'..'Z', 'a'..'z'] + TSynSpecialChars;
+  TSynWhiteChars = [' ', #9];
   TSynWordBreakChars = ['.', ',', ';', ':', '"', , '!', '?', '[', ']', '(',
 ')', '{', '}', '^', '-', '=', '+', '*', '/', '\', '|'];
 
Index: components/synedit/synedit.pp
===
--- components/synedit/synedit.pp	(revision 13890)
+++ components/synedit/synedit.pp	(working copy)
@@ -6453,9 +6453,6 @@
   Runner: TPoint;
   TempString: string;
   IdChars: TSynIdentChars;
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  BufChars: array of PChar;
-{$ENDIF}
 begin
   { Value is the position of the Carat in bytes }
   Value.x := MinMax(Value.x, 1, fMaxLeftChar);
@@ -6463,53 +6460,36 @@
   TempString := Lines[Value.Y - 1];
   if TempString = '' then exit;
   // Click on right side of text
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  UTF8ToArrayOfUTF8Char(PChar(TempString), Length(TempString), BufChars);
-  if Length(BufChars) < Value.X then Value.X := Length(BufChars);
-{$ELSE}
   if Length(TempString) < Value.X then Value.X := Length(TempString);
-{$ENDIF}
+
   Runner := Value;
-  if fHighlighter <> nil then
+  if Assigned(fHighlighter) then
+{$IFDEF SYN_LAZARUS}
+IdChars := [#1..#255] - (fHighlighter.WordBreakChars + TSynWhiteChars)
+{$ELSE}
 IdChars := fHighlighter.IdentChars
+{$ENDIF}
   else
+{$IFDEF SYN_LAZARUS}
+IDchars := [#1..#255] - (TSynWordBreakChars + TSynWhiteChars);
+{$ELSE}
 IDchars := [#33..#255];
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  if not (BufChars[Runner.X - 1]^ in IdChars) then begin
-{$ELSE}
+{$ENDIF}
   if not (TempString[Runner.X] in IdChars) then begin
-{$ENDIF}
 // no word under cursor and next char right is not start of a word
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-if (Runner.X > 1) and (not (BufChars[Runner.X - 1]^ in IdChars)) then begin
-{$ELSE}
 if (Runner.X > 1) and (not (TempString[Runner.X] in IdChars)) then begin
-{$ENDIF}
   // find end of word on the left side
   while Runner.X > 1 do begin
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-if (BufChars[Runner.X - 1]^ in IdChars) then break;
-{$ELSE}
 if (TempString[Runner.X] in IdChars) then break;
-{$ENDIF}
 Dec(Runner.X);
   end;
 end;
 // no word on the left side, so look to the right side
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-if not (BufChars[Runner.X - 1]^ in IdChars) then begin
-{$ELSE}
 if not (TempString[Runner.X] in IdChars) then begin
-{$ENDIF}
   Runner := Value;
   while (Runner.X < fMaxLeftChar)
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  {$IFDEF FPC} and (Runner.X < length(BufChars)){$ENDIF} do begin
-if (BufChars[Runner.X - 1]^ in IdChars) then break;
-{$ELSE}
   {$IFDEF FPC} and (Runner.X < length(TempString)){$ENDIF} do begin
 if (TempString[Runner.X] in IdChars) then break;
-{$ENDIF}
 Inc(Runner.X);
   end;
   if Runner.X > fMaxLeftChar then
@@ -6518,11 +6498,7 @@
 Value := Runner;
   end;
   while Runner.X > 0 do begin
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-if not (BufChars[Runner.X - 1]^ in IdChars) then break;
-{$ELSE}
 if not (TempString[Runner.X] in IdChars) then break;
-{$ENDIF}
 Dec(Runner.X);
   end;
   Inc(Runner.X);
@@ -6530,24 +6506,21 @@
   fBlockBegin := Runner;
   Runner := Value;
   while (Runner.X < fMaxLeftChar)
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  {$IFDEF FPC} and (Runner.X <= length(BufChars)){$ENDIF} do begin
-if not (BufChars[Runner.X - 1]^ in IdChars) then break;
-{$ELSE}
   {$IFDEF FPC} and (Runner.X <= length(TempString)){$ENDIF} do begin
 if not (TempString[Runner.X] in IdChars) then break;
-{$ENDIF}
 Inc(Runner.X);
   end;
   if Runner.X > fMaxLeftChar then Runner.X := fMaxLeftChar;
   fBlockEnd := Runner;
 // set caret to the end of selected block
   CaretXY := Runner;
+  {$IFDEF SYN_LAZARUS}
+  if UseUTF8 then begin
+CaretX := CaretX - Max(0, (Length(TempString) - UTF8Length(TempString)));
+  end;
+  {$ENDIF}
   InvalidateLine(Value.Y);
   StatusChanged([scSelection]);
-{$IFDEF NEW_UTF8_SETWORDBLOCK}
-  FreeArrayOfUTF8