Recent

Author Topic: Hebrew entries  (Read 16900 times)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Hebrew entries
« Reply #15 on: August 18, 2016, 05:33:23 pm »
I left in a hurry. I forgot to say thanks. I would never have found that RichEdit code. I didn't even know that there was a RichEdit unit in Lazarus.
"richedit" unit comes with FreePascal, rather than Lazarus. It's a part of standard WinAPI interface.

Unfortunately, however, it only works with the paragraph being RTL. If it isn't RTL it will make it RTL. So you can't do inline quotes from Hebrew within an English paragraph. You would only be able to that by copy/paste.
A bit more details:
I's possible to inline Hebrew characters into English paragraph. These characters would look and behave nicely. However, punctuation between these characters would act as if it's left-to-right punctuation.
That's a problem, because it should use surrounding (hebrew) letters as a direction, rather than text (or paragraph) left-to-right direction.

The fact, that a pasted text acts as expected, makes me think that it should be possible to make entered punctuation to work properly.

It also seems that
RIGHT-TO-LEFT EMBEDDING (U+202B)
and
RIGHT-TO-LEFT OVERRIDE (U+202E)
are accepted (they act as an invisible character), but ignored and do not affect the entered text.
« Last Edit: August 18, 2016, 05:40:57 pm by skalogryz »

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #16 on: August 18, 2016, 06:24:04 pm »
When I hit Hebrew Mode I have it set to do a MakeRTLPara, so it turns things into RTL paragraph. If I disable that function I can type Hebrew properly, but the cursor does not advance and I can only type one word (because a space wrecks the character order) with no punctuations.

There needs to be some RTL boundaries inserted (similar to MakeRTLPara) that are like Bolding or Italics. I know what those codes are, but I don't know how to insert them. I need a function that allows me to type in Rich Text code and have it embed in the document at the cursor position... ie. \ltrpar, \rtlch, \ltrch etc. Then I could take control of any document for any purpose.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #17 on: August 18, 2016, 06:49:00 pm »
In a mixed file code I have \rtlpar ... \ltrch *english* \rtlch *hebrew* \ltrch *english* ... \par

It makes an RTL paragraph, invokes LTR for english, invokes RTL for hebrew, and back to english and closes the paragraph.

The issue is that RichEdit apparently only knows how to handle punctuations and word separators when it initiates as an RTL paragraph... unless you can find another RichEdit code for inline entries.

I need some help on clicking an RTL line. RichMemo doesn't know that it is RTL. I have to invoke MakeRTLPara again in order to edit the text.

