After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 119891 - GtkEntry and GtkTextView need support for PangoLogAttr.backspace_deletes_character
GtkEntry and GtkTextView need support for PangoLogAttr.backspace_deletes_char...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: High normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 124514 (view as bug list)
Depends on: 107561 114483 141993
Blocks:
 
 
Reported: 2003-08-14 16:28 UTC by Noah Levitt
Modified: 2011-02-04 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Not to delete Marks with their base for arabic language (1.09 KB, patch)
2004-01-21 13:20 UTC, Soheil Hassas Yeganeh
none Details | Review
A quick-hack patch (GtkEntry only) (4.25 KB, patch)
2004-05-01 16:24 UTC, Theppitak Karoonboonyanan
none Details | Review
GtkEntry patch (using new signal + normalization) (4.97 KB, patch)
2004-05-03 09:58 UTC, Theppitak Karoonboonyanan
none Details | Review
Similar patch for GtkTextView (5.56 KB, patch)
2004-05-03 13:39 UTC, Theppitak Karoonboonyanan
none Details | Review

Description Noah Levitt 2003-08-14 16:28:55 UTC
GtkEntry and GtkTextView need support for
PangoLogAttr.backspace_deletes_character (bug #114483)
Comment 1 Owen Taylor 2003-10-13 21:13:22 UTC
*** Bug 124514 has been marked as a duplicate of this bug. ***
Comment 2 Soheil Hassas Yeganeh 2004-01-21 13:20:25 UTC
Created attachment 23597 [details] [review]
Not to delete Marks with their base for arabic language
Comment 3 Owen Taylor 2004-01-21 15:36:00 UTC
The correct fix is described in the Summmary.
Comment 4 Owen Taylor 2004-03-01 21:48:04 UTC
Requires a semi-API addition of another binding signal; 
but since it's pretty important, I may try to streamline
this into GTK+-2.4.1 or GTK+-2.4.2.
Comment 5 Theppitak Karoonboonyanan 2004-05-01 16:24:18 UTC
Created attachment 27270 [details] [review]
A quick-hack patch (GtkEntry only)

Should the fix be something like this?

However, one question just arises regarding the logic of pango_default_break()
which keeps the backspace_deletes_character flag *only* at cursor positions. To
handle backspace events, should the actual attribute value (whether to delete
the whole cluster or just the last character) be peeked from *previous* cursor
position instead of the current one as done in the patch? If so, wouldn't it be
more efficient to store the flag in *every* character, including combining
marks?
Comment 6 Owen Taylor 2004-05-01 20:50:39 UTC
I don't quite understand the question. As I understand how the Pango attribute
is set, it applies to a delete key *at* the cursor position; that is, to the
grapheme that precedes the cursor position.

Two other comments:

What I did in a now lost patch for GtkEntry and GtkTextView was to add a
separate binding signal for "backspace" rather than extending the delete
enumeration.

It's also necessary to actually convert the preceding grapheme to NFD before
deleting one character off of it; the deletion behavior should not depend on the
normalization form of the text.
Comment 7 Theppitak Karoonboonyanan 2004-05-02 05:37:19 UTC
OK. Let me elaborate the question:
Assuming B = base character, M = combining mark, L = Latin character (for which
backspace_deletes_character = false), | = cursor:

BBMBMM|L (text buffer)
110100 1 (is_cursor_position)
110100 0 (backspace_deletes_char)

When Backspace is pressed, the last M before the cursor should be deleted,
according to backspace_deletes_char of B in the previous cluster, rather than
that of L at the cursor position.

Another case (which is quite usual) is:

BBMBMM| (text buffer)
110100  (is_cursor_position)
110100  (backspace_deletes_char)

where the cursor is at the end of text buffer.

This makes me think it might have been more efficient had the
backspace_deletes_character been stored this way:

BBMBMM|L (text buffer)
110100 1 (is_cursor_position)
111111 0 (backspace_deletes_char)

so that the appropriate action can be immediately determined without moving back
to previous cursor position.

However, as you said that the cluster before the cursor needs to be analyzed to
determine the last character to delete anyway, the idea of storing flags for
every characters including combining marks may make no difference.
Comment 8 Theppitak Karoonboonyanan 2004-05-03 09:58:50 UTC
Created attachment 27323 [details] [review]
GtkEntry patch (using new signal + normalization)
Comment 9 Theppitak Karoonboonyanan 2004-05-03 13:39:41 UTC
Created attachment 27330 [details] [review]
Similar patch for GtkTextView
Comment 10 Theppitak Karoonboonyanan 2004-05-04 23:31:48 UTC
However, I doubt if it's appropriate to try to resolve the normalization thing
for backspace. I think what most users expect is that backspace undo the
previously typed character. Deleting something else may be beyond expectation.
Comment 11 Behdad Esfahbod 2004-05-04 23:45:03 UTC
IIRC backspace is supposed to delete marks for Arabic marks only, or similar
cases, which may happen to have no pre-composed equivalents.  At least that's
the case for Arabic.
Comment 12 Theppitak Karoonboonyanan 2004-05-05 10:22:05 UTC
Same for Thai. And my two patches above just perform what Thai users expect:
backspace deletes the mark only. (I've just found, however, that the GtkTextView
patch causes problem with GtkSourceView undo buffer.)

My question in #10 may be made more specific case by case:

1. In non-normalized string with non-canonical order of combining marks, what
should backspace delete: the last typed or the last logical character?

For example: if 'Bmn' is the NFD, but what appears before the cursor is 'Bnm'
(which just reflects the recent typing order), what is user's expectation when
pressing backspace, deleting 'n' or 'm'? (With normalization concern, 'n' is
removed, but my opinion is that 'm' should be expected to be removed to undo the
last keystroke.)

2. Where the grapheme before the cursor was converted into precomposed form by
the input method, what is expected when pressing backspace: delete the whole
precomposed character or decompose it before deleting the last logical component?

(With normalization concern, the latter is assumed. But I'm not sure if it's
expected, since there is no such case in my script/language.)
Comment 13 Theppitak Karoonboonyanan 2004-06-04 07:00:14 UTC
I must add to my previous opinion whether normalization should be concerned that
in case of Thai, this makes no difference, since most Thai IM's are implemented
such that text inputs are guaranteed to be always normalized. So, either case is
OK for Thai.
Comment 14 Elijah Newren 2004-06-19 18:42:15 UTC
Mass changing gtk+ bugs with target milestone of 2.4.2 to target 2.4.4, as
Matthias said he was trying to do himself on IRC and was asking for help with. 
If you see this message, it means I was successful at fixing the borken-ness in
bugzilla :)  Sorry for the spam; just query on this message and delete all
emails you get with this message, since there will probably be a lot.
Comment 15 Theppitak Karoonboonyanan 2004-07-13 13:13:14 UTC
Note that GtkTextView patch in Attachment #27330 [details] requires Bug #141993 to be fixed.
Comment 16 Matthias Clasen 2004-08-02 05:37:14 UTC
I've committed the patches to cvs HEAD now.
Comment 17 Behdad Esfahbod 2004-08-03 09:37:23 UTC
Works great, but the undo manager needs some work.  This is what I get when I
remove a mark in gedit:

