Commit Graph

273 Commits (7e4908f751f30473435da7abb8054f24971d688e)

Author SHA1 Message Date
nicm 900f6fc17e Tidy up some includes. 2014-10-20 23:27:14 +00:00
Thomas Adam 953c3ef47a Merge branch 'obsd-master'
Conflicts:
	Makefile
	tmux.1
	window.c
2014-04-23 11:26:11 +01:00
nicm a5d4b7f3d9 Some more long lines. 2014-04-17 14:45:49 +00:00
Nicholas Marriott 4273c1b80e Use utempter to update utmp if it's around for configure, from madmaverick9 at
roxxmail dot eu.
2014-02-24 23:07:22 +00:00
Thomas Adam b3de4a3dec Merge branch 'obsd-master'
Conflicts:
	tmux.1
	tmux.c
2014-02-16 23:02:07 +00:00
nicm f835be4bb2 Style nit - no space between function name and bracket. 2014-02-14 13:59:01 +00:00
nicm 282c5f9644 Alter how tmux handles the working directory to internally use file
descriptors rather than strings.

- Each session still has a current working directory.

- New sessions still get their working directory from the client that
  created them or its attached session if any.

- New windows are created by default in the session working directory.

- The -c flag to new, neww, splitw allows the working directory to be
  overridden.

- The -c flag to attach let's the session working directory be changed.

- The default-path option has been removed.

To get the equivalent to default-path '.', do:

        bind c neww -c $PWD

To get the equivalent of default-path '~', do:

        bind c neww -c ~

This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
2013-10-10 12:26:34 +00:00
nicm 10c38436aa Similarly for MSG_COMMAND - allow full imsg limit not arbitrary 2048. 2013-10-10 12:13:56 +00:00
nicm d3830e622f Grouped sessions were being leaked on destroy, correctly free them. 2013-10-10 11:46:28 +00:00
Nicholas Marriott 4538c269d0 Alter how tmux handles the working directory to internally use file descriptors
rather than strings.

- Each session still has a current working directory.

- New sessions still get their working directory from the client that created
  them or its attached session if any.

- New windows are created by default in the session working directory.

- The -c flag to new, neww, splitw allows the working directory to be
  overridden.

- The -c flag to attach let's the session working directory be changed.

- The default-path option has been removed.

To get the equivalent to default-path '.', do:

        bind c neww -c $PWD

To get the equivalent of default-path '', do:

        bind c neww -c '#{pane_current_path}'

The equivalent of default-path '~' is left as an exercise for the reader.

This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
2013-10-06 21:02:23 +01:00
Nicholas Marriott fa1375c09f Similarly for MSG_COMMAND - allow full imsg limit not arbitrary 2048. 2013-10-06 00:48:24 +01:00
Nicholas Marriott f141e9b37a Instead of fixed size buffers for some messages, send only the string length. 2013-10-06 00:28:35 +01:00
Nicholas Marriott b0b5cad496 Grouped sessions were being leaked on destroy, correctly free them. 2013-08-01 23:38:35 +01:00
Thomas Adam bdea2f9eda Merge branch 'obsd-master' 2013-07-06 11:18:49 +01:00
Nicholas Marriott 064124cc5f When the session option renumber-window is used, ensure we iterate over
all sessions in that group when the winlinks are reordered, otherwise
the winlink lists are out of sync with one another. From Thomas Adam.
2013-07-05 14:52:33 +00:00
Thomas Adam cd60e57b6a Merge branch 'obsd-master'
Sync from OpenBSD.
2013-04-23 08:26:04 +01:00
Nicholas Marriott 46c7dbef0f Call recalculate_sizes() after killing window in case it is in a grouped
session, from Daniel Ralston.
2013-04-22 13:35:18 +00:00
Nicholas Marriott e4c0730bf1 Use single stdout and stderr for control clients. 2013-03-25 11:36:59 +00:00
Nicholas Marriott 6fee3e9e4b Rename session idx to session id throughout and add $ prefix to targets
to use it, extended from a diff from George Nachman.
2013-03-25 10:11:45 +00:00
Nicholas Marriott c71844de63 Add resize-pane -Z to temporary zoom the active pane to occupy the full
window or unzoom (restored to the normal layout) if it already zoomed,
bound to C-b z by default. The pane is unzoomed on pretty much any
excuse whatsoever.

We considered making this a new layout but the requirements are quite
different from layouts so decided it is better as a special case. Each
current layout cell is saved, a temporary one-cell layout generated and
all except the active pane set to NULL.

