]> git.lyx.org Git - features.git/commitdiff
* cleaned up word dimension calculation of completion. There is still a bug with...
authorStefan Schimanski <sts@lyx.org>
Sat, 23 Feb 2008 03:15:05 +0000 (03:15 +0000)
committerStefan Schimanski <sts@lyx.org>
Sat, 23 Feb 2008 03:15:05 +0000 (03:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23151 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetText.cpp

index 5226edb6ae09eb6c60113fe3f4bb6f0edf4669cc..a67c72cefc0f964978d802bd06c49ad74ad6a44e 100644 (file)
@@ -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;
 }