Re: error in pangoLayout->index_to_pos() ?



Thanks a lot for giving me an answer so fast.
I changed my Glib::ustring::insert method to 
text.insert(position++, 1, gdk_keyval_to_unicode(event->keyval));
and called the PangoLayout::index_to_pos() with the byte-position,
instead of the character position. So far it works.
Unfortunately Glib::ustring doesnt support methods to convert
a byte-to-character and character-to-byte position. :-(

I would like to integrate input methods, but dont have any idea.
Isnt there a small example for that ?

thanks !!

-------- Original-Nachricht --------
Datum: Wed, 28 Feb 2007 20:18:33 +0100
Von: "David Nečas (Yeti)" <yeti physics muni cz>
An: gtk-list gnome org
CC: 
Betreff: Re: error in pangoLayout->index_to_pos() ?

> On Wed, Feb 28, 2007 at 07:53:40PM +0100, thom_schu gmx de wrote:
> > Im trying to implement something like a TextEntry.
> > So I need to compute the current position of the cursor.
> > For this Im using PangoLayout::index_to_pos().
> > Everything works fine, as long as the string doesnt have
> > any special characters. (like ö, ä, ü, ?).
> > It seems like it doesnt work with characters which have a keyval
> > higher than 177.
> > 
> > Im building the string in the on_key_press_event with 
> > text.insert(position, 1, event->keyval).
> 
> event->keyval is an *integer key code* (generally unrelated
> to character codes in any common encoding).
> You can only make Pango layouts from UTF-8 encoded *strings*.
> So this does not make sense.
> 
> In addition inserting something as you get key events does
> not work with input methods.  That is it may be impossible
> to enter international text.
> 
> > I also tried to use the function move_cursor_visually, but also this
> > doesnt work. For instance when I enter the letter "ä" many times,
> > Im getting the positions : 0, 2, 2, 6, 2, 8, 2, 10, 2, 12, 2 ........
> > but expected 0,1,2,3,4,5,6.....
> 
> If these position are byte positions, then it works exactly
> as expected (ä is two bytes in UTF-8).
> 
> Yeti
> 
> 
> --
> Whatever.
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list

-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]