Prompted by suggestions and scripts from several. Thanks to Aaron Jensen
and Thiago Padilha for testing an earlier version.
2013-03-24 09:57:59 +00:00
Nicholas Marriott 20636d956d Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.
2013-03-24 09:54:10 +00:00
Nicholas Marriott 29613f2f31 Prevent lock on control clients, not on others. 2013-03-22 10:42:55 +00:00
Nicholas Marriott 8d59b189cc No more lint means no more ARGSUSED. 2013-03-22 10:31:22 +00:00
Nicholas Marriott c5504af4a6 Add various checks to turn off bits that can't work in control mode
(such as lock).
2013-03-21 18:47:01 +00:00
Nicholas Marriott 412ac6bc3a Use single stdout and stderr for control clients. 2013-03-11 09:46:18 +00:00
Nicholas Marriott f47a063841 Rename session idx to session id throughout and add $ prefix to targets to use
it, extended from a diff from George Nachman.
2013-03-07 10:07:22 +00:00
Nicholas Marriott c5239c5984 Add resize-pane -Z to temporary zoom the active pane to occupy the full window
or unzoom (restored to the normal layout) if it already zoomed, bound to C-b z
by default. The pane is unzoomed on pretty much any excuse whatsoever.

We considered making this a new layout but the requirements are quite different
from layouts so decided it is better as a special case. Each current layout
cell is saved, a temporary one-cell layout generated and all except the active
pane set to NULL.

Prompted by suggestions and scripts from several. Thanks to Aaron Jensen and
Thiago Padilha for testing an earlier version.
2013-02-24 00:25:03 +00:00
Nicholas Marriott 3964309c67 Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent commands. This
allows run-shell and if-shell to be synchronous which has been much requested.

Each client has a default command queue and commands are consumed one at a time
from it. A command may suspend execution from the queue by returning
CMD_RETURN_WAIT and then resume it by calling cmd_continue() - for example
run-shell does this from the callback that is fired after the job is freed.

When the command queue becomes empty, command clients are automatically exited
(unless attaching). A callback is also fired - this is used for nested commands
in, for example, if-shell which can block execution of the client's cmdq until
a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the old
curclient/cmdclient distinction - a cmdq is bound to one client (or none if in
the configuration file), this is a command client if c->session is NULL
otherwise an attached client.
2013-02-23 22:25:58 +00:00
Nicholas Marriott 8a7d463b87 Prevent lock on control clients, not on others. 2013-02-19 21:11:32 +00:00
Nicholas Marriott 9d165df18a No more lint means no more ARGSUSED. 2013-02-17 23:15:38 +00:00
Nicholas Marriott 3d9fd1c7f2 Add various checks to turn off bits that can't work in control mode (such as
lock).
2013-02-17 10:12:55 +00:00
Nicholas Marriott f536dc47c4 If stdin in the client is enable immediately, tmux will eat anything
sent to stdin before it is needed, which can be inconvenient (eg pasting
commands). Instead, start with stdin disabled and reuse MSG_STDIN from
server->client to mean that stdin should be enabled. Based on a diff
from Chris Johnsen.
2012-09-04 22:35:52 +01:00
Nicholas Marriott 2e43372d0b If stdin in the client is enable immediately, tmux will eat anything
sent to stdin before it is needed, which can be inconvenient (eg pasting
commands). Instead, start with stdin disabled and reuse MSG_STDIN from
server->client to mean that stdin should be enabled. Based on a diff
from Chris Johnsen.
2012-09-03 08:48:57 +00:00
Tiago Cunha a432fcd306 Sync OpenBSD patchset 1150:
xfree is not particularly helpful, remove it. From Thomas Adam.
2012-07-11 19:34:16 +00:00
Nicholas Marriott df912e3540 xfree is not particularly helpful, remove it. From Thomas Adam. 2012-07-10 11:53:01 +00:00
Tiago Cunha 0159c74a32 Sync OpenBSD patchset 1138:
Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.
2012-06-18 15:23:01 +00:00
Nicholas Marriott 2942eca895 Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.
2012-06-18 13:16:42 +00:00
Tiago Cunha baafc17a1e Sync OpenBSD patchset 1118:
Add a helper function to send ready message.
2012-05-22 20:59:58 +00:00
Tiago Cunha ffab6dbc9a Sync OpenBSD patchset 1114:
Instead of passing stdin/stdout/stderr file descriptors over imsg and
handling them in the server, handle them in the client and pass buffers
over imsg. This is much tidier for some upcoming changes and the
performance hit isn't critical.

