]> git.lyx.org Git - lyx.git/commitdiff
move getColumnNearX next to iits only call site
authorJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 05:03:33 +0000 (05:03 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 05:03:33 +0000 (05:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6412 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C
src/text2.C

index 670b89adfc880c4a70075c97948b9f30388045f5..4815a810a88672ca82f84b68cfa3a17e1c8e682e 100644 (file)
@@ -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
index e23daf91d289e4812c60f03e378e30ccf9cf2277..f0e98d86fa4b4e4db234c2e3c61c7f8309793461 100644 (file)
@@ -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
 {
index e76491563d8c88680c20763f54bfe969e7e5c5e3..8e36ef99a313b122c3e08697e4eacaa737c0878f 100644 (file)
@@ -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;