summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/cmd-capture-pane.c97
-rw-r--r--usr.bin/tmux/cmd-show-options.c22
-rw-r--r--usr.bin/tmux/tmux.114
3 files changed, 75 insertions, 58 deletions
diff --git a/usr.bin/tmux/cmd-capture-pane.c b/usr.bin/tmux/cmd-capture-pane.c
index c172cc604c6..6f7bd0ef9eb 100644
--- a/usr.bin/tmux/cmd-capture-pane.c
+++ b/usr.bin/tmux/cmd-capture-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-capture-pane.c,v 1.20 2013/03/25 10:02:17 nicm Exp $ */
+/* $OpenBSD: cmd-capture-pane.c,v 1.21 2013/03/25 10:04:04 nicm Exp $ */
/*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
@@ -31,8 +31,8 @@ enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_capture_pane_entry = {
"capture-pane", "capturep",
- "ab:CeE:JpS:t:", 0, 0,
- "[-aCeJp] [-b buffer-index] [-E end-line] [-S start-line]"
+ "ab:CeE:JpqS:t:", 0, 0,
+ "[-aCeJpq] [-b buffer-index] [-E end-line] [-S start-line]"
CMD_TARGET_PANE_USAGE,
0,
NULL,
@@ -62,7 +62,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
s = NULL;
gd = wp->saved_grid;
sx = screen_size_x(&wp->base);
- if (gd == NULL) {
+ if (gd == NULL && !args_has(args, 'q')) {
cmdq_error(cmdq, "no alternate screen");
return (CMD_RETURN_ERROR);
}
@@ -75,54 +75,57 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
buf = NULL;
len = 0;
- n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
- if (cause != NULL) {
- top = gd->hsize;
- free(cause);
- } else if (n < 0 && (u_int) -n > gd->hsize)
- top = 0;
- else
- top = gd->hsize + n;
- if (top > gd->hsize + gd->sy - 1)
- top = gd->hsize + gd->sy - 1;
-
- n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
- if (cause != NULL) {
- bottom = gd->hsize + gd->sy - 1;
- free(cause);
- } else if (n < 0 && (u_int) -n > gd->hsize)
- bottom = 0;
- else
- bottom = gd->hsize + n;
- if (bottom > gd->hsize + gd->sy - 1)
- bottom = gd->hsize + gd->sy - 1;
-
- if (bottom < top) {
- tmp = bottom;
- bottom = top;
- top = tmp;
- }
+ if (gd != NULL) {
+ n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
+ if (cause != NULL) {
+ top = gd->hsize;
+ free(cause);
+ } else if (n < 0 && (u_int) -n > gd->hsize)
+ top = 0;
+ else
+ top = gd->hsize + n;
+ if (top > gd->hsize + gd->sy - 1)
+ top = gd->hsize + gd->sy - 1;
+
+ n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
+ if (cause != NULL) {
+ bottom = gd->hsize + gd->sy - 1;
+ free(cause);
+ } else if (n < 0 && (u_int) -n > gd->hsize)
+ bottom = 0;
+ else
+ bottom = gd->hsize + n;
+ if (bottom > gd->hsize + gd->sy - 1)
+ bottom = gd->hsize + gd->sy - 1;
+
+ if (bottom < top) {
+ tmp = bottom;
+ bottom = top;
+ top = tmp;
+ }
- with_codes = args_has(args, 'e');
- escape_c0 = args_has(args, 'C');
- join_lines = args_has(args, 'J');
+ with_codes = args_has(args, 'e');
+ escape_c0 = args_has(args, 'C');
+ join_lines = args_has(args, 'J');
- gc = NULL;
- for (i = top; i <= bottom; i++) {
- line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
- escape_c0);
- linelen = strlen(line);
+ gc = NULL;
+ for (i = top; i <= bottom; i++) {
+ line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
+ escape_c0);
+ linelen = strlen(line);
- buf = xrealloc(buf, 1, len + linelen + 1);
- memcpy(buf + len, line, linelen);
- len += linelen;
+ buf = xrealloc(buf, 1, len + linelen + 1);
+ memcpy(buf + len, line, linelen);
+ len += linelen;
- gl = grid_peek_line(gd, i);
- if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED))
- buf[len++] = '\n';
+ gl = grid_peek_line(gd, i);
+ if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED))
+ buf[len++] = '\n';
- free(line);
- }
+ free(line);
+ }
+ } else
+ buf = xstrdup("");
if (args_has(args, 'p')) {
c = cmdq->client;
diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c
index 16e46951acb..4949482c037 100644
--- a/usr.bin/tmux/cmd-show-options.c
+++ b/usr.bin/tmux/cmd-show-options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-show-options.c,v 1.19 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-show-options.c,v 1.20 2013/03/25 10:04:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,14 +30,14 @@
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_show_options_one(struct cmd *, struct cmd_q *,
- struct options *);
+ struct options *, int);
enum cmd_retval cmd_show_options_all(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *);
const struct cmd_entry cmd_show_options_entry = {
"show-options", "show",
- "gst:vw", 0, 1,
- "[-gsvw] [-t target-session|target-window] [option]",
+ "gqst:vw", 0, 1,
+ "[-gqsvw] [-t target-session|target-window] [option]",
0,
NULL,
NULL,
@@ -62,6 +62,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
struct winlink *wl;
const struct options_table_entry *table;
struct options *oo;
+ int quiet;
if (args_has(self->args, 's')) {
oo = &global_options;
@@ -89,15 +90,16 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
}
}
- if (args->argc != 0)
- return (cmd_show_options_one(self, cmdq, oo));
- else
+ quiet = args_has(self->args, 'q');
+ if (args->argc == 0)
return (cmd_show_options_all(self, cmdq, table, oo));
+ else
+ return (cmd_show_options_one(self, cmdq, oo, quiet));
}
enum cmd_retval
cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
- struct options *oo)
+ struct options *oo, int quiet)
{
struct args *args = self->args;
const struct options_table_entry *table, *oe;
@@ -106,6 +108,8 @@ cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
if (*args->argv[0] == '@') {
if ((o = options_find1(oo, args->argv[0])) == NULL) {
+ if (quiet)
+ return (CMD_RETURN_NORMAL);
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
@@ -122,6 +126,8 @@ cmd_show_options_one(struct cmd *self, struct cmd_q *cmdq,
return (CMD_RETURN_ERROR);
}
if (oe == NULL) {
+ if (quiet)
+ return (CMD_RETURN_NORMAL);
cmdq_error(cmdq, "unknown option: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index b3794831a16..7e095b371d7 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.339 2013/03/25 10:02:17 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.340 2013/03/25 10:04:04 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -1062,7 +1062,7 @@ By default, it uses the format
but a different format may be specified with
.Fl F .
.It Xo Ic capture-pane
-.Op Fl aep
+.Op Fl aepq
.Op Fl b Ar buffer-index
.Op Fl E Ar end-line
.Op Fl S Ar start-line
@@ -1078,6 +1078,9 @@ or a new buffer if omitted.
If
.Fl a
is given, the alternate screen is used, and the history is not accessible.
+If no alternate screen exists, an error will be returned unless
+.Fl q
+is given.
If
.Fl e
is given, the output includes escape sequences for text and background
@@ -2948,7 +2951,7 @@ If this option is set, searches will wrap around the end of the pane contents.
The default is on.
.El
.It Xo Ic show-options
-.Op Fl gsvw
+.Op Fl gqsvw
.Op Fl t Ar target-session | Ar target-window
.Op Ar option
.Xc
@@ -2966,6 +2969,11 @@ Global session or window options are listed if
is used.
.Fl v
shows only the option value, not the name.
+If
+.Fl q
+is set, no error will be returned if
+.Ar option
+is unset.
.It Xo Ic show-window-options
.Op Fl gv
.Op Fl t Ar target-window