Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

/* The delete terminal key. */
#define DELETE_NODE KEY(L'w')
#define ONLY_NODE KEY(L'q')

/* does nothing, specifically */
#define BAILOUT KEY(L'c')
Expand Down
2 changes: 2 additions & 0 deletions mtm.1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ or stack vertically
the newly-created terminal will be focused.
.It Em "w"
Delete the currently focused terminal.
.It Em "q"
Delete all other terminals, except this one.
.It Em "l"
.Pq "the letter ell"
Redraw the screen.
Expand Down
21 changes: 21 additions & 0 deletions mtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,26 @@ deletenode(NODE *n) /* Delete a node. */
freenode(n, true);
}

static void
onlynode(NODE *n) /* Delete other nodes. */
{
struct NODE *node = NULL;
int next = false;
if (n != focused)
focus(n);
while(true){
/* KLUDGE: should go to the "next" node instead. */
(next=false) || ((node=findnode(root, ABOVE(n))) && (next=true));
next || ((node=findnode(root, BELOW(n))) && (next=true));
next || ((node=findnode(root, LEFT(n))) && (next=true));
next || ((node=findnode(root, RIGHT(n))) && (next=true));
if(!next)
break;
deletenode(node);
}
}


static void
reshapeview(NODE *n, int d, int ow) /* Reshape a view. */
{
Expand Down Expand Up @@ -1101,6 +1121,7 @@ handlechar(int r, int k) /* Handle a single input character. */
DO(true, HSPLIT, split(n, HORIZONTAL))
DO(true, VSPLIT, split(n, VERTICAL))
DO(true, DELETE_NODE, deletenode(n))
DO(true, ONLY_NODE, onlynode(n))
DO(true, BAILOUT, (void)1)
DO(true, REDRAW, touchwin(stdscr); draw(root); redrawwin(stdscr))
DO(true, SCROLLUP, scrollback(n))
Expand Down