commit bc184526459a8095d46021474566dd7564d98133
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Sun Feb 28 17:36:29 2016 +0100

    Rename Cursor::setSelection(bool) to selection(bool)
    
    The old name would be confusing wrt setSelection(), which does additional 
checks.
    This one is a pure acessor, and the more complete methods are
    * setSelection(), which avoids empty selections
    * clearSelection(), which resets anchor, and sets word selection and mark 
more to false.
    
    Most of the code should use these two instead of selection(bool), but this 
is for later.

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 883987e..1daee5c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1587,7 +1587,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                break;
 
        case LFUN_MARK_TOGGLE:
-               cur.setSelection(false);
+               cur.selection(false);
                if (cur.mark()) {
                        cur.setMark(false);
                        dr.setMessage(from_utf8(N_("Mark removed")));
@@ -1786,7 +1786,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        // Select the inset from outside.
                        cur.pop();
                        cur.resetAnchor();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        cur.posForward();
                } else if (cells_selected) {
                        // At least one complete cell is selected and inset is 
a table.
@@ -1794,7 +1794,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        cur.idx() = 0;
                        cur.pos() = 0;
                        cur.resetAnchor();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        cur.idx() = cur.lastidx();
                        cur.pos() = cur.lastpos();
                } else {
@@ -1802,7 +1802,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        cur.pit() = 0;
                        cur.pos() = 0;
                        cur.resetAnchor();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        cur.pit() = cur.lastpit();
                        cur.pos() = cur.lastpos();
                }
@@ -2187,7 +2187,7 @@ void BufferView::mouseEventDispatch(FuncRequest const & 
cmd0)
        Cursor old = cursor();
        Cursor cur(*this);
        cur.push(buffer_.inset());
-       cur.setSelection(d->cursor_.selection());
+       cur.selection(d->cursor_.selection());
 
        // Either the inset under the cursor or the
        // surrounding Text will handle this event.
@@ -2374,7 +2374,7 @@ void BufferView::setCursorFromRow(int row, TexRow const & 
texrow)
        }
        d->cursor_.reset();
        buffer_.text().setCursor(d->cursor_, newpit, newpos);
-       d->cursor_.setSelection(false);
+       d->cursor_.selection(false);
        d->cursor_.resetAnchor();
        recenter();
 }
@@ -2460,7 +2460,7 @@ void BufferView::setCursor(DocIterator const & dit)
                dit[i].inset().edit(d->cursor_, true);
 
        d->cursor_.setCursor(dit);
-       d->cursor_.setSelection(false);
+       d->cursor_.selection(false);
        d->cursor_.setCurrentFont();
        // FIXME
        // It seems on general grounds as if this is probably needed, but
@@ -2589,7 +2589,7 @@ bool BufferView::selectIfEmpty(DocIterator & cur)
        d->cursor_.setCursor(cur);
        d->cursor_.pit() = beg_pit;
        d->cursor_.pos() = 0;
-       d->cursor_.setSelection(false);
+       d->cursor_.selection(false);
        d->cursor_.resetAnchor();
        d->cursor_.pit() = end_pit;
        d->cursor_.pos() = end_pos;
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index b4ca8e0..baf529b 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -997,18 +997,18 @@ DocIterator Cursor::selectionEnd() const
 
 void Cursor::setSelection()
 {
-       setSelection(true);
+       selection(true);
        if (idx() == normalAnchor().idx() &&
            pit() == normalAnchor().pit() &&
            pos() == normalAnchor().pos())
-               setSelection(false);
+               selection(false);
 }
 
 
 void Cursor::setSelection(DocIterator const & where, int n)
 {
        setCursor(where);
-       setSelection(true);
+       selection(true);
        anchor_ = where;
        pos() += n;
 }
@@ -1016,7 +1016,7 @@ void Cursor::setSelection(DocIterator const & where, int 
n)
 
 void Cursor::clearSelection()
 {
-       setSelection(false);
+       selection(false);
        setWordSelection(false);
        setMark(false);
        resetAnchor();
@@ -1079,7 +1079,7 @@ bool Cursor::selHandle(bool sel)
                cap::saveSelection(*this);
 
        resetAnchor();
-       setSelection(sel);
+       selection(sel);
        return true;
 }
 } // namespace lyx
@@ -1319,7 +1319,7 @@ bool Cursor::backspace()
                // let's require two backspaces for 'big stuff' and
                // highlight on the first
                resetAnchor();
