From 2d01fcd0798867d2dba3ddd83d486b47e9b76772 Mon Sep 17 00:00:00 2001 From: Daniel Ramoeller Date: Sun, 30 Jan 2022 05:42:45 +0100 Subject: [PATCH] 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. --- lib/bind/cua.bind | 2 ++ src/FuncCode.h | 2 ++ src/LyXAction.cpp | 16 ++++++++++++++ src/frontends/qt/GuiView.cpp | 41 +++++++++++++++++++++++++++++++----- src/frontends/qt/GuiView.h | 6 ++++-- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 2ba0064c41..9ec1f340ca 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -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" diff --git a/src/FuncCode.h b/src/FuncCode.h index 956a3a4890..aaa88f2466 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -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 }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 1692605945..f67a535ee9 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -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. diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 2c409d626e..ccc2b8e59c 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -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); diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h index 7bac49091f..8cf031585a 100644 --- a/src/frontends/qt/GuiView.h +++ b/src/frontends/qt/GuiView.h @@ -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; -- 2.39.5