mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 02:49:46 +00:00
Make inset-select-all select all cells only in tables
inset-select-all has 3 levels 1. select current cell 2. select all cells 3. select inset from outside. The second level makes sense for tables (text and math), but not for things like a math fraction. Introduce a new method Inset::isTable() that allows to detect this case properly and skip level 2.
This commit is contained in:
parent
fd3a41e035
commit
d8f6e65ec7
@ -1777,21 +1777,25 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case LFUN_INSET_SELECT_ALL:
|
case LFUN_INSET_SELECT_ALL: {
|
||||||
if (cur.depth() > 1
|
// true if all cells are selected
|
||||||
|
bool const all_selected = cur.depth() > 1
|
||||||
&& cur.selBegin().at_begin()
|
&& cur.selBegin().at_begin()
|
||||||
&& cur.selEnd().at_end()) {
|
&& cur.selEnd().at_end();
|
||||||
// All the contents of the inset if selected.
|
// true if some cells are selected
|
||||||
|
bool const cells_selected = cur.depth() > 1
|
||||||
|
&& cur.selBegin().at_cell_begin()
|
||||||
|
&& cur.selEnd().at_cell_end();
|
||||||
|
if (all_selected || (cells_selected && !cur.inset().isTable())) {
|
||||||
|
// All the contents of the inset if selected, or only at
|
||||||
|
// least one cell but inset is not a table.
|
||||||
// Select the inset from outside.
|
// Select the inset from outside.
|
||||||
cur.pop();
|
cur.pop();
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
cur.setSelection(true);
|
cur.setSelection(true);
|
||||||
cur.posForward();
|
cur.posForward();
|
||||||
} else if (cur.selBegin().idx() != cur.selEnd().idx()
|
} else if (cells_selected) {
|
||||||
|| (cur.depth() > 1
|
// At least one complete cell is selected and inset is a table.
|
||||||
&& cur.selBegin().at_cell_begin()
|
|
||||||
&& cur.selEnd().at_cell_end())) {
|
|
||||||
// At least one complete cell is selected.
|
|
||||||
// Select all cells
|
// Select all cells
|
||||||
cur.idx() = 0;
|
cur.idx() = 0;
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
@ -1811,6 +1815,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
cur.setCurrentFont();
|
cur.setCurrentFont();
|
||||||
dr.screenUpdate(Update::Force);
|
dr.screenUpdate(Update::Force);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// This would be in Buffer class if only Cursor did not
|
// This would be in Buffer class if only Cursor did not
|
||||||
|
@ -347,6 +347,8 @@ public:
|
|||||||
virtual bool clickable(BufferView const &, int, int) const { return false; }
|
virtual bool clickable(BufferView const &, int, int) const { return false; }
|
||||||
/// Move one cell backwards
|
/// Move one cell backwards
|
||||||
virtual bool allowsCaptionVariation(std::string const &) const { return false; }
|
virtual bool allowsCaptionVariation(std::string const &) const { return false; }
|
||||||
|
// true for insets that have a table structure (InsetMathGrid, InsetTabular)
|
||||||
|
virtual bool isTable() const { return false; }
|
||||||
|
|
||||||
/// does this contain text that can be change track marked in DVI?
|
/// does this contain text that can be change track marked in DVI?
|
||||||
virtual bool canTrackChanges() const { return false; }
|
virtual bool canTrackChanges() const { return false; }
|
||||||
|
@ -881,6 +881,8 @@ public:
|
|||||||
bool inheritFont() const { return false; }
|
bool inheritFont() const { return false; }
|
||||||
///
|
///
|
||||||
bool allowsCaptionVariation(std::string const &) const;
|
bool allowsCaptionVariation(std::string const &) const;
|
||||||
|
//
|
||||||
|
bool isTable() const { return true; }
|
||||||
///
|
///
|
||||||
DisplayType display() const;
|
DisplayType display() const;
|
||||||
///
|
///
|
||||||
|
@ -154,6 +154,8 @@ public:
|
|||||||
InsetMathGrid * asGridInset() { return this; }
|
InsetMathGrid * asGridInset() { return this; }
|
||||||
/// identifies GridInset
|
/// identifies GridInset
|
||||||
InsetMathGrid const * asGridInset() const { return this; }
|
InsetMathGrid const * asGridInset() const { return this; }
|
||||||
|
//
|
||||||
|
bool isTable() const { return true; }
|
||||||
///
|
///
|
||||||
col_type ncols() const;
|
col_type ncols() const;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user