Commit Graph

393 Commits (a41cd8d75b55da5a1e75e187b30b33917c18c1b2)

Author SHA1 Message Date
Nicholas Marriott 5b6f78186c Clean up and simplify the choose mode code, from Thomas Adam. 2012-06-25 14:08:55 +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
Nicholas Marriott 1845800651 Strip layout from choose-windows again (leave in list-windows),
suggested by Romain Francoise, diff from Thomas Adam.
2012-05-28 07:59:07 +00:00
Nicholas Marriott 993f1b96a3 Fix client templates, from Romain Francoise. 2012-05-27 21:43:57 +00:00
Nicholas Marriott 196710e2d3 Simplify logging and just fprintf(stderr, ...) for early errors. 2012-05-25 08:28:10 +00:00
Nicholas Marriott 1f23f6d686 Use a predefined structure for not-space cells used to set attributes. 2012-05-23 19:19:40 +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 fe4f00834d Store mouse data in tty structure not on the stack. 2012-05-22 14:11:30 +00:00
Nicholas Marriott ebf94bc9cb Switch all of the various choose- and list- commands over to the format
infrastructure, from Thomas Adam.
2012-05-22 11:35:37 +00:00
Nicholas Marriott 682884edc5 Add a helper function to send ready message. 2012-05-22 10:56:48 +00:00
Nicholas Marriott 2f93affb98 If there are any terminals with insert mode but not ich1, they can go
through the slow path. Tidies code slightly.
2012-05-22 09:36:12 +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
Nicholas Marriott 37f9bb46d8 Add a helper function to open the terminal for attach-/new-session. 2012-05-06 07:38:17 +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
Nicholas Marriott ff5155f719 Add a buffer with all input from last ground state, will be used for
control mode. From George Nachman.
2012-04-25 21:12:49 +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
Nicholas Marriott ed54f01d2f Fix comment for mouse bits. 2012-04-01 21:45:48 +00:00
Nicholas Marriott 85f5485cb5 Add a layout history which can be stepped through with select-layout -u
and -U commands (bound to 'u' and 'U' by default).
2012-04-01 13:18:38 +00:00
Nicholas Marriott f59971276a Add a simple form of output rate limiting by counting the number of
certain C0 sequences (linefeeds, backspaces, carriage returns) and if it
exceeds a threshold (current default 50/millisecond), start to redraw
the pane every 100 milliseconds instead of making each change as it
comes. Two configuration options - c0-change-trigger and
c0-change-interval.

This makes tmux much more responsive under very fast output (for example
yes(1) or accidentally cat'ing a large file) but may not be perfect on
all terminals and connections - feedback very welcome, particularly
where this change has a negative rather than positive effect (making it
off by default is a possibility).

After much experimentation based originally on a request Robin Lee
Powell (which ended with a completely different solution), this idea
from discussion with Ailin Nemui.
2012-03-20 11:01:00 +00:00
Nicholas Marriott d8805af66b On xterm 271 and later, put the terminal into SCL 5 and use DECCRA for
scrolling the region in panes (if the large region check isn't
hit). With help from Ailin Nemui.
2012-03-17 22:56:04 +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 889fe42e11 Break out termios initialization into a separate function, from George
Nachman.
2012-03-17 21:27:51 +00:00
Nicholas Marriott c8c0d68128 Send secondary DA to terminals with XT in terminfo when starting up and
parse it to work out the xterm version.
2012-03-15 10:36:00 +00:00
Nicholas Marriott 799f437eff Remove some bits leftover from unused backoff code. 2012-03-09 21:42:13 +00:00
Nicholas Marriott ac9ebc29a2 Use a lock file and flock() to serialize server start, avoids problems
when running a bunch of tmux from cron at the same time. Based on a diff
from Tim Ruehsen.
2012-03-09 09:57:40 +00:00
Nicholas Marriott 30f4c30ca3 Add A and I keys for vi status line editing. 2012-03-04 07:38:11 +00:00
Nicholas Marriott f4fdddc930 Support "bracketed paste" mode. This adds a -p flag to paste-buffer - if
this is used and the application has requested bracketed pastes, then
tmux surrounds the pasted text by \033[200~ and \033[201~. Applications
like vim can (apparently) use this to avoid, for example, indenting the
text. From Ailin Nemui.
2012-03-03 09:43:22 +00:00
Nicholas Marriott 4b8bb7770f The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.
2012-03-03 08:55:56 +00:00
Nicholas Marriott 07ac16807f Add move-pane command (like join-pane but allows the same window). Also
-b flag to join-pane and move-pane to place the pane to the left or
above. From George Nachman.
2012-03-03 08:31:18 +00:00
Nicholas Marriott 4d9ccd3229 Add printf attribute to a couple of functions, from Tim Ruehsen. 2012-03-02 11:16:44 +00:00
Nicholas Marriott 4e7de210e4 Allow a single option to be specified to show-options to show just that
option.
2012-02-25 12:57:42 +00:00
Nicholas Marriott fddbd44c18 Add a wrapper function tty_set_size from George Nachman. 2012-02-15 17:25:02 +00:00
Nicholas Marriott 8363d19307 Move window name changes into wrapper function window_set_name, from
George Nachman.
2012-02-02 00:10:11 +00:00
Nicholas Marriott 908a22e41c Provide defined ways to set the various default-path possibilities: ~
for home directory, . for server start directory, - for session start
directory and empty for the pane's working directory (the default). All
can also be used as part of a relative path (eg -/foo). Also provide -c
flags to neww and splitw to override default-path setting.

Based on a diff from sthen. ok sthen
2012-01-31 15:52:21 +00:00
Nicholas Marriott 0e59bc75fd Give each window a unique id, like panes but prefixed with @. Based on
work from George Nachman.
2012-01-30 09:39:34 +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 678e67437f Remove unused backoff code that doesn't do any good. 2012-01-21 23:51:34 +00:00
Nicholas Marriott 8ed9124f3f Use RB trees not SPLAY. 2012-01-21 11:12:13 +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
Nicholas Marriott 66f04514cf Add a -R flag to send-keys to reset the terminal. Written ages ago and
Suggested by someone, I forget who.
2012-01-21 08:10:21 +00:00
Nicholas Marriott 8332413305 Add some const and fix a warning. 2012-01-20 19:54:07 +00:00
Nicholas Marriott e6519d3e27 Add space movement keys for vi mode in the status line from Ben Boeckel. 2012-01-20 19:10:29 +00:00
Nicholas Marriott f308ba93aa Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise:

1) If tmux neww is run from the command line, the working directory of the
   client is used.

2) Otherwise sysctl KERN_PROC_CWD is used to retrieve the current
   working directory of the process in the active pane.

3) If that fails, the directory where the session was created is used.

