Permalink
Browse files

Import upstream snapshot from SVN r2647

  • Loading branch information...
1 parent d873474 commit 4ecaa5116c58516f1aec2aaccd1a390766bb6b90 @rfrancoise rfrancoise committed Dec 9, 2011
Showing with 280 additions and 44 deletions.
  1. +2 −8 cmd-new-window.c
  2. +2 −8 cmd-split-window.c
  3. +26 −1 cmd.c
  4. +13 −1 mode-key.c
  5. +7 −1 osdep-aix.c
  6. +8 −1 osdep-darwin.c
  7. +8 −1 osdep-dragonfly.c
  8. +25 −1 osdep-freebsd.c
  9. +7 −1 osdep-hpux.c
  10. +18 −1 osdep-linux.c
  11. +8 −1 osdep-netbsd.c
  12. +14 −1 osdep-openbsd.c
  13. +18 −1 osdep-sunos.c
  14. +7 −1 osdep-unknown.c
  15. +2 −5 status.c
  16. +7 −5 tmux.1
  17. +5 −1 tmux.h
  18. +3 −1 tty-term.c
  19. +100 −4 window-copy.c
View
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-window.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: cmd-new-window.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -98,13 +98,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd = options_get_string(&s->options, "default-command");
else
cmd = args->argv[0];
- cwd = options_get_string(&s->options, "default-path");
- if (*cwd == '\0') {
- if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
- cwd = ctx->cmdclient->cwd;
- else
- cwd = s->cwd;
- }
+ cwd = cmd_get_default_path(ctx);
if (idx == -1)
idx = -1 - options_get_number(&s->options, "base-index");
View
@@ -1,4 +1,4 @@
-/* $Id: cmd-split-window.c 2638 2011-11-25 13:30:45Z tcunha $ */
+/* $Id: cmd-split-window.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -77,13 +77,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd = options_get_string(&s->options, "default-command");
else
cmd = args->argv[0];
- cwd = options_get_string(&s->options, "default-path");
- if (*cwd == '\0') {
- if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
- cwd = ctx->cmdclient->cwd;
- else
- cwd = s->cwd;
- }
+ cwd = cmd_get_default_path(ctx);
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h'))
View
27 cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: cmd.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1212,3 +1212,28 @@ cmd_template_replace(char *template, const char *s, int idx)
return (buf);
}
+
+/* Return the default path for a new pane. */
+char *
+cmd_get_default_path(struct cmd_ctx *ctx)
+{
+ char *cwd;
+ struct session *s;
+ struct window_pane *wp;
+
+ if ((s = cmd_current_session(ctx, 0)) == NULL)
+ return (NULL);
+
+ cwd = options_get_string(&s->options, "default-path");
+ if (*cwd == '\0') {
+ if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
+ return (ctx->cmdclient->cwd);
+ if (ctx->curclient != NULL) {
+ wp = s->curw->window->active;
+ if ((cwd = osdep_get_cwd(wp->pid)) != NULL)
+ return (cwd);
+ }
+ return (s->cwd);
+ }
+ return (cwd);
+}
View
@@ -1,4 +1,4 @@
-/* $Id: mode-key.c 2641 2011-11-25 13:34:20Z tcunha $ */
+/* $Id: mode-key.c 2646 2011-12-06 18:50:26Z tcunha $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -98,6 +98,8 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_JUMPAGAIN, "jump-again" },
{ MODEKEYCOPY_JUMPREVERSE, "jump-reverse" },
{ MODEKEYCOPY_JUMPBACK, "jump-backward" },
+ { MODEKEYCOPY_JUMPTO, "jump-to-forward" },
+ { MODEKEYCOPY_JUMPTOBACK, "jump-to-backward" },
{ MODEKEYCOPY_LEFT, "cursor-left" },
{ MODEKEYCOPY_RECTANGLETOGGLE, "rectangle-toggle" },
{ MODEKEYCOPY_MIDDLELINE, "middle-line" },
@@ -141,10 +143,13 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
+ { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
+ { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
{ '$', 1, MODEKEYEDIT_ENDOFLINE },
{ '0', 1, MODEKEYEDIT_STARTOFLINE },
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
+ { 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
{ '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE },
{ '\r', 1, MODEKEYEDIT_ENTER },
@@ -160,6 +165,7 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ 'l', 1, MODEKEYEDIT_CURSORRIGHT },
{ 'p', 1, MODEKEYEDIT_PASTE },
{ 'w', 1, MODEKEYEDIT_NEXTWORD },
+ { 'x', 1, MODEKEYEDIT_DELETE },
{ KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE },
{ KEYC_DC, 1, MODEKEYEDIT_DELETE },
{ KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN },
@@ -223,6 +229,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ 'L', 0, MODEKEYCOPY_BOTTOMLINE },
{ 'M', 0, MODEKEYCOPY_MIDDLELINE },
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
+ { 'T', 0, MODEKEYCOPY_JUMPTOBACK },
{ 'W', 0, MODEKEYCOPY_NEXTSPACE },
{ '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL },
@@ -244,6 +251,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ 'k', 0, MODEKEYCOPY_UP },
{ 'l', 0, MODEKEYCOPY_RIGHT },
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN },
+ { 't', 0, MODEKEYCOPY_JUMPTO },
{ 'q', 0, MODEKEYCOPY_CANCEL },
{ 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE },
{ 'w', 0, MODEKEYCOPY_NEXTWORD },
@@ -289,6 +297,8 @@ const struct mode_key_entry mode_key_emacs_edit[] = {
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
+ { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
+ { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
{ 0, -1, 0 }
};
@@ -335,6 +345,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE },
{ 'R', 0, MODEKEYCOPY_RECTANGLETOGGLE },
+ { 'T', 0, MODEKEYCOPY_JUMPTOBACK },
{ '\000' /* C-Space */, 0, MODEKEYCOPY_STARTSELECTION },
{ '\001' /* C-a */, 0, MODEKEYCOPY_STARTOFLINE },
{ '\002' /* C-b */, 0, MODEKEYCOPY_LEFT },
@@ -359,6 +370,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN },
{ 'q', 0, MODEKEYCOPY_CANCEL },
{ 'r' | KEYC_ESCAPE, 0, MODEKEYCOPY_MIDDLELINE },
+ { 't', 0, MODEKEYCOPY_JUMPTO },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION },
{ KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN },
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-aix.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-aix.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,6 +28,12 @@ osdep_get_name(unused int fd, unused char *tty)
return (NULL);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-darwin.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-darwin.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
@@ -25,6 +25,7 @@
#include <unistd.h>
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
#define unused __attribute__ ((unused))
@@ -48,6 +49,12 @@ osdep_get_name(int fd, unused char *tty)
return (strdup(kp.kp_proc.p_comm));
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-dragonfly.c 2600 2011-09-29 08:43:01Z nicm $ */
+/* $Id: osdep-dragonfly.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,6 +31,7 @@
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
#ifndef nitems
@@ -119,6 +120,12 @@ osdep_get_name(int fd, char *tty)
return (NULL);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-freebsd.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-freebsd.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,9 +29,11 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libutil.h>
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
#ifndef nitems
@@ -130,6 +132,28 @@ osdep_get_name(int fd, char *tty)
return (NULL);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ static char wd[PATH_MAX];
+ struct kinfo_file *info = NULL;
+ int nrecords, i;
+
+ if ((info = kinfo_getfile(pid, &nrecords)) == NULL)
+ return (NULL);
+
+ for (i = 0; i < nrecords; i++) {
+ if (info[i].kf_fd == KF_FD_TYPE_CWD) {
+ strlcpy(wd, info[i].kf_path, sizeof wd);
+ free(info);
+ return (wd);
+ }
+ }
+
+ free(info);
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-hpux.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-hpux.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,6 +28,12 @@ osdep_get_name(unused int fd, unused char *tty)
return (NULL);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-linux.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-linux.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -60,6 +60,23 @@ osdep_get_name(int fd, unused char *tty)
return (buf);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ static char target[MAXPATHLEN + 1];
+ char *path;
+ ssize_t n;
+
+ xasprintf(&path, "/proc/%d/cwd", pid);
+ n = readlink(path, target, MAXPATHLEN);
+ xfree(path);
+ if (n > 0) {
+ target[n] = '\0';
+ return (target);
+ }
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-netbsd.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-netbsd.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,6 +34,7 @@
struct kinfo_proc2 *cmp_procs(struct kinfo_proc2 *, struct kinfo_proc2 *);
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
struct kinfo_proc2 *
@@ -123,6 +124,12 @@ osdep_get_name(int fd, __unused char *tty)
return (NULL);
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ return (NULL);
+}
+
struct event_base *
osdep_event_init(void)
{
View
@@ -1,4 +1,4 @@
-/* $Id: osdep-openbsd.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-openbsd.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -37,6 +37,7 @@
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
struct kinfo_proc *
@@ -133,6 +134,18 @@ osdep_get_name(int fd, char *tty)
return (NULL);
}
+char*
+osdep_get_cwd(pid_t pid)
+{
+ int name[] = { CTL_KERN, KERN_PROC_CWD, (int)pid };
+ static char path[MAXPATHLEN];
+ size_t pathlen = sizeof path;
+
+ if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
+ return (NULL);
+ return (path);
+}
+
struct event_base *
osdep_event_init(void)
{
Oops, something went wrong.

0 comments on commit 4ecaa51

Please sign in to comment.