]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Implement os::current_root for native Win32 builds.
[lyx.git] / src / text2.C
index 2f90fd73b1a4db07bf11eaef1795a8746fb05638..44e897db0fae661c17a8c4ec35b665381cc095fd 100644 (file)
@@ -74,7 +74,8 @@ using std::string;
 LyXText::LyXText(BufferView * bv)
        : maxwidth_(bv ? bv->workWidth() : 100),
          background_color_(LColor::background),
-         bv_owner(bv)
+         bv_owner(bv),
+         autoBreakRows_(false)
 {}
 
 
@@ -335,7 +336,7 @@ void LyXText::setLayout(LCursor & cur, string const & layout)
 
        pit_type start = cur.selBegin().pit();
        pit_type end = cur.selEnd().pit() + 1;
-       pit_type endpit = setLayout(start, end, layout);
+       setLayout(start, end, layout);
        updateCounters();
 }
 
@@ -343,18 +344,6 @@ void LyXText::setLayout(LCursor & cur, string const & layout)
 namespace {
 
 
-void getSelectionSpan(LCursor & cur, pit_type & beg, pit_type & end)
-{
-       if (!cur.selection()) {
-               beg = cur.pit();
-               end = cur.pit() + 1;
-       } else {
-               beg = cur.selBegin().pit();
-               end = cur.selEnd().pit() + 1;
-       }
-}
-
-
 bool changeDepthAllowed(LyXText::DEPTH_CHANGE type,
        Paragraph const & par, int max_depth)
 {
@@ -375,11 +364,9 @@ bool changeDepthAllowed(LyXText::DEPTH_CHANGE type,
 bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const
 {
        BOOST_ASSERT(this == cur.text());
-       pit_type beg, end;
-       getSelectionSpan(cur, beg, end);
-       int max_depth = 0;
-       if (beg != 0)
-               max_depth = pars_[beg - 1].getMaxDepthAfter();
+       pit_type const beg = cur.selBegin().pit();
+       pit_type const end = cur.selEnd().pit() + 1;
+       int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
 
        for (pit_type pit = beg; pit != end; ++pit) {
                if (::changeDepthAllowed(type, pars_[pit], max_depth))
@@ -393,13 +380,10 @@ bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const
 void LyXText::changeDepth(LCursor & cur, DEPTH_CHANGE type)
 {
        BOOST_ASSERT(this == cur.text());
-       pit_type beg, end;
-       getSelectionSpan(cur, beg, end);
+       pit_type const beg = cur.selBegin().pit();
+       pit_type const end = cur.selEnd().pit() + 1;
        recordUndoSelection(cur);
-
-       int max_depth = 0;
-       if (beg != 0)
-               max_depth = pars_[beg - 1].getMaxDepthAfter();
+       int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
 
        for (pit_type pit = beg; pit != end; ++pit) {
                Paragraph & par = pars_[pit];
@@ -910,7 +894,8 @@ void LyXText::insertStringAsLines(LCursor & cur, string const & str)
 
        // only to be sure, should not be neccessary
        cur.clearSelection();
-       cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str);
+       cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str,
+               autoBreakRows_);
 
        cur.resetAnchor();
        setCursor(cur, cur.pit(), pos);
@@ -1438,8 +1423,6 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old)
 
        if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
                // ok, we will delete something
-               CursorSlice tmpcursor;
-
                deleted = true;
 
                bool selection_position_was_oldcursor_position =