mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 07:03:32 +00:00
Reimplement inset-select-all in a generic way
There are 3 possible actions (in order) * select current cell * select all calls of inset * select the inset from outside (in the containing inset) C-a is now bound to inset-select-all C-M-a is bound to the global "select all". The reason for this change is that selecting an inset is a more common operation that selecting an entire document. This patch is the result of discussion on #7727.
This commit is contained in:
parent
e0840f28b7
commit
1997e8b817
@ -175,6 +175,11 @@ The following LyX functions have been changed:
|
||||
|
||||
The following LyX key bindings have been changed:
|
||||
|
||||
- In LyX 2.1.3, the binding "C-a" was moved from selecting the whole
|
||||
document to "inset-select-all". This function allows to select the
|
||||
document in a incremental way. The old behavior is now bound to
|
||||
"C-M-a".
|
||||
|
||||
- The binding "C-w" was moved from "buffer-close" to "view-close"
|
||||
(only in cua.bind).
|
||||
|
||||
|
@ -87,8 +87,8 @@ Format 2
|
||||
\bind "C-y" "redo"
|
||||
\bind "C-S-Z" "redo"
|
||||
|
||||
\bind "C-a" "command-sequence buffer-begin ; buffer-end-select" # select all
|
||||
\bind "C-M-a" "inset-select-all"
|
||||
\bind "C-M-a" "command-sequence buffer-begin ; buffer-end-select" # select all
|
||||
\bind "C-a" "inset-select-all"
|
||||
|
||||
\bind "C-S-E" "changes-track" # it's what MS Word uses
|
||||
\bind "~S-M-quotedbl" "quote-insert single"
|
||||
|
@ -123,8 +123,8 @@ Format 2
|
||||
# +: "Shift-Command-4" # Capture a selection to a file
|
||||
# +: "Shift-Control-Command-4" # Capture a selection to the Clipboard
|
||||
# +: "Command-A" # Highlight every item in a document or window, or all characters in a text field
|
||||
\bind "C-a" "command-sequence buffer-begin ; buffer-end-select"
|
||||
\bind "C-M-a" "inset-select-all"
|
||||
\bind "C-M-a" "command-sequence buffer-begin ; buffer-end-select"
|
||||
\bind "C-a" "inset-select-all"
|
||||
# +: "Command-B" # Boldface the selected text or toggle boldfaced text on and off
|
||||
\bind "C-M-b" "font-boldsymbol"
|
||||
\bind "C-b" "font-bold"
|
||||
|
@ -113,7 +113,8 @@ Format 2
|
||||
\bind "C-x" "cut"
|
||||
\bind "C-z" "undo"
|
||||
\bind "S-C-Z" "redo"
|
||||
\bind "C-a" "command-sequence buffer-begin ; buffer-end-select" # select all
|
||||
\bind "C-a" "inset-select-all"
|
||||
\bind "C-M-a" "command-sequence buffer-begin ; buffer-end-select" # select all
|
||||
|
||||
|
||||
# This combination makes an umlaut accent now.
|
||||
|
@ -98,7 +98,7 @@ The LyX Team
|
||||
\end_layout
|
||||
|
||||
\begin_layout Date
|
||||
2014-02-13
|
||||
2014-11-20
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section*
|
||||
@ -2171,13 +2171,16 @@ Sample inset-modify note Note Comment
|
||||
inset-select-all
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Action Selects all contents of an inset.
|
||||
Action Select all contents of an inset.
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Notion There are 3 successive levels: select current cell, select all cells of inset, select the inset from outside (in the enclosing inset).
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Syntax inset-select-all
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Origin vfr, 22 Aug 2009
|
||||
Origin vfr, 22 Aug 2009; lasgouttes 1 Nov 2014
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection*
|
||||
@ -3047,7 +3050,7 @@ Origin Abdel, Dec 27 2007
|
||||
section-select
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Action Selects the whole section.
|
||||
Action Select the whole section.
|
||||
\end_layout
|
||||
\begin_layout Description
|
||||
Notion The cursor should be in a section heading before calling this lfun.
|
||||
|
@ -1089,6 +1089,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
case LFUN_KEYMAP_PRIMARY:
|
||||
case LFUN_KEYMAP_SECONDARY:
|
||||
case LFUN_KEYMAP_TOGGLE:
|
||||
case LFUN_INSET_SELECT_ALL:
|
||||
flag.setEnabled(true);
|
||||
break;
|
||||
|
||||
@ -1800,6 +1801,41 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
}
|
||||
|
||||
|
||||
case LFUN_INSET_SELECT_ALL:
|
||||
if (cur.depth() > 1
|
||||
&& cur.selBegin().at_begin()
|
||||
&& cur.selEnd().at_end()) {
|
||||
// All the contents of the inset if selected.
|
||||
// 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.
|
||||
// Select all cells
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
cur.resetAnchor();
|
||||
cur.setSelection(true);
|
||||
cur.idx() = cur.lastidx();
|
||||
cur.pos() = cur.lastpos();
|
||||
} else {
|
||||
// select current cell
|
||||
cur.pit() = 0;
|
||||
cur.pos() = 0;
|
||||
cur.resetAnchor();
|
||||
cur.setSelection(true);
|
||||
cur.pit() = cur.lastpit();
|
||||
cur.pos() = cur.lastpos();
|
||||
}
|
||||
dr.screenUpdate(Update::Force);
|
||||
break;
|
||||
|
||||
|
||||
// This would be in Buffer class if only Cursor did not
|
||||
// require a bufferview
|
||||
case LFUN_INSET_FORALL: {
|
||||
|
@ -158,15 +158,27 @@ void CursorSlice::backwardPos()
|
||||
}
|
||||
|
||||
|
||||
bool CursorSlice::at_end() const
|
||||
bool CursorSlice::at_cell_end() const
|
||||
{
|
||||
return idx_ == lastidx() && pit_ == lastpit() && pos_ == lastpos();
|
||||
return pit_ == lastpit() && pos_ == lastpos();
|
||||
}
|
||||
|
||||
|
||||
bool CursorSlice::at_cell_begin() const
|
||||
{
|
||||
return pit_ == 0 && pos_ == 0;
|
||||
}
|
||||
|
||||
|
||||
bool CursorSlice::at_end() const
|
||||
{
|
||||
return idx_ == lastidx() && at_cell_end();
|
||||
}
|
||||
|
||||
|
||||
bool CursorSlice::at_begin() const
|
||||
{
|
||||
return idx_ == 0 && pit_ == 0 && pos_ == 0;
|
||||
return idx_ == 0 && at_cell_begin();
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,6 +132,10 @@ public:
|
||||
void forwardIdx();
|
||||
/// move to previous cell
|
||||
void backwardIdx();
|
||||
/// are we at the end of the cell
|
||||
bool at_cell_end() const;
|
||||
/// are we at the start of the cell
|
||||
bool at_cell_begin() const;
|
||||
/// are we at the end of this slice
|
||||
bool at_end() const;
|
||||
/// are we at the start of this slice
|
||||
|
@ -1141,16 +1141,19 @@ void LyXAction::init()
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_INSET_SELECT_ALL
|
||||
* \li Action: Selects all contents of an inset.
|
||||
* \li Action: Select all contents of an inset.
|
||||
* \li Notion: There are 3 successive levels: select current cell,
|
||||
* select all cells of inset, select the inset from outside
|
||||
* (in the enclosing inset).
|
||||
* \li Syntax: inset-select-all
|
||||
* \li Origin: vfr, 22 Aug 2009
|
||||
* \li Origin: vfr, 22 Aug 2009; lasgouttes 1 Nov 2014
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_INSET_SELECT_ALL, "inset-select-all", ReadOnly, Edit },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_SECTION_SELECT
|
||||
* \li Action: Selects the whole section.
|
||||
* \li Action: Select the whole section.
|
||||
* \li Notion: The cursor should be in a section heading
|
||||
before calling this lfun.
|
||||
* \li Syntax: section-select
|
||||
|
@ -616,18 +616,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.screenUpdateFlags(Update::FitCursor);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_SELECT_ALL:
|
||||
if (cur.depth() == 1 || !cur.selection() || !cur.selBegin().at_begin()
|
||||
|| !cur.selEnd().at_end()) {
|
||||
needsUpdate |= cur.selHandle(false);
|
||||
needsUpdate |= cursorTop(cur);
|
||||
needsUpdate |= cur.selHandle(true);
|
||||
needsUpdate |= cursorBottom(cur);
|
||||
} else
|
||||
cur.undispatched();
|
||||
cur.screenUpdateFlags(Update::FitCursor);
|
||||
break;
|
||||
|
||||
case LFUN_CHAR_FORWARD:
|
||||
case LFUN_CHAR_FORWARD_SELECT:
|
||||
//LYXERR0(" LFUN_CHAR_FORWARD[SEL]:\n" << cur);
|
||||
@ -3058,7 +3046,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_INSET_END:
|
||||
case LFUN_INSET_BEGIN_SELECT:
|
||||
case LFUN_INSET_END_SELECT:
|
||||
case LFUN_INSET_SELECT_ALL:
|
||||
case LFUN_PARAGRAPH_UP:
|
||||
case LFUN_PARAGRAPH_DOWN:
|
||||
case LFUN_LINE_BEGIN:
|
||||
|
@ -729,7 +729,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
case LFUN_MOUSE_TRIPLE:
|
||||
case LFUN_WORD_SELECT:
|
||||
case LFUN_INSET_SELECT_ALL:
|
||||
cur.pos() = 0;
|
||||
cur.idx() = 0;
|
||||
cur.resetAnchor();
|
||||
|
@ -58,14 +58,17 @@ What's new
|
||||
|
||||
* USER INTERFACE
|
||||
|
||||
- Debug options in message pane are now sorted alphabetically.
|
||||
|
||||
- References no longer truncated in outliner (bug 9312).
|
||||
|
||||
- Allow computing selected subformulas with computer algebra systems.
|
||||
|
||||
- Number correctly footnotes in title layouts (part of bug 2666).
|
||||
|
||||
- Ctrl+A is now bound to inset-select-all, which does a local
|
||||
selection (current inset) and grows at each new invokation. Try it!
|
||||
|
||||
- Debug options in message pane are now sorted alphabetically.
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
- New example file "PDF-comment.lyx" describing the support for PDF annotations.
|
||||
|
Loading…
x
Reference in New Issue
Block a user