From f3cb98c784cea4c778ad11496985f452a703d6a2 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 14 Mar 2016 11:46:28 +0100 Subject: [PATCH] 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. (cherry picked from commit 5de28b9ac6736c791146a1a3ebe7f4826c22a9b7) --- src/BufferView.cpp | 23 ++++++++++++++--------- src/insets/Inset.h | 2 ++ src/insets/InsetTabular.h | 2 ++ src/mathed/InsetMathGrid.h | 2 ++ status.22x | 2 ++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index a158393579..f304798c82 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1771,21 +1771,25 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) } - case LFUN_INSET_SELECT_ALL: - if (cur.depth() > 1 + case LFUN_INSET_SELECT_ALL: { + // true if all cells are selected + bool const all_selected = cur.depth() > 1 && cur.selBegin().at_begin() - && cur.selEnd().at_end()) { - // All the contents of the inset if selected. + && cur.selEnd().at_end(); + // 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. cur.pop(); cur.resetAnchor(); cur.setSelection(true); cur.posForward(); - } else if (cur.selBegin().idx() != cur.selEnd().idx() - || (cur.depth() > 1 - && cur.selBegin().at_cell_begin() - && cur.selEnd().at_cell_end())) { - // At least one complete cell is selected. + } else if (cells_selected) { + // At least one complete cell is selected and inset is a table. // Select all cells cur.idx() = 0; cur.pos() = 0; @@ -1805,6 +1809,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.setCurrentFont(); dr.screenUpdate(Update::Force); break; + } // This would be in Buffer class if only Cursor did not diff --git a/src/insets/Inset.h b/src/insets/Inset.h index c413f9b4cc..cbcaf518a2 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -347,6 +347,8 @@ public: virtual bool clickable(BufferView const &, int, int) const { return false; } /// Move one cell backwards 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? virtual bool canTrackChanges() const { return false; } diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index bb36b7f13d..f63b84af42 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -881,6 +881,8 @@ public: bool inheritFont() const { return false; } /// bool allowsCaptionVariation(std::string const &) const; + // + bool isTable() const { return true; } /// DisplayType display() const; /// diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h index 7faf938818..e9ea396930 100644 --- a/src/mathed/InsetMathGrid.h +++ b/src/mathed/InsetMathGrid.h @@ -154,6 +154,8 @@ public: InsetMathGrid * asGridInset() { return this; } /// identifies GridInset InsetMathGrid const * asGridInset() const { return this; } + // + bool isTable() const { return true; } /// col_type ncols() const; /// diff --git a/status.22x b/status.22x index cb23eb86a3..37b296cac0 100644 --- a/status.22x +++ b/status.22x @@ -35,6 +35,8 @@ What's new - Change mouse cursor to indicate row/column selection in tabulars. +- Make inset-select-all select all cells only in tables. + - Automatically show the review toolbar if the document has tracked changes (bug 8738), and related UI imrovements. -- 2.39.5