Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Imported Upstream version 1.3

  • Loading branch information...
commit fb53a63ddc8cd44b7eb993c0dd8b86df3cc8fec6 1 parent dda8e8e
@kfebert kfebert authored
Showing with 4,201 additions and 2,959 deletions.
  1. +1 −0  .pc/.quilt_patches
  2. +1 −0  .pc/.quilt_series
  3. +1 −0  .pc/.version
  4. +47 −1 CHANGES
  5. +8 −7 GNUmakefile
  6. +7 −6 Makefile
  7. +31 −14 TODO
  8. +2 −2 array.h
  9. +3 −3 attributes.c
  10. +2 −2 cfg.c
  11. +23 −31 client.c
  12. +12 −3 cmd-bind-key.c
  13. +146 −0 cmd-choose-buffer.c
  14. +6 −5 cmd-choose-window.c
  15. +5 −1 cmd-command-prompt.c
  16. +2 −1  cmd-copy-mode.c
  17. +0 −60 cmd-down-pane.c
  18. +5 −2 cmd-if-shell.c
  19. +5 −4 cmd-join-pane.c
  20. +2 −12 cmd-kill-session.c
  21. +6 −21 cmd-list-buffers.c
  22. +5 −1 cmd-list-windows.c
  23. +17 −9 cmd-list.c
  24. +26 −7 cmd-load-buffer.c
  25. +16 −7 cmd-new-session.c
  26. +42 −11 cmd-new-window.c
  27. +148 −26 cmd-paste-buffer.c
  28. +10 −3 cmd-pipe-pane.c
  29. +10 −2 cmd-run-shell.c
  30. +23 −12 cmd-save-buffer.c
  31. +13 −7 cmd-select-layout.c
  32. +39 −4 cmd-select-pane.c
  33. +0 −91 cmd-select-prompt.c
  34. +4 −3 cmd-send-keys.c
  35. +2 −2 cmd-send-prefix.c
  36. +5 −1 cmd-set-option.c
  37. +8 −5 cmd-split-window.c
  38. +0 −60 cmd-up-pane.c
  39. +123 −53 cmd.c
  40. +34 −9 compat.h
  41. +34 −34 compat/imsg-buffer.c
  42. +13 −13 compat/imsg.c
  43. +22 −22 compat/imsg.h
  44. +49 −0 compat/setenv.c
  45. +27 −8 configure
  46. +38 −2 environ.c
  47. +4 −3 examples/tmux.vim
  48. +1 −42 grid.c
  49. +1,140 −1,149 input.c
  50. +4 −3 job.c
  51. +18 −11 key-bindings.c
  52. +101 −115 key-string.c
  53. +264 −0 layout-custom.c
  54. +102 −1 layout-set.c
  55. +1 −2  layout-string.c
  56. +79 −51 layout.c
  57. +14 −1 mode-key.c
  58. +25 −1 paste.c
  59. +2 −2 resize.c
  60. +18 −31 screen-write.c
  61. +9 −3 screen.c
  62. +75 −28 server-client.c
  63. +43 −19 server-fn.c
  64. +31 −32 server-window.c
  65. +14 −83 server.c
  66. +30 −108 session.c
  67. +88 −0 signal.c
  68. +22 −50 status.c
  69. +270 −77 tmux.1
  70. +36 −92 tmux.c
  71. +113 −69 tmux.h
  72. +4 −3 tty-keys.c
  73. +44 −16 tty.c
  74. +5 −5 window-choose.c
  75. +3 −3 window-clock.c
  76. +364 −85 window-copy.c
  77. +0 −260 window-more.c
  78. +254 −47 window.c
