summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-14 23:49:23 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-14 23:49:23 +0000
commit4f34e25dd867e30652682d9aac01d8b1af220fa6 (patch)
tree864efa4c724a6d295c4dbd7437db2677a62fb843 /cmd-new-session.c
parent9ad9e8c5dded2e9134a8386bacd1ddd6625e07d1 (diff)
Support -x and -y for new-session to specify the initial size of the
window if created detached with -d.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index d53e2692..1aa1c087 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <pwd.h>
+#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
@@ -34,8 +35,9 @@ int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new",
- "dn:s:t:", 0, 1,
- "[-d] [-n window-name] [-s session-name] [-t target-session] [command]",
+ "dn:s:t:x:y:", 0, 1,
+ "[-d] [-n window-name] [-s session-name] [-t target-session] "
+ "[-x width] [-y height] [command]",
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
NULL,
cmd_new_session_check,
@@ -47,6 +49,9 @@ cmd_new_session_check(struct args *args)
{
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
return (-1);
+ if (!args_has(args, 'd') &&
+ (args_has(args, 'x') || args_has(args, 'y')))
+ return (-1);
return (0);
}
@@ -60,7 +65,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct environ env;
struct termios tio, *tiop;
struct passwd *pw;
- const char *newname, *target, *update, *cwd;
+ const char *newname, *target, *update, *cwd, *errstr;
char *overrides, *cmd, *cause;
int detached, idx;
u_int sx, sy, i;
@@ -149,6 +154,22 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (detached) {
sx = 80;
sy = 24;
+ if (args_has(args, 'x')) {
+ sx = strtonum(
+ args_get(args, 'x'), 1, USHRT_MAX, &errstr);
+ if (errstr != NULL) {
+ ctx->error(ctx, "width %s", errstr);
+ return (-1);
+ }
+ }
+ if (args_has(args, 'y')) {
+ sy = strtonum(
+ args_get(args, 'y'), 1, USHRT_MAX, &errstr);
+ if (errstr != NULL) {
+ ctx->error(ctx, "height %s", errstr);
+ return (-1);
+ }
+ }
} else if (ctx->cmdclient != NULL) {
sx = ctx->cmdclient->tty.sx;
sy = ctx->cmdclient->tty.sy;