From: Stefan Schimanski Date: Sat, 23 Feb 2008 03:15:05 +0000 (+0000) Subject: * cleaned up word dimension calculation of completion. There is still a bug with... X-Git-Tag: 1.6.10~6144 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b7782d19739a8366a5c48006150fdb64ae9d4a3a;p=features.git * cleaned up word dimension calculation of completion. There is still a bug with RTL which moves the popup to left when completing. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23151 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 5226edb6ae..a67c72cefc 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -552,22 +552,28 @@ bool InsetText::insertCompletion(Cursor & cur, docstring const & s, void InsetText::completionPosAndDim(Cursor const & cur, int & x, int & y, Dimension & dim) const { + Cursor const & bvcur = cur.bv().cursor(); + // get word in front of cursor - docstring word = previousWord(cur.buffer(), cur.top()); - DocIterator wordStart = cur; + docstring word = previousWord(cur.buffer(), bvcur.top()); + DocIterator wordStart = bvcur; wordStart.pos() -= word.length(); - // get position on screen of the word start + // get position on screen of the word start and end Point lxy = cur.bv().getPos(wordStart, false); - x = lxy.x_; - y = lxy.y_; - - // Calculate dimensions of the word + Point rxy = cur.bv().getPos(bvcur, bvcur.boundary()); + + // calculate dimensions of the word TextMetrics const & tm = cur.bv().textMetrics(&text_); - dim = tm.rowHeight(cur.pit(), wordStart.pos(), cur.pos(), false); - Point rxy = cur.bv().getPos(cur, cur.boundary()); - dim.wid = abs(rxy.x_ - x); - x = (rxy.x_ < x) ? x - dim.wid : x; // for RTL + dim = tm.rowHeight(bvcur.pit(), wordStart.pos(), bvcur.pos(), false); + dim.wid = abs(rxy.x_ - lxy.x_); + + // calculate position of word + y = lxy.y_; + x = min(rxy.x_, lxy.x_); + + //lyxerr << "wid=" << dim.width() << " x=" << x << " y=" << y << " lxy.x_=" << lxy.x_ << " rxy.x_=" << rxy.x_ << " word=" << word << std::endl; + //lyxerr << " wordstart=" << wordStart << " bvcur=" << bvcur << " cur=" << cur << std::endl; }