Support code by Romain Francois, OpenBSD specific bits by me.

Note this requires a recent userland and kernel with KERN_PROC_CWD.
2011-12-09 16:28:18 +00:00
Nicholas Marriott e04d13f6a6 Support "jump to" like vi in copy mode using t and T keys. Also add x
and X for delete in edit mode.

From Ben Boeckel, thanks.
2011-12-04 16:18:01 +00:00
Nicholas Marriott fc5f8804ec Add word movement and editing command for command prompt editing, from
Ben Boeckel.
2011-11-15 23:34:12 +00:00
Nicholas Marriott 57df442916 Make window_pane_index work the same as window_index, from Ben Boeckel. 2011-11-15 23:19:51 +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
Nicholas Marriott 7ff4cf9405 Try to resolve relative paths for loadb and saveb (first using client
working directory if any then default-path or session wd).
2011-10-23 08:34:01 +00:00
Nicholas Marriott 16d75a6bf2 Add client formats, from Ben Boeckel. 2011-10-23 01:12:46 +00:00
Nicholas Marriott 4a5dff3f11 Add initial framework for more powerful formatting of command output and
use it for list-{panes,windows,sessions}. This allows more descriptive
replacements (such as #{session_name}) and conditionals.

Later this will be used for status_replace and list-keys and other
places.
2011-08-26 10:53:16 +00:00
Nicholas Marriott 029c34ce6b Add a tty_bell wrapper function, from Dylan Alex Simon. 2011-08-24 09:58:44 +00:00
Nicholas Marriott ad60a2c952 Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.
2011-07-02 21:05:44 +00:00
Nicholas Marriott 1202284f37 PANE_FREEZE doesn't do anything anymore, so remove it. 2011-06-27 00:04:49 +00:00
Nicholas Marriott 65177b82be Add a respawn-pane command, from Marcel Partap. 2011-06-05 11:19:03 +00:00
Nicholas Marriott 2b60c648c4 Get rid of the layout string code which tries to walk through the layout
hierarchy and instead just look at what panes are actually in the window.
2011-06-05 10:53:05 +00:00
Nicholas Marriott 3ea5e06bfb Support DECSCUSR sequence to set the cursor style with two new
terminfo(5) extensions, Cs and Csr. Written by Ailin Nemui.
2011-05-20 19:17:39 +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
Nicholas Marriott 96e7f33da3 Support setting the xterm clipboard when copying from copy mode using
the xterm escape sequence for the purpose (if xterm is configured to
allow it).

Written by and much discussed Ailin Nemui, guidance on
xterm/termcap/terminfo from Thomas Dickey.
2011-05-18 20:24:29 +00:00
Nicholas Marriott 58908fd8c5 Add three new copy-mode commands - select-line, copy-line,
copy-end-of-line. From Dave Disser and Randy Stauner a while back.
2011-05-18 18:06:36 +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
Nicholas Marriott 295ace6820 Use the tsl and fsl terminfo(5) capabilities to update terminal title
and automatically fill them in on terminals with the XT capability
(which means their title setting is xterm-compatible). From hsim at
gmx.li.
2011-05-08 19:53:06 +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 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 0a09d04e1b If the terminal supports sitm for italics, use it instead of standout
(smso). From Tiago Resende.
2011-04-09 07:48:08 +00:00
Nicholas Marriott ec89eb9552 Change so that an empty session name always means the current sessions
even if given with, for example, -t '', and explicitly forbid empty
session names and those containing a : when they are created.
2011-04-06 21:51:31 +00:00
Nicholas Marriott 5d519ba526 Add a flag to cmd_find_session so that attach-session can prefer
unattached sessions when choosing the most recently used (if -t is not
given). Suggested by claudio@.
2011-04-05 19:37:01 +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
Nicholas Marriott fa6abac98d Style: uint -> u_int and a missing else. 2011-03-28 19:44:31 +00:00
Nicholas Marriott 7ce8fee4f3 Don't include meta twice when working out the flags to output for
xterm-style keys - bit 3 is accepted on input but not on output. Also a
style nit in the header.
2011-03-27 20:31:25 +00:00
Nicholas Marriott 808502ac3d Give each pane created in a tmux server a unique id (starting from 0),
put it in the TMUX_PANE environment variable and accept it as a
target. Suggested by and with testing and tweaks from Ben Boeckel.
2011-03-27 20:27:26 +00:00
Nicholas Marriott 79e30daeae Support passing through escape sequences to the underlying terminal by
using DCS with a "tmux;" prefix. Escape characters in the sequences must
be doubled. For example:

$ printf '\033Ptmux;\033\033]12;red\007\033\\'

Will pass \033]12;red\007 to the terminal (and change the cursor colour
in xterm). From Kevin Goodsell.
2011-03-07 23:46:27 +00:00
Nicholas Marriott 7954126dcd Add a -P option to detach to HUP the client's parent process (usually
causing it to exit as well).
2011-03-03 08:51:47 +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
Nicholas Marriott 4dfb29fa38 Use LIST_* not SLIST_*. 2011-01-26 00:11:47 +00:00
Nicholas Marriott ecc22c521d When clearing the entire screen, clear lines that are used into the
history like xterm does. Requested ages ago by someone I've forgotten.
2011-01-25 23:40:26 +00:00
Nicholas Marriott 1270f8fed8 Check if the index is in use and fail before creating the child process,
rather than leaving a stray child on failure.
2011-01-25 22:31:50 +00:00
Nicholas Marriott b8023044c3 Set $TMUX without the session when background jobs are run. 2011-01-23 11:03:43 +00:00
Nicholas Marriott 8f8e81c0c9 Mouse highlight mode (1001) requires a program to cooperate so
supporting it through tmux is not as easy as this, remove it for now.
2011-01-15 00:16:00 +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
Nicholas Marriott 7502cb3adb Clean up and simplify tmux command argument parsing.
Originally, tmux commands were parsed in the client process into a
struct with the command data which was then serialised and sent to the
server to be executed. The parsing was later moved into the server (an
argv was sent from the client), but the parse step and intermediate
struct was kept.

