mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
less crude MathXArray::x2pos for preciser cursor positioning using the mouse
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2325 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c1bd906202
commit
c1364850c0
@ -9,6 +9,9 @@
|
||||
* formulabase.C: fix memory leak
|
||||
|
||||
* math_cursor.C: ^ now copies selection into new srriptinset
|
||||
|
||||
* xarray.C: less crude MathXArray::x2pos for preciser cursor positioning
|
||||
using the mouse
|
||||
|
||||
2001-07-22 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
|
@ -96,9 +96,16 @@ int MathXArray::pos2x(int targetpos) const
|
||||
|
||||
int MathXArray::x2pos(int targetx) const
|
||||
{
|
||||
int pos = 0;
|
||||
for (int x = 0; x < targetx && pos < data_.size(); data_.next(pos))
|
||||
x += width(pos);
|
||||
int pos = 0;
|
||||
int lastx = 0;
|
||||
int currx = 0;
|
||||
while (currx < targetx && pos < data_.size()) {
|
||||
lastx = currx;
|
||||
currx += width(pos);
|
||||
data_.next(pos);
|
||||
}
|
||||
if (abs(lastx - targetx) < abs(currx - targetx))
|
||||
data_.prev(pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user