Commit Graph

231 Commits

Author SHA1 Message Date
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 ee0f8adfac Handle focus events from the terminal, from Aaron Jensen. 2013-02-23 10:01:34 +00:00
Nicholas Marriott dbd8e47846 Do pane resize ioctls once at the end of the server loop rather than
immediately.
2013-02-22 21:35:29 +00:00
Nicholas Marriott 4c9f9438ff Add support for focus notifications when tmux pane changes, based on work by
Aaron Jensen.
2013-02-22 07:23:11 +00:00
Nicholas Marriott afd5e978cf Need to set clients in context before changing their reference count. 2013-02-20 10:25:15 +00:00
Nicholas Marriott 693244795c Remove unnecessary initializers of cmd_ctx. 2013-02-18 23:38:57 +00:00
Nicholas Marriott 293e331d69 Add functions to allocate and free command contexts rather than doing it all on
the stack.
2013-02-18 23:20:21 +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 06ac4b628d Add a format client_prefix which is 1 if prefix key has been pressed, used for
example #{?client_prefix,X,Y}. Also a few extra server_client_status needed.
2013-02-10 18:58:05 +00:00
Thomas Adam 64da762c15 Merge branch 'obsd-master' 2013-02-07 12:08:55 +00:00
Nicholas Marriott 85531fd404 Unused variable/type nit from Thomas Adam. 2013-01-30 17:00:17 +00:00
Thomas Adam a3f4eb7b24 Merge branch 'obsd-master'
Conflicts:
	Makefile
	grid-utf8.c
2013-01-30 15:27:19 +00:00
Nicholas Marriott c2e2107063 Style nits - return (x) not return x. 2013-01-18 02:10:29 +00:00
Thomas Adam de194016ec Merge branch 'obsd-master' 2013-01-17 01:38:21 +00:00
Nicholas Marriott bc2e4a36df If timing between keys is less than (by default) 1 millisecond, assume
the text is being pasted. assume-paste-time option changes the value (0
disables). Based on a diff from Marcin Kulik.
2013-01-15 22:55:29 +00:00
Thomas Adam 47fbf87185 Merge branch 'obsd-master'
Sync from OpenBSD.
2012-10-26 20:28:58 +01:00
Nicholas Marriott d210d99cce Make mouse event structure clearer by defining events (up, click, drag)
and simplifying how buttons and wheels are represented, from Ailin
Nemui. Should be no functional changes.
2012-10-26 14:35:42 +00:00
Thomas 80b5c0e076 Merge branch 'obsd-master'
Sync from OpenBSD.

* obsd-master:
  Do not leak file descriptor if not a tty, reported by Sebastien Marie.