-               setSelection(true);
+               selection(true);
                --pos();
        } else {
                --pos();
@@ -1366,7 +1366,7 @@ bool Cursor::erase()
        // 'clever' UI hack: only erase large items if previously slected
        if (pos() != lastpos() && nextAtom()->nargs() > 0) {
                resetAnchor();
-               setSelection(true);
+               selection(true);
                ++pos();
        } else {
                plainErase();
diff --git a/src/Cursor.h b/src/Cursor.h
index acec127..aa31f91 100644
--- a/src/Cursor.h
+++ b/src/Cursor.h
@@ -161,8 +161,8 @@ public:
        //
        /// selection active?
        bool selection() const { return selection_; }
-       /// set selection;
-       void setSelection(bool sel) { selection_ = sel; }
+       /// set selection; this is lower level than (set|clear)Selection
+       void selection(bool sel) { selection_ = sel; }
        /// do we have a multicell selection?
        bool selIsMultiCell() const 
                { return selection_ && selBegin().idx() != selEnd().idx(); }
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 5f3e809..86f6690 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -1325,7 +1325,7 @@ void selClearOrDel(Cursor & cur)
        if (lyxrc.auto_region_delete)
                selDel(cur);
        else
-               cur.setSelection(false);
+               cur.selection(false);
 }
 
 
diff --git a/src/Text.cpp b/src/Text.cpp
index f51646e..89028c8 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -1455,7 +1455,7 @@ void Text::deleteWordForward(Cursor & cur)
                cursorForward(cur);
        else {
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cursorForwardOneWord(cur);
                cur.setSelection();
                cutSelection(cur, true, false);
@@ -1471,7 +1471,7 @@ void Text::deleteWordBackward(Cursor & cur)
                cursorBackward(cur);
        else {
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cursorBackwardOneWord(cur);
                cur.setSelection();
                cutSelection(cur, true, false);
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 49df75e..0e8b412 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -178,7 +178,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & 
cmd)
                        LASSERT(cur.inMathed(), return);
                        cur.pos() = 0;
                        cur.resetAnchor();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        cur.pos() = cur.lastpos();
                        if (cmd.action() != LFUN_MATH_MODE)
                                // LFUN_MATH_MODE has a different meaning in 
math mode
@@ -1678,7 +1678,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // We continue with our existing selection or start a new one, 
so don't
                // reset the anchor.
                bvcur.setCursor(cur);
-               bvcur.setSelection(true);
+               bvcur.selection(true);
                if (cur.top() == old) {
                        // We didn't move one iota, so no need to update the 
screen.
                        cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
@@ -2060,7 +2060,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        cur.push(*inset);
                        cur.top().pos() = cur.top().lastpos();
                        cur.resetAnchor();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        cur.top().pos() = 0;
                }
                break;
@@ -2436,7 +2436,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_ESCAPE:
                if (cur.selection()) {
-                       cur.setSelection(false);
+                       cur.selection(false);
                } else {
                        cur.undispatched();
                        // This used to be LFUN_FINISHED_RIGHT, I think FORWARD 
is more
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 6fb12b3..e69ffe9 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1622,7 +1622,7 @@ void TextMetrics::deleteLineForward(Cursor & cur)
                text_->cursorForward(cur);
        } else {
                cur.resetAnchor();
-               cur.setSelection(true); // to avoid deletion
+               cur.selection(true); // to avoid deletion
                cursorEnd(cur);
                cur.setSelection();
                // What is this test for ??? (JMarc)
diff --git a/src/frontends/qt4/GuiSpellchecker.cpp 
b/src/frontends/qt4/GuiSpellchecker.cpp
index aa62a9a..24aa43d 100644
--- a/src/frontends/qt4/GuiSpellchecker.cpp
+++ b/src/frontends/qt4/GuiSpellchecker.cpp
@@ -337,9 +337,9 @@ void SpellcheckerWidget::Private::setSelection(
                Cursor & bvcur = bv->cursor();
                bvcur.setCursor(from);
                bvcur.clearSelection();
-               bvcur.setSelection(true);
+               bvcur.selection(true);
                bvcur.setCursor(end);
-               bvcur.setSelection(true);
+               bvcur.selection(true);
        } else {
                // FIXME LFUN
                // If we used a LFUN, dispatch would do all of this for us
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index ac63676..dda3003 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3997,7 +3997,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                        cur.idx() = tabular.getLastCellInRow(r);
                        cur.pit() = cur.lastpit();
                        cur.pos() = cur.lastpos();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        bvcur = cur;
                        rowselect_ = true;
                        break;
@@ -4012,7 +4012,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                        cur.idx() = tabular.cellIndex(tabular.nrows() - 1, c);
                        cur.pit() = cur.lastpit();
                        cur.pos() = cur.lastpos();
-                       cur.setSelection(true);
+                       cur.selection(true);
                        bvcur = cur;
                        colselect_ = true;
                        break;
@@ -4045,7 +4045,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                                cur.pit() = 0;
                                cur.pos() = 0;
                                bvcur.setCursor(cur);
-                               bvcur.setSelection(true);
+                               bvcur.selection(true);
                                break;
                        }
                        // select (additional) column
@@ -4057,7 +4057,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                                cur.pit() = 0;
                                cur.pos() = 0;
                                bvcur.setCursor(cur);
-                               bvcur.setSelection(true);
+                               bvcur.selection(true);
                                break;
                        }
                        // only update if selection changes
@@ -4066,7 +4066,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                                cur.noScreenUpdate();
                        setCursorFromCoordinates(cur, cmd.x(), cmd.y());
                        bvcur.setCursor(cur);
-                       bvcur.setSelection(true);
+                       bvcur.selection(true);
                        // if this is a multicell selection, we just set the 
cursor to
                        // the beginning of the cell's text.
                        if (bvcur.selIsMultiCell()) {
@@ -4083,12 +4083,12 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest 
& cmd)
 
        case LFUN_CELL_BACKWARD:
                movePrevCell(cur);
-               cur.setSelection(false);
+               cur.selection(false);
                break;
 
        case LFUN_CELL_FORWARD:
                moveNextCell(cur);
-               cur.setSelection(false);
+               cur.selection(false);
                break;
 
        case LFUN_CHAR_FORWARD_SELECT:
@@ -5186,7 +5186,7 @@ int InsetTabular::dist(BufferView & bv, idx_type const 
cell, int x, int y) const
 Inset * InsetTabular::editXY(Cursor & cur, int x, int y)
 {
        //lyxerr << "InsetTabular::editXY: " << this << endl;
-       cur.setSelection(false);
+       cur.selection(false);
        cur.push(*this);
        cur.idx() = getNearestCell(cur.bv(), x, y);
        return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y);
@@ -5545,7 +5545,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                cur.idx() = tabular.cellIndex(sel_row_start, column);
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                break;
 
        case Tabular::DELETE_COLUMN:
@@ -5568,7 +5568,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                cur.idx() = tabular.cellIndex(row, sel_col_start);
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                break;
 
        case Tabular::COPY_ROW:
@@ -5684,7 +5684,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                                                   
tabular.rightLine(cur.selEnd().idx()));
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                break;
        }
 