This change removes that struct and the separate parse step. Argument
parsing and printing is now common to all commands (in arguments.c) with
each command left with just an optional check function (to validate the
arguments at parse time), the exec function and a function to set up any
key bindings (renamed from the old init function).

This is overall more simple and consistent.

There should be no changes to any commands behaviour or syntax although
as this touches every command please watch for any unexpected changes.
2011-01-04 00:42:46 +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
Nicholas Marriott 3e8124009f Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.
2011-01-01 16:51:21 +00:00
Nicholas Marriott 67ee86085c Sprinkle a little more const. 2011-01-01 03:39:21 +00:00
Nicholas Marriott 5d0cfe079b Another table that should be const. 2011-01-01 03:32:28 +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
Nicholas Marriott 4fb1045f5a Remove some unused defines. 2010-12-30 23:20:13 +00:00
Nicholas Marriott cc42614fa9 Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.
2010-12-30 23:16:18 +00:00
Nicholas Marriott 2231e72968 Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.
2010-12-30 21:35:17 +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
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 8705c6b435 Dead sessions are never on the active sessions list, so the SESSION_DEAD
flag is effectively unused. Remove it.
2010-12-20 00:19:20 +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 a51dcdc430 Unify the way sessions are used by callbacks - store the address and use
the reference count, then check it is still on the global sessions list
in the callback.
2010-12-20 00:03:55 +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 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
Nicholas Marriott e26a351865 Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.
2010-12-06 22:51:02 +00:00
Nicholas Marriott ef9b2eb566 There is somewhere that WINDOW_HIDDEN is getting set when it shouldn't
be and I can't find it, but the flag itself is a useless optimisation
that only applies to automatic-resize windows, so just dispose of it
entirely.

Fixes problems reported by Nicholas Riley.
2010-11-22 21:13:13 +00:00
Nicholas Marriott c7fccfa299 Declaration in header should be extern. 2010-11-11 20:51:30 +00:00
Nicholas Marriott 34d05ea7cd We now send argv to the server after parsing it in the client to get the
command, so the client should not modify it. Instead, take a copy. Fixes
parsing command lists, reported by mcbride@.
2010-10-29 20:11:57 +00:00
Nicholas Marriott 5de84eca3d Add a last-pane command (bound to ; by default). Requested ages ago by
somebody whose name I have forgotten.
2010-10-23 13:04:34 +00:00