From 46ab08c0734342b224b02d21e9f0c0fbdc3f985c Mon Sep 17 00:00:00 2001
From: Stefanus Du Toit <sjdutoit@gmail.com>
Date: Sun, 15 Aug 2021 16:59:47 +0800
Subject: [PATCH] Add "killright" command.

This command kills all windows to the right of the current one,
similar to analogous commands in tab-based UIs like web browsers.
---
 src/comm.c    |  1 +
 src/process.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/comm.c b/src/comm.c
index 90eaa7e..f37b2ec 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -218,6 +218,7 @@ struct comm comms[RC_LAST + 1] =
   { "kanji",		NEED_FORE|ARGS_12 },
 #endif
   { "kill",		NEED_FORE|ARGS_0 },
+  { "killright",       NEED_FORE|ARGS_0 },
   { "lastmsg",		CAN_QUERY|NEED_DISPLAY|ARGS_0 },
   { "layout",           ARGS_1|ARGS_ORMORE},
   { "license",		NEED_LAYER|ARGS_0 },
diff --git a/src/process.c b/src/process.c
index 004b22a..4d31efb 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1356,6 +1356,22 @@ int key;
 	  free(name);
 	break;
       }
+    case RC_KILLRIGHT:
+      {
+       n = 0;
+       if (key >= 0)
+         {
+           Input("Really kill all windows to the right [y/n]", 1, INP_RAW, confirm_fn, NULL, RC_KILLRIGHT);
+           break;
+         }
+       while (NextWindow() > fore->w_number)
+         {
+           KillWindow(wtab[NextWindow()]);
+           ++n;
+         }
+       OutputMsg(0, "%d windows killed.", n);
+       break;
+      }
     case RC_QUIT:
       if (key >= 0)
 	{
-- 
2.27.0