(gedit:1327): GtkSourceView-CRITICAL **: file gtksourceundomanager.c: line 617
(gtk_source_undo_manager_insert_text_handler): assertion `strlen (text) ==
(guint)length' failed

And if I undo, I get both the mark *and a copy of it's base character* inserted,
resulting in two base characters, which is wrong.

For example, say I have this:

بهِداد

and I remove the Kasre mark, I get:

بهداد

and Undo and get:

بهِهداد

Should be easy to fix though.
Comment 18 Behdad Esfahbod 2004-08-03 09:52:48 UTC
Sorry, it's in gtksourceview.  Filed as bug 149128.
Comment 19 Theppitak Karoonboonyanan 2004-08-03 16:00:46 UTC
The same bug for GtkSourceView was already filed as Bug #141993, as said in
Comment #15.
Comment 20 Behdad Esfahbod 2005-03-15 04:25:46 UTC
> ------- Additional Comment #10 From Theppitak Karoonboonyanan 2004-05-04 19:31 
> 
> However, I doubt if it's appropriate to try to resolve the normalization thing
> for backspace. I think what most users expect is that backspace undo the
> previously typed character. Deleting something else may be beyond expectation.

Actually this issue has just showed itself to me for Arabic:  I type 
U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE, which is indeed one letter in
Persian/Arabic, but then press the backspace, get the U+0653 ARABIC MADDAH ABOVE
removed, remains a U+0627 ARABIC LETTER ALEF.  So, thinking again, I think it's
quite important to try to keep what user typed in.  Any idea?  Open a new bug?