[immodule-qt] Surrounding text

Anuradha Ratnaweera gnu.slash.linux at gmail.com
Mon Sep 20 07:38:57 EEST 2004


On Sat, 18 Sep 2004 00:01:59 +0900, Daisuke Kameda
<kaminmat at cc.rim.or.jp> wrote:
> On Friday 17 September 2004 21:38, Anuradha Ratnaweera wrote:
> 
> > After considering several options, I am thinking of doing it this way:
> > please comment.  (Please forgive my poor knowledge of OOP terminology.
> >
> > :-))
> >
> > - Implement getSurrounding() and deleteSurrounding() in QWidget which
> > does nothing (and returns null).
> >
> > - QLineEdit and QTextEdit overides imGetSurrounding() and
> > imDeleteSurrounding().
> 
> Do you mean "overides getSurrounding() and deleteSurrounding()"?

Oops.  Well, a getSurrounding and deleteSurrounding() in QWidget
doesn't mean that it's specific to text (it can also be interpreted as
getting surrounding *graphics*), so I changed the name
imGetSurrounding() and imDeleteSurrounding().  Sorry about the
inconsistency in the mail.

Or is there a better name?

> > - QInputContext implements getSurrounding() and deleteSurrounding().
> 
> How is each function implemented concretely?

Simply by calling imGetSurrounding() and imDeleteSurrounding() of
d->composingWidget.
 
> How does QInputContext acquire cursor position and text at getSurrounding()?
> Is getSurrounding() of QWidget (QLineEdit and QTextEdit) performed?

Yes.  QLineEdit can retrieve the text using text() and cursor with
cursorPosition(), so when QLineEdit overides imGetSurrounding() of
QWidget, if simply uses these two functions.

The interface of imDeleteSurrounding() is a little different from GTK.
 It takes two parameters, before and after, which are the number of
characters to be deleted before and after the cursor.  This can be
implemented easily using backspace() and del() functions of QLineEdit.

Implementing the two functions in QTextEdit is a little different. 
Instead of working with whole texts, we need to work with paragraphs. 
It doesn't have a backspace() function, so we have to cursor right,
delete combinations to implement backspace.  But again, the
implementation is quite neat, and no dirty tricks needed.

I have already tested QLineEdit.  The really bad news is that this
breaks binary compatibility (Right now, I am in the process of
recompiling all my qt dependent applications :-( ).

Will post the patch soon.

> Does QInputContext::deleteSurrounding() perform deleteSurrounding()
> of QWidget (QLineEdit and QTextEdit)?

Yes.  imDeleteSurrounding() of QWidget, rather.

> > At the same time, I am writing, rather porting from gtk-im, the
> > Sinhala (Transliterated) input method, so that I have something to
> > test along the way.
> >
> > http://cvs.linux.lk/cgi-bin/cvsweb/sinhala/qt/im/
> 
> It is good news. I will try later.

Don't do it just yet.  It's only the skeleton.  I will post the
complete IM ported from GTK and make a note here.

Thanks.

        Anuradha

-- 

http://www.linux.lk/~anuradha/
http://www.gnu.org/philosophy/no-word-attachments.html



More information about the immodule-qt mailing list