Recent

Author Topic: BiDi support in the native widgetset?  (Read 6940 times)

vicot

  • Full Member
  • ***
  • Posts: 114
BiDi support in the native widgetset?
« on: May 23, 2013, 07:53:56 am »
Some time ago I read on this forum that there was work going on in the trunk about adding BiDi support to the native widgetset.
Is this BiDi-oriented effort still going on? What is its progress status?

Thanks


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #1 on: May 23, 2013, 11:04:37 am »
What specifically do you need BiDi support for?  I may be able to help.  I have done a lot or work and have most things working for RightToLeft.
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #2 on: May 23, 2013, 02:51:46 pm »
Thanks, Avishai.
Simply to be able to edit text within a window, with mixed text (RTL & LTR) on the same line. For example, Arabic and English text on the same line.


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #3 on: May 23, 2013, 03:16:55 pm »
If you mean something like "بامبسي sadff شسيبس sfasfd" then that should not be a problem.  You don't even need BiDiMode for that.  You can use TMemo for that.  You only need to switch Keyboard languages.  At least for MSWindows.  If you need something that can Left justify one line and Right justify the next, then I don't have an answer for that.

If you don't already have code for switching keyboard lang (MSWindows). let me know.

Edit: I typed the mixed text example in NotePad just switching lang.
« Last Edit: May 23, 2013, 03:18:55 pm by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #4 on: May 23, 2013, 03:26:19 pm »
Yes, that's what I need to do.
So, you say that I don't even need Qt for that? That is, can I do it with LCL's native widgets?
Switching between keyboard layouts should not be a problem.

But one more question: when you have mixed text on the same line (as in the example you gave, which seems to be perfectly fine), and you move the cursor along the line (right and left arrow keys), how does the cursor behave, while moving from one end to the other of the line? Does it behave normally, i.e. as if it was normal text from the same language? Or by keeping pressed the same arrow key, the direction of the cursor suddenly changes when it reaches the text in the other language?


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #5 on: May 23, 2013, 03:37:00 pm »
The cursor follows the direction of the lang. of the word it is on.  Try it in MSNotePad and you can see how it will behave in TMemo.  Punctuation is a bit problematic as well, but that's true in almost anything.  MSWord is about the only thing I know that will do it without using something like HTML where you insert specifiers to control word sections.
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #6 on: May 23, 2013, 03:40:49 pm »
Sorry, what do you mean by "follows the direction of the language"? In theory, when you press the right arrow key, the cursor should always move to the right, whatever the language. This is the proper (required) behaviour.
Sorry to be a bore, but you saying that when you press the right arrow key on Arabic text, it moves to left?

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #7 on: May 23, 2013, 03:44:09 pm »
Ok, I have just tried Notepad, as you suggested, and the cursor direction is inverted for Arabic, so that answers my question.

Do you know if this happens only on Windows, or is a feature of the class itself?
If so, where can I report this as a problem to be solved?


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #8 on: May 23, 2013, 03:44:32 pm »
Yes.  If you are on an Arabic word, the Right Arrow moves to the Left.  It seems strange, but once you start using it you will see that it makes more sense this way.
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #9 on: May 23, 2013, 03:47:56 pm »
Sorry to contradict you, but it does NOT make sense. When the user hits an arrow key, he expects to see the cursor move in the direction visually indicated.

The best GUI toolkits (Qt and Gtk) overcome this problem, so that for example a right arrow key always moves the cursor right, even in Arabic.
Now the question is how to make modifications to TMemo.
Where can I report this feature request?

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #10 on: May 23, 2013, 03:56:00 pm »
I see that we have different opinions on the "Best Normal" behavior, but that's OK.  As for feature request, you should use BugTracker (It's on the left side of this web page near the top).
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #11 on: May 23, 2013, 04:16:22 pm »
Should my feature request be filed in Bugtracker under the Lazarus or the FPC section?

(In theory, it concerns the class itself, so I am tempted to file it under FPC, but I just want to be sure.)

Thanks again

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #12 on: May 23, 2013, 04:23:57 pm »
Under Lazarus.  TMemo is LCL so it's a Lazarus issue, not FPC.  But there are other answers besides TMemo.  You might want to try some of them first.  Maybe HTML is what you are looking for.
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: BiDi support in the native widgetset?
« Reply #13 on: May 23, 2013, 05:22:09 pm »
Just to be clear: LCL cannot use Qt or Gtk2 as back-end, right? (If it could, my problem would be solved automatically).
« Last Edit: May 23, 2013, 05:24:58 pm by vicot »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: BiDi support in the native widgetset?
« Reply #14 on: May 23, 2013, 05:27:59 pm »
OK.  I've tried MSWord, WordPad, NotePad, TMemo, Delphi's RichText, Visual Studio RichText and a couple of others and they all behave in the same way.  The cursor follows the direction of the word sequence they are in.  I think anything else would seem strange to me and I live in a mixed language world where I deal with R2L and L2R routinely.  I think what you are looking for is non-standard behavior for Windows.

I have no idea if you can use Qt or Gtk2 with Lazarus.
Lazarus Trunk / fpc 2.6.2 / Win32