mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
move getColumnNearX next to iits only call site
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6412 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
901c092504
commit
52fd7be07f
@ -1,3 +1,9 @@
|
||||
2003-03-10 John Levon <levon@movementarian.org>
|
||||
|
||||
* text.C:
|
||||
* text2.C: move getColumnNearX() near its
|
||||
only call site
|
||||
|
||||
2003-03-10 John Levon <levon@movementarian.org>
|
||||
|
||||
* text.C: fix break before a minipage
|
||||
|
112
src/text.C
112
src/text.C
@ -2729,118 +2729,6 @@ void LyXText::backspace(BufferView * bview)
|
||||
}
|
||||
|
||||
|
||||
// returns the column near the specified x-coordinate of the row
|
||||
// x is set to the real beginning of this column
|
||||
pos_type
|
||||
LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
bool & boundary) const
|
||||
{
|
||||
float tmpx = 0.0;
|
||||
float fill_separator;
|
||||
float fill_hfill;
|
||||
float fill_label_hfill;
|
||||
|
||||
prepareToPrint(bview, row, tmpx, fill_separator,
|
||||
fill_hfill, fill_label_hfill);
|
||||
|
||||
pos_type vc = row->pos();
|
||||
pos_type last = row->lastPrintablePos();
|
||||
pos_type c = 0;
|
||||
|
||||
LyXLayout_ptr const & layout = row->par()->layout();
|
||||
|
||||
bool left_side = false;
|
||||
|
||||
pos_type body_pos = row->par()->beginningOfBody();
|
||||
float last_tmpx = tmpx;
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
!row->par()->isLineSeparator(body_pos - 1)))
|
||||
body_pos = 0;
|
||||
|
||||
// check for empty row
|
||||
if (!row->par()->size()) {
|
||||
x = int(tmpx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (vc <= last && tmpx <= x) {
|
||||
c = vis2log(vc);
|
||||
last_tmpx = tmpx;
|
||||
if (body_pos > 0 && c == body_pos-1) {
|
||||
tmpx += fill_label_hfill +
|
||||
font_metrics::width(layout->labelsep,
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(body_pos - 1))
|
||||
tmpx -= singleWidth(bview, row->par(), body_pos-1);
|
||||
}
|
||||
|
||||
if (row->hfillExpansion(c)) {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
if (c >= body_pos)
|
||||
tmpx += fill_hfill;
|
||||
else
|
||||
tmpx += fill_label_hfill;
|
||||
} else if (row->par()->isSeparator(c)) {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
if (c >= body_pos)
|
||||
tmpx+= fill_separator;
|
||||
} else {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
}
|
||||
++vc;
|
||||
}
|
||||
|
||||
if ((tmpx + last_tmpx) / 2 > x) {
|
||||
tmpx = last_tmpx;
|
||||
left_side = true;
|
||||
}
|
||||
|
||||
if (vc > last + 1) // This shouldn't happen.
|
||||
vc = last + 1;
|
||||
|
||||
boundary = false;
|
||||
bool const lastrow = lyxrc.rtl_support // This is not needed, but gives
|
||||
// some speedup if rtl_support=false
|
||||
&& (!row->next() || row->next()->par() != row->par());
|
||||
bool const rtl = (lastrow)
|
||||
? row->par()->isRightToLeftPar(bview->buffer()->params)
|
||||
: false; // If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
|
||||
if (lastrow &&
|
||||
((rtl && left_side && vc == row->pos() && x < tmpx - 5) ||
|
||||
(!rtl && !left_side && vc == last + 1 && x > tmpx + 5)))
|
||||
c = last + 1;
|
||||
else if (vc == row->pos()) {
|
||||
c = vis2log(vc);
|
||||
if (bidi_level(c) % 2 == 1)
|
||||
++c;
|
||||
} else {
|
||||
c = vis2log(vc - 1);
|
||||
bool const rtl = (bidi_level(c) % 2 == 1);
|
||||
if (left_side == rtl) {
|
||||
++c;
|
||||
boundary = isBoundary(bview->buffer(), row->par(), c);
|
||||
}
|
||||
}
|
||||
|
||||
if (row->pos() <= last && c > last
|
||||
&& row->par()->isNewline(last)) {
|
||||
if (bidi_level(last) % 2 == 0)
|
||||
tmpx -= singleWidth(bview, row->par(), last);
|
||||
else
|
||||
tmpx += singleWidth(bview, row->par(), last);
|
||||
c = last;
|
||||
}
|
||||
|
||||
c -= row->pos();
|
||||
x = int(tmpx);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
// returns pointer to a specified row
|
||||
Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
|
||||
{
|
||||
|
112
src/text2.C
112
src/text2.C
@ -1943,6 +1943,118 @@ void LyXText::setCurrentFont(BufferView * bview) const
|
||||
}
|
||||
|
||||
|
||||
// returns the column near the specified x-coordinate of the row
|
||||
// x is set to the real beginning of this column
|
||||
pos_type
|
||||
LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
bool & boundary) const
|
||||
{
|
||||
float tmpx = 0.0;
|
||||
float fill_separator;
|
||||
float fill_hfill;
|
||||
float fill_label_hfill;
|
||||
|
||||
prepareToPrint(bview, row, tmpx, fill_separator,
|
||||
fill_hfill, fill_label_hfill);
|
||||
|
||||
pos_type vc = row->pos();
|
||||
pos_type last = row->lastPrintablePos();
|
||||
pos_type c = 0;
|
||||
|
||||
LyXLayout_ptr const & layout = row->par()->layout();
|
||||
|
||||
bool left_side = false;
|
||||
|
||||
pos_type body_pos = row->par()->beginningOfBody();
|
||||
float last_tmpx = tmpx;
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
!row->par()->isLineSeparator(body_pos - 1)))
|
||||
body_pos = 0;
|
||||
|
||||
// check for empty row
|
||||
if (!row->par()->size()) {
|
||||
x = int(tmpx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (vc <= last && tmpx <= x) {
|
||||
c = vis2log(vc);
|
||||
last_tmpx = tmpx;
|
||||
if (body_pos > 0 && c == body_pos-1) {
|
||||
tmpx += fill_label_hfill +
|
||||
font_metrics::width(layout->labelsep,
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(body_pos - 1))
|
||||
tmpx -= singleWidth(bview, row->par(), body_pos-1);
|
||||
}
|
||||
|
||||
if (row->hfillExpansion(c)) {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
if (c >= body_pos)
|
||||
tmpx += fill_hfill;
|
||||
else
|
||||
tmpx += fill_label_hfill;
|
||||
} else if (row->par()->isSeparator(c)) {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
if (c >= body_pos)
|
||||
tmpx+= fill_separator;
|
||||
} else {
|
||||
tmpx += singleWidth(bview, row->par(), c);
|
||||
}
|
||||
++vc;
|
||||
}
|
||||
|
||||
if ((tmpx + last_tmpx) / 2 > x) {
|
||||
tmpx = last_tmpx;
|
||||
left_side = true;
|
||||
}
|
||||
|
||||
if (vc > last + 1) // This shouldn't happen.
|
||||
vc = last + 1;
|
||||
|
||||
boundary = false;
|
||||
bool const lastrow = lyxrc.rtl_support // This is not needed, but gives
|
||||
// some speedup if rtl_support=false
|
||||
&& (!row->next() || row->next()->par() != row->par());
|
||||
bool const rtl = (lastrow)
|
||||
? row->par()->isRightToLeftPar(bview->buffer()->params)
|
||||
: false; // If lastrow is false, we don't need to compute
|
||||
// the value of rtl.
|
||||
|
||||
if (lastrow &&
|
||||
((rtl && left_side && vc == row->pos() && x < tmpx - 5) ||
|
||||
(!rtl && !left_side && vc == last + 1 && x > tmpx + 5)))
|
||||
c = last + 1;
|
||||
else if (vc == row->pos()) {
|
||||
c = vis2log(vc);
|
||||
if (bidi_level(c) % 2 == 1)
|
||||
++c;
|
||||
} else {
|
||||
c = vis2log(vc - 1);
|
||||
bool const rtl = (bidi_level(c) % 2 == 1);
|
||||
if (left_side == rtl) {
|
||||
++c;
|
||||
boundary = isBoundary(bview->buffer(), row->par(), c);
|
||||
}
|
||||
}
|
||||
|
||||
if (row->pos() <= last && c > last
|
||||
&& row->par()->isNewline(last)) {
|
||||
if (bidi_level(last) % 2 == 0)
|
||||
tmpx -= singleWidth(bview, row->par(), last);
|
||||
else
|
||||
tmpx += singleWidth(bview, row->par(), last);
|
||||
c = last;
|
||||
}
|
||||
|
||||
c -= row->pos();
|
||||
x = int(tmpx);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::setCursorFromCoordinates(BufferView * bview, int x, int y) const
|
||||
{
|
||||
LyXCursor old_cursor = cursor;
|
||||
|
Loading…
Reference in New Issue
Block a user