mirror of
https://github.com/tmux/tmux.git
synced 2025-12-24 17:56:02 +00:00
Restore -n, now after the command.
This commit is contained in:
51
op.c
51
op.c
@@ -1,4 +1,4 @@
|
||||
/* $Id: op.c,v 1.1 2007-09-26 13:43:15 nicm Exp $ */
|
||||
/* $Id: op.c,v 1.2 2007-09-26 14:08:16 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@@ -27,14 +28,32 @@ op_new(char *path, int argc, unused char **argv)
|
||||
{
|
||||
struct new_data data;
|
||||
struct client_ctx cctx;
|
||||
char name[MAXNAMELEN];
|
||||
int opt;
|
||||
|
||||
if (argc != 0) /* XXX -n */
|
||||
return (usage("new"));
|
||||
optind = 1;
|
||||
while ((opt = getopt(argc, argv, "n:?")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
if (strlcpy(name, optarg, sizeof name) >= sizeof name) {
|
||||
log_warnx("%s: session name too long", optarg);
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
return (usage("new [-n session]"));
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 0)
|
||||
return (usage("new [-n session]"));
|
||||
|
||||
if (client_init(path, &cctx, 1) != 0)
|
||||
return (1);
|
||||
|
||||
strlcpy(data.name, "XXX"/*XXX*/, sizeof data.name);
|
||||
strlcpy(data.name, name, sizeof data.name);
|
||||
data.sx = cctx.ws.ws_col;
|
||||
data.sy = cctx.ws.ws_row;
|
||||
client_write_server(&cctx, MSG_NEW, &data, sizeof data);
|
||||
@@ -47,14 +66,32 @@ op_attach(char *path, int argc, unused char **argv)
|
||||
{
|
||||
struct attach_data data;
|
||||
struct client_ctx cctx;
|
||||
char name[MAXNAMELEN];
|
||||
int opt;
|
||||
|
||||
if (argc != 0) /* XXX -n */
|
||||
return (usage("attach"));
|
||||
optind = 1;
|
||||
while ((opt = getopt(argc, argv, "n:?")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
if (strlcpy(name, optarg, sizeof name) >= sizeof name) {
|
||||
log_warnx("%s: session name too long", optarg);
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
return (usage("attach [-n session]"));
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 0)
|
||||
return (usage("attach [-n session]"));
|
||||
|
||||
if (client_init(path, &cctx, 1) != 0)
|
||||
return (1);
|
||||
|
||||
strlcpy(data.name, "XXX"/*XXX*/, sizeof data.name);
|
||||
strlcpy(data.name, name, sizeof data.name);
|
||||
data.sx = cctx.ws.ws_col;
|
||||
data.sy = cctx.ws.ws_row;
|
||||
client_write_server(&cctx, MSG_ATTACH, &data, sizeof data);
|
||||
|
||||
Reference in New Issue
Block a user