src/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py

branch
eric7
changeset 10380
7c14ccd2a0e1
parent 10212
68b6b5127363
child 10394
056d1b2cd3c4
diff -r 6f27d7bcfe56 -r 7c14ccd2a0e1 src/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py
--- a/src/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py	Tue Dec 05 10:54:20 2023 +0100
+++ b/src/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py	Tue Dec 05 14:31:45 2023 +0100
@@ -7,6 +7,7 @@
 Module implementing the listspace viewmanager class.
 """
 
+import itertools
 import os
 
 from PyQt6.QtCore import QEvent, Qt, pyqtSignal, pyqtSlot
@@ -291,6 +292,14 @@
             self.tr("Close Others"),
             self.__contextMenuCloseOthers,
         )
+        self.closeAboveMenuAct = self.__menu.addAction(
+            self.tr("Close Editors Above"),
+            self.__contextMenuCloseAbove,
+        )
+        self.closeBelowMenuAct = self.__menu.addAction(
+            self.tr("Close Editors Below"),
+            self.__contextMenuCloseBelow,
+        )
         self.__menu.addAction(self.tr("Close All"), self.__contextMenuCloseAll)
         self.__menu.addSeparator()
         self.saveMenuAct = self.__menu.addAction(
@@ -359,6 +368,8 @@
                         self.__startAct.setEnabled(False)
 
                     self.closeOthersMenuAct.setEnabled(self.viewlist.count() > 1)
+                    self.closeAboveMenuAct.setEnabled(row > 0)
+                    self.closeBelowMenuAct.setEnabled(row < self.viewlist.count() - 1)
 
                     self.__menu.popup(self.viewlist.mapToGlobal(point))
 
@@ -840,12 +851,31 @@
         Private method to close the other editors.
         """
         index = self.contextMenuIndex
-        for i in list(range(self.viewlist.count() - 1, index, -1)) + list(
+        for i in itertools.chain(
+            range(self.viewlist.count() - 1, index, -1),
             range(index - 1, -1, -1)
         ):
             editor = self.editors[i]
             self.closeEditorWindow(editor)
 
+    def __contextMenuCloseAbove(self):
+        """
+        Private method to close editors above.
+        """
+        index = self.contextMenuIndex
+        for i in range(index - 1, -1, -1):
+            editor = self.editors[i]
+            self.closeEditorWindow(editor)
+
+    def __contextMenuCloseBelow(self):
+        """
+        Private method to close editors below.
+        """
+        index = self.contextMenuIndex
+        for i in range(self.viewlist.count() - 1, index, -1):
+            editor = self.editors[i]
+            self.closeEditorWindow(editor)
+
     def __contextMenuCloseAll(self):
         """
         Private method to close all editors.

eric ide

mercurial