From 08726fe2dcaa7156cfa8c97293d3701bff4f62e6 Mon Sep 17 00:00:00 2001
From: onefang
Date: Wed, 4 Aug 2021 15:11:21 +1000
Subject: Kill the rest of the panes that are not on the original window.

---
 src/sledjchisl/sledjchisl.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'src')

diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index 230371b..e779c0c 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -8292,6 +8292,26 @@ fcgiDone:
     }
     ourSims->simsLua->unlock(ourSims->simsLua);
 
+    // Kill the rest of the panes that are not on the original window.
+    snprintf(toybuf, sizeof(toybuf), "echo 'IDs={' >%s/IDs_ALL.lua", scTemp);
+    system(toybuf);
+    doTmuxCmd("list-panes -s -F '\"#{window_id}.#{pane_id}\",' >> %s/IDs_ALL.lua", scTemp);
+    snprintf(toybuf, sizeof(toybuf), "echo '}\nreturn IDs' >>%s/IDs_ALL.lua", scTemp);
+    system(toybuf);
+
+    snprintf(toybuf, sizeof(toybuf), "%s/IDs_ALL.lua", scTemp);
+    qtreetbl_t *IDs = Lua2tree(toybuf, "IDs");
+
+    memset((void*)&obj0, 0, sizeof(obj0));
+    IDs->lock(IDs);
+    while(IDs->getnext(IDs, &obj0, false) == true)
+    {
+      q0 = obj0.data;
+      if ('0' != q0->v.s[1])
+        doTmuxCmd("kill-pane -t %s", q0->v.s);
+    }
+    IDs->unlock(IDs);
+    freeLuaTree(IDs);
     char *c = xmprintf("rm -fr %s/*", scTemp);
     if (!WIFEXITED(system(c)))
       E("rrm command failed!  %s", c);
-- 
cgit v1.1