The tty fd is still passed to the server as before.

This bumps the tmux protocol version so new clients and old servers are
incompatible.
2012-05-22 20:56:35 +00:00
Nicholas Marriott 682884edc5 Add a helper function to send ready message. 2012-05-22 10:56:48 +00:00
Nicholas Marriott 7a4679a17f Instead of passing stdin/stdout/stderr file descriptors over imsg and
handling them in the server, handle them in the client and pass buffers
over imsg. This is much tidier for some upcoming changes and the
performance hit isn't critical.

The tty fd is still passed to the server as before.

This bumps the tmux protocol version so new clients and old servers are
incompatible.
2012-05-21 18:27:42 +00:00
Tiago Cunha b728970c65 Sync OpenBSD patchset 1104:
Add a flag to move-window to renumber the windows in a session (closing
any gaps) and add an option to do this automatically each time a window
is killed. From Thomas Adam.
2012-05-03 17:51:04 +00:00
Nicholas Marriott a6c22d650b Add a flag to move-window to renumber the windows in a session (closing
any gaps) and add an option to do this automatically each time a window
is killed. From Thomas Adam.
2012-04-29 17:20:01 +00:00
Tiago Cunha f41efd9d89 Sync OpenBSD patchset 1069:
Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
2012-03-18 02:22:09 +00:00
Tiago Cunha 0987d55231 Sync OpenBSD patchset 1057:
Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.
2012-03-18 01:59:34 +00:00
Nicholas Marriott 46210344a6 Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
2012-03-17 22:35:09 +00:00
Nicholas Marriott d3c842d367 Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.
2012-03-17 18:24:07 +00:00
Tiago Cunha e23df3af5a Sync OpenBSD patchset 1014:
Call bufferevent_free before closing file descriptor associated with it
or bugs in $EventMechanism on $OtherOS makes libevent get it's knickers
in a twist. From Dylan Alex Simon.
2012-01-29 12:53:33 +00:00
Nicholas Marriott 9bbc63ed65 Call bufferevent_free before closing file descriptor associated with it
or bugs in $EventMechanism on $OtherOS makes libevent get it's knickers
in a twist. From Dylan Alex Simon.
2012-01-29 02:22:11 +00:00
Tiago Cunha 03ee7f7edf Sync OpenBSD patchset 969:
Support for \e[3J to clear the history. Also send the corresponding
terminfo code (E3) before locking.
2011-10-23 15:10:22 +00:00
Nicholas Marriott f0aad68aee Support for \e[3J to clear the history. Also send the corresponding
terminfo code (E3) before locking.
2011-10-23 10:16:14 +00:00
Tiago Cunha 6e0c097d9f Sync OpenBSD patchset 957:
Mark dead panes with some text saying they are dead, suggested by and
with help from Randy Stauner.
2011-09-21 16:35:13 +00:00
Nicholas Marriott 5985143813 Mark dead panes with some text saying they are dead, suggested by and
with help from Randy Stauner.
2011-09-05 23:40:51 +00:00
Tiago Cunha 391f1f08c0 Expand the Id keyword. 2011-07-09 09:42:33 +00:00
Tiago Cunha d0d1c0e486 Sync OpenBSD patchset 848:
Set $TMUX without the session when background jobs are run.
2011-02-14 23:11:33 +00:00
Nicholas Marriott b8023044c3 Set $TMUX without the session when background jobs are run. 2011-01-23 11:03:43 +00:00
Tiago Cunha d3c04b74ec Sync OpenBSD patchset 819:
Don't reset the activity timer for unattached sessions every second,
this screws up the choice of most-recently-used. Instead, break the time
update into a little function and do it when the session is attached.

Pointed out by joshe@.
2011-01-03 23:27:54 +00:00
Nicholas Marriott 04b32fa734 Don't reset the activity timer for unattached sessions every second,
this screws up the choice of most-recently-used. Instead, break the time
update into a little function and do it when the session is attached.

Pointed out by joshe@.
2011-01-01 01:12:09 +00:00
Tiago Cunha 3cd9ea1789 Sync OpenBSD patchset 808:
server_kill_window can modify the RB tree so don't use RB_FOREACH, fixes
crash seen by Dan Harnett.
2010-12-25 23:44:37 +00:00
Nicholas Marriott d3d25365f1 server_kill_window can modify the RB tree so don't use RB_FOREACH, fixes
crash seen by Dan Harnett.
2010-12-23 21:56:38 +00:00
Tiago Cunha a373235106 Sync OpenBSD patchset 806:
Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists
(list-sessions/choose-sessions).

Keep a session index which is used in a couple of places internally but
make it an ever-increasing number rather than filling in gaps with new
sessions.
2010-12-22 15:36:44 +00:00
Tiago Cunha bb728b89a7 Sync OpenBSD patchset 802:
Use pointer rather than index for the client's last session.
2010-12-22 15:31:00 +00:00
Nicholas Marriott acf13ce978 Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists
(list-sessions/choose-sessions).

Keep a session index which is used in a couple of places internally but
make it an ever-increasing number rather than filling in gaps with new
sessions.
2010-12-21 22:37:59 +00:00
Nicholas Marriott 9358cfaf4a Use pointer rather than index for the client's last session. 2010-12-20 00:17:22 +00:00
Nicholas Marriott 5fcd6711e4 Track the last session for a client and add a flag to switch-client and
a key binding (L) to move a client back to its last session.
2010-12-11 18:42:20 +00:00
Nicholas Marriott 51487ed22f Track the last session for a client and add a flag to switch-client and
a key binding (L) to move a client back to its last session.
2010-12-11 18:39:25 +00:00
Tiago Cunha b2ae7c6261 Sync OpenBSD patchset 770:
Set cause when failing due to linking a window to itself, from Martin
Pieuchot.
2010-10-09 14:31:50 +00:00
Tiago Cunha 6c9269baa7 Sync OpenBSD patchset 769:
Skip NULL entries in the sessions list when choosing the next session,
from Simon Olofsson.
2010-10-09 14:31:14 +00:00
Tiago Cunha b5349ab5d9 Sync OpenBSD patchset 766:
Two new options:

- server option "exit-unattached" makes the server exit when no clients
  are attached, even if sessions are present;

- session option "destroy-unattached" destroys a session once no clients
  are attached to it.

These are useful for preventing tmux remaining in the background where
it is undesirable and when using tmux as a login shell to keep a limit
on new sessions.
2010-10-09 14:29:32 +00:00
Nicholas Marriott 7aef2994e4 Set cause when failing due to linking a window to itself, from Martin
Pieuchot.
2010-10-09 12:58:00 +00:00
Nicholas Marriott 08bcd6978c Skip NULL entries in the sessions list when choosing the next session,
from Simon Olofsson.
2010-10-05 17:15:21 +00:00
Nicholas Marriott 9a7cde0c9b Two new options:
- server option "exit-unattached" makes the server exit when no clients
  are attached, even if sessions are present;

- session option "destroy-unattached" destroys a session once no clients
  are attached to it.

These are useful for preventing tmux remaining in the background where
it is undesirable and when using tmux as a login shell to keep a limit
on new sessions.
2010-09-26 20:43:30 +00:00
Tiago Cunha e34c6e2305 Sync OpenBSD patchset 746:
Treat trying to link or move to the same window as an error to avoid
removing it accidentally.
2010-08-11 22:16:43 +00:00
Nicholas Marriott cc474b4ede Treat trying to link or move to the same window as an error to avoid
removing it accidentally.
2010-08-11 07:36:23 +00:00
Tiago Cunha d7bae0edce Sync OpenBSD patchset 741:
When changing so that the client passes its stdout and stderr as well as
stdin up to the server, I forgot one essential point - the tmux server
could now be both the producer and consumer. This happens when tmux is
run inside tmux, as well as when piping tmux commands together.

So, using stdio(3) was a bad idea - if sufficient data was written, this
could block in write(2). When that happened and the server was both
producer and consumer, it deadlocks.

Change to use libevent bufferevents for the client stdin, stdout and
stderr instead. This is trivial enough for output but requires a
callback mechanism to trigger when stdin is finished.

This relies on the underlying polling mechanism for libevent to work
with whatever devices to which the user could redirect stdin, stdout or
stderr, hence the change to use poll(2) over kqueue(2) for tmux.
2010-08-09 21:44:25 +00:00
Nicholas Marriott c87187f913 When changing so that the client passes its stdout and stderr as well as
stdin up to the server, I forgot one essential point - the tmux server
could now be both the producer and consumer. This happens when tmux is
run inside tmux, as well as when piping tmux commands together.

So, using stdio(3) was a bad idea - if sufficient data was written, this
could block in write(2). When that happened and the server was both
producer and consumer, it deadlocks.

Change to use libevent bufferevents for the client stdin, stdout and
stderr instead. This is trivial enough for output but requires a
callback mechanism to trigger when stdin is finished.

This relies on the underlying polling mechanism for libevent to work
with whatever devices to which the user could redirect stdin, stdout or
stderr, hence the change to use poll(2) over kqueue(2) for tmux.
2010-07-24 20:11:59 +00:00
Tiago Cunha fa34c76275 Sync OpenBSD patchset 729:
New option, detach-on-destroy, to set what happens to a client when the session
it is attached to is destroyed. If on (the default), it is detached; if off, it
is switched to the most recently active session.
2010-07-02 02:45:52 +00:00
Tiago Cunha 985cd3a4de Sync OpenBSD patchset 728:
Use server_destroy_session() for kill-session.
2010-07-02 02:43:50 +00:00
Nicholas Marriott 26524c99f6 New option, detach-on-destroy, to set what happens to a client when the session
it is attached to is destroyed. If on (the default), it is detached; if off, it
is switched to the most recently active session.
2010-06-27 00:22:22 +00:00
Nicholas Marriott 34464da8d3 Use server_destroy_session() for kill-session. 2010-06-26 23:55:50 +00:00
Tiago Cunha 47b335dee7 Sync OpenBSD patchset 724:
Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.
2010-06-22 23:26:18 +00:00
Nicholas Marriott e63f0546a1 Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.
2010-06-21 01:27:46 +00:00
Tiago Cunha b03418fc6b Sync OpenBSD patchset 682:
If remain-on-exit is set, both the error callback and a SIGCHLD could
destroy the same pane (because the first one doesn't remove it from the
list of panes), causing the pane bufferevent to be freed twice. So don't
free it if the fd has already been set to -1, from Romain Francoise.
2010-04-18 15:10:55 +00:00
Nicholas Marriott a6d52405a8 If remain-on-exit is set, both the error callback and a SIGCHLD could
destroy the same pane (because the first one doesn't remove it from the
list of panes), causing the pane bufferevent to be freed twice. So don't
free it if the fd has already been set to -1, from Romain Francoise.
2010-04-17 23:25:16 +00:00
Nicholas Marriott 67300e9524 Stupid style nits. 2010-04-06 21:45:36 +00:00
Nicholas Marriott 4012917302 Nuke unused functions. 2010-03-27 15:12:56 +00:00
Nicholas Marriott c550e66e85 Dead functions, lint. 2010-03-22 19:18:46 +00:00
Tiago Cunha 391b209008 Sync OpenBSD patchset 615:
When a window is destroyed, remove all links to it from each session rather
than just the first. Reported by Robin Lee Powell.
2010-01-25 17:13:43 +00:00
Nicholas Marriott b9ade6e6bb When a window is destroyed, remove all links to it from each session rather
than just the first. Reported by Robin Lee Powell.
2010-01-23 21:07:31 +00:00
Tiago Cunha 106011aa53 Sync OpenBSD patchset 597:
Options to set the colour of the pane borders, with different colours for the
active pane.
2010-01-05 23:52:37 +00:00
Nicholas Marriott 7e4f8b45b6 Options to set the colour of the pane borders, with different colours for the
active pane.
2010-01-03 12:51:05 +00:00
Tiago Cunha f81b3ddf94 Sync OpenBSD patchset 591:
Fix a couple of problems with grouped sessions reported by danh: redraw
properly and choose the correct last window after a window is killed.
2009-12-26 23:45:21 +00:00
Nicholas Marriott 4feee126b8 Fix a couple of problems with grouped sessions reported by danh: redraw
properly and choose the correct last window after a window is killed.
2009-12-22 10:20:08 +00:00
Tiago Cunha cc094fdfe6 Sync OpenBSD patchset 581:
Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...
2009-12-04 22:14:47 +00:00
Nicholas Marriott 15a64b805e Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...
2009-12-03 22:50:09 +00:00
Tiago Cunha c12e0b0708 Sync OpenBSD patchset 567:
Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.
2009-11-28 14:50:37 +00:00
Nicholas Marriott 4ca857e0e9 Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.
2009-11-26 21:37:13 +00:00
Tiago Cunha 72bc03ac4c Sync OpenBSD patchset 535:
Destroy panes immediately rather than checking them all every loop.
2009-11-14 17:48:39 +00:00
Nicholas Marriott 8e47966225 Destroy panes immediately rather than checking them all every loop. 2009-11-13 17:33:07 +00:00
Tiago Cunha 02438c01b7 Sync OpenBSD patchset 504:
Use timeout events for the identify and message timers.
2009-11-08 23:11:23 +00:00