mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-23 15:19:06 +01:00
rotate-window command.
This commit is contained in:
parent
e0eff354f9
commit
325d43e417
6
CHANGES
6
CHANGES
@ -1,3 +1,7 @@
|
||||
03 April 2009
|
||||
|
||||
* rotate-window command. -U flag (default) for up, -D flag for down.
|
||||
|
||||
02 April 2009
|
||||
|
||||
* Change scroll/pane redraws to only redraw the single pane affected rather
|
||||
@ -1194,7 +1198,7 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.270 2009-04-02 21:08:13 nicm Exp $
|
||||
$Id: CHANGES,v 1.271 2009-04-03 17:21:46 nicm Exp $
|
||||
|
||||
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
||||
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.80 2009-04-02 23:28:15 nicm Exp $
|
||||
# $Id: GNUmakefile,v 1.81 2009-04-03 17:21:46 nicm Exp $
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@ -38,6 +38,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
|
||||
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
|
||||
cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
|
||||
cmd-rotate-window.c \
|
||||
window-clock.c window-scroll.c window-more.c window-copy.c \
|
||||
window-choose.c \
|
||||
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
|
||||
|
3
Makefile
3
Makefile
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.119 2009-04-02 23:28:16 nicm Exp $
|
||||
# $Id: Makefile,v 1.120 2009-04-03 17:21:46 nicm Exp $
|
||||
|
||||
.SUFFIXES: .c .o .y .h
|
||||
.PHONY: clean update-index.html upload-index.html
|
||||
@ -41,6 +41,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
|
||||
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
|
||||
cmd-copy-buffer.c cmd-break-pane.c cmd-swap-pane.c cmd-next-layout.c \
|
||||
cmd-rotate-window.c \
|
||||
window-clock.c window-scroll.c window-more.c window-copy.c \
|
||||
window-choose.c \
|
||||
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
|
||||
|
6
TODO
6
TODO
@ -80,6 +80,8 @@
|
||||
- refer to windows by name etc (duplicates? fnmatch?)
|
||||
- the output code (tty.c) could do with optimisation depending on term
|
||||
capibilities
|
||||
- resize-pane-up/down should be resize-pane -U/-D. ditto up-pane/down-pane
|
||||
should be select-pane -U/-D
|
||||
|
||||
(hopefully) for 0.8, in no particular order:
|
||||
- test bug sshing from freebsd console
|
||||
@ -94,10 +96,10 @@
|
||||
more layouts
|
||||
better resizing of shells when changing layout
|
||||
find and fix bug with clear screen after horiz split
|
||||
speed improvements?
|
||||
speed improvements? -- still too slow over ssh!
|
||||
hardcoded 81 for left-vertical is nasty
|
||||
- document new layout stuff: next-layout
|
||||
- document swap-pane
|
||||
- document swap-pane and rotate-window
|
||||
- document repeat behaviour and -r on bind-key
|
||||
- document status-keys
|
||||
- document break-pane
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-generic.c,v 1.23 2009-01-23 20:20:23 nicm Exp $ */
|
||||
/* $Id: cmd-generic.c,v 1.24 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -23,7 +23,9 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
#define CMD_FLAGS "adgku"
|
||||
#define CMD_FLAGS "adDgkuU"
|
||||
#define CMD_FLAGMASK \
|
||||
(CMD_DFLAG|CMD_GFLAG|CMD_KFLAG|CMD_UFLAG|CMD_UPPERUFLAG|CMD_UPPERDFLAG)
|
||||
|
||||
int cmd_do_flags(int, int, int *);
|
||||
size_t cmd_print_flags(char *, size_t, size_t, int);
|
||||
@ -53,6 +55,12 @@ cmd_do_flags(int opt, int iflags, int *oflags)
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
case 'D':
|
||||
if (iflags & CMD_UPPERDFLAG) {
|
||||
(*oflags) |= CMD_UPPERDFLAG;
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
case 'g':
|
||||
if (iflags & CMD_GFLAG) {
|
||||
(*oflags) |= CMD_GFLAG;
|
||||
@ -71,6 +79,12 @@ cmd_do_flags(int opt, int iflags, int *oflags)
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
case 'U':
|
||||
if (iflags & CMD_UPPERUFLAG) {
|
||||
(*oflags) |= CMD_UPPERUFLAG;
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
@ -80,11 +94,13 @@ cmd_print_flags(char *buf, size_t len, size_t off, int flags)
|
||||
{
|
||||
size_t boff = off;
|
||||
|
||||
if ((flags & (CMD_DFLAG|CMD_GFLAG|CMD_KFLAG|CMD_UFLAG)) == 0)
|
||||
if ((flags & CMD_FLAGMASK) == 0)
|
||||
return (0);
|
||||
off += xsnprintf(buf + off, len - off, " -");
|
||||
if (off < len && flags & CMD_AFLAG)
|
||||
off += xsnprintf(buf + off, len - off, "a");
|
||||
if (off < len && flags & CMD_UPPERDFLAG)
|
||||
off += xsnprintf(buf + off, len - off, "D");
|
||||
if (off < len && flags & CMD_DFLAG)
|
||||
off += xsnprintf(buf + off, len - off, "d");
|
||||
if (off < len && flags & CMD_GFLAG)
|
||||
@ -93,6 +109,8 @@ cmd_print_flags(char *buf, size_t len, size_t off, int flags)
|
||||
off += xsnprintf(buf + off, len - off, "k");
|
||||
if (off < len && flags & CMD_UFLAG)
|
||||
off += xsnprintf(buf + off, len - off, "u");
|
||||
if (off < len && flags & CMD_UPPERUFLAG)
|
||||
off += xsnprintf(buf + off, len - off, "U");
|
||||
return (off - boff);
|
||||
}
|
||||
|
||||
|
111
cmd-rotate-window.c
Normal file
111
cmd-rotate-window.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* $Id: cmd-rotate-window.c,v 1.1 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Rotate the panes in a window.
|
||||
*/
|
||||
|
||||
void cmd_rotate_window_init(struct cmd *, int);
|
||||
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
||||
|
||||
const struct cmd_entry cmd_rotate_window_entry = {
|
||||
"rotate-window", "rotatew",
|
||||
CMD_TARGET_WINDOW_USAGE,
|
||||
CMD_UPPERUFLAG|CMD_UPPERDFLAG,
|
||||
cmd_rotate_window_init,
|
||||
cmd_target_parse,
|
||||
cmd_rotate_window_exec,
|
||||
cmd_target_send,
|
||||
cmd_target_recv,
|
||||
cmd_target_free,
|
||||
cmd_target_print
|
||||
};
|
||||
|
||||
void
|
||||
cmd_rotate_window_init(struct cmd *self, int key)
|
||||
{
|
||||
struct cmd_target_data *data;
|
||||
|
||||
cmd_target_init(self, key);
|
||||
data = self->data;
|
||||
|
||||
if (key == KEYC_ADDESC('o'))
|
||||
data->flags |= CMD_UPPERDFLAG;
|
||||
}
|
||||
|
||||
int
|
||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_target_data *data = self->data;
|
||||
struct winlink *wl;
|
||||
struct window *w;
|
||||
struct window_pane *wp, *wp2;
|
||||
u_int sx, sy, xoff, yoff;
|
||||
|
||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
||||
return (-1);
|
||||
w = wl->window;
|
||||
|
||||
if (data->flags & CMD_UPPERDFLAG) {
|
||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||
|
||||
xoff = wp->xoff; yoff = wp->yoff;
|
||||
sx = wp->sx; sy = wp->sy;
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL)
|
||||
break;
|
||||
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
||||
window_pane_resize(wp, wp2->sx, wp2->sy);
|
||||
}
|
||||
wp->xoff = xoff; wp->yoff = yoff;
|
||||
window_pane_resize(wp, sx, sy);
|
||||
|
||||
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
|
||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
window_set_active_pane(w, wp);
|
||||
} else {
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||
TAILQ_INSERT_TAIL(&w->panes, wp, entry);
|
||||
|
||||
xoff = wp->xoff; yoff = wp->yoff;
|
||||
sx = wp->sx; sy = wp->sy;
|
||||
TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) {
|
||||
if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL)
|
||||
break;
|
||||
wp->xoff = wp2->xoff; wp->yoff = wp2->yoff;
|
||||
window_pane_resize(wp, wp2->sx, wp2->sy);
|
||||
}
|
||||
wp->xoff = xoff; wp->yoff = yoff;
|
||||
window_pane_resize(wp, sx, sy);
|
||||
|
||||
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
window_set_active_pane(w, wp);
|
||||
}
|
||||
|
||||
layout_refresh(w, 0);
|
||||
|
||||
return (0);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-split-window.c,v 1.11 2009-04-01 21:10:08 nicm Exp $ */
|
||||
/* $Id: cmd-split-window.c,v 1.12 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -24,7 +24,7 @@
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Create a new window.
|
||||
* Split a window (add a new pane).
|
||||
*/
|
||||
|
||||
int cmd_split_window_parse(struct cmd *, int, char **, char **);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-swap-pane.c,v 1.3 2009-04-02 23:38:37 nicm Exp $ */
|
||||
/* $Id: cmd-swap-pane.c,v 1.4 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,13 +39,13 @@ struct cmd_swap_pane_data {
|
||||
int src;
|
||||
int dst;
|
||||
int flag_detached;
|
||||
int flag_next;
|
||||
int flag_previous;
|
||||
int flag_up;
|
||||
int flag_down;
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_swap_pane_entry = {
|
||||
"swap-pane", "swapp",
|
||||
"[-dnr] [-t target-window] [-p src-index] [-q dst-index]",
|
||||
"[-dDU] [-t target-window] [-p src-index] [-q dst-index]",
|
||||
0,
|
||||
cmd_swap_pane_init,
|
||||
cmd_swap_pane_parse,
|
||||
@ -66,15 +66,15 @@ cmd_swap_pane_init(struct cmd *self, int key)
|
||||
data->src = -1;
|
||||
data->dst = -1;
|
||||
data->flag_detached = 0;
|
||||
data->flag_next = 0;
|
||||
data->flag_previous = 0;
|
||||
data->flag_up = 0;
|
||||
data->flag_down = 0;
|
||||
|
||||
switch (key) {
|
||||
case '}':
|
||||
data->flag_next = 1;
|
||||
break;
|
||||
case '{':
|
||||
data->flag_previous = 1;
|
||||
data->flag_up = 1;
|
||||
break;
|
||||
case '}':
|
||||
data->flag_down = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -89,14 +89,14 @@ cmd_swap_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
||||
self->entry->init(self, 0);
|
||||
data = self->data;
|
||||
|
||||
while ((opt = getopt(argc, argv, "dt:np:q:r")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "dDt:p:q:U")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
data->flag_detached = 1;
|
||||
break;
|
||||
case 'n':
|
||||
data->flag_next = 1;
|
||||
data->flag_previous = 0;
|
||||
case 'D':
|
||||
data->flag_up = 0;
|
||||
data->flag_down = 1;
|
||||
data->dst = -1;
|
||||
break;
|
||||
case 't':
|
||||
@ -122,12 +122,12 @@ cmd_swap_pane_parse(struct cmd *self, int argc, char **argv, char **cause)
|
||||
}
|
||||
data->dst = n;
|
||||
}
|
||||
data->flag_next = 0;
|
||||
data->flag_previous = 0;
|
||||
data->flag_up = 0;
|
||||
data->flag_down = 0;
|
||||
break;
|
||||
case 'r':
|
||||
data->flag_next = 0;
|
||||
data->flag_previous = 1;
|
||||
case 'U':
|
||||
data->flag_up = 1;
|
||||
data->flag_down = 0;
|
||||
data->dst = -1;
|
||||
break;
|
||||
|
||||
@ -185,14 +185,14 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
if (data->dst == -1 && data->flag_next) {
|
||||
if ((dst_wp = TAILQ_NEXT(src_wp, entry)) == NULL)
|
||||
dst_wp = TAILQ_FIRST(&w->panes);
|
||||
}
|
||||
if (data->dst == -1 && data->flag_previous) {
|
||||
if (data->dst == -1 && data->flag_up) {
|
||||
if ((dst_wp = TAILQ_PREV(src_wp, window_panes, entry)) == NULL)
|
||||
dst_wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
}
|
||||
if (data->dst == -1 && data->flag_down) {
|
||||
if ((dst_wp = TAILQ_NEXT(src_wp, entry)) == NULL)
|
||||
dst_wp = TAILQ_FIRST(&w->panes);
|
||||
}
|
||||
|
||||
if (src_wp == dst_wp)
|
||||
return (0);
|
||||
@ -266,14 +266,14 @@ cmd_swap_pane_print(struct cmd *self, char *buf, size_t len)
|
||||
if (data == NULL)
|
||||
return (off);
|
||||
if (off < len &&
|
||||
(data->flag_next || data->flag_previous || data->flag_detached)) {
|
||||
(data->flag_down || data->flag_up || data->flag_detached)) {
|
||||
off += xsnprintf(buf + off, len - off, " -");
|
||||
if (off < len && data->flag_detached)
|
||||
off += xsnprintf(buf + off, len - off, "d");
|
||||
if (off < len && data->flag_next)
|
||||
off += xsnprintf(buf + off, len - off, "n");
|
||||
if (off < len && data->flag_previous)
|
||||
off += xsnprintf(buf + off, len - off, "r");
|
||||
if (off < len && data->flag_up)
|
||||
off += xsnprintf(buf + off, len - off, "D");
|
||||
if (off < len && data->flag_down)
|
||||
off += xsnprintf(buf + off, len - off, "U");
|
||||
}
|
||||
if (off < len && data->target != NULL)
|
||||
off += cmd_prarg(buf + off, len - off, " -t ", data->target);
|
||||
|
3
cmd.c
3
cmd.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd.c,v 1.88 2009-04-02 23:28:16 nicm Exp $ */
|
||||
/* $Id: cmd.c,v 1.89 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -67,6 +67,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_resize_pane_down_entry,
|
||||
&cmd_resize_pane_up_entry,
|
||||
&cmd_respawn_window_entry,
|
||||
&cmd_rotate_window_entry,
|
||||
&cmd_save_buffer_entry,
|
||||
&cmd_scroll_mode_entry,
|
||||
&cmd_select_pane_entry,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: key-bindings.c,v 1.65 2009-04-02 23:28:16 nicm Exp $ */
|
||||
/* $Id: key-bindings.c,v 1.66 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -128,6 +128,8 @@ key_bindings_init(void)
|
||||
{ KEYC_ADDESC(KEYC_DOWN), 1, &cmd_resize_pane_down_entry },
|
||||
{ KEYC_ADDCTL(KEYC_UP), 1, &cmd_resize_pane_up_entry },
|
||||
{ KEYC_ADDCTL(KEYC_DOWN), 1, &cmd_resize_pane_down_entry },
|
||||
{ KEYC_ADDESC('o'), 0, &cmd_rotate_window_entry },
|
||||
{ '\017', 0, &cmd_rotate_window_entry },
|
||||
};
|
||||
u_int i;
|
||||
struct cmd *cmd;
|
||||
|
6
tmux.h
6
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.298 2009-04-02 23:28:16 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.299 2009-04-03 17:21:46 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -910,6 +910,9 @@ struct cmd_entry {
|
||||
#define CMD_GFLAG 0x40
|
||||
#define CMD_UFLAG 0x80
|
||||
#define CMD_AFLAG 0x100
|
||||
#define CMD_UPPERUFLAG 0x200
|
||||
#define CMD_UPPERDFLAG 0x400
|
||||
|
||||
int flags;
|
||||
|
||||
void (*init)(struct cmd *, int);
|
||||
@ -1211,6 +1214,7 @@ extern const struct cmd_entry cmd_rename_window_entry;
|
||||
extern const struct cmd_entry cmd_resize_pane_down_entry;
|
||||
extern const struct cmd_entry cmd_resize_pane_up_entry;
|
||||
extern const struct cmd_entry cmd_respawn_window_entry;
|
||||
extern const struct cmd_entry cmd_rotate_window_entry;
|
||||
extern const struct cmd_entry cmd_save_buffer_entry;
|
||||
extern const struct cmd_entry cmd_scroll_mode_entry;
|
||||
extern const struct cmd_entry cmd_select_pane_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user