Is that going to clutter the file? Alternately, is there a another way to activate the RTL or LTR porperty?

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #18 on: August 18, 2016, 06:55:20 pm »
I just found my own answer on cluttering the file. It does not clutter it. RichEdit takes care of that.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Hebrew entries
« Reply #19 on: August 18, 2016, 07:43:25 pm »
Well, here's a thing.
The control follows the input layout selected.
(if you've "ENG" layout, then the period you type in is left-to-right period)

If you install Hebrew keyboard layout on your OS
remove the text, that tries to substitute the period for period:
Code: Pascal  [Select][+][-]
  1. //'.' : begin PageMemo.SelText:= '.'; Hkey:= true; end;
  2.  
and try to input "." with hebrew layout t - it works flawlessly.

But, if it's expected, that someone would not like to install Hebrew layout, it should be possible to clean up /ltrch once period is entered and re-insert it back.

It's hard to say why, even on Hebrew layout "PageMemo.SelText:= '.';" inserts l-t-r period. The richedit control is created as unicode w/o any explicit binding to system codepage.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #20 on: August 18, 2016, 07:46:29 pm »
How do I invoke and disable the Hebrew layout within the code?

Rick
« Last Edit: August 18, 2016, 07:55:03 pm by rick2691 »
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #21 on: August 18, 2016, 07:57:12 pm »
Also I am doing a character layout (which is phonetic) that is identical (with a few exceptions) for both Hebrew and Syriac. Will the keyboard allow me to override its hardwired layout?

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #22 on: August 18, 2016, 08:14:16 pm »
This is just a note... all of the Windows unicode fonts (ie. Arial and Tahoma) cannot do a Holam (xlm) vowel (point) character. At present I have only found that the  SBL Hebrew font will insert it correctly.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Hebrew entries
« Reply #23 on: August 18, 2016, 08:15:30 pm »
How do I invoke and disable the Hebrew layout within the code?
You might to load it first
and then you active it

The problem though, it might not work, since it has to been done prior to KeyPress (or even prior to KeyDown). Though I didn't try.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Hebrew entries
« Reply #24 on: August 18, 2016, 08:16:07 pm »
This is just a note... all of the Windows unicode fonts (ie. Arial and Tahoma) cannot do a Holam (xlm) vowel (point) character. At present I have only found that the  SBL Hebrew font will insert it correctly.
You have to distribute the font with your application. That's normal.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #25 on: August 18, 2016, 08:20:17 pm »
Quote
You might to load it first
and then you active it

Installing it is a given, but I don't want the user to have to activate it on their own. What can I do with the code that will handle that for them?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #26 on: August 18, 2016, 08:25:31 pm »
Another item... some of these letters are several key strokes. As is, with the OnKeyPress, I can only post one character. Is there a way to enter several key strokes? Or another reactor that can follow up with another key stroke?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #27 on: August 18, 2016, 08:33:52 pm »
OK. I have my own answer...

Code: Pascal  [Select][+][-]
  1. 'S' : begin
  2.                 UTF8Key:=#0;
  3.                 PageMemo.SelText:= UnicodeToUTF8(1513)+UnicodeToUTF8(1473);  // shn  ...must add 1473 for dot
  4.                 PageMemo.SelLength:=0;
  5.                 PageMemo.SelStart:= PageMemo.SelStart+1;
  6.                 end;
  7.  

Richedit also handles the advance cursor for this method.

Rick
« Last Edit: August 18, 2016, 08:38:34 pm by rick2691 »
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Hebrew entries
« Reply #28 on: August 18, 2016, 09:01:54 pm »
So, here's a way to handle the LTR "period" in RTL text.
Instead of letting RichEdit (RichMemo) decide the language and direction of the character, you can do it yourself, by inserting plain RTF.
Warning: this method is quite an overhead, since it requires richedit to parse RTF.

Code: Pascal  [Select][+][-]
  1. type
  2.   TSetTextEx = packed record
  3.     flags    : DWORD;
  4.     codepage : UINT;
  5.   end;
  6.  
  7. const
  8.   ST_DEFAULT   = $00000000;
  9.   ST_KEEPUNDO  = $00000001;
  10.   ST_SELECTION = $00000002;
  11.   ST_NEWCHARS  = $00000004;
  12.   ST_UNICODE   = $00000008;
  13.  
  14. procedure InsertAsRTF(rm: TRichMemo; const str: string);
  15. var
  16.   st: TSetTextEx;
  17.   s: String;
  18. begin
  19.   st.flags:=ST_SELECTION or ST_NEWCHARS or ST_KEEPUNDO;
  20.   s:=StringReplace(str,'\','\\', [rfReplaceAll]);
  21.   s:='{\rtf1\ansi '+s+'}';
  22.   st.codepage:=CP_ACP;
  23.   SendMessage(rm.Handle, EM_SETTEXTEX, WPARAM(@st), LPARAM(@s[1]));
  24. end;
  25.  

and your code should look like this:
Code: Pascal  [Select][+][-]
  1.   case Key of
  2.     ..
  3.     '.' : begin InsertAsRTF(PageMemo, '.'); Hkey:= true; end;
  4.   end
  5.  

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Hebrew entries
« Reply #29 on: August 18, 2016, 09:05:58 pm »
Can I say "very cool"? I haven't tried it yet, but it looks like simple code... what gives it a hefty overhead?
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

 

TinyPortal © 2005-2018