mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
* 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
This commit is contained in:
parent
919e9a80eb
commit
b7782d1973
@ -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_;
|
||||
Point rxy = cur.bv().getPos(bvcur, bvcur.boundary());
|
||||
|
||||
// Calculate dimensions of the word
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user