View
1  .pc/.quilt_patches
@@ -0,0 +1 @@
+./debian/patches
View
1  .pc/.quilt_series
@@ -0,0 +1 @@
+series
View
1  .pc/.version
@@ -0,0 +1 @@
+2
View
48 CHANGES
@@ -1,3 +1,49 @@
+CHANGES FROM 1.2 TO 1.3, 18 July 2010
+
+* New input parser.
+* Flags to move through panes -UDLR added to select-pane.
+* Commands up-pane, and down-pane removed, since equivalent behaviour is now
+ available through the target flag (-t:+ and -t:-).
+* Jump-forward/backward in copy move (based on vi's F, and f commands).
+* Make paste-buffer accept a pane as a target.
+* Flag -a added to new-window to insert a window after an existing one, moving
+ windows up if necessary.
+* Merge more mode into copy mode.
+* Run job commands explicitly in the global environment (which can be modified
+ with setenv -g), rather than with the environment tmux started with.
+* Use the machine's hostname as the default title, instead of an empty string.
+* Prevent double free if the window option remain-on-exit is set.
+* Key string conversions rewritten.
+* Mark zombie windows as dead in the choose-window list.
+* Tiled layout added.
+* Signal handling reworked.
+* Reset SIGCHLD after fork to fix problems with some shells.
+* Select-prompt command removed. Therefore, bound ' to command-prompt -p index
+ "select-window -t:%%" by default.
+* Catch SIGHUP and terminate if running as a client, thus avoiding clients from
+ being left hanging around when, for instance, a SSH session is disconnected.
+* Solaris 9 fixes (such as adding compat {get,set}env(3) code).
+* Accept none instead of default for attributes.
+* Window options window-status-alert-{alert,bg,fg} added.
+* Flag -s added to the paste-buffer command to specify a custom separator.
+* Allow dragging to make a selection in copy mode if the mode-mouse option is
+ set.
+* Support the mouse scroll wheel.
+* Make pipe-pane accept special character sequences (eg #I).
+* Fix problems with window sizing when starting tmux from .xinitrc.
+* Give tmux sockets (but not the containing folder) group permissions.
+* Extend the target flags (ie -t) to accept an offset (for example -t:+2), and
+ make it wrap windows, and panes.
+* New command choose-buffer added.
+* New server option detach-on-destroy to set what happens to a client when the
+ session it is attached to is destroyed. If on (default), the client is
+ detached. Otherwise, the client is switched to the most recently active of
+ the remaining sessions.
+* The commands load-buffer, and save-buffer now accept a dash (-) as the file
+ to read from stdin, or write to stdout.
+* Custom layouts added.
+* Additional code reduction, bug fixes, and manpage enhancements.
+
CHANGES FROM 1.1 TO 1.2, 10 March 2010
* Switch to libevent.
@@ -1467,7 +1513,7 @@ The list of older changes is below.
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.302 2010/03/10 15:18:11 tcunha Exp $
+$Id: CHANGES,v 1.303 2010/07/18 13:40:59 tcunha Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
View
15 GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.122 2010/03/10 15:15:33 tcunha Exp $
+# $Id: GNUmakefile,v 1.128 2010/07/18 13:36:52 tcunha Exp $
#
# Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
#
@@ -17,7 +17,7 @@
.PHONY: clean
-VERSION= 1.2
+VERSION= 1.3
#FDEBUG= 1
@@ -28,7 +28,7 @@ LIBS+=
# Sun CC
ifneq ($(shell ($(CC) -V 2>&1|awk '/Sun C/' || true)), )
- CFLAGS+=-erroff=E_EMPTY_DECLARATION
+ CFLAGS+= -erroff=E_EMPTY_DECLARATION
FDEBUG=
endif
@@ -52,11 +52,12 @@ endif
endif
PREFIX?= /usr/local
-INSTALLDIR= install -d
-INSTALLBIN= install -g bin -o root -m 555
-INSTALLMAN= install -g bin -o root -m 444
+INSTALL?= install
+INSTALLDIR= $(INSTALL) -d
+INSTALLBIN= $(INSTALL) -m 555
+INSTALLMAN= $(INSTALL) -m 444
-SRCS= $(shell echo *.c|sed 's|osdep-[a-z0-9]*.c||g')
+SRCS= $(shell echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g')
include config.mk
OBJS= $(patsubst %.c,%.o,$(SRCS))
View
13 Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.155 2010/03/10 15:15:33 tcunha Exp $
+# $Id: Makefile,v 1.160 2010/07/18 13:36:52 tcunha Exp $
#
# Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
#
@@ -18,7 +18,7 @@
.SUFFIXES: .c .o
.PHONY: clean
-VERSION= 1.2
+VERSION= 1.3
#FDEBUG= 1
@@ -48,11 +48,12 @@ CFLAGS+= -Wno-pointer-sign
.endif
PREFIX?= /usr/local
-INSTALLDIR= install -d
-INSTALLBIN= install -g bin -o root -m 555
-INSTALLMAN= install -g bin -o root -m 444
+INSTALL?= install
+INSTALLDIR= ${INSTALL} -d
+INSTALLBIN= ${INSTALL} -m 555
+INSTALLMAN= ${INSTALL} -m 444
-SRCS!= echo *.c|sed 's|osdep-[a-z0-9]*.c||g'
+SRCS!= echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g'
.include "config.mk"
OBJS= ${SRCS:S/.c/.o/}
View
45 TODO
@@ -15,7 +15,6 @@
session not being watched?
- next prev word etc in command prompt
- many more info() displays for various things
-- input.c is too complicated. simplify?
- use a better termcap internally instead of screen, perhaps xterm
- fix rxvt cursor fg issue (text under cursor can have non-white fg)
- should be able to move to a hidden pane and it would be moved into view. pane
@@ -90,8 +89,6 @@
message display
copy and paste cursor and wide characters
...?
-- option so that when session is destroyed, attach client to another session
- rather than exiting
- session history for client and last-session command
- option to change status line colour when current window is in a mode?
- option to move copy mode indicator into status line
@@ -100,12 +97,10 @@
- live update: server started with -U connects to server, requests sessions and
windows, receives fds
- convert status line history to be server global (anything else?)
-- something for -t "last window in session" so a session can be used as a stack
- command to show a tree of sessions-windows-panes (active marked with *)
- sort out inheriting config from shell on new sessions/windows:
should pick up default-path/termios/etc from client if possible,
else leave empty/default
-- define custom layouts
- link panes into multiple windows
- -h option to capture-pane to capture the history as well
- bells should be passed between sessions with visual-bell etc
@@ -118,18 +113,40 @@
- multiline status line
- flag for absolute pane size to resize-pane
- sanity check input to socket
-- stdin fd should be passed up to parent so load-buffer and others could use it
- for nonattaching clients
-- environment should be set up for jobs
- select-buffer command
-- fix jobs so they block in config file rather than executing at an arbitrary
- future point -- need state stored in client so other clients can proceed
-- rectangle copy:
- when selecting leftward, cursor should be inside block per emacs
- key to rotate corner at which cursor is
-- double C-a should walk back over wrapped lines like C-e
- support title stack, both internally and externally
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=1149299+0+archive/2010/freebsd-questions/20100207.freebsd-questions
- copy buffers should be global, limit can be server option, nuke copy-buffer
command
- command to show status line information briefly when it is off
+- some way to pad # stuff with spaces, #!2T maybe
+- FreeBSD console problems
+- a binding to "scroll down and exit at bottom" copy mode
+- some way to pass keystrokes in copy mode through to underlying window
+- last window update time and # replacement for it for display-message
+- find-window across sessions - other ways to make session handling easier?
+- ' and " should be parsed the same (eg "\e" vs '\e') in config and command
+ prompt?
+- command to toggle selection not to move it in copy-mode
+
+For 1.3 (not in order):
+
+3 why are alerts per-winlink? try per window?
+4 audit of escape sequence support vs xterm
+6 rectangle copy: when selecting leftward, cursor should be inside block per
+ emacs key to rotate corner at which cursor is
+9 something for -t "last window in session" so a session can be used as a stack
+10 synchronous commands - client sends cmd and blocks, neww/splitw saves client
+ ptr then when program inside died, sends MSG_SOMETHING with wait status to
+ client
+11 documentation improvements - rlpowell's tutorial
+ - build instructions
+12 better configure? with-libevent
+14 bind commands to key sequences?
+16 monitor, bell etc should monitor /all/ panes in the window not just one
+17 wd should be updated on attach etc. maybe lose default-path and use PWD
+18 a history of commands that can be reversed (reverse member of each command, and a buffer)
+19 info() when changing to same window
+20 don't pass UTF-8 through vis for titles
+...
+
View
4 array.h
@@ -1,4 +1,4 @@
-/* $Id: array.h,v 1.10 2010/02/08 18:29:32 tcunha Exp $ */
+/* $Id: array.h,v 1.11 2010/06/06 00:27:08 tcunha Exp $ */
/*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -47,7 +47,7 @@
} \
} while (0)
-#define ARRAY_EMPTY(a) ((a) == NULL || (a)->num == 0)
+#define ARRAY_EMPTY(a) (((void *) (a)) == NULL || (a)->num == 0)
#define ARRAY_LENGTH(a) ((a)->num)
#define ARRAY_DATA(a) ((a)->list)
View
6 attributes.c
@@ -1,4 +1,4 @@
-/* $Id: attributes.c,v 1.3 2009/11/28 14:46:23 tcunha Exp $ */
+/* $Id: attributes.c,v 1.4 2010/06/05 23:54:51 tcunha Exp $ */
/*
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
@@ -28,7 +28,7 @@ attributes_tostring(u_char attr)
static char buf[128];
if (attr == 0)
- return ("default");
+ return ("none");
buf[0] = '\0';
if (attr & GRID_ATTR_BRIGHT)
@@ -63,7 +63,7 @@ attributes_fromstring(const char *str)
if (strchr(delimiters, str[strlen(str) - 1]) != NULL)
return (-1);
- if (strcasecmp(str, "default") == 0)
+ if (strcasecmp(str, "default") == 0 || strcasecmp(str, "none") == 0)
return (0);
attr = 0;
View
4 cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.26 2010/02/08 18:29:32 tcunha Exp $ */
+/* $Id: cfg.c,v 1.27 2010/06/06 00:04:18 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -69,7 +69,7 @@ cfg_add_cause(struct causelist *causes, const char *fmt, ...)
/*
* Load configuration file. Returns -1 for an error with a list of messages in
- * causes. Note that causes and ncauses must be initialised by the caller!
+ * causes. Note that causes must be initialised by the caller!
*/
int
load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
View
54 client.c
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.90 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: client.c,v 1.95 2010/07/02 02:52:13 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -17,7 +17,6 @@
*/
#include <sys/types.h>
-#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
@@ -101,8 +100,7 @@ client_init(char *path, int cmdflags, int flags)
if (cmdflags & CMD_SENDENVIRON)
client_send_environ();
- if (isatty(STDIN_FILENO))
- client_send_identify(flags);
+ client_send_identify(flags);
return (&client_ibuf);
@@ -119,12 +117,9 @@ void
client_send_identify(int flags)
{
struct msg_identify_data data;
- struct winsize ws;
char *term;
int fd;
- if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
- fatal("ioctl(TIOCGWINSZ)");
data.flags = flags;
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
@@ -139,6 +134,14 @@ client_send_identify(int flags)
fatal("dup failed");
imsg_compose(&client_ibuf,
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
+
+ if ((fd = dup(STDOUT_FILENO)) == -1)
+ fatal("dup failed");
+ imsg_compose(&client_ibuf, MSG_STDOUT, PROTOCOL_VERSION, -1, fd, NULL, 0);
+
+ if ((fd = dup(STDERR_FILENO)) == -1)
+ fatal("dup failed");
+ imsg_compose(&client_ibuf, MSG_STDERR, PROTOCOL_VERSION, -1, fd, NULL, 0);
}
void
@@ -176,35 +179,19 @@ client_update_event(void)
__dead void
client_main(void)
{
- struct event ev_sigcont, ev_sigterm, ev_sigwinch;
- struct sigaction sigact;
-
logfile("client");
/* Note: event_init() has already been called. */
/* Set up signals. */
- memset(&sigact, 0, sizeof sigact);
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = SA_RESTART;
- sigact.sa_handler = SIG_IGN;
- if (sigaction(SIGINT, &sigact, NULL) != 0)
- fatal("sigaction failed");
- if (sigaction(SIGPIPE, &sigact, NULL) != 0)
- fatal("sigaction failed");
- if (sigaction(SIGUSR1, &sigact, NULL) != 0)
- fatal("sigaction failed");
- if (sigaction(SIGUSR2, &sigact, NULL) != 0)
- fatal("sigaction failed");
- if (sigaction(SIGTSTP, &sigact, NULL) != 0)
- fatal("sigaction failed");
-
- signal_set(&ev_sigcont, SIGCONT, client_signal, NULL);
- signal_add(&ev_sigcont, NULL);
- signal_set(&ev_sigterm, SIGTERM, client_signal, NULL);
- signal_add(&ev_sigterm, NULL);
- signal_set(&ev_sigwinch, SIGWINCH, client_signal, NULL);
- signal_add(&ev_sigwinch, NULL);
+ set_signals(client_signal);
+
+ /*
+ * Send a resize message immediately in case the terminal size has
+ * changed between the identify message to the server and the MSG_READY
+ * telling us to move into the client code.
+ */
+ client_write_server(MSG_RESIZE, NULL, 0);
/*
* imsg_read in the first client poll loop (before the terminal has
@@ -233,6 +220,11 @@ client_signal(int sig, unused short events, unused void *data)
struct sigaction sigact;
switch (sig) {
+ case SIGHUP:
+ client_exitmsg = "lost tty";
+ client_exitval = 1;
+ client_write_server(MSG_EXITING, NULL, 0);
+ break;
case SIGTERM:
client_exitmsg = "terminated";
client_exitval = 1;
View
15 cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-bind-key.c,v 1.28 2010/01/25 17:12:44 tcunha Exp $ */
+/* $Id: cmd-bind-key.c,v 1.29 2010/07/02 02:43:01 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -130,7 +130,7 @@ cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
return (cmd_bind_key_table(self, ctx));
key_bindings_add(data->key, data->can_repeat, data->cmdlist);
- data->cmdlist = NULL; /* avoid free */
+ data->cmdlist->references++;
return (0);
}
@@ -192,8 +192,17 @@ cmd_bind_key_print(struct cmd *self, char *buf, size_t len)
off += xsnprintf(buf, len, "%s", self->entry->name);
if (data == NULL)
return (off);
+
+ if (off < len && data->command_key)
+ off += xsnprintf(buf + off, len - off, " -c");
+ if (off < len && !(data->key & KEYC_PREFIX))
+ off += xsnprintf(buf + off, len - off, " -n");
+ if (off < len && data->can_repeat)
+ off += xsnprintf(buf + off, len - off, " -r");
+ if (off < len && data->tablename != NULL)
+ off += cmd_prarg(buf + off, len - off, " -t ", data->tablename);
if (off < len) {
- skey = key_string_lookup_key(data->key);
+ skey = key_string_lookup_key(data->key & ~KEYC_PREFIX);
off += xsnprintf(buf + off, len - off, " %s ", skey);
}
if (off < len)
View
146 cmd-choose-buffer.c
@@ -0,0 +1,146 @@
+/* $Id: cmd-choose-buffer.c,v 1.1 2010/06/22 23:35:20 tcunha Exp $ */
+
+/*
+ * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <ctype.h>
+
+#include "tmux.h"
+
+/*
+ * Enter choice mode to choose a buffer.
+ */
+
+int cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
+
+void cmd_choose_buffer_callback(void *, int);
+void cmd_choose_buffer_free(void *);
+
+const struct cmd_entry cmd_choose_buffer_entry = {
+ "choose-buffer", NULL,
+ CMD_TARGET_WINDOW_USAGE " [template]",
+ CMD_ARG01, "",
+ cmd_target_init,
+ cmd_target_parse,
+ cmd_choose_buffer_exec,
+ cmd_target_free,
+ cmd_target_print
+};
+
+struct cmd_choose_buffer_data {
+ struct client *client;
+ char *template;
+};
+
+int
+cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
+{
+ struct cmd_target_data *data = self->data;
+ struct cmd_choose_buffer_data *cdata;
+ struct session *s;
+ struct winlink *wl;
+ struct paste_buffer *pb;
+ u_int idx;
+ char *tmp;
+
+ if (ctx->curclient == NULL) {
+ ctx->error(ctx, "must be run interactively");
+ return (-1);
+ }
+ s = ctx->curclient->session;
+
+ if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
+ return (-1);
+
+ if (paste_get_top(&s->buffers) == NULL)
+ return (0);
+
+ if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
+ return (0);
+
+ idx = 0;
+ while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
+ tmp = paste_print(pb, 50);
+ window_choose_add(wl->window->active, idx - 1,
+ "%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
+ xfree(tmp);
+ }
+
+ cdata = xmalloc(sizeof *cdata);
+ if (data->arg != NULL)
+ cdata->template = xstrdup(data->arg);
+ else
+ cdata->template = xstrdup("paste-buffer -b '%%'");
+ cdata->client = ctx->curclient;
+ cdata->client->references++;
+
+ window_choose_ready(wl->window->active,
+ 0, cmd_choose_buffer_callback, cmd_choose_buffer_free, cdata);
+
+ return (0);
+}
+
+void
+cmd_choose_buffer_callback(void *data, int idx)
+{
+ struct cmd_choose_buffer_data *cdata = data;
+ struct cmd_list *cmdlist;
+ struct cmd_ctx ctx;
+ char *template, *cause, tmp[16];
+
+ if (idx == -1)
+ return;
+ if (cdata->client->flags & CLIENT_DEAD)
+ return;
+
+ xsnprintf(tmp, sizeof tmp, "%u", idx);
+ template = cmd_template_replace(cdata->template, tmp, 1);
+
+ if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
+ if (cause != NULL) {
+ *cause = toupper((u_char) *cause);
+ status_message_set(cdata->client, "%s", cause);
+ xfree(cause);
+ }
+ xfree(template);
+ return;
+ }
+ xfree(template);
+
+ ctx.msgdata = NULL;
+ ctx.curclient = cdata->client;
+
+ ctx.error = key_bindings_error;
+ ctx.print = key_bindings_print;
+ ctx.info = key_bindings_info;
+
+ ctx.cmdclient = NULL;
+
+ cmd_list_exec(cmdlist, &ctx);
+ cmd_list_free(cmdlist);
+}
+
+void
+cmd_choose_buffer_free(void *data)
+{
+ struct cmd_choose_buffer_data *cdata = data;
+
+ cdata->client->references--;
+ xfree(cdata->template);
+ xfree(cdata);
+}
View
11 cmd-choose-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-window.c,v 1.20 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-choose-window.c,v 1.22 2010/06/22 23:26:18 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -81,11 +81,11 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
idx++;
flag = ' ';
- if (session_alert_has(s, wm, WINDOW_ACTIVITY))
+ if (wm->flags & WINLINK_ACTIVITY)
flag = '#';
- else if (session_alert_has(s, wm, WINDOW_BELL))
+ else if (wm->flags & WINLINK_BELL)
flag = '!';
- else if (session_alert_has(s, wm, WINDOW_CONTENT))
+ else if (wm->flags & WINLINK_CONTENT)
flag = '+';
else if (wm == s->curw)
flag = '*';
@@ -101,8 +101,9 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
left = right = "";
window_choose_add(wl->window->active,
- wm->idx, "%3d: %s%c [%ux%u] (%u panes)%s%s%s",
+ wm->idx, "%3d: %s%c [%ux%u] (%u panes%s)%s%s%s",
wm->idx, w->name, flag, w->sx, w->sy, window_count_panes(w),
+ w->active->fd == -1 ? ", dead" : "",
left, title, right);
}
View
6 cmd-command-prompt.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-command-prompt.c,v 1.27 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-command-prompt.c,v 1.28 2010/05/14 14:33:39 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -81,6 +81,10 @@ cmd_command_prompt_init(struct cmd *self, int key)
case 'f':
data->template = xstrdup("find-window '%%'");
break;
+ case '\'':
+ data->template = xstrdup("select-window -t ':%%'");
+ data->prompts = xstrdup("index");
+ break;
}
}
View
3  cmd-copy-mode.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-copy-mode.c,v 1.26 2010/01/05 23:50:22 tcunha Exp $ */
+/* $Id: cmd-copy-mode.c,v 1.27 2010/04/05 05:11:42 micahcowan Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,6 +63,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
window_pane_set_mode(wp, &window_copy_mode);
+ window_copy_init_from_pane(wp);
if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
window_copy_pageup(wp);
View
60 cmd-down-pane.c
@@ -1,60 +0,0 @@
-/* $Id: cmd-down-pane.c,v 1.14 2010/01/05 23:52:37 tcunha Exp $ */
-
-/*
- * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-
-#include "tmux.h"
-
-/*
- * Move down a pane.
- */
-
-int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
-
-const struct cmd_entry cmd_down_pane_entry = {
- "down-pane", "downp",
- CMD_TARGET_WINDOW_USAGE,
- 0, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_down_pane_exec,
- cmd_target_free,
- cmd_target_print
-};
-
-int
-cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
-{
- struct cmd_target_data *data = self->data;
- struct winlink *wl;
- struct window *w;
-
- if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
- return (-1);
- w = wl->window;
-
- do {
- w->active = TAILQ_NEXT(w->active, entry);
- if (w->active == NULL)
- w->active = TAILQ_FIRST(&w->panes);
- } while (!window_pane_visible(w->active));
- server_status_window(wl->window);
- server_redraw_window_borders(wl->window);
-
- return (0);
-}
View
7 cmd-if-shell.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-if-shell.c,v 1.8 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-if-shell.c,v 1.9 2010/07/17 14:36:40 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -104,10 +104,13 @@ cmd_if_shell_free(void *data)
{
struct cmd_if_shell_data *cdata = data;
struct cmd_ctx *ctx = &cdata->ctx;
+ struct msg_exit_data exitdata;
if (ctx->cmdclient != NULL) {
ctx->cmdclient->references--;
- server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+ exitdata.retcode = ctx->cmdclient->retcode;
+ server_write_client(
+ ctx->cmdclient, MSG_EXIT, &exitdata, sizeof exitdata);
}
if (ctx->curclient != NULL)
ctx->curclient->references--;
View
9 cmd-join-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-join-pane.c,v 1.2 2010/01/08 16:34:17 tcunha Exp $ */
+/* $Id: cmd-join-pane.c,v 1.4 2010/04/09 07:09:37 micahcowan Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,7 +44,7 @@ struct cmd_join_pane_data {
const struct cmd_entry cmd_join_pane_entry = {
"join-pane", "joinp",
- "[-dhv] [-p percentage|-l size] [-t src-pane] [-t dst-pane] [command]",
+ "[-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane] [command]",
0, "",
cmd_join_pane_init,
cmd_join_pane_parse,
@@ -150,13 +150,14 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
struct winlink *src_wl, *dst_wl;
struct window *src_w, *dst_w;
struct window_pane *src_wp, *dst_wp;
- int size;
+ int size, dst_idx;
enum layout_type type;
struct layout_cell *lc;
if ((dst_wl = cmd_find_pane(ctx, data->dst, &dst_s, &dst_wp)) == NULL)
return (-1);
dst_w = dst_wl->window;
+ dst_idx = dst_wl->idx;
if ((src_wl = cmd_find_pane(ctx, data->src, NULL, &src_wp)) == NULL)
return (-1);
@@ -209,7 +210,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
if (!data->flag_detached) {
window_set_active_pane(dst_w, src_wp);
- session_select(dst_s, dst_wl->idx);
+ session_select(dst_s, dst_idx);
server_redraw_session(dst_s);
} else
server_status_session(dst_s);
View
14 cmd-kill-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-kill-session.c,v 1.17 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-kill-session.c,v 1.18 2010/07/02 02:43:50 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -45,21 +45,11 @@ cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
struct session *s;
- struct client *c;
- u_int i;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c != NULL && c->session == s) {
- c->session = NULL;
- server_write_client(c, MSG_EXIT, NULL, 0);
- }
- }
- recalculate_sizes();
-
+ server_destroy_session(s);
session_destroy(s);
return (0);
View
27 cmd-list-buffers.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-buffers.c,v 1.15 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-list-buffers.c,v 1.16 2010/06/22 23:35:20 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -46,32 +46,17 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct paste_buffer *pb;
u_int idx;
- char tmp[51 * 4 + 1];
- size_t size, len;
+ char *tmp;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
idx = 0;
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
- size = pb->size;
-
- /* Translate the first 50 characters. */
- len = size;
- if (len > 50)
- len = 50;
- strvisx(tmp, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL);
-
- /*
- * If the first 50 characters were encoded as a longer string,
- * or there is definitely more data, add "...".
- */
- if (size > 50 || strlen(tmp) > 50) {
- tmp[50 - 3] = '\0';
- strlcat(tmp, "...", sizeof tmp);
- }
-
- ctx->print(ctx, "%u: %zu bytes: \"%s\"", idx - 1, size, tmp);
+ tmp = paste_print(pb, 50);
+ ctx->print(ctx,
+ "%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
+ xfree(tmp);
}
return (0);
View
6 cmd-list-windows.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-windows.c,v 1.42 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-list-windows.c,v 1.43 2010/07/02 02:54:52 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -45,6 +45,7 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_target_data *data = self->data;
struct session *s;
struct winlink *wl;
+ char *layout;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
@@ -52,6 +53,9 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
RB_FOREACH(wl, winlinks, &s->windows) {
ctx->print(ctx, "%d: %s [%ux%u]",
wl->idx, wl->window->name, wl->window->sx, wl->window->sy);
+ layout = layout_dump(wl->window);
+ ctx->print(ctx, " layout: %s", layout);
+ xfree(layout);
}
return (0);
View
26 cmd-list.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list.c,v 1.7 2010/02/02 23:51:04 tcunha Exp $ */
+/* $Id: cmd-list.c,v 1.9 2010/07/02 02:43:01 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,7 +32,8 @@ cmd_list_parse(int argc, char **argv, char **cause)
char **new_argv;
cmdlist = xmalloc(sizeof *cmdlist);
- TAILQ_INIT(cmdlist);
+ cmdlist->references = 1;
+ TAILQ_INIT(&cmdlist->list);
lastsplit = 0;
for (i = 0; i < argc; i++) {
@@ -54,7 +55,7 @@ cmd_list_parse(int argc, char **argv, char **cause)
cmd = cmd_parse(new_argc, new_argv, cause);
if (cmd == NULL)
goto bad;
- TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
+ TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
lastsplit = i + 1;
}
@@ -63,7 +64,7 @@ cmd_list_parse(int argc, char **argv, char **cause)
cmd = cmd_parse(argc - lastsplit, argv + lastsplit, cause);
if (cmd == NULL)
goto bad;
- TAILQ_INSERT_TAIL(cmdlist, cmd, qentry);
+ TAILQ_INSERT_TAIL(&cmdlist->list, cmd, qentry);
}
return (cmdlist);
@@ -80,7 +81,7 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
int n, retval;
retval = 0;
- TAILQ_FOREACH(cmd, cmdlist, qentry) {
+ TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
if ((n = cmd_exec(cmd, ctx)) == -1)
return (-1);
@@ -99,6 +100,10 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
if (ctx->curclient == NULL) {
ctx->curclient = ctx->cmdclient;
ctx->cmdclient = NULL;
+
+ ctx->error = key_bindings_error;
+ ctx->print = key_bindings_print;
+ ctx->info = key_bindings_info;
}
}
}
@@ -110,9 +115,12 @@ cmd_list_free(struct cmd_list *cmdlist)
{
struct cmd *cmd;
- while (!TAILQ_EMPTY(cmdlist)) {
- cmd = TAILQ_FIRST(cmdlist);
- TAILQ_REMOVE(cmdlist, cmd, qentry);
+ if (--cmdlist->references != 0)
+ return;
+
+ while (!TAILQ_EMPTY(&cmdlist->list)) {
+ cmd = TAILQ_FIRST(&cmdlist->list);
+ TAILQ_REMOVE(&cmdlist->list, cmd, qentry);
cmd_free(cmd);
}
xfree(cmdlist);
@@ -125,7 +133,7 @@ cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
size_t off;
off = 0;
- TAILQ_FOREACH(cmd, cmdlist, qentry) {
+ TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
if (off >= len)
break;
off += cmd_print(cmd, buf + off, len - off);
View
33 cmd-load-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-load-buffer.c,v 1.15 2010/02/26 13:30:07 tcunha Exp $ */
+/* $Id: cmd-load-buffer.c,v 1.16 2010/07/02 02:52:13 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -16,10 +16,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "tmux.h"
@@ -45,7 +48,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_buffer_data *data = self->data;
struct session *s;
- FILE *f;
+ FILE *f, *close_f;
char *pdata, *new_pdata;
size_t psize;
u_int limit;
@@ -54,9 +57,23 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
- if ((f = fopen(data->arg, "rb")) == NULL) {
- ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
- return (-1);
+ if (strcmp(data->arg, "-") == 0 ) {
+ if (ctx->cmdclient == NULL) {
+ ctx->error(ctx, "%s: can't read from stdin", data->arg);
+ return (-1);
+ }
+ f = ctx->cmdclient->stdin_file;
+ if (isatty(fileno(ctx->cmdclient->stdin_file))) {
+ ctx->error(ctx, "%s: stdin is a tty", data->arg);
+ return (-1);
+ }
+ close_f = NULL;
+ } else {
+ if ((f = fopen(data->arg, "rb")) == NULL) {
+ ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
+ return (-1);
+ }
+ close_f = f;
}
pdata = NULL;
@@ -77,7 +94,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (pdata != NULL)
pdata[psize] = '\0';
- fclose(f);
+ if (close_f != NULL)
+ fclose(close_f);
limit = options_get_number(&s->options, "buffer-limit");
if (data->buffer == -1) {
@@ -94,6 +112,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
error:
if (pdata != NULL)
xfree(pdata);
- fclose(f);
+ if (close_f != NULL)
+ fclose(close_f);
return (-1);
}
View
23 cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-session.c,v 1.76 2010/02/26 13:28:15 tcunha Exp $ */
+/* $Id: cmd-new-session.c,v 1.78 2010/07/02 02:49:19 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -18,8 +18,10 @@
#include <sys/types.h>
+#include <pwd.h>
#include <string.h>
#include <termios.h>
+#include <unistd.h>
#include "tmux.h"
@@ -125,8 +127,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window_pane *wp;
struct environ env;
struct termios tio, *tiop;
- const char *update;
- char *overrides, *cmd, *cwd, *cause;
+ struct passwd *pw;
+ const char *update, *cwd;
+ char *overrides, *cmd, *cause;
int detached, idx;
u_int sx, sy, i;
@@ -198,8 +201,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
/* Get the new session working directory. */
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
cwd = ctx->cmdclient->cwd;
- else
- cwd = options_get_string(&global_s_options, "default-path");
+ else {
+ pw = getpwuid(getuid());
+ if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
+ cwd = pw->pw_dir;
+ else
+ cwd = "/";
+ }
/* Find new session size. */
if (detached) {
@@ -287,10 +295,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
*/
if (cfg_finished && !ARRAY_EMPTY(&cfg_causes)) {
wp = s->curw->window->active;
- window_pane_set_mode(wp, &window_more_mode);
+ window_pane_set_mode(wp, &window_copy_mode);
+ window_copy_init_for_output(wp);
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
cause = ARRAY_ITEM(&cfg_causes, i);
- window_more_add(wp, "%s", cause);
+ window_copy_add(wp, "%s", cause);
xfree(cause);
}
ARRAY_FREE(&cfg_causes);
View
53 cmd-new-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-window.c,v 1.43 2010/01/22 17:28:34 tcunha Exp $ */
+/* $Id: cmd-new-window.c,v 1.47 2010/07/02 02:49:19 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -36,13 +36,14 @@ struct cmd_new_window_data {
char *target;
char *name;
char *cmd;
+ int flag_insert_after;
int flag_detached;
int flag_kill;
};
const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww",
- "[-dk] [-n window-name] [-t target-window] [command]",
+ "[-adk] [-n window-name] [-t target-window] [command]",
0, "",
cmd_new_window_init,
cmd_new_window_parse,
@@ -61,6 +62,7 @@ cmd_new_window_init(struct cmd *self, unused int arg)
data->target = NULL;
data->name = NULL;
data->cmd = NULL;
+ data->flag_insert_after = 0;
data->flag_detached = 0;
data->flag_kill = 0;
}
@@ -74,8 +76,11 @@ cmd_new_window_parse(struct cmd *self, int argc, char **argv, char **cause)
self->entry->init(self, KEYC_NONE);
data = self->data;
- while ((opt = getopt(argc, argv, "dkt:n:")) != -1) {
+ while ((opt = getopt(argc, argv, "adkt:n:")) != -1) {
switch (opt) {
+ case 'a':
+ data->flag_insert_after = 1;
+ break;
case 'd':
data->flag_detached = 1;
break;
@@ -118,13 +123,36 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct winlink *wl;
char *cmd, *cwd, *cause;
- int idx;
+ int idx, last;
if (data == NULL)
return (0);
- if ((idx = cmd_find_index(ctx, data->target, &s)) == -2)
- return (-1);
+ if (data->flag_insert_after) {
+ if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
+ return (-1);
+ idx = wl->idx + 1;
+
+ /* Find the next free index. */
+ for (last = idx; last < INT_MAX; last++) {
+ if (winlink_find_by_index(&s->windows, last) == NULL)
+ break;
+ }
+ if (last == INT_MAX) {
+ ctx->error(ctx, "no free window indexes");
+ return (-1);
+ }
+
+ /* Move everything from last - 1 to idx up a bit. */
+ for (; last > idx; last--) {
+ wl = winlink_find_by_index(&s->windows, last - 1);
+ server_link_window(s, wl, s, last, 0, 0, NULL);
+ server_unlink_window(s, wl);
+ }
+ } else {
+ if ((idx = cmd_find_index(ctx, data->target, &s)) == -2)
+ return (-1);
+ }
wl = NULL;
if (idx != -1)
@@ -134,7 +162,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
* Can't use session_detach as it will destroy session if this
* makes it empty.
*/
- session_alert_cancel(s, wl);
+ wl->flags &= ~WINLINK_ALERTFLAGS;
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
@@ -148,10 +176,13 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd = data->cmd;
if (cmd == NULL)
cmd = options_get_string(&s->options, "default-command");
- if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
- cwd = options_get_string(&s->options, "default-path");
- else
- cwd = ctx->cmdclient->cwd;
+ 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;
+ }
if (idx == -1)
idx = -1 - options_get_number(&s->options, "base-index");
View
174 cmd-paste-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-paste-buffer.c,v 1.24 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-paste-buffer.c,v 1.28 2010/06/06 00:03:02 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -18,6 +18,7 @@
#include <sys/types.h>
+#include <stdlib.h>
#include <string.h>
#include "tmux.h"
@@ -26,32 +27,112 @@
* Paste paste buffer if present.
*/
+struct cmd_paste_buffer_data {
+ char *target;
+ int buffer;
+
+ int flag_delete;
+ char *sepstr;
+};
+
+void cmd_paste_buffer_init(struct cmd *, int);
+int cmd_paste_buffer_parse(struct cmd *, int, char **, char **);
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
-void cmd_paste_buffer_lf2cr(struct window_pane *, const char *, size_t);
+void cmd_paste_buffer_filter(
+ struct window_pane *, const char *, size_t, char *);
+void cmd_paste_buffer_free(struct cmd *);
+size_t cmd_paste_buffer_print(struct cmd *, char *, size_t);
const struct cmd_entry cmd_paste_buffer_entry = {
"paste-buffer", "pasteb",
- "[-dr] " CMD_BUFFER_WINDOW_USAGE,
- 0, "dr",
- cmd_buffer_init,
- cmd_buffer_parse,
+ "[-dr] [-s separator] [-b buffer-index] [-t target-window]",
+ 0, "",
+ cmd_paste_buffer_init,
+ cmd_paste_buffer_parse,
cmd_paste_buffer_exec,
- cmd_buffer_free,
- cmd_buffer_print
+ cmd_paste_buffer_free,
+ cmd_paste_buffer_print
};
+/* ARGSUSED */
+void
+cmd_paste_buffer_init(struct cmd *self, unused int arg)
+{
+ struct cmd_paste_buffer_data *data;
+
+ self->data = data = xmalloc(sizeof *data);
+ data->target = NULL;
+ data->buffer = -1;
+ data->flag_delete = 0;
+ data->sepstr = xstrdup("\r");
+}
+
+int
+cmd_paste_buffer_parse(struct cmd *self, int argc, char **argv, char **cause)
+{
+ struct cmd_paste_buffer_data *data;
+ int opt, n;
+ const char *errstr;
+
+ cmd_paste_buffer_init(self, 0);
+ data = self->data;
+
+ while ((opt = getopt(argc, argv, "b:ds:t:r")) != -1) {
+ switch (opt) {
+ case 'b':
+ if (data->buffer == -1) {
+ n = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr != NULL) {
+ xasprintf(cause, "buffer %s", errstr);
+ goto error;
+ }
+ data->buffer = n;
+ }
+ break;
+ case 'd':
+ data->flag_delete = 1;
+ break;
+ case 's':
+ if (data->sepstr != NULL)
+ xfree(data->sepstr);
+ data->sepstr = xstrdup(optarg);
+ break;
+ case 't':
+ if (data->target == NULL)
+ data->target = xstrdup(optarg);
+ break;
+ case 'r':
+ if (data->sepstr != NULL)
+ xfree(data->sepstr);
+ data->sepstr = xstrdup("\n");
+ break;
+ default:
+ goto usage;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ return (0);
+
+usage:
+ xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
+
+error:
+ self->entry->free(self);
+ return (-1);
+}
+
int
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_buffer_data *data = self->data;
- struct winlink *wl;
- struct window_pane *wp;
- struct session *s;
- struct paste_buffer *pb;
+ struct cmd_paste_buffer_data *data = self->data;
+ struct window_pane *wp;
+ struct session *s;
+ struct paste_buffer *pb;
- if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
+ if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
return (-1);
- wp = wl->window->active;
if (data->buffer == -1)
pb = paste_get_top(&s->buffers);
@@ -62,16 +143,11 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
}
- if (pb != NULL) {
- /* -r means raw data without LF->CR conversion. */
- if (cmd_check_flag(data->chflags, 'r'))
- bufferevent_write(wp->event, pb->data, pb->size);
- else
- cmd_paste_buffer_lf2cr(wp, pb->data, pb->size);
- }
+ if (pb != NULL)
+ cmd_paste_buffer_filter(wp, pb->data, pb->size, data->sepstr);
/* Delete the buffer if -d. */
- if (cmd_check_flag(data->chflags, 'd')) {
+ if (data->flag_delete) {
if (data->buffer == -1)
paste_free_top(&s->buffers);
else
@@ -81,20 +157,66 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0);
}
-/* Add bytes to a buffer but change every '\n' to '\r'. */
+/* Add bytes to a buffer and filter '\n' according to separator. */
void
-cmd_paste_buffer_lf2cr(struct window_pane *wp, const char *data, size_t size)
+cmd_paste_buffer_filter(
+ struct window_pane *wp, const char *data, size_t size, char *sep)
{
const char *end = data + size;
const char *lf;
+ size_t seplen;
+ seplen = strlen(sep);
while ((lf = memchr(data, '\n', end - data)) != NULL) {
if (lf != data)
bufferevent_write(wp->event, data, lf - data);
- bufferevent_write(wp->event, "\r", 1);
+ bufferevent_write(wp->event, sep, seplen);
data = lf + 1;
}
if (end != data)
bufferevent_write(wp->event, data, end - data);
}
+
+void
+cmd_paste_buffer_free(struct cmd *self)
+{
+ struct cmd_paste_buffer_data *data = self->data;
+
+ if (data->target != NULL)
+ xfree(data->target);
+ if (data->sepstr != NULL)
+ xfree(data->sepstr);
+ xfree(data);
+}
+
+size_t
+cmd_paste_buffer_print(struct cmd *self, char *buf, size_t len)
+{
+ struct cmd_paste_buffer_data *data = self->data;
+ size_t off = 0;
+ char tmp[BUFSIZ];
+ int r_flag;
+
+ r_flag = 0;
+ if (data->sepstr != NULL)
+ r_flag = (data->sepstr[0] == '\n' && data->sepstr[1] == '\0');
+
+ off += xsnprintf(buf, len, "%s", self->entry->name);
+ if (data == NULL)
+ return (off);
+ if (off < len && data->flag_delete)
+ off += xsnprintf(buf + off, len - off, " -d");
+ if (off < len && r_flag)
+ off += xsnprintf(buf + off, len - off, " -r");
+ if (off < len && data->buffer != -1)
+ off += xsnprintf(buf + off, len - off, " -b %d", data->buffer);
+ if (off < len && data->sepstr != NULL && !r_flag) {
+ strnvis(
+ tmp, data->sepstr, sizeof tmp, VIS_OCTAL|VIS_TAB|VIS_NL);
+ off += cmd_prarg(buf + off, len - off, " -s ", tmp);
+ }
+ if (off < len && data->target != NULL)
+ off += cmd_prarg(buf + off, len - off, " -t ", data->target);
+ return (off);
+}
View
13 cmd-pipe-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-pipe-pane.c,v 1.10 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-pipe-pane.c,v 1.13 2010/06/15 20:25:40 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -22,6 +22,7 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "tmux.h"
@@ -49,9 +50,14 @@ int
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
+ struct client *c;
struct window_pane *wp;
+ char *command;
int old_fd, pipe_fd[2], null_fd, mode;
+ if ((c = cmd_find_client(ctx, NULL)) == NULL)
+ return (-1);
+
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
return (-1);
@@ -90,7 +96,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
case 0:
/* Child process. */
close(pipe_fd[0]);
- server_signal_clear();
+ clear_signals();
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
_exit(1);
@@ -105,7 +111,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
close(null_fd);
- execl(_PATH_BSHELL, "sh", "-c", data->arg, (char *) NULL);
+ command = status_replace(c, NULL, data->arg, time(NULL), 0);
+ execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
_exit(1);
default:
/* Parent process. */
View
12 cmd-run-shell.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-run-shell.c,v 1.6 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-run-shell.c,v 1.8 2010/07/17 14:36:40 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -82,6 +82,11 @@ cmd_run_shell_callback(struct job *job)
int retcode;
u_int lines;
+ if (ctx->cmdclient != NULL && ctx->cmdclient->flags & CLIENT_DEAD)
+ return;
+ if (ctx->curclient != NULL && ctx->curclient->flags & CLIENT_DEAD)
+ return;
+
lines = 0;
do {
if ((line = evbuffer_readline(job->event->input)) != NULL) {
@@ -126,10 +131,13 @@ cmd_run_shell_free(void *data)
{
struct cmd_run_shell_data *cdata = data;
struct cmd_ctx *ctx = &cdata->ctx;
+ struct msg_exit_data exitdata;
if (ctx->cmdclient != NULL) {
ctx->cmdclient->references--;
- server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+ exitdata.retcode = ctx->cmdclient->retcode;
+ server_write_client(
+ ctx->cmdclient, MSG_EXIT, &exitdata, sizeof exitdata);
}
if (ctx->curclient != NULL)
ctx->curclient->references--;
View
35 cmd-save-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-save-buffer.c,v 1.10 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-save-buffer.c,v 1.11 2010/07/02 02:52:13 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -48,7 +48,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct paste_buffer *pb;
mode_t mask;
- FILE *f;
+ FILE *f, *close_f;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
@@ -65,15 +65,25 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
}
- mask = umask(S_IRWXG | S_IRWXO);
- if (cmd_check_flag(data->chflags, 'a'))
- f = fopen(data->arg, "ab");
- else
- f = fopen(data->arg, "wb");
- umask(mask);
- if (f == NULL) {
- ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
- return (-1);
+ if (strcmp(data->arg, "-") == 0) {
+ if (ctx->cmdclient == NULL) {
+ ctx->error(ctx, "%s: can't write to stdout", data->arg);
+ return (-1);
+ }
+ f = ctx->cmdclient->stdout_file;
+ close_f = NULL;
+ } else {
+ mask = umask(S_IRWXG | S_IRWXO);
+ if (cmd_check_flag(data->chflags, 'a'))
+ f = fopen(data->arg, "ab");
+ else
+ f = fopen(data->arg, "wb");
+ umask(mask);
+ if (f == NULL) {
+ ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
+ return (-1);
+ }
+ close_f = f;
}
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
@@ -82,7 +92,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
- fclose(f);
+ if (close_f != NULL)
+ fclose(close_f);
return (0);
}
View
20 cmd-select-layout.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-select-layout.c,v 1.10 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-select-layout.c,v 1.12 2010/07/02 02:54:52 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -59,6 +59,9 @@ cmd_select_layout_init(struct cmd *self, int key)
case ('4' | KEYC_ESCAPE):
data->arg = xstrdup("main-vertical");
break;
+ case ('5' | KEYC_ESCAPE):
+ data->arg = xstrdup("tiled");
+ break;
}
}
@@ -76,13 +79,16 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
layout = wl->window->lastlayout;
if (layout == -1)
return (0);
- } else if ((layout = layout_set_lookup(data->arg)) == -1) {
- ctx->error(ctx, "unknown layout or ambiguous: %s", data->arg);
- return (-1);
+ } else if ((layout = layout_set_lookup(data->arg)) != -1) {
+ layout = layout_set_select(wl->window, layout);
+ ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
+ } else {
+ if (layout_parse(wl->window, data->arg) == -1) {
+ ctx->error(ctx, "can't set layout: %s", data->arg);
+ return (-1);
+ }
+ ctx->info(ctx, "arranging in: %s", data->arg);
}
- layout = layout_set_select(wl->window, layout);
- ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
-
return (0);
}
View
43 cmd-select-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-select-pane.c,v 1.12 2010/01/05 23:52:37 tcunha Exp $ */
+/* $Id: cmd-select-pane.c,v 1.13 2010/03/15 22:03:38 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -24,19 +24,40 @@
* Select pane.
*/
+void cmd_select_pane_init(struct cmd *, int);
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_select_pane_entry = {
"select-pane", "selectp",
- CMD_TARGET_PANE_USAGE,
- 0, "",
- cmd_target_init,
+ "[-DLRU] " CMD_TARGET_PANE_USAGE,
+ 0, "DLRU",
+ cmd_select_pane_init,
cmd_target_parse,
cmd_select_pane_exec,
cmd_target_free,
cmd_target_print
};
+void
+cmd_select_pane_init(struct cmd *self, int key)
+{
+ struct cmd_target_data *data;
+
+ cmd_target_init(self, key);
+ data = self->data;
+
+ if (key == KEYC_UP)
+ cmd_set_flag(&data->chflags, 'U');
+ if (key == KEYC_DOWN)
+ cmd_set_flag(&data->chflags, 'D');
+ if (key == KEYC_LEFT)
+ cmd_set_flag(&data->chflags, 'L');
+ if (key == KEYC_RIGHT)
+ cmd_set_flag(&data->chflags, 'R');
+ if (key == 'o')
+ data->target = xstrdup(":.+");
+}
+
int
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
@@ -51,6 +72,20 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->error(ctx, "pane not visible: %s", data->target);
return (-1);
}
+
+ if (cmd_check_flag(data->chflags, 'L'))
+ wp = window_pane_find_left(wp);
+ else if (cmd_check_flag(data->chflags, 'R'))
+ wp = window_pane_find_right(wp);
+ else if (cmd_check_flag(data->chflags, 'U'))
+ wp = window_pane_find_up(wp);
+ else if (cmd_check_flag(data->chflags, 'D'))
+ wp = window_pane_find_down(wp);
+ if (wp == NULL) {
+ ctx->error(ctx, "pane not found");
+ return (-1);
+ }
+
window_set_active_pane(wl->window, wp);
server_status_window(wl->window);
server_redraw_window_borders(wl->window);
View
91 cmd-select-prompt.c
@@ -1,91 +0,0 @@
-/* $Id: cmd-select-prompt.c,v 1.13 2009/11/14 17:56:39 tcunha Exp $ */
-
-/*
- * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-
-#include <stdlib.h>
-
-#include "tmux.h"
-
-/*
- * Prompt for window index and select it.
- */
-
-int cmd_select_prompt_exec(struct cmd *, struct cmd_ctx *);
-
-int cmd_select_prompt_callback(void *, const char *);
-
-const struct cmd_entry cmd_select_prompt_entry = {
- "select-prompt", NULL,
- CMD_TARGET_CLIENT_USAGE,
- 0, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_select_prompt_exec,
- cmd_target_free,
- cmd_target_print
-};
-
-int
-cmd_select_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
-{
- struct cmd_target_data *data = self->data;
- struct client *c;
-
- if ((c = cmd_find_client(ctx, data->target)) == NULL)
- return (-1);
-
- if (c->prompt_string != NULL)
- return (0);
-
- status_prompt_set(c, "index ", cmd_select_prompt_callback, NULL, c, 0);
-
- return (0);
-}
-
-int
-cmd_select_prompt_callback(void *data, const char *s)
-{
- struct client *c = data;
- const char *errstr;
- char msg[128];
- u_int idx;
-
- if (s == NULL || *s == '\0')
- return (0);
-
- idx = strtonum(s, 0, UINT_MAX, &errstr);
- if (errstr != NULL) {
- xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
- status_message_set(c, "%s", msg);
- return (0);
- }
-
- if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
- xsnprintf(msg, sizeof msg,
- "Window not found: %s:%d", c->session->name, idx);
- status_message_set(c, "%s", msg);
- return (0);
- }
-
- if (session_select(c->session, idx) == 0)
- server_redraw_session(c->session);
- recalculate_sizes();
-
- return (0);
-}
View
7 cmd-send-keys.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-send-keys.c,v 1.24 2009/12/04 22:14:47 tcunha Exp $ */
+/* $Id: cmd-send-keys.c,v 1.25 2010/05/22 21:56:04 micahcowan Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -105,16 +105,17 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_send_keys_data *data = self->data;
struct window_pane *wp;
+ struct session *s;
u_int i;
if (data == NULL)
return (-1);
- if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
+ if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
return (-1);
for (i = 0; i < data->nkeys; i++)
- window_pane_key(wp, ctx->curclient, data->keys[i]);
+ window_pane_key(wp, s, data->keys[i]);
return (0);
}
View
4 cmd-send-prefix.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-send-prefix.c,v 1.28 2009/11/14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-send-prefix.c,v 1.29 2010/05/22 21:56:04 micahcowan Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -49,7 +49,7 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
keylist = options_get_data(&s->options, "prefix");
- window_pane_key(wp, ctx->curclient, ARRAY_FIRST(keylist));
+ window_pane_key(wp, s, ARRAY_FIRST(keylist));
return (0);
}
View
6 cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-set-option.c,v 1.96 2010/02/26 13:31:39 tcunha Exp $ */
+/* $Id: cmd-set-option.c,v 1.98 2010/07/02 02:45:52 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -87,6 +87,7 @@ const struct set_option_entry set_session_option_table[] = {
{ "default-path", SET_OPTION_STRING, 0, 0, NULL },
{ "default-shell", SET_OPTION_STRING, 0, 0, NULL },
{ "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
+ { "detach-on-destroy", SET_OPTION_FLAG, 0, 0, NULL },
{ "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
{ "display-panes-active-colour", SET_OPTION_COLOUR, 0, 0, NULL },
{ "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },
@@ -157,6 +158,9 @@ const struct set_option_entry set_window_option_table[] = {
{ "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
{ "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
{ "utf8", SET_OPTION_FLAG, 0, 0, NULL },
+ { "window-status-alert-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
+ { "window-status-alert-bg", SET_OPTION_COLOUR, 0, 0, NULL },
+ { "window-status-alert-fg", SET_OPTION_COLOUR, 0, 0, NULL },
{ "window-status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
{ "window-status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
{ "window-status-current-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
View
13 cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-split-window.c,v 1.34 2010/01/08 16:31:35 tcunha Exp $ */
+/* $Id: cmd-split-window.c,v 1.35 2010/07/02 02:49:19 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -169,10 +169,13 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd = data->cmd;
if (cmd == NULL)
cmd = options_get_string(&s->options, "default-command");
- if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
- cwd = options_get_string(&s->options, "default-path");
- else
- cwd = ctx->cmdclient->cwd;
+ 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;
+ }
type = LAYOUT_TOPBOTTOM;
if (data->flag_horizontal)
View
60 cmd-up-pane.c
@@ -1,60 +0,0 @@
-/* $Id: cmd-up-pane.c,v 1.14 2010/01/05 23:52:37 tcunha Exp $ */
-
-/*
- * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-
-#include "tmux.h"
-
-/*
- * Move up a pane.
- */
-
-int cmd_up_pane_exec(struct cmd *, struct cmd_ctx *);
-
-const struct cmd_entry cmd_up_pane_entry = {
- "up-pane", "upp",
- CMD_TARGET_WINDOW_USAGE,
- 0, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_up_pane_exec,
- cmd_target_free,
- cmd_target_print
-};
-
-int
-cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
-{
- struct cmd_target_data *data = self->data;
- struct winlink *wl;
- struct window *w;
-
- if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
- return (-1);
- w = wl->window;
-
- do {
- w->active = TAILQ_PREV(w->active, window_panes, entry);
- if (w->active == NULL)
- w->active = TAILQ_LAST(&w->panes, window_panes);
- } while (!window_pane_visible(w->active));
- server_status_window(wl->window);
- server_redraw_window_borders(wl->window);
-
- return (0);
-}
View
176 cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.137 2010/01/22 17:28:34 tcunha Exp $ */
+/* $Id: cmd.c,v 1.142 2010/07/17 14:38:13 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,6 +31,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_bind_key_entry,
&cmd_break_pane_entry,
&cmd_capture_pane_entry,
+ &cmd_choose_buffer_entry,
&cmd_choose_client_entry,
&cmd_choose_session_entry,
&cmd_choose_window_entry,
@@ -44,7 +45,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_detach_client_entry,
&cmd_display_message_entry,
&cmd_display_panes_entry,
- &cmd_down_pane_entry,
&cmd_find_window_entry,
&cmd_has_session_entry,
&cmd_if_shell_entry,
@@ -85,7 +85,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_save_buffer_entry,
&cmd_select_layout_entry,
&cmd_select_pane_entry,
- &cmd_select_prompt_entry,
&cmd_select_window_entry,
&cmd_send_keys_entry,
&cmd_send_prefix_entry,
@@ -108,7 +107,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_switch_client_entry,
&cmd_unbind_key_entry,
&cmd_unlink_window_entry,
- &cmd_up_pane_entry,
NULL
};
@@ -118,6 +116,9 @@ struct client *cmd_lookup_client(const char *);
struct session *cmd_lookup_session(const char *, int *);
struct winlink *cmd_lookup_window(struct session *, const char *, int *);
int cmd_lookup_index(struct session *, const char *, int *);
+struct winlink *cmd_find_window_offset(const char *, struct session *, int *);
+int cmd_find_index_offset(const char *, struct session *, int *);
+struct window_pane *cmd_find_pane_offset(const char *, struct winlink *);
int
cmd_pack_argv(int argc, char **argv, char *buf, size_t len)
@@ -540,7 +541,7 @@ cmd_lookup_session(const char *name, int *ambiguous)
/*
* Lookup a window or return -1 if not found or ambigious. First try as an
* index and if invalid, use fnmatch or leading prefix. Return NULL but fill in
- * idx if the window index is a valid number but there is now window with that
+ * idx if the window index is a valid number but there is no window with that
* index.
*/
struct winlink *
@@ -707,10 +708,8 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp)
wl = s->curw;
else if (winptr[0] == '!' && winptr[1] == '\0')
wl = TAILQ_FIRST(&s->lastw);
- else if (winptr[0] == '+' && winptr[1] == '\0')
- wl = winlink_next(s->curw);
- else if (winptr[0] == '-' && winptr[1] == '\0')
- wl = winlink_previous(s->curw);
+ else if (winptr[0] == '+' || winptr[0] == '-')
+ wl = cmd_find_window_offset(winptr, s, &ambiguous);
else
wl = cmd_lookup_window(s, winptr, &ambiguous);
if (wl == NULL)
@@ -728,25 +727,28 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp)
if (arg[0] == '!' && arg[1] == '\0') {
if ((wl = TAILQ_FIRST(&s->lastw)) == NULL)
goto not_found;
- } else if (arg[0] == '+' && arg[1] == '\0') {
- if ((wl = winlink_next(s->curw)) == NULL)
- goto not_found;
- } else if (arg[0] == '-' && arg[1] == '\0') {
- if ((wl = winlink_previous(s->curw)) == NULL)
- goto not_found;
- } else if ((wl = cmd_lookup_window(s, arg, &ambiguous)) == NULL) {
- if (ambiguous)
- goto not_found;
- if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
- goto no_session;
- wl = s->curw;
- }
+ } else if (arg[0] == '+' || arg[0] == '-') {
+ if ((wl = cmd_find_window_offset(arg, s, &ambiguous)) == NULL)
+ goto lookup_session;
+ } else if ((wl = cmd_lookup_window(s, arg, &ambiguous)) == NULL)
+ goto lookup_session;
if (sp != NULL)
*sp = s;
return (wl);
+lookup_session:
+ if (ambiguous)
+ goto not_found;
+ if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)