mirror of
https://github.com/tmux/tmux.git
synced 2025-03-22 21:08:49 +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 char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
|
||||
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
|
||||
size_t *);
|
||||
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
|
||||
};
|
||||
|
||||
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 *
|
||||
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
size_t *len)
|
||||
@ -95,11 +85,11 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
|
||||
tmp[1] = '\0';
|
||||
} else
|
||||
xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
|
||||
buf = cmd_capture_pane_append(buf, len, tmp,
|
||||
buf = append_string(buf, len, tmp,
|
||||
strlen(tmp));
|
||||
}
|
||||
} else
|
||||
buf = cmd_capture_pane_append(buf, len, line, linelen);
|
||||
buf = append_string(buf, len, line, linelen);
|
||||
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);
|
||||
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);
|
||||
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)
|
||||
h = tty->sy;
|
||||
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)
|
||||
w = 80;
|
||||
if (h == 0)
|
||||
@ -493,7 +494,8 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
else if (args_has(args, 'E'))
|
||||
flags |= POPUP_CLOSEEXIT;
|
||||
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);
|
||||
if (env != NULL)
|
||||
environ_free(env);
|
||||
|
@ -262,7 +262,8 @@ control_notify_paste_buffer_deleted(const char *name)
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
@ -227,8 +227,7 @@ control_free_sub(struct control_state *cs, struct control_sub *csub)
|
||||
static void
|
||||
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)
|
||||
evbuffer_free(cb->buffer);
|
||||
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. */
|
||||
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);
|
||||
|
||||
@ -444,7 +444,6 @@ control_write_buffer(struct client *c, struct evbuffer *buffer)
|
||||
{
|
||||
struct control_state *cs = c->control_state;
|
||||
struct control_block *cb;
|
||||
va_list ap;
|
||||
|
||||
if (TAILQ_EMPTY(&cs->all_blocks)) {
|
||||
control_vwrite_buffer(c, buffer);
|
||||
@ -452,8 +451,6 @@ control_write_buffer(struct client *c, struct evbuffer *buffer)
|
||||
}
|
||||
|
||||
control_enqueue(c, cs, NULL, buffer);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/* Write a line. */
|
||||
|
23
popup.c
23
popup.c
@ -615,16 +615,6 @@ popup_job_update_cb(struct job *job)
|
||||
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
|
||||
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);
|
||||
linelen = strlen(line);
|
||||
|
||||
buf = popup_append(buf, &len, line, linelen);
|
||||
buf = append_string(buf, &len, line, linelen);
|
||||
|
||||
gl = grid_peek_line(gd, i);
|
||||
if (!(gl->flags & GRID_LINE_WRAPPED))
|
||||
@ -679,11 +669,12 @@ popup_job_complete_cb(struct job *job)
|
||||
}
|
||||
|
||||
int
|
||||
popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
||||
u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd,
|
||||
int argc, char **argv, const char *cwd, const char *title, struct client *c,
|
||||
struct session *s, const char *style, const char *border_style,
|
||||
popup_close_cb cb, void *arg, struct window_pane *wp)
|
||||
popup_display(int flags, enum box_lines lines, struct cmdq_item *item,
|
||||
u_int px, u_int py, u_int sx, u_int sy, struct environ *env,
|
||||
const char *shellcmd, int argc, char **argv, const char *cwd,
|
||||
const char *title, struct client *c, struct session *s, const char *style,
|
||||
const char *border_style, popup_close_cb cb, void *arg,
|
||||
struct window_pane *wp)
|
||||
{
|
||||
struct popup_data *pd;
|
||||
u_int jx, jy;
|
||||
|
9
tmux.c
9
tmux.c
@ -319,6 +319,15 @@ find_cwd(void)
|
||||
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 *
|
||||
find_home(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user