[PATCH wayland-protocols] text: Create second version of text input protocol
Jan Arne Petersen
janarne at gmail.com
Tue Feb 2 13:02:12 UTC 2016
On 29/01/16 21:43, Bill Spitzak wrote:
>
>
> On Wed, Jan 27, 2016 at 11:52 PM, Jan Arne Petersen <janarne at gmail.com
> <mailto:janarne at gmail.com>> wrote:
>
>
> + <event name="preedit_string">
> + <description summary="pre-edit">
> + Notify when a new composing text (pre-edit) should be set
> around the
> + current cursor position. Any previously set composing text
> should
> + be removed.
> +
> + The commit text can be used to replace the preedit text on reset
> + (for example on unfocus).
> +
> + The text input should also handle all preedit_style and
> preedit_cursor
> + events occurring directly before preedit_string.
> + </description>
> + <arg name="serial" type="uint" summary="serial of the latest
> known text input state"/>
> + <arg name="text" type="string"/>
> + <arg name="commit" type="string"/>
> + </event>
> + <enum name="preedit_style">
> + <entry name="default" value="0" summary="default style for
> composing text"/>
> + <entry name="none" value="1" summary="style should be the
> same as in non-composing text"/>
> + <entry name="active" value="2"/>
> + <entry name="inactive" value="3"/>
> + <entry name="highlight" value="4"/>
> + <entry name="underline" value="5"/>
> + <entry name="selection" value="6"/>
> + <entry name="incorrect" value="7"/>
> + </enum>
> + <event name="preedit_styling">
> + <description summary="pre-edit styling">
> + Sets styling information on composing text. The style is
> applied for
> + length bytes from index relative to the beginning of the
> composing
> + text (as byte offset). Multiple styles can
> + be applied to a composing text by sending multiple
> preedit_styling
> + events.
> +
> + This event is handled as part of a following preedit_string
> event.
> + </description>
> + <arg name="index" type="uint"/>
> + <arg name="length" type="uint"/>
> + <arg name="style" type="uint" enum="preedit_style"/>
> + </event>
> + <event name="preedit_cursor">
> + <description summary="pre-edit cursor">
> + Sets the cursor position inside the composing text (as byte
> + offset) relative to the start of the composing text. When
> index is a
> + negative number no cursor is shown.
> +
> + This event is handled as part of a following preedit_string
> event.
> + </description>
> + <arg name="index" type="int"/>
> + </event>
> + <event name="commit_string">
> + <description summary="commit">
> + Notify when text should be inserted into the editor widget.
> The text to
> + commit could be either just a single character after a key
> press or the
> + result of some composing (pre-edit). It could be also an
> empty text
> + when some text should be removed (see
> delete_surrounding_text) or when
> + the input cursor should be moved (see cursor_position).
> +
> + Any previously set composing text should be removed.
> + </description>
> + <arg name="serial" type="uint" summary="serial of the latest
> known text input state"/>
> + <arg name="text" type="string"/>
> + </event>
> + <event name="cursor_position">
> + <description summary="set cursor to new position">
> + Notify when the cursor or anchor position should be modified.
> +
> + This event should be handled as part of a following
> commit_string
> + event.
> + </description>
> + <arg name="index" type="int"/>
> + <arg name="anchor" type="int"/>
> + </event>
> + <event name="delete_surrounding_text">
> + <description summary="delete surrounding text">
> + Notify when the text around the current cursor position
> should be
> + deleted.
> +
> + Index is relative to the current cursor (in bytes).
> + Length is the length of deleted text (in bytes).
> +
> + This event should be handled as part of a following
> commit_string
> + event.
> + </description>
> + <arg name="index" type="int"/>
> + <arg name="length" type="uint"/>
> + </event>
>
>
> I feel there are a lot of reasons to combine the preview and commit
> strings. An actual commit would be done by setting the preview and then
> sending a commit event.
>
> - The preview has to be able to delete surrounding text, so that it can
> preview a merge between typed text and surrounding characters.
>
> - Conversely, to match how most text input works in software now, you
> need to preserve the "incorrect" indicator in the committed text. This
> is so the word remains marked as incorrect. There also has to be a way
> for the client to return to that text and tell the input method to
> continue, so the spelling correction code in the input method can be
> reused (not just to make the client's work easier, but for the far more
> important reason of making the ui consistent!).
>
> These remove the differences between commit and preview, so it makes
> sense to merge them.
>
> Besides allowing the user to return to a misspelled word, it may make
> sense to return to a preedit. I'm not sure as I have no experience with
> Asian input methods. But it does seem possible.
Sorry no toolkit supports that. While the current proposed protocol can
be implemented with current Qt, Gtk+ and EFL. Androids input method API
is also quite similar to what is proposed here.
> So some possible modifications:
>
> - Make delete surrounding text part of preview. Client has to remember
> the deleted text so it can restore it for the next preview (which may
> delete less).
Delete surrounding text also works for pre-edit, i fixed the documentation.
> - Change commit_string to just a commit event that says the previous
> preview string is the final result. This allows the commit to include
> highlighting.
>
> - Possibly allow the highlight regions to be larger than the preview
> text. This could allow a spelling corrector to mark existing text as
> part of the incorrect word. The alternative is that the spelling
> corrector would have to delete the word, and insert it again with the
> incorrect highlighting.
>
> - Add a request to return to composing without a keystroke. The cursor
> must be inside a previous commit or preview string. The idea is that the
> user can later click on the misspelled words and somehow get the
> spelling corrector to reappear. Also maybe it would allow returning to
> other partially-composed strings.
See above.
Thanks,
Jan Arne
--
Jan Arne Petersen | jan.petersen at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
More information about the wayland-devel
mailing list