Activate another tab group (aka split view)

Bind the new functions tab-group-next/previous to F6/S-F6 in CUA bindings.

Fix for #12115.
This commit is contained in:
Daniel Ramoeller 2022-01-30 05:42:45 +01:00 committed by Jean-Marc Lasgouttes
parent 315d347d3e
commit 2d01fcd079
5 changed files with 60 additions and 7 deletions

View File

@ -116,6 +116,8 @@ Format 5
\bind "C-M-Down" "scroll line down"
\bind "C-M-Prior" "scroll page up"
\bind "C-M-Next" "scroll page down"
\bind "F6" "tab-group-next"
\bind "S-F6" "tab-group-previous"
\bind "C-F6" "buffer-next"
\bind "C-S-F6" "buffer-previous"
\bind "F7" "dialog-show spellchecker"

View File

@ -504,6 +504,8 @@ enum FuncCode
LFUN_INDEXMACRO_INSERT, // spitz 20220220
LFUN_INSET_INSERT_COPY, // spitz 20221101
LFUN_INDEX_TAG_ALL, // spitz 20221105
LFUN_TAB_GROUP_NEXT, // daniel 20220130
LFUN_TAB_GROUP_PREVIOUS, // daniel 20220130
// 395
LFUN_LASTACTION // end of the table
};

View File

@ -3981,6 +3981,22 @@ void LyXAction::init()
*/
{ LFUN_TAB_DELETE, "tab-delete", SingleParUpdate, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_TAB_GROUP_NEXT
* \li Action: Switch to the next tab group.
* \li Syntax: tab-group-next
* \endvar
*/
{ LFUN_TAB_GROUP_NEXT, "tab-group-next", ReadOnly, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_TAB_GROUP_PREVIOUS
* \li Action: Switch to the previous tab group.
* \li Syntax: tab-group-previous
* \endvar
*/
{ LFUN_TAB_GROUP_PREVIOUS, "tab-group-previous", ReadOnly, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_TAB_GROUP_CLOSE
* \li Action: Close the current tab group.

View File

@ -2473,6 +2473,11 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
d.splitter_->orientation() == Qt::Horizontal);
break;
case LFUN_TAB_GROUP_NEXT:
case LFUN_TAB_GROUP_PREVIOUS:
enable = (d.splitter_->count() > 1);
break;
case LFUN_TAB_GROUP_CLOSE:
enable = d.tabWorkAreaCount() > 1;
break;
@ -3816,7 +3821,7 @@ void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move)
for (int i = 0; i < nwa; ++i) {
if (&workArea(i)->bufferView().buffer() == curbuf) {
int next_index;
if (np == NEXTBUFFER)
if (np == NEXT)
next_index = (i == nwa - 1 ? 0 : i + 1);
else
next_index = (i == 0 ? nwa - 1 : i - 1);
@ -3831,6 +3836,23 @@ void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move)
}
void GuiView::gotoNextTabWorkArea(NextOrPrevious np)
{
int count = d.splitter_->count();
for (int i = 0; i < count; ++i) {
if (d.tabWorkArea(i) == d.currentTabWorkArea()) {
int new_index;
if (np == NEXT)
new_index = (i == count - 1 ? 0 : i + 1);
else
new_index = (i == 0 ? count - 1 : i - 1);
setCurrentWorkArea(d.tabWorkArea(new_index)->currentWorkArea());
break;
}
}
}
/// make sure the document is saved
static bool ensureBufferClean(Buffer * buffer)
{
@ -4493,19 +4515,19 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
}
case LFUN_BUFFER_NEXT:
gotoNextOrPreviousBuffer(NEXTBUFFER, false);
gotoNextOrPreviousBuffer(NEXT, false);
break;
case LFUN_BUFFER_MOVE_NEXT:
gotoNextOrPreviousBuffer(NEXTBUFFER, true);
gotoNextOrPreviousBuffer(NEXT, true);
break;
case LFUN_BUFFER_PREVIOUS:
gotoNextOrPreviousBuffer(PREVBUFFER, false);
gotoNextOrPreviousBuffer(PREV, false);
break;
case LFUN_BUFFER_MOVE_PREVIOUS:
gotoNextOrPreviousBuffer(PREVBUFFER, true);
gotoNextOrPreviousBuffer(PREV, true);
break;
case LFUN_BUFFER_CHKTEX:
@ -4831,6 +4853,15 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
setCurrentWorkArea(wa);
break;
}
case LFUN_TAB_GROUP_NEXT:
gotoNextTabWorkArea(NEXT);
break;
case LFUN_TAB_GROUP_PREVIOUS:
gotoNextTabWorkArea(PREV);
break;
case LFUN_TAB_GROUP_CLOSE:
if (TabWorkArea * twa = d.currentTabWorkArea()) {
closeTabWorkArea(twa);

View File

@ -476,11 +476,13 @@ private:
bool inOtherView(Buffer & buf);
///
enum NextOrPrevious {
NEXTBUFFER,
PREVBUFFER
NEXT,
PREV
};
///
void gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move);
///
void gotoNextTabWorkArea(NextOrPrevious np);
/// Is the dialog currently visible?
bool isDialogVisible(std::string const & name) const;