Recent

Author Topic: Considerations on IME - Japanese in SynEdit (probably all other IME users too)  (Read 18634 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
This is a follow up on http://bugs.freepascal.org/view.php?id=27712

http://bugs.freepascal.org/view.php?id=27712#c82262
Quote
This issue is related to your Q"Do you think the default highlight should be dotted underline instead of dotted box?".

Right, I broke the rule myself. It is tricky do decide, if something should go into a bug report or not, and sometimes even it changes when a part of the issue grows bigger.

The problem is that the issue o mantis is about what should happen to selected text.

The code I committed refers to that issue, and sometimes years after I wrote some code I need to know why. Then I can use SVN to find related mantis issues, and read up on it.
In this case  I need to read up on the "overwriting" of selections.

As it stands now a huge parts of the notes (including many of mine) are not about this. This makes it much harder to keep track.

Also as a rule of thumb: Mantis is to describe the issue, and describe what solution was picked and why.
If there is a need to discuss many options, that is sometimes better moved to the forum.
But again that is a rule of thumb, it does not always apply, So there was nothing wrong with bringing up added topics.

------------------------------
Well I am obviously never using the IME in productions myself.So I can only act on feedback, and I am happy for any feedback I can get. Of course feedback must be divided in to (and all a valid, but have different importance)
- technical
- official (design) guidelines / usability
- personal taste

In that aspect (especially for issues that are either of the last category or not clear which category, it would be good if more people could comment.
------------------------------
********** IME and highlighting  **********

The point of the below in **NOT** to impose my taste (that is not worth anything, since I do not use IME at all). It is for me to categorize the comments I received according to the above outline, and ideally get feedback from more people.


http://bugs.freepascal.org/view.php?id=27712#c82255
Quote
Can the highlighter be turned off during input with IME? (See img7.png))
The highlighter bothers input with IME.
(According to image, referring to "Same word highlight" during IME activity (within IME)


http://bugs.freepascal.org/view.php?id=27712#c82262
Quote
The IME has his own drawing attribute. (See https://www.coscom.co.jp/learnjapanese801/lesson11.html [^] and https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide [^] ).
So you must not draw your selfish attribute in during input with IME.
Or you should turn on "IME handled by system" by default.

1) According to the first link, in Japanese words are not separated by spaces. So a "current word" highlight makes limited sense overall? (it acts a current phrase?). That leaves the question if it should be switched off altogether for any Japanese text?

Btw, in such case, if you use SynEdit for Japanese, you can disable the feature entirely. But maybe in mixed text, some detection is needed?

2) The 2nd link mentions that there are 2 styles. One for the entire IME string, one for the clause (active clause). That exists in SynEdit.
The link explicitly states that (in case of full IME integration) those styles are not coming from the IME but are applied by the app. (It gives details on how they can be configured)
Quote
Style of each clause
... Therefore, it can be overridden by prefs
It does not mention if or how that style is affected by other styles that may apply in combination.


My test with libre office (my reference for full IME) show, that the IME applies text color, background color, borders, over-lining, and strike-through to the active IME composition (those attributes are taken from the surrounding text).
Libre office does not apply underlining (as that would obliviously interfere with the underlining of the IME style. (In open office the borders (frame) are several pixels away from the IME underline.

I also think that in SynEdit it is correct to use the current font color (e.g. if string and comment are different color, depending on what you are editing.)


That leaves to consider what to do in SynEdit. For current word, it has first to be decided, if that should apply to Japanese at all.
But there also are other highlight, You can set up user-defined-markup http://wiki.lazarus.freepascal.org/New_IDE_features_since#Multiple_user_defined_word_highlight.2Fmarkup
to have some words or text parts to be highlighted. And there may be other highlights in future that would apply.

A)
If they change font color, or bold/italic then they do not interfere with the IME. I would in such cases expect that it is a matter of taste, if they should be applied to an active IME.
Even if they change background, it would still be a matter of taste.

B)
Of course if they add underline, (or maybe a border, or a backgorund color) - that is anything that obscures the IME dotted underline - then it becomes a usability case.


On (A) I would be keen to get opinions from more people who use an IME.

On (B) I would think it might be a good idea, if the active IME would suppress any frame and underline from other highlights.
(Adding background suppression can be later made an option, but would be simple to archive by changing the code on your own PC)

On example of the "current word" highlight that would mean, that the background color would still change, but the border would no longer be drawn into the IME.

------------------------------
********** IME and the drop down **********

I noted that the IME dropdown, is kind of glued right below the text.

Maybe between 1 and 3 extra pixel would improve the visibility of the underlines?

For testing:
components\synedit\lazsynimm.pas
line 518
In: procedure LazSynImeFull.WMImeRequest(var Msg: TMessage);
Code: [Select]
        cp^.cLineHeight := TCustomSynEdit(FriendEdit).LineHeight + 1;
The " + 1" does not currently exist. Also try " + 2" or " + 3"

------------------------------
Other comments?
« Last Edit: March 24, 2015, 06:27:40 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
On a more serious note: There seems to be an actual bug.

The full IME does not support the changing of "clauses" by using shift-cursor-right/left.
That obviously will need fixing.


The system IME also draws indicative underlines for *all* clauses (current selected clause and other clauses. But this is something that I do not see in libre office (nor Firefox) (the 2 full IME examples I know off). So I consider it an optional feature. (And SynEdit does not support any suitable underlining. That is underlining needs to start 1 or 2 pixel into the word, to be distinct from the previous/next underline). That is considerable more work, therefore not a quick to add feature. But a welcome feature request for the long term.


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
Martin, do you have access to Windows? malcome is using notepad (windows's IMM) for comparison.

There's mozilla link used as a reference.
I'm afraid that mozilla IME is used in mozilla based applications only (firefox, thunderbird) and cannot be used by SynEdit. But still the article is pretty good for understanding of how IMEs work.
« Last Edit: March 24, 2015, 06:32:47 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
on the note about colors of IME - they should match editor's selected colors. And styles (underlines) should follow system IME defaults
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
IME integration can be done at different levels.

Notepad is kind of minimum. App provides the coordinates on screen. Windows does all the rest. It works, but is not very nice, since it simply goes on top of existing text, and temporarily hides that.
In SynEdit, you get this if you choose "IME handled by system".

Libre Office and Firefox do a full integration. App draws the text as part of the entire document. SynEdit attempts that too. (Very few editors seem to do that)

Firefox docs help little, since it does not match Windows API. Good documentation on Windows API... well still looking for it. MSDN is of little help.

Sure underlines should match defaults. (As far as this is supported. SynEdit can not currently underline a half a char.

The question was how match of the extra highlight should be applied. (That is only of interest for full IME).
IMHO, since the text is immediately part of the document, all extras should be applied. Exception: If such highlight interferes with IME markup. E.g. underline is used by IME. not a good idea to apply other underlines.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Afaik  "IME handled by system" now works like notepad.

There was a bug about overwriting selection. Fixed, and also adapted the fix to be notepad like.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
IME is windows only sofar.
That is part of the reason, that there is little user conf. When I did this, I wanted to first see how it would be on other platforms. But then again, that might be to long to wait for.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
Libre Office and Firefox do a full integration. App draws the text as part of the entire document. SynEdit attempts that too. (Very few editors seem to do that)
what about Windows Wordpad?

The question was how match of the extra highlight should be applied. (That is only of interest for full IME).
IMHO, since the text is immediately part of the document, all extras should be applied. Exception: If such highlight interferes with IME markup. E.g. underline is used by IME. not a good idea to apply other underlines.
Maybe you shouldn't apply extra highlight while composition is in progress? In that case IME users can distinguish between when composition is happening and when it's not happening.

Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
what about Windows Wordpad?
Behaves like libre office. Except you cant test styles like frames. Wordpad does not offer frames as text format

Quote
Maybe you shouldn't apply extra highlight while composition is in progress? In that case IME users can distinguish between when composition is happening and when it's not happening.

Well that was the initial question.

And as I said. Underlines, should be suppressed for exactly that reason.
Font color does not affect this. Neither does bold or italic.

Background color, may in some cases. That one is hard to decide.

The problem is: SynEdit is modular. The IME does not (and can not) know, which other modules apply highlights, or if a highlight is because it is a string (in pascal), or something else. (Well on that last note, SynEdit could be extended, but then we talk about bigger development, not just a change to IME)

IME can simply say cancel ALL other backgrounds (actually all below priority X, and if X is high enough...). But that will also cancel, if you configured pascal strings to have a yellow background.

Also (besides the question, what is a word, see orig post), if I type new text (and I have the "same word highlight" active), then personally, I would want to see the highlight as I type.

The same applies for user-defined-words highlight. I have a list of "wrong text fragments", that get an immediate red warning. I assume I would want to see them in the IME too?

Any way. In cases where it does not interfere with the underlines of the IME, it is IMHO a personal choice.

@skalogryz Are you using an IME in daily work?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
Behaves like libre office. Except you cant test styles like frames. Wordpad does not offer frames as text format
Hmm. I've tested IME in richmemo - no surprises - it works, but looks a bit different than wordpad. (font size difference maybe?)

@skalogryz Are you using an IME in daily work?
Nope. Just had some experience working with IME in the past.
We (the company i worked for) ran in the exactly the same problem as Lazarus-team right now - lack of knowledgeable users and testers :)
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Hmm. I've tested IME in richmemo - no surprises - it works, but looks a bit different than wordpad. (font size difference maybe?)
If you start the IME in the middle of a line, then while you type does text to the right of the IME move? Or does the IME overlap that text?

Quote
Nope. Just had some experience working with IME in the past.
We (the company i worked for) ran in the exactly the same problem as Lazarus-team right now - lack of knowledgeable users and testers
I am happy for any feedback I can get. After all I am flying blind.

But before I go and develop something, I want to
1) ensure I understand it deep enough
2) Differentiate between personal taste (even if it might be very very common taste, I could not judge that anyway), or guideline/technical issue.

If I change something, because of taste, changes are that some one else will complain and want it back.

Also Understanding things helps me to find a reasonable solution I can add now, rather than a perfect one I can do at some time in the distant future.
« Last Edit: March 24, 2015, 08:43:08 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
On a more serious note: There seems to be an actual bug.

The full IME does not support the changing of "clauses" by using shift-cursor-right/left.
That obviously will need fixing.

Fixed in 1.5

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
If you start the IME in the middle of a line, then while you type does text to the right of the IME move? Or does the IME overlap that text?
It does move the text to the right. But that's no surprise, since even in Vista wordpad is doing the same. I'd think it has been doing that since adding support for IME to windows richedit control.

But before I go and develop something, I want to
1) ensure I understand it deep enough
2) Differentiate between personal taste (even if it might be very very common taste, I could not judge that anyway), or guideline/technical issue.

