mirror of
https://github.com/tmux/tmux.git
synced 2025-03-28 01:08:53 +00:00
Add a -M flag to capture-pane to use the copy mode screen, GitHub issue
4358.
This commit is contained in:
parent
18331e39bf
commit
084e6ee9ec
@ -39,8 +39,8 @@ const struct cmd_entry cmd_capture_pane_entry = {
|
|||||||
.name = "capture-pane",
|
.name = "capture-pane",
|
||||||
.alias = "capturep",
|
.alias = "capturep",
|
||||||
|
|
||||||
.args = { "ab:CeE:JNpPqS:Tt:", 0, 0, NULL },
|
.args = { "ab:CeE:JMNpPqS:Tt:", 0, 0, NULL },
|
||||||
.usage = "[-aCeJNpPqT] " CMD_BUFFER_USAGE " [-E end-line] "
|
.usage = "[-aCeJMNpPqT] " CMD_BUFFER_USAGE " [-E end-line] "
|
||||||
"[-S start-line] " CMD_TARGET_PANE_USAGE,
|
"[-S start-line] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@ -107,14 +107,16 @@ static char *
|
|||||||
cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
||||||
struct window_pane *wp, size_t *len)
|
struct window_pane *wp, size_t *len)
|
||||||
{
|
{
|
||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
const struct grid_line *gl;
|
const struct grid_line *gl;
|
||||||
struct grid_cell *gc = NULL;
|
struct screen *s;
|
||||||
int n, join_lines, flags = 0;
|
struct grid_cell *gc = NULL;
|
||||||
u_int i, sx, top, bottom, tmp;
|
struct window_mode_entry *wme;
|
||||||
char *cause, *buf, *line;
|
int n, join_lines, flags = 0;
|
||||||
const char *Sflag, *Eflag;
|
u_int i, sx, top, bottom, tmp;
|
||||||
size_t linelen;
|
char *cause, *buf, *line;
|
||||||
|
const char *Sflag, *Eflag;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
sx = screen_size_x(&wp->base);
|
sx = screen_size_x(&wp->base);
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
@ -126,8 +128,20 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
}
|
}
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
}
|
}
|
||||||
} else
|
s = &wp->base;
|
||||||
|
} else if (args_has(args, 'M')) {
|
||||||
|
wme = TAILQ_FIRST(&wp->modes);
|
||||||
|
if (wme != NULL && wme->mode->get_screen != NULL) {
|
||||||
|
s = wme->mode->get_screen (wme);
|
||||||
|
gd = s->grid;
|
||||||
|
} else {
|
||||||
|
s = &wp->base;
|
||||||
|
gd = wp->base.grid;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s = &wp->base;
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
|
}
|
||||||
|
|
||||||
Sflag = args_get(args, 'S');
|
Sflag = args_get(args, 'S');
|
||||||
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
if (Sflag != NULL && strcmp(Sflag, "-") == 0)
|
||||||
@ -181,7 +195,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
for (i = top; i <= bottom; i++) {
|
for (i = top; i <= bottom; i++) {
|
||||||
line = grid_string_cells(gd, 0, i, sx, &gc, flags, wp->screen);
|
line = grid_string_cells(gd, 0, i, sx, &gc, flags, s);
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
|
|
||||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||||
|
5
tmux.1
5
tmux.1
@ -2554,7 +2554,7 @@ but a different format may be specified with
|
|||||||
.Fl F .
|
.Fl F .
|
||||||
.Tg capturep
|
.Tg capturep
|
||||||
.It Xo Ic capture-pane
|
.It Xo Ic capture-pane
|
||||||
.Op Fl aAepPqCJN
|
.Op Fl aepPqCJMN
|
||||||
.Op Fl b Ar buffer-name
|
.Op Fl b Ar buffer-name
|
||||||
.Op Fl E Ar end-line
|
.Op Fl E Ar end-line
|
||||||
.Op Fl S Ar start-line
|
.Op Fl S Ar start-line
|
||||||
@ -2573,6 +2573,9 @@ is given, the alternate screen is used, and the history is not accessible.
|
|||||||
If no alternate screen exists, an error will be returned unless
|
If no alternate screen exists, an error will be returned unless
|
||||||
.Fl q
|
.Fl q
|
||||||
is given.
|
is given.
|
||||||
|
Similarly, if the pane is in a mode,
|
||||||
|
.Fl M
|
||||||
|
uses the screen for the mode.
|
||||||
If
|
If
|
||||||
.Fl e
|
.Fl e
|
||||||
is given, the output includes escape sequences for text and background
|
is given, the output includes escape sequences for text and background
|
||||||
|
1
tmux.h
1
tmux.h
@ -1059,6 +1059,7 @@ struct window_mode {
|
|||||||
struct mouse_event *);
|
struct mouse_event *);
|
||||||
void (*formats)(struct window_mode_entry *,
|
void (*formats)(struct window_mode_entry *,
|
||||||
struct format_tree *);
|
struct format_tree *);
|
||||||
|
struct screen *(*get_screen)(struct window_mode_entry *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Active window mode. */
|
/* Active window mode. */
|
||||||
|
@ -40,6 +40,7 @@ static void window_copy_free(struct window_mode_entry *);
|
|||||||
static void window_copy_resize(struct window_mode_entry *, u_int, u_int);
|
static void window_copy_resize(struct window_mode_entry *, u_int, u_int);
|
||||||
static void window_copy_formats(struct window_mode_entry *,
|
static void window_copy_formats(struct window_mode_entry *,
|
||||||
struct format_tree *);
|
struct format_tree *);
|
||||||
|
static struct screen *window_copy_get_screen(struct window_mode_entry *);
|
||||||
static void window_copy_scroll1(struct window_mode_entry *,
|
static void window_copy_scroll1(struct window_mode_entry *,
|
||||||
struct window_pane *wp, int, u_int, int);
|
struct window_pane *wp, int, u_int, int);
|
||||||
static void window_copy_pageup1(struct window_mode_entry *, int);
|
static void window_copy_pageup1(struct window_mode_entry *, int);
|
||||||
@ -160,6 +161,7 @@ const struct window_mode window_copy_mode = {
|
|||||||
.key_table = window_copy_key_table,
|
.key_table = window_copy_key_table,
|
||||||
.command = window_copy_command,
|
.command = window_copy_command,
|
||||||
.formats = window_copy_formats,
|
.formats = window_copy_formats,
|
||||||
|
.get_screen = window_copy_get_screen
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct window_mode window_view_mode = {
|
const struct window_mode window_view_mode = {
|
||||||
@ -171,6 +173,7 @@ const struct window_mode window_view_mode = {
|
|||||||
.key_table = window_copy_key_table,
|
.key_table = window_copy_key_table,
|
||||||
.command = window_copy_command,
|
.command = window_copy_command,
|
||||||
.formats = window_copy_formats,
|
.formats = window_copy_formats,
|
||||||
|
.get_screen = window_copy_get_screen
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -972,6 +975,14 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft)
|
|||||||
window_copy_cursor_hyperlink_cb);
|
window_copy_cursor_hyperlink_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct screen *
|
||||||
|
window_copy_get_screen(struct window_mode_entry *wme)
|
||||||
|
{
|
||||||
|
struct window_copy_mode_data *data = wme->data;
|
||||||
|
|
||||||
|
return (data->backing);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
window_copy_size_changed(struct window_mode_entry *wme)
|
window_copy_size_changed(struct window_mode_entry *wme)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user