@@ -5741,7 +5741,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                                                
tabular.getAlignment(cur.selEnd().idx()));
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                break;
        }
 
@@ -5946,7 +5946,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                cur.idx() = tabular.setLTCaption(row, true);
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                // If a row is set as caption, then also insert
                // a caption. Otherwise the LaTeX output is broken.
                // Select cell if it is non-empty
@@ -5962,7 +5962,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                cur.idx() = tabular.setLTCaption(row, false);
                cur.pit() = 0;
                cur.pos() = 0;
-               cur.setSelection(false);
+               cur.selection(false);
                FuncRequest fr(LFUN_INSET_DISSOLVE, "caption");
                if (lyx::getStatus(fr).enabled())
                        lyx::dispatch(fr);
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 3d120a5..b505886 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1416,7 +1416,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest 
& cmd)
 
        case LFUN_CELL_BACKWARD:
                // See below.
-               cur.setSelection(false);
+               cur.selection(false);
                if (!idxPrev(cur)) {
                        cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
                        cur.undispatched();
@@ -1426,7 +1426,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest 
& cmd)
        case LFUN_CELL_FORWARD:
                // Can't handle selection by additional 'shift' as this is
                // hard bound to LFUN_CELL_BACKWARD
-               cur.setSelection(false);
+               cur.selection(false);
                if (!idxNext(cur)) {
                        cmd = FuncRequest(LFUN_FINISHED_FORWARD);
                        cur.undispatched();
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 9d90c19..7357b5f 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -740,7 +740,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & 
cmd)
        case LFUN_WORD_SELECT:
                cur.pos() = 0;
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cur.pos() = cur.lastpos();
                cur.bv().cursor() = cur;
                break;
@@ -749,7 +749,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                cur.idx() = 0;
                cur.pos() = 0;
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cur.idx() = cur.lastidx();
                cur.pos() = cur.lastpos();
                cur.bv().cursor() = cur;
@@ -1621,7 +1621,7 @@ void InsetMathNest::lfunMouseRelease(Cursor & cur, 
FuncRequest & cmd)
                        cur.noScreenUpdate();
                else {
                        Cursor & bvcur = cur.bv().cursor();
-                       bvcur.setSelection(true);
+                       bvcur.selection(true);
                }
                return;
        }
@@ -1762,7 +1762,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type 
const c)
 
        // just clear selection on pressing the space bar
        if (cur.selection() && c == ' ') {
-               cur.setSelection(false);
+               cur.selection(false);
                return true;
        }
 

Reply via email to