mirror of
https://github.com/tmux/tmux.git
synced 2025-03-25 07:18:48 +00:00
Respond to code review comments
This commit is contained in:
parent
5fcda70d0c
commit
cf3b038d5c
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *);
|
static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *);
|
||||||
|
|
||||||
static char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
|
||||||
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||||
size_t *);
|
size_t *);
|
||||||
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
|
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
|
||||||
@ -62,15 +61,6 @@ const struct cmd_entry cmd_clear_history_entry = {
|
|||||||
.exec = cmd_capture_pane_exec
|
.exec = cmd_capture_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
|
||||||
cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen)
|
|
||||||
{
|
|
||||||
buf = xrealloc(buf, *len + linelen + 1);
|
|
||||||
memcpy(buf + *len, line, linelen);
|
|
||||||
*len += linelen;
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||||
size_t *len)
|
size_t *len)
|
||||||
@ -95,11 +85,11 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
|||||||
tmp[1] = '\0';
|
tmp[1] = '\0';
|
||||||
} else
|
} else
|
||||||
xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
|
xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
|
||||||
buf = cmd_capture_pane_append(buf, len, tmp,
|
buf = append_string(buf, len, tmp,
|
||||||
strlen(tmp));
|
strlen(tmp));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
buf = append_string(buf, len, line, linelen);
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +174,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
|
|||||||
line = grid_string_cells(gd, 0, i, sx, &gc, flags, wp->screen);
|
line = grid_string_cells(gd, 0, i, sx, &gc, flags, wp->screen);
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
|
|
||||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
buf = append_string(buf, len, line, linelen);
|
||||||
|
|
||||||
gl = grid_peek_line(gd, i);
|
gl = grid_peek_line(gd, i);
|
||||||
if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED))
|
if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED))
|
||||||
|
@ -433,7 +433,8 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (h > tty->sy)
|
if (h > tty->sy)
|
||||||
h = tty->sy;
|
h = tty->sy;
|
||||||
if (tc->flags & CLIENT_CONTROL) {
|
if (tc->flags & CLIENT_CONTROL) {
|
||||||
/* Control clients may not have a window size, so provide a reasonable default so popups can still work. */
|
/* Control clients may not have a window size, so provide a
|
||||||
|
* reasonable default so popups can still work. */
|
||||||
if (w == 0)
|
if (w == 0)
|
||||||
w = 80;
|
w = 80;
|
||||||
if (h == 0)
|
if (h == 0)
|
||||||
@ -493,7 +494,8 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
else if (args_has(args, 'E'))
|
else if (args_has(args, 'E'))
|
||||||
flags |= POPUP_CLOSEEXIT;
|
flags |= POPUP_CLOSEEXIT;
|
||||||
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc,
|
||||||
argv, cwd, title, tc, s, style, border_style, NULL, NULL, target->wp) != 0) {
|
argv, cwd, title, tc, s, style, border_style, NULL, NULL,
|
||||||
|
target->wp) != 0) {
|
||||||
cmd_free_argv(argc, argv);
|
cmd_free_argv(argc, argv);
|
||||||
if (env != NULL)
|
if (env != NULL)
|
||||||
environ_free(env);
|
environ_free(env);
|
||||||
|
@ -262,7 +262,8 @@ control_notify_paste_buffer_deleted(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
control_notify_popup(struct client *c, int status, char *buf, size_t len, int wp)
|
control_notify_popup(struct client *c, int status, char *buf, size_t len,
|
||||||
|
int wp)
|
||||||
{
|
{
|
||||||
struct evbuffer *message = evbuffer_new();
|
struct evbuffer *message = evbuffer_new();
|
||||||
|
|
||||||
|
@ -227,8 +227,7 @@ control_free_sub(struct control_state *cs, struct control_sub *csub)
|
|||||||
static void
|
static void
|
||||||
control_free_block(struct control_state *cs, struct control_block *cb)
|
control_free_block(struct control_state *cs, struct control_block *cb)
|
||||||
{
|
{
|
||||||
if (cb->line != NULL)
|
free(cb->line);
|
||||||
free(cb->line);
|
|
||||||
if (cb->buffer != NULL)
|
if (cb->buffer != NULL)
|
||||||
evbuffer_free(cb->buffer);
|
evbuffer_free(cb->buffer);
|
||||||
TAILQ_REMOVE(&cs->all_blocks, cb, all_entry);
|
TAILQ_REMOVE(&cs->all_blocks, cb, all_entry);
|
||||||
@ -421,7 +420,8 @@ control_vwrite_buffer(struct client *c, struct evbuffer *buffer)
|
|||||||
|
|
||||||
/* Frees line and buffer after using them asynchronously. */
|
/* Frees line and buffer after using them asynchronously. */
|
||||||
static void
|
static void
|
||||||
control_enqueue(struct client *c, struct control_state *cs, char *line, struct evbuffer *buffer)
|
control_enqueue(struct client *c, struct control_state *cs, char *line,
|
||||||
|
struct evbuffer *buffer)
|
||||||
{
|
{
|
||||||
struct control_block *cb = xcalloc(1, sizeof *cb);
|
struct control_block *cb = xcalloc(1, sizeof *cb);
|
||||||
|
|
||||||
@ -444,7 +444,6 @@ control_write_buffer(struct client *c, struct evbuffer *buffer)
|
|||||||
{
|
{
|
||||||
struct control_state *cs = c->control_state;
|
struct control_state *cs = c->control_state;
|
||||||
struct control_block *cb;
|
struct control_block *cb;
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&cs->all_blocks)) {
|
if (TAILQ_EMPTY(&cs->all_blocks)) {
|
||||||
control_vwrite_buffer(c, buffer);
|
control_vwrite_buffer(c, buffer);
|
||||||
@ -452,8 +451,6 @@ control_write_buffer(struct client *c, struct evbuffer *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
control_enqueue(c, cs, NULL, buffer);
|
control_enqueue(c, cs, NULL, buffer);
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a line. */
|
/* Write a line. */
|
||||||
|
23
popup.c
23
popup.c
@ -615,16 +615,6 @@ popup_job_update_cb(struct job *job)
|
|||||||
evbuffer_drain(evb, size);
|
evbuffer_drain(evb, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE TO REVIEWER: This is a copy of cmd_capture_pane_append. I think we'd want a shared implementation but I don't know where it should go.
|
|
||||||
static char *
|
|
||||||
popup_append(char *buf, size_t *len, char *line, size_t linelen)
|
|
||||||
{
|
|
||||||
buf = xrealloc(buf, *len + linelen + 1);
|
|
||||||
memcpy(buf + *len, line, linelen);
|
|
||||||
*len += linelen;
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
popup_notify_control(struct client *c, int status, struct screen *s, int wp)
|
popup_notify_control(struct client *c, int status, struct screen *s, int wp)
|
||||||
{
|
{
|
||||||
@ -643,7 +633,7 @@ popup_notify_control(struct client *c, int status, struct screen *s, int wp)
|
|||||||
line = grid_string_cells(gd, 0, i, sx, &gc, GRID_STRING_WITH_SEQUENCES, s);
|
line = grid_string_cells(gd, 0, i, sx, &gc, GRID_STRING_WITH_SEQUENCES, s);
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
|
|
||||||
buf = popup_append(buf, &len, line, linelen);
|
buf = append_string(buf, &len, line, linelen);
|
||||||
|
|
||||||
gl = grid_peek_line(gd, i);
|
gl = grid_peek_line(gd, i);
|
||||||
if (!(gl->flags & GRID_LINE_WRAPPED))
|
if (!(gl->flags & GRID_LINE_WRAPPED))
|
||||||
@ -679,11 +669,12 @@ popup_job_complete_cb(struct job *job)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
popup_display(int flags, enum box_lines lines, struct cmdq_item *item,
|
||||||
u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd,
|
u_int px, u_int py, u_int sx, u_int sy, struct environ *env,
|
||||||
int argc, char **argv, const char *cwd, const char *title, struct client *c,
|
const char *shellcmd, int argc, char **argv, const char *cwd,
|
||||||
struct session *s, const char *style, const char *border_style,
|
const char *title, struct client *c, struct session *s, const char *style,
|
||||||
popup_close_cb cb, void *arg, struct window_pane *wp)
|
const char *border_style, popup_close_cb cb, void *arg,
|
||||||
|
struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct popup_data *pd;
|
struct popup_data *pd;
|
||||||
u_int jx, jy;
|
u_int jx, jy;
|
||||||
|
9
tmux.c
9
tmux.c
@ -319,6 +319,15 @@ find_cwd(void)
|
|||||||
return (pwd);
|
return (pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
append_string(char *buf, size_t *len, char *line, size_t linelen)
|
||||||
|
{
|
||||||
|
buf = xrealloc(buf, *len + linelen + 1);
|
||||||
|
memcpy(buf + *len, line, linelen);
|
||||||
|
*len += linelen;
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
find_home(void)
|
find_home(void)
|
||||||
{
|
{
|
||||||
|
1
tmux.h
1
tmux.h
@ -2213,6 +2213,7 @@ const char *sig2name(int);
|
|||||||
const char *find_cwd(void);
|
const char *find_cwd(void);
|
||||||
const char *find_home(void);
|
const char *find_home(void);
|
||||||
const char *getversion(void);
|
const char *getversion(void);
|
||||||
|
char *append_string(char *buf, size_t *len, char *line, size_t linelen);
|
||||||
|
|
||||||
/* proc.c */
|
/* proc.c */
|
||||||
struct imsg;
|
struct imsg;
|
||||||
|
Loading…
Reference in New Issue
Block a user