diff --git a/config.def.h b/config.def.h index 6e7c4e8..55ac03b 100644 --- a/config.def.h +++ b/config.def.h @@ -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') diff --git a/mtm.1 b/mtm.1 index da00118..130b6ab 100644 --- a/mtm.1 +++ b/mtm.1 @@ -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. diff --git a/mtm.c b/mtm.c index 477ef14..1e8ecc9 100644 --- a/mtm.c +++ b/mtm.c @@ -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. */ { @@ -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))