mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-08 01:04:06 +01:00
Added window renaming support (tmux rename)
This commit is contained in:
parent
32a80a73a1
commit
d2e035f892
5
CHANGES
5
CHANGES
@ -1,3 +1,6 @@
|
||||
28 September 2007
|
||||
* (mxey) Added window remaming, like "tmux rename [-s session] [-i index] name"
|
||||
|
||||
27 September 2007
|
||||
|
||||
* Split "tmux list" into "tmux list-sessions" (ls) and "list-windows" (lsw).
|
||||
@ -55,5 +58,5 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.11 2007-09-27 10:14:10 nicm Exp $
|
||||
$Id: CHANGES,v 1.12 2007-09-28 21:41:51 mxey Exp $
|
||||
|
||||
|
3
TODO
3
TODO
@ -1,7 +1,6 @@
|
||||
- key remapping
|
||||
- decide if TIOCPKT is necessary and either handle it or remove the code
|
||||
- it would be nice if there wasn't so much copying buffers about, audit uses
|
||||
- window names
|
||||
- status bar
|
||||
- useful env vars like WINDOW
|
||||
- lots of scripting love: add, remove, move around windows, status bar
|
||||
@ -25,7 +24,7 @@
|
||||
i : show window info (show name, title, size, tty, ...)
|
||||
meta-meta : pass through meta (will need this...)
|
||||
- commands to add:
|
||||
rename window/sessions
|
||||
rename sessions
|
||||
swap windows
|
||||
link/copy windows
|
||||
detach session
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: client-cmd.c,v 1.4 2007-09-27 09:15:58 nicm Exp $ */
|
||||
/* $Id: client-cmd.c,v 1.5 2007-09-28 21:41:52 mxey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -53,8 +53,6 @@ struct cmd client_cmd_table[] = {
|
||||
{ 'p', client_cmd_fn_msg, MSG_PREVIOUS },
|
||||
{ 'R', client_cmd_fn_msg, MSG_REFRESH },
|
||||
{ 'r', client_cmd_fn_msg, MSG_REFRESH },
|
||||
{ 'T', client_cmd_fn_msg, MSG_RENAME },
|
||||
{ 't', client_cmd_fn_msg, MSG_RENAME },
|
||||
{ 'L', client_cmd_fn_msg, MSG_LAST },
|
||||
{ 'l', client_cmd_fn_msg, MSG_LAST },
|
||||
{ 'W', client_cmd_fn_msg, MSG_WINDOWLIST },
|
||||
|
54
op.c
54
op.c
@ -1,4 +1,4 @@
|
||||
/* $Id: op.c,v 1.6 2007-09-27 09:52:03 nicm Exp $ */
|
||||
/* $Id: op.c,v 1.7 2007-09-28 21:41:52 mxey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -101,3 +102,54 @@ op_attach(char *path, int argc, char **argv)
|
||||
return (client_main(&cctx));
|
||||
}
|
||||
|
||||
int
|
||||
op_rename(char *path, int argc, char **argv)
|
||||
{
|
||||
struct rename_data data;
|
||||
struct client_ctx cctx;
|
||||
char sname[MAXNAMELEN];
|
||||
int opt;
|
||||
const char *errstr;
|
||||
|
||||
*sname = '\0';
|
||||
data.idx = -1;
|
||||
optind = 1;
|
||||
while ((opt = getopt(argc, argv, "i:s:?")) != EOF) {
|
||||
switch (opt) {
|
||||
case 's':
|
||||
if (strlcpy(sname, optarg, sizeof sname)
|
||||
>= sizeof sname) {
|
||||
log_warnx("%s: session name too long", optarg);
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
data.idx = strtonum(optarg, 0, INT_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
log_warnx("%s: window index %s", optarg,
|
||||
errstr);
|
||||
return (1);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
return (usage("rename [-s session] [-i index] name"));
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 1)
|
||||
return (usage("rename [-s session] [-i index] name"));
|
||||
|
||||
if (client_init(path, &cctx, 1) != 0)
|
||||
return (1);
|
||||
|
||||
client_fill_sessid(&data.sid, sname);
|
||||
if ((strlcpy(data.newname, argv[0], sizeof data.newname)
|
||||
>= sizeof data.newname)) {
|
||||
log_warnx("%s: new window name too long", argv[0]);
|
||||
return (1);
|
||||
}
|
||||
client_write_server(&cctx, MSG_RENAME, &data, sizeof data);
|
||||
|
||||
return (client_flush(&cctx));
|
||||
}
|
||||
|
36
server-msg.c
36
server-msg.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server-msg.c,v 1.6 2007-09-28 21:08:30 nicm Exp $ */
|
||||
/* $Id: server-msg.c,v 1.7 2007-09-28 21:41:52 mxey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -385,12 +385,38 @@ server_msg_fn_windows(struct hdr *hdr, struct client *c)
|
||||
int
|
||||
server_msg_fn_rename(struct hdr *hdr, struct client *c)
|
||||
{
|
||||
if (c->session == NULL)
|
||||
return (0);
|
||||
if (hdr->size != 0)
|
||||
struct rename_data data;
|
||||
char *cause;
|
||||
struct window *w;
|
||||
struct session *s;
|
||||
|
||||
|
||||
if (hdr->size != sizeof data)
|
||||
fatalx("bad MSG_RENAME size");
|
||||
|
||||
fatalx("not implemented");
|
||||
buffer_read(c->in, &data, hdr->size);
|
||||
|
||||
data.newname[sizeof data.newname] = '\0';
|
||||
|
||||
if ((s = server_find_sessid(&data.sid, &cause)) == NULL) {
|
||||
/* XXX: Send message to client */
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (data.idx == -1)
|
||||
w = s->window;
|
||||
else
|
||||
w = window_at(&s->windows, data.idx);
|
||||
|
||||
if (w == NULL) {
|
||||
/* XXX: Send message to client */
|
||||
return (0);
|
||||
}
|
||||
|
||||
strlcpy(w->name, data.newname, sizeof w->name);
|
||||
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
/* Last window message from client */
|
||||
|
6
tmux.c
6
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.16 2007-09-27 20:54:43 nicm Exp $ */
|
||||
/* $Id: tmux.c,v 1.17 2007-09-28 21:41:52 mxey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -48,9 +48,7 @@ struct op op_table[] = {
|
||||
{ "list-sessions", "ls", op_list_sessions },
|
||||
{ "list-windows", "lsw", op_list_windows },
|
||||
{ "new-session", "new", op_new/*_session*/ },
|
||||
// { "new-window", "neww", op_new_window },
|
||||
// { "rename-window", "rw", op_rename_window },
|
||||
// { "rename-session", "rs", op_rename_session },
|
||||
{ "rename-window", NULL, op_rename },
|
||||
};
|
||||
#define NOP (sizeof op_table / sizeof op_table[0])
|
||||
|
||||
|
9
tmux.h
9
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.19 2007-09-28 19:04:21 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.20 2007-09-28 21:41:52 mxey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -341,6 +341,12 @@ struct refresh_data {
|
||||
u_int py_lower;
|
||||
};
|
||||
|
||||
struct rename_data {
|
||||
int idx;
|
||||
struct sessid sid;
|
||||
char newname[MAXNAMELEN];
|
||||
};
|
||||
|
||||
/* Attributes. */
|
||||
#define ATTR_BRIGHT 0x1
|
||||
#define ATTR_DIM 0x2
|
||||
@ -448,6 +454,7 @@ void sigreset(void);
|
||||
/* op.c */
|
||||
int op_new(char *, int, char **);
|
||||
int op_attach(char *, int, char **);
|
||||
int op_rename(char *, int, char **);
|
||||
|
||||
/* op-list.c */
|
||||
int op_list_sessions(char *, int, char **);
|
||||
|
Loading…
Reference in New Issue
Block a user