2012-09-27 11:55:55 +01:00
Nicholas Marriott 7a3ec77dbd Do not leak file descriptor if not a tty, reported by Sebastien Marie. 2012-09-27 10:02:56 +00:00
Nicholas Marriott 41a448193f Send notifications to control clients. Also don't redraw client when
suspended.
2012-09-04 22:36:47 +01:00
Nicholas Marriott 9247c90d69 Send notifications to control clients. Also don't redraw client when
suspended.
2012-09-03 09:32:38 +00:00
Tiago Cunha 1f5e6e35d5 Sync OpenBSD patchset 1151:
Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11 19:37:32 +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 ede8312d59 Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11 07:10:15 +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 f4053bc217 Sync OpenBSD patchset 1140:
Remove a couple of unused variables from redbrain at gcc dot gnu dot org.
2012-07-04 10:54:45 +00:00
Nicholas Marriott a7917430d8 Remove a couple of unused variables from redbrain at gcc dot gnu dot org. 2012-06-20 12:55:55 +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 17da2f7d5f Sync OpenBSD patchset 1121:
Store client in tty struct directly instead of using a callback function
pointer.
2012-05-22 21:05:30 +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 84c708f355 Store client in tty struct directly instead of using a callback function
pointer.
2012-05-22 14:32:28 +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 1340c012b0 Sync OpenBSD patchset 1111:
Add a helper function to open the terminal for attach-/new-session.
2012-05-12 15:00:19 +00:00
Nicholas Marriott 37f9bb46d8 Add a helper function to open the terminal for attach-/new-session. 2012-05-06 07:38:17 +00:00
Tiago Cunha bae2701289 Sync OpenBSD patchset 1092:
Stop accepting new clients for 1 second on EMFILE/ENFILE. Based on
ongoing fixes to other daemons by Theo.
2012-04-12 12:43:40 +00:00
Nicholas Marriott 6703ca8d26 Stop accepting new clients for 1 second on EMFILE/ENFILE. Based on
ongoing fixes to other daemons by Theo.
2012-04-11 06:16:14 +00:00
Tiago Cunha cf8faa3b33 Sync OpenBSD patchset 1064:
Need to call recalculate_sizes() when changing window with the mouse,
from marcel partap.
2012-03-18 02:10:50 +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
Tiago Cunha 166681eee9 Sync OpenBSD patchset 1045:
Remove some bits leftover from unused backoff code.
2012-03-18 01:33:56 +00:00
Nicholas Marriott e87d4b43ab Need to call recalculate_sizes() when changing window with the mouse,
from marcel partap.
2012-03-17 21:34:34 +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
Nicholas Marriott 799f437eff Remove some bits leftover from unused backoff code. 2012-03-09 21:42:13 +00:00
Tiago Cunha 509a7e8b73 Sync OpenBSD patchset 1023:
Do not change pane when changing window with mouse on status line,
pointed out by Romain Francoise.
2012-02-02 01:58:47 +00:00
Nicholas Marriott fdeaa73342 Do not change pane when changing window with mouse on status line,
pointed out by Romain Francoise.
2012-02-02 00:04:54 +00:00
Tiago Cunha e4a7cefe0c Sync OpenBSD patchset 1015:
Add an option to move the status line to the top of the screen,
requested by many.
2012-01-29 12:57:01 +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 230d0fbc9e Add an option to move the status line to the top of the screen,
requested by many.
2012-01-29 09:37:02 +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 a34a72d2d9 Sync OpenBSD patchset 1011:
Remove unused backoff code that doesn't do any good.
2012-01-23 12:24:00 +00:00
Nicholas Marriott 678e67437f Remove unused backoff code that doesn't do any good. 2012-01-21 23:51:34 +00:00
Tiago Cunha a7b0b30bdd Sync OpenBSD patchset 1007:
Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).
2012-01-21 19:36:40 +00:00
Nicholas Marriott 535286c05a Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).
2012-01-21 08:40:09 +00:00
Tiago Cunha 3a9a24a7c0 Sync OpenBSD patchset 988:
Fix so that when mouse-select-pane and mouse-select-window are both
enabled, clicking on the status line does not change the current
pane. From Romain Francoise.
2011-12-25 23:33:30 +00:00
Nicholas Marriott d655566ce7 Fix so that when mouse-select-pane and mouse-select-window are both
enabled, clicking on the status line does not change the current
pane. From Romain Francoise.
2011-12-24 08:26:59 +00:00
Tiago Cunha 2651c0d69c Sync OpenBSD patchset 947:
Fix a couple of memory leaks, from marcel partap.
2011-08-21 12:39:34 +00:00
Nicholas Marriott 3657aa675e Fix a couple of memory leaks, from marcel partap. 2011-08-20 20:37:30 +00:00
Tiago Cunha 67e70770c8 Sync OpenBSD patchset 936:
Do not continue to send data to suspended/locked clients or there will
be a huge rush of it after they are resumed/unlocked. The main output
path was fine but status line updates and the terminal state reset code
were missed.
2011-07-08 22:58:30 +00:00
Nicholas Marriott d5269a2eed Do not continue to send data to suspended/locked clients or there will
be a huge rush of it after they are resumed/unlocked. The main output
path was fine but status line updates and the terminal state reset code
were missed.
2011-07-08 21:51:40 +00:00
Tiago Cunha 719755574d Sync OpenBSD patchset 915:
Support xterm(1) cursor colour change sequences through terminfo(5) Cc
(set) and Cr (reset) extensions. Originally by Sean Estabrooks, tweaked
by me and Ailin Nemui.
2011-05-22 16:25:02 +00:00
Nicholas Marriott 944b5e6fa0 Support xterm(1) cursor colour change sequences through terminfo(5) Cc
(set) and Cr (reset) extensions. Originally by Sean Estabrooks, tweaked
by me and Ailin Nemui.
2011-05-20 19:03:58 +00:00
Tiago Cunha 1e7cea407d Sync OpenBSD patchset 908:
Only select pane on click, not drag. From hsim at gmx.li.
2011-05-18 20:31:32 +00:00
Tiago Cunha 4efd45628d Sync OpenBSD patchset 905:
Add a new option, mouse-resize-pane. When on, panes may be resized by
dragging their borders. From hsim at gmx.li.
2011-05-18 20:30:14 +00:00
Nicholas Marriott acfabf3a50 Only select pane on click, not drag. From hsim at gmx.li. 2011-05-08 20:45:35 +00:00
Nicholas Marriott f3741f0653 Add a new option, mouse-resize-pane. When on, panes may be resized by
dragging their borders. From hsim at gmx.li.
2011-05-08 20:34:12 +00:00
Tiago Cunha 268a2efb16 Sync OpenBSD patchset 903:
Change window with mouse wheel over status line if mouse-select-window
is on, from marcel partap.
2011-05-05 10:12:33 +00:00
Tiago Cunha a734b41fda Sync OpenBSD patchset 900:
Check if mouse-select-pane is ON not off when setting mouse flags,
reported by oga.
2011-05-05 10:03:05 +00:00
Nicholas Marriott b0a88ebead Change window with mouse wheel over status line if mouse-select-window
is on, from marcel partap.
2011-05-04 18:10:28 +00:00
Nicholas Marriott 7dddf56c08 Check if mouse-select-pane is ON not off when setting mouse flags,
reported by oga.
2011-05-04 17:40:32 +00:00
Tiago Cunha 215ee46106 Sync OpenBSD patchset 896:
When mode-mouse is on (it is off by default), automatically enter copy
mode when the mouse is dragged or the mouse wheel is used. Also exit
copy mode when the mouse wheel is scrolled off the bottom. Discussed
with and written by hsim at gmx dot li.
2011-04-25 20:33:42 +00:00
Nicholas Marriott 8738141913 When mode-mouse is on (it is off by default), automatically enter copy
mode when the mouse is dragged or the mouse wheel is used. Also exit
copy mode when the mouse wheel is scrolled off the bottom. Discussed
with and written by hsim at gmx dot li.
2011-04-19 21:31:33 +00:00
Nicholas Marriott dc6bd98425 |PatchSet 893
|Date: 2011/04/18 20:49:05
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Add an option (mouse-select-window) which allows the mouse to be used by
|clicking on the status line, written by hsim at gmx dot li.
2011-04-18 21:07:58 +00:00
Nicholas Marriott 0bb2119781 Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.
2011-04-18 19:49:05 +00:00
Nicholas Marriott ffce6b34b2 |PatchSet 876
|Date: 2011/03/29 20:30:16
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Change -t on display-message to be target-pane for the #[A-Z]
|replacements and add -c as target-client.
2011-04-06 22:21:02 +00:00
Nicholas Marriott d88c20e718 Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.
2011-03-29 19:30:16 +00:00
Tiago Cunha 3d7b8105e1 Sync OpenBSD patchset 855:
Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).
2011-02-15 15:20:03 +00:00
Nicholas Marriott db7a89b1ee Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).
2011-01-26 01:54:56 +00:00
Tiago Cunha 1930181b18 Sync OpenBSD patchset 846:
Only set a mouse mode for mouse-select-pane if none already set by the
mode (any will do).
2011-01-21 23:56:53 +00:00
Tiago Cunha 492e3aa437 Sync OpenBSD patchset 834:
Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things
like "tmux ls && cat").
2011-01-21 23:44:13 +00:00
Nicholas Marriott 3de1700f61 Only set a mouse mode for mouse-select-pane if none already set by the
mode (any will do).
2011-01-15 00:46:19 +00:00
Nicholas Marriott 69cb1f830e Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things
like "tmux ls && cat").
2011-01-08 01:52:36 +00:00
Tiago Cunha 219442cff7 Sync OpenBSD patchset 828:
Support for UTF-8 mouse input (\033[1005h). This was added in xterm 262
and supports larger terminals than the older way.

If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
UTF-8 terminals. The option defaults to on if LANG etc are set in the
same manner as the utf8 option.

With help and based on code from hsim at gmx.li.
2011-01-07 14:34:45 +00:00
Nicholas Marriott ac3b78a841 Support for UTF-8 mouse input (\033[1005h). This was added in xterm 262
and supports larger terminals than the older way.

If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
UTF-8 terminals. The option defaults to on if LANG etc are set in the
same manner as the utf8 option.

With help and based on code from hsim at gmx.li.
2011-01-03 23:35:21 +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 095e1b410a Sync OpenBSD patchset 812:
Support all four of the xterm mouse modes. Based on a diff from hsim at
gmx.li.
2010-12-30 22:27:38 +00:00
Nicholas Marriott f7c42c21ba Support all four of the xterm mouse modes. Based on a diff from hsim at
gmx.li.
2010-12-29 21:49:06 +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 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
Nicholas Marriott 095ffe9cd1 Make the prompt history global for all clients which is much more useful
than per-client history.
2010-12-11 16:15:02 +00:00
Nicholas Marriott 7ce77ffc9c Make the prompt history global for all clients which is much more useful than per-client history. 2010-12-11 16:05:57 +00:00
Tiago Cunha 1cd9ff4460 Ugh. Don't know how this happened, but make it compile by removing duplicate
code.
2010-10-24 01:51:34 +00:00
Tiago Cunha 1276ea3653 Zap paths.h compat include. 2010-10-24 00:50:11 +00:00
Tiago Cunha d4b58c71a2 Sync OpenBSD patchset 775:
Trying to set FD_CLOEXEC on every fd is a lost cause, just use
closefrom() before exec.
2010-10-24 00:45:57 +00:00
Nicholas Marriott f56b4ec2ff Trying to set FD_CLOEXEC on every fd is a lost cause, just use
closefrom() before exec.
2010-10-16 08:31:55 +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 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