Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'upstream' into experimental

* upstream:
  Import upstream snapshot from SVN r2647
  • Loading branch information...
commit 5340d8b75d116926e14f51ee9916955da493ce79 2 parents 8d5465b + 4ecaa51
@orebokech orebokech authored
View
10 cmd-new-window.c
@@ -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
10 cmd-split-window.c
@@ -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
14 mode-key.c
@@ -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
8 osdep-aix.c
@@ -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
9 osdep-darwin.c
@@ -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
9 osdep-dragonfly.c
@@ -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
26 osdep-freebsd.c
@@ -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
8 osdep-hpux.c
@@ -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
19 osdep-linux.c
@@ -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
9 osdep-netbsd.c
@@ -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
15 osdep-openbsd.c
@@ -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)
{
View
19 osdep-sunos.c
@@ -1,4 +1,4 @@
-/* $Id: osdep-sunos.c 2589 2011-09-11 23:54:32Z nicm $ */
+/* $Id: osdep-sunos.c 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2009 Todd Carson <toc@daybefore.net>
@@ -64,6 +64,23 @@ osdep_get_name(int fd, char *tty)
return (xstrdup(p.pr_fname));
}
+char *
+osdep_get_cwd(pid_t pid)
+{
+ static char target[MAXPATHLEN + 1];
+ char *path;
+ ssize_t n;
+
+ xasprintf(&path, "/proc/%u/path/cwd", (u_int) 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
8 osdep-unknown.c
@@ -1,4 +1,4 @@
-/* $Id: osdep-unknown.c 2553 2011-07-09 09:42:33Z tcunha $ */
+/* $Id: osdep-unknown.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
7 status.c
@@ -1,4 +1,4 @@
-/* $Id: status.c 2641 2011-11-25 13:34:20Z tcunha $ */
+/* $Id: status.c 2643 2011-12-06 18:47:14Z tcunha $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1156,11 +1156,8 @@ status_prompt_key(struct client *c, int key)
/* Find the separator at the end of the word. */
while (c->prompt_index != size) {
c->prompt_index++;
- if (strchr(wsep, c->prompt_buffer[c->prompt_index])) {
- /* Go back to the word. */
- c->prompt_index--;
+ if (strchr(wsep, c->prompt_buffer[c->prompt_index]))
break;
- }
}
c->flags |= CLIENT_STATUS;
View
12 tmux.1
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 15 2011 $
+.Dd $Mdocdate: December 4 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -807,7 +807,9 @@ The following keys are supported as appropriate for the mode:
.It Li "Half page down" Ta "C-d" Ta "M-Down"
.It Li "Half page up" Ta "C-u" Ta "M-Up"
.It Li "Jump forward" Ta "f" Ta "f"
+.It Li "Jump to forward" Ta "t" Ta ""
.It Li "Jump backward" Ta "F" Ta "F"
+.It Li "Jump to backward" Ta "T" Ta ""
.It Li "Jump again" Ta ";" Ta ";"
.It Li "Jump again in reverse" Ta "," Ta ","
.It Li "Next page" Ta "C-f" Ta "Page down"
@@ -1843,10 +1845,10 @@ to create a login shell using the value of the
.Ic default-shell
option.
.It Ic default-path Ar path
-Set the default working directory for processes created from keys, or
-interactively from the prompt.
-The default is empty, which means to use the working directory of the shell
-from which the server was started if it is available or the user's home if not.
+Set the default working directory for new panes.
+If empty (the default), the working directory is determined from the process
+running in the active pane, from the command line environment or from the
+working directory where the session was created.
.It Ic default-shell Ar path
Specify the default shell.
This is used as the login shell for new windows when the
View
6 tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h 2641 2011-11-25 13:34:20Z tcunha $ */
+/* $Id: tmux.h 2647 2011-12-09 16:37:29Z nicm $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -481,6 +481,8 @@ enum mode_key_cmd {
MODEKEYCOPY_JUMPAGAIN,
MODEKEYCOPY_JUMPREVERSE,
MODEKEYCOPY_JUMPBACK,
+ MODEKEYCOPY_JUMPTO,
+ MODEKEYCOPY_JUMPTOBACK,
MODEKEYCOPY_LEFT,
MODEKEYCOPY_MIDDLELINE,
MODEKEYCOPY_NEXTPAGE,
@@ -1556,6 +1558,7 @@ int cmd_find_index(
struct winlink *cmd_find_pane(struct cmd_ctx *,
const char *, struct session **, struct window_pane **);
char *cmd_template_replace(char *, const char *, int);
+char *cmd_get_default_path(struct cmd_ctx *ctx);
extern const struct cmd_entry *cmd_table[];
extern const struct cmd_entry cmd_attach_session_entry;
extern const struct cmd_entry cmd_bind_key_entry;
@@ -2073,6 +2076,7 @@ u_int utf8_split2(u_int, u_char *);
/* osdep-*.c */
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
/* log.c */
View
4 tty-term.c
@@ -1,4 +1,4 @@
-/* $Id: tty-term.c 2621 2011-10-23 15:10:22Z tcunha $ */
+/* $Id: tty-term.c 2645 2011-12-06 18:48:45Z tcunha $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -266,6 +266,8 @@ tty_term_override(struct tty_term *term, const char *overrides)
} else
val = xstrdup("");
+ log_debug("%s override: %s %s",
+ term->name, entstr, removeflag ? "@" : val);
for (i = 0; i < NTTYCODE; i++) {
ent = &tty_term_codes[i];
if (strcmp(entstr, ent->name) != 0)
View
104 window-copy.c
@@ -1,4 +1,4 @@
-/* $Id: window-copy.c 2640 2011-11-25 13:33:04Z tcunha $ */
+/* $Id: window-copy.c 2646 2011-12-06 18:50:26Z tcunha $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -67,6 +67,8 @@ void window_copy_cursor_up(struct window_pane *, int);
void window_copy_cursor_down(struct window_pane *, int);
void window_copy_cursor_jump(struct window_pane *);
void window_copy_cursor_jump_back(struct window_pane *);
+void window_copy_cursor_jump_to(struct window_pane *);
+void window_copy_cursor_jump_to_back(struct window_pane *);
void window_copy_cursor_next_word(struct window_pane *, const char *);
void window_copy_cursor_next_word_end(struct window_pane *, const char *);
void window_copy_cursor_previous_word(struct window_pane *, const char *);
@@ -90,6 +92,8 @@ enum window_copy_input_type {
WINDOW_COPY_SEARCHDOWN,
WINDOW_COPY_JUMPFORWARD,
WINDOW_COPY_JUMPBACK,
+ WINDOW_COPY_JUMPTOFORWARD,
+ WINDOW_COPY_JUMPTOBACK,
WINDOW_COPY_GOTOLINE,
};
@@ -132,7 +136,7 @@ struct window_copy_mode_data {
enum window_copy_input_type inputtype;
const char *inputprompt;
- char *inputstr;
+ char *inputstr;
int numprefix;
@@ -367,16 +371,24 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
np = 1;
if (data->inputtype == WINDOW_COPY_JUMPFORWARD ||
- data->inputtype == WINDOW_COPY_JUMPBACK) {
+ data->inputtype == WINDOW_COPY_JUMPBACK ||
+ data->inputtype == WINDOW_COPY_JUMPTOFORWARD ||
+ data->inputtype == WINDOW_COPY_JUMPTOBACK) {
/* Ignore keys with modifiers. */
if ((key & KEYC_MASK_MOD) == 0) {
data->jumpchar = key;
if (data->inputtype == WINDOW_COPY_JUMPFORWARD) {
for (; np != 0; np--)
window_copy_cursor_jump(wp);
- } else {
+ } else if (data->inputtype == WINDOW_COPY_JUMPBACK) {
for (; np != 0; np--)
window_copy_cursor_jump_back(wp);
+ } else if (data->inputtype == WINDOW_COPY_JUMPTOFORWARD) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to(wp);
+ } else if (data->inputtype == WINDOW_COPY_JUMPTOBACK) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to_back(wp);
}
}
data->jumptype = data->inputtype;
@@ -581,6 +593,12 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
} else if (data->jumptype == WINDOW_COPY_JUMPBACK) {
for (; np != 0; np--)
window_copy_cursor_jump_back(wp);
+ } else if (data->jumptype == WINDOW_COPY_JUMPTOFORWARD) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to(wp);
+ } else if (data->jumptype == WINDOW_COPY_JUMPTOBACK) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to_back(wp);
}
break;
case MODEKEYCOPY_JUMPREVERSE:
@@ -590,6 +608,12 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
} else if (data->jumptype == WINDOW_COPY_JUMPBACK) {
for (; np != 0; np--)
window_copy_cursor_jump(wp);
+ } else if (data->jumptype == WINDOW_COPY_JUMPTOFORWARD) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to_back(wp);
+ } else if (data->jumptype == WINDOW_COPY_JUMPTOBACK) {
+ for (; np != 0; np--)
+ window_copy_cursor_jump_to(wp);
}
break;
case MODEKEYCOPY_JUMPBACK:
@@ -598,6 +622,18 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
*data->inputstr = '\0';
window_copy_redraw_lines(wp, screen_size_y(s) - 1, 1);
return; /* skip numprefix reset */
+ case MODEKEYCOPY_JUMPTO:
+ data->inputtype = WINDOW_COPY_JUMPTOFORWARD;
+ data->inputprompt = "Jump To";
+ *data->inputstr = '\0';
+ window_copy_redraw_lines(wp, screen_size_y(s) - 1, 1);
+ return; /* skip numprefix reset */
+ case MODEKEYCOPY_JUMPTOBACK:
+ data->inputtype = WINDOW_COPY_JUMPTOBACK;
+ data->inputprompt = "Jump To Back";
+ *data->inputstr = '\0';
+ window_copy_redraw_lines(wp, screen_size_y(s) - 1, 1);
+ return; /* skip numprefix reset */
case MODEKEYCOPY_SEARCHUP:
data->inputtype = WINDOW_COPY_SEARCHUP;
data->inputprompt = "Search Up";
@@ -613,6 +649,8 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
case WINDOW_COPY_GOTOLINE:
case WINDOW_COPY_JUMPFORWARD:
case WINDOW_COPY_JUMPBACK:
+ case WINDOW_COPY_JUMPTOFORWARD:
+ case WINDOW_COPY_JUMPTOBACK:
case WINDOW_COPY_NUMERICPREFIX:
break;
case WINDOW_COPY_SEARCHUP:
@@ -719,6 +757,8 @@ window_copy_key_input(struct window_pane *wp, int key)
case WINDOW_COPY_OFF:
case WINDOW_COPY_JUMPFORWARD:
case WINDOW_COPY_JUMPBACK:
+ case WINDOW_COPY_JUMPTOFORWARD:
+ case WINDOW_COPY_JUMPTOBACK:
case WINDOW_COPY_NUMERICPREFIX:
break;
case WINDOW_COPY_SEARCHUP:
@@ -1713,6 +1753,62 @@ window_copy_cursor_jump_back(struct window_pane *wp)
}
void
+window_copy_cursor_jump_to(struct window_pane *wp)
+{
+ struct window_copy_mode_data *data = wp->modedata;
+ struct screen *back_s = data->backing;
+ const struct grid_cell *gc;
+ u_int px, py, xx;
+
+ px = data->cx + 1;
+ py = screen_hsize(back_s) + data->cy - data->oy;
+ xx = window_copy_find_length(wp, py);
+
+ while (px < xx) {
+ gc = grid_peek_cell(back_s->grid, px, py);
+ if ((gc->flags & (GRID_FLAG_PADDING|GRID_FLAG_UTF8)) == 0
+ && gc->data == data->jumpchar) {
+
+ window_copy_update_cursor(wp, px - 1, data->cy);
+ if (window_copy_update_selection(wp))
+ window_copy_redraw_lines(wp, data->cy, 1);
+ return;
+ }
+ px++;
+ }
+}
+
+void
+window_copy_cursor_jump_to_back(struct window_pane *wp)
+{
+ struct window_copy_mode_data *data = wp->modedata;
+ struct screen *back_s = data->backing;
+ const struct grid_cell *gc;
+ u_int px, py;
+
+ px = data->cx;
+ py = screen_hsize(back_s) + data->cy - data->oy;
+
+ if (px > 0)
+ px--;
+
+ for (;;) {
+ gc = grid_peek_cell(back_s->grid, px, py);
+ if ((gc->flags & (GRID_FLAG_PADDING|GRID_FLAG_UTF8)) == 0
+ && gc->data == data->jumpchar) {
+
+ window_copy_update_cursor(wp, px + 1, data->cy);
+ if (window_copy_update_selection(wp))
+ window_copy_redraw_lines(wp, data->cy, 1);
+ return;
+ }
+ if (px == 0)
+ break;
+ px--;
+ }
+}
+
+void
window_copy_cursor_next_word(struct window_pane *wp, const char *separators)
{
struct window_copy_mode_data *data = wp->modedata;
Please sign in to comment.
Something went wrong with that request. Please try again.