summaryrefslogtreecommitdiffstats
path: root/cmd-resize-pane.c
diff options
context:
space:
mode:
authornicm <nicm>2020-03-31 17:13:20 +0000
committernicm <nicm>2020-03-31 17:13:20 +0000
commite6cddcf752b335cb945bba4619b500b527cfee0a (patch)
tree14c221ec9118347f15f4626aabf095df2104c769 /cmd-resize-pane.c
parent2624edde46ad13995d4dd33f7d61fce74ac8f1ac (diff)
Add a -T flag to resize-pane to trim lines below the cursor, moving
lines out of the history. GitHub issue 2134.
Diffstat (limited to 'cmd-resize-pane.c')
-rw-r--r--cmd-resize-pane.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c
index b0aa2756..fd303cc1 100644
--- a/cmd-resize-pane.c
+++ b/cmd-resize-pane.c
@@ -36,8 +36,8 @@ const struct cmd_entry cmd_resize_pane_entry = {
.name = "resize-pane",
.alias = "resizep",
- .args = { "DLMRt:Ux:y:Z", 0, 1 },
- .usage = "[-DLMRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
+ .args = { "DLMRTt:Ux:y:Z", 0, 1 },
+ .usage = "[-DLMRTUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " "
"[adjustment]",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -60,6 +60,19 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
char *cause;
u_int adjust;
int x, y;
+ struct grid *gd = wp->base.grid;
+
+ if (args_has(args, 'T')) {
+ if (!TAILQ_EMPTY(&wp->modes))
+ return (CMD_RETURN_NORMAL);
+ adjust = screen_size_y(&wp->base) - 1 - wp->base.cy;
+ if (adjust > gd->hsize)
+ adjust = gd->hsize;
+ grid_remove_history(gd, adjust);
+ wp->base.cy += adjust;
+ wp->flags |= PANE_REDRAW;
+ return (CMD_RETURN_NORMAL);
+ }
if (args_has(args, 'M')) {
if (cmd_mouse_window(&shared->mouse, &s) == NULL)