[LyX/master] Activate another tab group (aka split view)

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Nov 27 16:57:11 UTC 2022


commit 2d01fcd0798867d2dba3ddd83d486b47e9b76772
Author: Daniel Ramoeller <d.lyx at web.de>
Date:   Sun Jan 30 05:42:45 2022 +0100

    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 2ba0064..9ec1f34 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 956a3a4..aaa88f2 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 1692605..f67a535 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -3982,6 +3982,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.
  * \li Notion: This only closes the work areas, not the buffers themselves.
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 2c409d6..ccc2b8e 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 7bac490..8cf0315 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;


More information about the lyx-cvs mailing list