mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Merge branch 'obsd-master'
Conflicts: cmd-find.c
This commit is contained in:
commit
4acc8d0ff5
38
cmd-find.c
38
cmd-find.c
@ -50,6 +50,7 @@ struct cmd_find_state {
|
|||||||
int idx;
|
int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct session *cmd_find_try_TMUX(struct client *, struct window *);
|
||||||
int cmd_find_client_better(struct client *, struct client *);
|
int cmd_find_client_better(struct client *, struct client *);
|
||||||
struct client *cmd_find_best_client(struct client **, u_int);
|
struct client *cmd_find_best_client(struct client **, u_int);
|
||||||
int cmd_find_session_better(struct session *, struct session *,
|
int cmd_find_session_better(struct session *, struct session *,
|
||||||
@ -108,6 +109,33 @@ const char *cmd_find_pane_table[][2] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Get session from TMUX if present. */
|
||||||
|
struct session *
|
||||||
|
cmd_find_try_TMUX(struct client *c, struct window *w)
|
||||||
|
{
|
||||||
|
struct environ_entry *envent;
|
||||||
|
char tmp[256];
|
||||||
|
long long pid;
|
||||||
|
u_int session;
|
||||||
|
struct session *s;
|
||||||
|
|
||||||
|
envent = environ_find(&c->environ, "TMUX");
|
||||||
|
if (envent == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (sscanf(envent->value, "%255[^,],%lld,%d", tmp, &pid, &session) != 3)
|
||||||
|
return (NULL);
|
||||||
|
if (pid != getpid())
|
||||||
|
return (NULL);
|
||||||
|
log_debug("client %d TMUX is %s (session @%u)", c->ibuf.fd,
|
||||||
|
envent->value, session);
|
||||||
|
|
||||||
|
s = session_find_by_id(session);
|
||||||
|
if (s == NULL || (w != NULL && !session_has(s, w)))
|
||||||
|
return (NULL);
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
/* Is this client better? */
|
/* Is this client better? */
|
||||||
int
|
int
|
||||||
cmd_find_client_better(struct client *c, struct client *than)
|
cmd_find_client_better(struct client *c, struct client *than)
|
||||||
@ -191,6 +219,12 @@ cmd_find_best_session_with_window(struct cmd_find_state *fs)
|
|||||||
u_int ssize;
|
u_int ssize;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
|
if (fs->cmdq->client != NULL) {
|
||||||
|
fs->s = cmd_find_try_TMUX(fs->cmdq->client, fs->w);
|
||||||
|
if (fs->s != NULL)
|
||||||
|
return (cmd_find_best_winlink_with_window(fs));
|
||||||
|
}
|
||||||
|
|
||||||
ssize = 0;
|
ssize = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
if (!session_has(s, fs->w))
|
if (!session_has(s, fs->w))
|
||||||
@ -276,7 +310,9 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
unknown_pane:
|
unknown_pane:
|
||||||
fs->s = cmd_find_best_session(NULL, 0, fs->flags);
|
fs->s = cmd_find_try_TMUX(fs->cmdq->client, NULL);
|
||||||
|
if (fs->s == NULL)
|
||||||
|
fs->s = cmd_find_best_session(NULL, 0, fs->flags);
|
||||||
if (fs->s == NULL)
|
if (fs->s == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
fs->wl = fs->s->curw;
|
fs->wl = fs->s->curw;
|
||||||
|
@ -133,7 +133,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (cp != NULL)
|
} else
|
||||||
free(cp);
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (c != NULL && c->session == NULL)
|
} else if (c != NULL && c->session == NULL)
|
||||||
|
@ -107,7 +107,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (cp != NULL)
|
} else
|
||||||
free(cp);
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||||
|
@ -100,7 +100,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (cp != NULL)
|
} else
|
||||||
free(cp);
|
free(cp);
|
||||||
cwd = fd;
|
cwd = fd;
|
||||||
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
|
||||||
|
6
format.c
6
format.c
@ -1022,7 +1022,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
|||||||
{
|
{
|
||||||
struct grid *gd = wp->base.grid;
|
struct grid *gd = wp->base.grid;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
int status;
|
int status, scroll_position;
|
||||||
|
|
||||||
if (ft->w == NULL)
|
if (ft->w == NULL)
|
||||||
ft->w = wp->window;
|
ft->w = wp->window;
|
||||||
@ -1070,6 +1070,10 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
|||||||
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
|
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
|
||||||
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
|
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
|
||||||
|
|
||||||
|
scroll_position = window_copy_scroll_position(wp);
|
||||||
|
if (scroll_position != -1)
|
||||||
|
format_add(ft, "scroll_position", "%d", scroll_position);
|
||||||
|
|
||||||
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
|
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
|
||||||
format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
|
format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
|
||||||
format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);
|
format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);
|
||||||
|
@ -597,7 +597,7 @@ server_client_handle_key(struct client *c, int key)
|
|||||||
m->valid = 0;
|
m->valid = 0;
|
||||||
|
|
||||||
/* Treat everything as a regular key when pasting is detected. */
|
/* Treat everything as a regular key when pasting is detected. */
|
||||||
if (server_client_assume_paste(s)) {
|
if (!KEYC_IS_MOUSE(key) && server_client_assume_paste(s)) {
|
||||||
if (!(c->flags & CLIENT_READONLY))
|
if (!(c->flags & CLIENT_READONLY))
|
||||||
window_pane_key(wp, c, s, key, m);
|
window_pane_key(wp, c, s, key, m);
|
||||||
return;
|
return;
|
||||||
|
4
server.c
4
server.c
@ -177,6 +177,10 @@ server_start(struct event_base *base, int lockfd, char *lockfile)
|
|||||||
}
|
}
|
||||||
close(pair[0]);
|
close(pair[0]);
|
||||||
|
|
||||||
|
if (pledge("stdio rpath wpath cpath fattr unix recvfd proc exec tty "
|
||||||
|
"ps", NULL) != 0)
|
||||||
|
fatal("pledge failed");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Must daemonise before loading configuration as the PID changes so
|
* Must daemonise before loading configuration as the PID changes so
|
||||||
* $TMUX would be wrong for sessions created in the config file.
|
* $TMUX would be wrong for sessions created in the config file.
|
||||||
|
1
tmux.1
1
tmux.1
@ -3411,6 +3411,7 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "pid" Ta "" Ta "Server PID"
|
.It Li "pid" Ta "" Ta "Server PID"
|
||||||
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
|
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
|
||||||
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
|
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
|
||||||
|
.It Li "scroll_position" Ta "" Ta "Scroll position in copy mode"
|
||||||
.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts"
|
.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts"
|
||||||
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
|
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
|
||||||
.It Li "session_activity" Ta "" Ta "Integer time of session last activity"
|
.It Li "session_activity" Ta "" Ta "Integer time of session last activity"
|
||||||
|
5
tmux.c
5
tmux.c
@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -260,6 +261,10 @@ main(int argc, char **argv)
|
|||||||
if (shell_cmd != NULL && argc != 0)
|
if (shell_cmd != NULL && argc != 0)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
if (pledge("stdio rpath wpath cpath flock fattr unix sendfd recvfd "
|
||||||
|
"proc exec tty ps", NULL) != 0)
|
||||||
|
err(1, "pledge");
|
||||||
|
|
||||||
if (!(flags & CLIENT_UTF8)) {
|
if (!(flags & CLIENT_UTF8)) {
|
||||||
/*
|
/*
|
||||||
* If the user has set whichever of LC_ALL, LC_CTYPE or LANG
|
* If the user has set whichever of LC_ALL, LC_CTYPE or LANG
|
||||||
|
1
tmux.h
1
tmux.h
@ -2083,6 +2083,7 @@ void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
|
|||||||
void window_copy_vadd(struct window_pane *, const char *, va_list);
|
void window_copy_vadd(struct window_pane *, const char *, va_list);
|
||||||
void window_copy_pageup(struct window_pane *);
|
void window_copy_pageup(struct window_pane *);
|
||||||
void window_copy_start_drag(struct client *, struct mouse_event *);
|
void window_copy_start_drag(struct client *, struct mouse_event *);
|
||||||
|
int window_copy_scroll_position(struct window_pane *);
|
||||||
|
|
||||||
/* window-choose.c */
|
/* window-choose.c */
|
||||||
extern const struct window_mode window_choose_mode;
|
extern const struct window_mode window_choose_mode;
|
||||||
|
24
tty.c
24
tty.c
@ -228,7 +228,7 @@ tty_start_tty(struct tty *tty)
|
|||||||
if (tty_term_has(tty->term, TTYC_KMOUS))
|
if (tty_term_has(tty->term, TTYC_KMOUS))
|
||||||
tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
|
tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
|
||||||
|
|
||||||
if (tty_term_has(tty->term, TTYC_XT)) {
|
if (tty_term_flag(tty->term, TTYC_XT)) {
|
||||||
if (options_get_number(&global_options, "focus-events")) {
|
if (options_get_number(&global_options, "focus-events")) {
|
||||||
tty->flags |= TTY_FOCUS;
|
tty->flags |= TTY_FOCUS;
|
||||||
tty_puts(tty, "\033[?1004h");
|
tty_puts(tty, "\033[?1004h");
|
||||||
@ -293,7 +293,7 @@ tty_stop_tty(struct tty *tty)
|
|||||||
if (tty_term_has(tty->term, TTYC_KMOUS))
|
if (tty_term_has(tty->term, TTYC_KMOUS))
|
||||||
tty_raw(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
|
tty_raw(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
|
||||||
|
|
||||||
if (tty_term_has(tty->term, TTYC_XT)) {
|
if (tty_term_flag(tty->term, TTYC_XT)) {
|
||||||
if (tty->flags & TTY_FOCUS) {
|
if (tty->flags & TTY_FOCUS) {
|
||||||
tty->flags &= ~TTY_FOCUS;
|
tty->flags &= ~TTY_FOCUS;
|
||||||
tty_raw(tty, "\033[?1004l");
|
tty_raw(tty, "\033[?1004l");
|
||||||
@ -338,10 +338,8 @@ tty_free(struct tty *tty)
|
|||||||
tty_close(tty);
|
tty_close(tty);
|
||||||
|
|
||||||
free(tty->ccolour);
|
free(tty->ccolour);
|
||||||
if (tty->path != NULL)
|
free(tty->path);
|
||||||
free(tty->path);
|
free(tty->termname);
|
||||||
if (tty->termname != NULL)
|
|
||||||
free(tty->termname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1647,6 +1645,13 @@ tty_try_256(struct tty *tty, u_char colour, const char *type)
|
|||||||
{
|
{
|
||||||
char s[32];
|
char s[32];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user has specified -2 to the client, setaf and setab may not
|
||||||
|
* work (or they may not want to use them), so send the usual sequence.
|
||||||
|
*/
|
||||||
|
if (tty->term_flags & TERM_256COLOURS)
|
||||||
|
goto fallback;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the terminfo entry has 256 colours and setaf and setab exist,
|
* If the terminfo entry has 256 colours and setaf and setab exist,
|
||||||
* assume that they work correctly.
|
* assume that they work correctly.
|
||||||
@ -1664,13 +1669,6 @@ tty_try_256(struct tty *tty, u_char colour, const char *type)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If the user has specified -2 to the client, setaf and setab may not
|
|
||||||
* work, so send the usual sequence.
|
|
||||||
*/
|
|
||||||
if (tty->term_flags & TERM_256COLOURS)
|
|
||||||
goto fallback;
|
|
||||||
|
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
fallback:
|
fallback:
|
||||||
|
@ -2219,6 +2219,16 @@ window_copy_scroll_down(struct window_pane *wp, u_int ny)
|
|||||||
screen_write_stop(&ctx);
|
screen_write_stop(&ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
window_copy_scroll_position(struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
|
|
||||||
|
if (wp->mode != &window_copy_mode)
|
||||||
|
return (-1);
|
||||||
|
return (data->oy);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_copy_rectangle_toggle(struct window_pane *wp)
|
window_copy_rectangle_toggle(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user