If I change something, because of taste, changes are that some one else will complain and want it back.

Also Understanding things helps me to find a reasonable solution I can add now, rather than a perfect one I can do at some time in the distant future.
The article on mozilla explains the logic behind "underlines" pretty well.
0) (not explained in the article), if a text has not underlines it's ready to read text (this text is subject to any additional underlines by SynEdit)
1) curved underline is user entry. (in the video, you can see that windows is using "dashed-underline" instead). So this is a raw input and might not match the final text
2) then the entered text is split into clause. Each defined clause is underlines by a single line. Currently editted clause is underlined by a thick line (or double-line). (kinda-briefed through this steeps in the video). BUT. in the (www.coscom.co.jp) it suggest that you need to press Shift-Left. in windows you instead need to press Shift-Right to switch between clauses.
3) once the adjustment of clauses is done - hit enter.
the whole section become non-underlined - that's an indication that entry is finished and text is in "ready-to-read" mode... and so on - back to 0)

I presume that CJK speakers/writers are rarely using clause adjustments.  And it's as hard for them as for us to to hold shift when putting Capital Letters.
« Last Edit: March 24, 2015, 09:30:19 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2268
    • havefunsoft.com
from SynEdit perspective. All you want to know is that's the state of the composition (what's the clauses are (if any defined), what raw input text is). Then you could "redraw" the right size according to the width of composting text .
Knowledge about clauses is needed to draw correct underlines.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Quote
0) (not explained in the article), if a text has not underlines it's ready to read text (this text is subject to any additional underlines by SynEdit)
1) curved underline is user entry. (in the video, you can see that windows is using "dashed-underline" instead). So this is a raw input and might not match the final text
2) then the entered text is split into clause. Each defined clause is underlines by a single line. Currently editted clause is underlined by a thick line (or double-line). (kinda-briefed through this steeps in the video). BUT. in the (www.coscom.co.jp) it suggest that you need to press Shift-Left. in windows you instead need to press Shift-Right to switch between clauses.
3) once the adjustment of clauses is done - hit enter.
the whole section become non-underlined - that's an indication that entry is finished and text is in "ready-to-read" mode... and so on - back to 0)

In Synedit:
1) dotted, easy to change to dashed. I've seen both styles.
2) Current SynEdit text drawer has no support to "interrupt" an underline. So it is currently not possible to underline each clause. (wordpad switches to a continuous, none dotted underline, so you can not see where clauses start/end either.)
The key press are handled by system, so they are the same everywhere: Shift-right/left resizes the clause. (shows a selection like style in most editors.