]> git.lyx.org Git - features.git/commitdiff
Activate another tab group (aka split view)
authorDaniel Ramoeller <d.lyx@web.de>
Sun, 30 Jan 2022 04:42:45 +0000 (05:42 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 27 Nov 2022 17:52:05 +0000 (18:52 +0100)
Bind the new functions tab-group-next/previous to F6/S-F6 in CUA bindings.

Fix for #12115.

lib/bind/cua.bind
src/FuncCode.h
src/LyXAction.cpp
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiView.h

index 2ba0064c41d18236e2483fddf66a989e0dab15cf..9ec1f340cae1243a41e2bc03030b61bbfb469663 100644 (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"
index 956a3a4890c4fa1cf953ee88003edec879f541d2..aaa88f246673adda01dd89d5dbc9ade1c4417e26 100644 (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
 };
index 16926059459674f8adca283b9e9d4cb8a5088690..f67a535ee9be8e968faaac53bbef84ed6a880868 100644 (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.
index 2c409d626e64baeff529a4420ce8842b63bad76e..ccc2b8e59ccc1c1ec15bb0d24d3a92b64802adcd 100644 (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);
index 7bac49091fe0d9d6c9be20c807aae92b3acb88a7..8cf031585aff898249c9eef0fb04bda9aa6706fe 100644 (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;