Commit Graph

242 Commits (6c42f1a89e16d69d5fe24bb8b3f6b37148cfa308)

Author SHA1 Message Date
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
Nicholas Marriott 6c9862662f Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.
2009-12-03 17:44:02 +00:00
Nicholas Marriott 0926a23014 New command, capture-pane, which copies the entire pane contents to a paste
buffer. From Jonathan Alvarado.
2009-12-01 18:42:38 +00:00
Nicholas Marriott 29a5931c6a Handle partial xterm function key sequences. 2009-11-30 16:44:03 +00:00
Nicholas Marriott 106ee8f30a This doesn't need to be u_int. 2009-11-26 23:13:47 +00:00
Nicholas Marriott 8cb410c63c Tidy up various bits of the paste code, make the data buffer char * and add
comments.
2009-11-26 22:28:24 +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
Nicholas Marriott 094bca5ac3 Output the right keys for application and number keypad modes (they were the
wrong way round).
2009-11-25 12:24:31 +00:00
Nicholas Marriott 33b337f618 Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.
2009-11-19 19:47:28 +00:00
Nicholas Marriott 543fb99bc6 Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.
2009-11-19 16:22:10 +00:00
Nicholas Marriott ac5b7d518e Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.
2009-11-19 10:22:06 +00:00
Nicholas Marriott a78cc98c8b Cleanup by moving various (mostly horrible) little bits handling UTF-8 grid
data into functions in a new file, grid-utf8.c, and use sizeof intead of
UTF8_DATA.

Also nuke trailing whitespace from tmux.1, reminded by jmc.
2009-11-18 17:02:17 +00:00
Nicholas Marriott 8db145da1e Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.
2009-11-18 13:16:33 +00:00
Nicholas Marriott 10e05f9867 Tweak a comment and add some spacing. 2009-11-13 19:58:32 +00:00
Nicholas Marriott 76ef8770cd Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in the
command entry structs and a couple of functions to check/set the flags.
2009-11-13 19:53:28 +00:00
Nicholas Marriott 8e47966225 Destroy panes immediately rather than checking them all every loop. 2009-11-13 17:33:07 +00:00
Nicholas Marriott 5d397462e4 Zap unused functions, prompted by deraadt. 2009-11-13 07:00:54 +00:00
Nicholas Marriott 2756437f4b Only need to chmod +x or -x the socket when a client is created, lost or
attached, rather than every event loop.
2009-11-11 08:00:42 +00:00
Nicholas Marriott b92fcf23fd Whoops, this is needed for last commit as well. 2009-11-10 17:41:35 +00:00
Nicholas Marriott 80e0158112 Switch the tty key tree over to an (unbalanced) ternary tree which allows
partial matches to be done (they wait for further data or a timer to expire,
like a naked escape).

Mouse and xterm-style keys still expect to be atomic.
2009-11-05 19:29:41 +00:00
Nicholas Marriott a790e16fa2 Key flags are only used for initialisation so they are not needed in the main
tty_key struct.
2009-11-05 10:44:36 +00:00
Nicholas Marriott 38e13942ac Now all timers are events, there is no longer any need to wake up every 50 ms -
only wake up when an event happens.
2009-11-05 08:48:15 +00:00
Nicholas Marriott b58bf49e91 Switch tty key input over to happen on a read event. This is a bit more
complicated because of escape input, but in that case instead of processing a
key immediately, schedule a timer and reprocess the bufer when it expires.

This currently assumes that keys will be atomic (ie that if eg F1 is pressed
the entire sequence is present in the buffer). This is usually but not always
true, a change in the tree format so it can differentiate potential (partial)
key sequences will happens soon and will allow this to be fixed.
2009-11-05 08:45:08 +00:00
Nicholas Marriott 80444436f3 Convert the key repeat timer to an event. 2009-11-05 00:05:00 +00:00
Nicholas Marriott 44d6a2c435 Change window name change to use a timer event rather than a gettimeofday()
check every loop.
2009-11-04 23:54:57 +00:00
Nicholas Marriott 946ed97273 Move status timer check into the global once-per-second timer, this could maybe
be done better but one every second is better than once every 50 ms.
2009-11-04 23:42:51 +00:00
Nicholas Marriott b1264a7416 Use timeout events for the identify and message timers. 2009-11-04 23:29:42 +00:00
Nicholas Marriott b3c4956efe Don't reenlist the client imsg event every loop, instead have a small function
to it and call it after the event triggers or after a imsg is added.
2009-11-04 23:12:43 +00:00
Nicholas Marriott 5bebbd81d7 Bye-bye buffer*.c. 2009-11-04 22:44:53 +00:00
Nicholas Marriott a02c7e804c Convert the window pane (pty master side) fd over to use a bufferevent.
The evbuffer API is very similar to the existing tmux buffer API so this was
remarkably painless. Not many possible ways to do it, I suppose.
2009-11-04 22:43:11 +00:00
Nicholas Marriott 91ad830c88 Switch window pane pipe redirect fd over to a bufferevent. 2009-11-04 22:02:38 +00:00
Nicholas Marriott 7342615c7d Switch tty fds over to a bufferevent. 2009-11-04 21:47:42 +00:00
Nicholas Marriott 4d6091379b Switch jobs over to use a bufferevent. 2009-11-04 21:04:43 +00:00
Nicholas Marriott abf3a5d50e Initial changes to move tmux to libevent.
This moves the client-side loops are pretty much fully over to event-based only
(tmux.c and client.c) but server-side (server.c and friends) treats libevent as
a sort of clever poll, waking up after every event to run various things.

Moving the server stuff over to bufferevents and timers and so on will come
later.
2009-11-04 20:50:11 +00:00
Nicholas Marriott 0785f2872f Add an activity time for clients, like for sessions, and change session and
client lookup to pick the most recently used rather than the most recently
created - this is much more useful when used interactively and (because the
activity time is set at creation) should have no effect on source-file.

Based on a problem reported by Jan Johansson.
2009-11-03 22:40:40 +00:00
Nicholas Marriott 5761ab6b55 If it isn't available explicitly, work out the current client in a similar way
to the current session - build a list of the possibilities then pick the
newest.
2009-11-03 20:59:22 +00:00
Nicholas Marriott 5289da29ba Change session and client activity and creation time members to have more
meaningful names.

Also, remove the code to try and update the session activity time for the
command client when a command message is received as is pointless because it
des not have a session.
2009-11-03 20:29:47 +00:00
Nicholas Marriott c95f1d1ff9 tv member of struct paste_buffer is updated but not otherwise used, so remove
it.
2009-11-03 17:17:24 +00:00
Nicholas Marriott 86182f33c3 Double the escape timer (the time after a \033 is received before tmux gives up
waiting to see if it is part of a key sequence and passes it through) to 500
ms, the previous setting was too fast. Suggested by naddy.
2009-11-02 20:18:22 +00:00
Nicholas Marriott 2f813ef75d Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().
2009-11-01 23:20:37 +00:00
Nicholas Marriott dc3fdc8dc7 If any client currently displaying a window pane has more than 1 KB of output
buffered, don't accept any further data from the process running in the pane.

This makes tmux much more responsive when flooded with output, although other
buffers can still have an impact when running remotely.

Prompted by a query from Ranganathan Sankaralingam.
2009-10-28 22:53:14 +00:00
Nicholas Marriott 37ffdff5ba Move the poll registration functions into the server-*.c files. 2009-10-27 13:03:33 +00:00
Nicholas Marriott fd2ef18a70 Rewrite xterm-keys code (both input and output) so that works (doesn't always
output the same modifiers, accepts all the possible input keys) and is more
understandable.
2009-10-26 17:46:33 +00:00
Nicholas Marriott c92c2bfb10 Support the (mostly new) function key+modifier caps (kIC-kIC7). Most of these
will be caught (soon) by the xterm keys code in xterm itself but some other
descriptions such as rxvt define them as well.
2009-10-26 16:00:51 +00:00
Nicholas Marriott db4452d307 Rename keypad keys to something more useful. 2009-10-26 13:13:33 +00:00
Nicholas Marriott 3a7636ff0f Remove the -d flag to tmux and just use op/AX to detect default colours.
Irritatingly, although op can be used to tell if a terminal supports default
colours, it can't be used to set them because in some terminfo descriptions it
resets attributes as a side-effect (acts as sgr0) and in others it doesn't, so
it is not possible to determine reliably what the terminal state will be
afterwards. So if AX is missing and op is present, tmux just sends sgr0.

Anyone using -d for a terminal who finds they actually needed it can replace it
using terminal-overrides, but please let me know as it is probably an omission
from terminfo.
2009-10-25 21:11:21 +00:00
Nicholas Marriott eddcc3dfa9 Split the server code handling clients, jobs and windows off into separate
files from server.c (merging server-msg.c into the client file) and rather than
iterating over each set after poll(), allow a callback to be specified when the
fd is added and just walk once over the returned pollfds calling each callback
where needed.

More to come, getting this in so it is tested.
2009-10-22 19:41:51 +00:00
Nicholas Marriott 90ad041fa5 Client tidying: get rid of client_ctx struct in favour of two variables in
client.c, and move the functions in client-fn.c into other files.
2009-10-21 20:11:47 +00:00
Nicholas Marriott a22c06a2d6 Remove unused function. 2009-10-21 18:20:16 +00:00
Nicholas Marriott 1af09d6330 Try to reduce the UTF-8 mess.
Get rid of passing around u_char[4]s and define a struct utf8_data which has
character data, size (sequence length) and width. Move UTF-8 character
collection into two functions utf8_open/utf8_append in utf8.c which fill in
this struct and use these functions from input.c and the various functions in
screen-write.c.

Space for rather more data than is necessary for one UTF-8 sequence is in the
utf8_data struct because screen_write_copy is still nasty and needs to reinject
the character (after combining) into screen_write_cell.
2009-10-20 19:18:28 +00:00
Nicholas Marriott 62f234ce3b UTF-8 combined character fixes.
Thai can have treble combinations (1 x width=1 then 2 x width=0) so bump the
UTF-8 cell data size to 9 and alter the code to allow this.

Also break off the combining code into a separate function, handle any further
combining beyond the buffer size by replacing the character with _s, and when
redrawing the UTF-8 character don't assume the first part has just been
printed, redraw the entire line.
2009-10-20 17:33:33 +00:00
Nicholas Marriott d1e6388fed Nuke stray blank line. 2009-10-20 14:22:57 +00:00
Nicholas Marriott 43d62c1ae3 Instead of having a complicated check to see if the cursor is in the last
position to avoid an explicit wrap, actually move it there.

Some UTF-8 fixes to come.
2009-10-17 08:24:46 +00:00
Nicholas Marriott ad566a86de Move lines into the history when scrolling even if the scroll region is not
the entire screen.

Allows ircII users to see history, prompted by naddy.
2009-10-13 15:38:37 +00:00
Nicholas Marriott 38df960e68 Add mode keys to move the cursor to the top, middle and bottom of the screen.
H/M/L in vi mode and M-R/M-r in emacs (bottom of screen not bound in emacs).
2009-10-13 13:45:56 +00:00
Nicholas Marriott d7626cd9d7 When drawing lines that have wrapped naturally, don't force a newline but
permit them to wrap naturally again. This allows terminals that use this to
guess where lines start and end for eg mouse selecting (like xterm) to work
correctly.

This was another long-standing issue raised by several people over the last
while.

Thanks to martynas@ for much testing. This was not trivial to get right so
bringing it in for wider testing and adn to fix any further glitches in-tree.
2009-10-12 17:19:47 +00:00
Nicholas Marriott 8608c6970d When backspace is received at the beginning of a line and the previous line was
wrapped, move the cursor back up to the end of the previous line.

Another one of the forgotten persons requested this quite a while ago (I need
to start noting names on todo items...) when it was quite hard to
implement. Now it is easy and I don't see it can do any harm, so hey presto...
2009-10-12 16:59:55 +00:00
Nicholas Marriott 687c4a9fab Use relative cursor movement instead of absolute when possible and when
supported by the terminal to reduce the size of the output data (generally
about 10-20%).
2009-10-12 13:01:18 +00:00
Nicholas Marriott 762459954f Similarly add a tty_cursor_pane function to tidy up most of the calls. 2009-10-12 09:29:58 +00:00
Nicholas Marriott 972a6f5656 _absolute is redundant, just use tty_region. 2009-10-12 09:16:59 +00:00
Nicholas Marriott f05b32f7ad Cleanup: use two functions for region setting, one for absolute and one inside
pane.
2009-10-12 09:09:35 +00:00
Nicholas Marriott 64b5f39656 Add a pipe-pane command to allow a pane to be piped to a shell command, for
example:

	pipe-pane 'cat >~/out'

No arguments stops outputing and closes the pipe; the -o flag toggles a pipe
and on and off (useful for key bindings).

Suggested by espie@.
2009-10-11 10:04:27 +00:00
Nicholas Marriott ff4b4e667a Collect status from dead jobs and don't invoke the callback until both
all input (the socket is closed) and status is available.
2009-10-11 07:20:16 +00:00
Nicholas Marriott 4bc0f6e7e9 Clean up by introducing a wrapper struct for mouse clicks rather than passing
three u_chars around.

As a side-effect this fixes incorrectly rejecting high cursor positions
(because it was comparing them as signed char), reported by Tom Doherty.
2009-10-11 07:01:10 +00:00
Nicholas Marriott 095ecf2d90 Put all jobs on a global all_jobs list and use that in server.c instead of
running through all the clients.
2009-10-10 18:42:14 +00:00
Nicholas Marriott 5aa49e695e Split list-panes off from list-windows. 2009-10-10 17:19:38 +00:00
Nicholas Marriott 6bca92db4d Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
  only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.
2009-10-10 15:03:01 +00:00
Nicholas Marriott 4658c063d5 New option, mouse-select-pane. If on, the mouse may be used to select the
current pane.

Suggested by sthen@ and also by someone else ages ago who I have forgotten.
2009-10-10 14:51:16 +00:00
Nicholas Marriott 9dd72b9583 Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.
2009-10-10 10:02:48 +00:00
Nicholas Marriott b7d031cc92 Support for individual session idle time locking. May be enabled by turning off
the lock-server option (it is on by default). When this is off, each session
locks when it has been idle for the lock-after-time setting. When on, the
entire server locks when ALL sessions have been idle for their individual
lock-after-time settings.

This replaces one global-only option (lock-after-time) with another
(lock-server), but the default behaviour is usually preferable so there don't
seem to be many alternatives.

Diff/idea largely from Thomas Adam, tweaked by me.
2009-10-10 09:46:11 +00:00
Nicholas Marriott bf38a311da The UTF-8 detection idea doesn't work and I am reasonably happy with the
current methods, so remove the (already #ifdef 0'd) code.
2009-10-09 07:33:12 +00:00
Nicholas Marriott 35ca994ba2 Remove scroll mode which is now redundant, copy mode should be used instead.
The = key binding now does nothing.
2009-10-06 07:19:32 +00:00
Nicholas Marriott 9400fdac77 Make C-Up and C-Down in copy mode scroll the screen up and down one line
without moving the cursor, like Up and Down in scroll mode (which will shortly
disappear).
2009-10-06 07:09:00 +00:00
Nicholas Marriott 4ca2200d83 If no target client is specified to commands which accept one, try to guess the
current client, in a similar manner to how sessions already work: if the
current session can be established and has only one client, use that; otherwise
use the most recently created client.
2009-10-05 18:30:54 +00:00
Nicholas Marriott 8fa1858a2c New lock-client and lock-session commands to lock an individual client or all
clients attached to a session respectively.
2009-09-24 14:17:09 +00:00
Nicholas Marriott fecf8dc44e Remove PROMPT_HIDDEN code which is now unused. 2009-09-23 14:42:48 +00:00
Nicholas Marriott 9200a0be7a Support -c like sh(1) to execute a command, useful when tmux is a login
shell. Suggested by halex@.

This includes another protocol version increase (the last for now) so again
restart the tmux server before upgrading.
2009-09-23 12:03:30 +00:00
Nicholas Marriott b01dcd7971 Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.
2009-09-23 06:18:47 +00:00
Nicholas Marriott 962fa20b36 Trim some code by moving the ioctl(TIOCGWINSZ) after SIGWINCH from the client
into the server.

This is another (the second of four) protocol version changes coming this
morning, so again the server should be killed before upgrading.
2009-09-23 06:12:58 +00:00
Nicholas Marriott 64caf59e84 Don't attempt to open() the tty path, rely on the client sending its stdin fd
with imsg and fatal if it doesn't, then set the FD_CLOEXEC flag in tty_init
instead of tty_open to prevent them leaking into child processes if any are
created between the two calls.

This bumps the protocol version, so the tmux server should be killed before
upgrading.
2009-09-23 06:05:02 +00:00
Nicholas Marriott 96dd3e8eb9 Permit multiple prefix keys to be defined, separated by commas, for example:
set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.
2009-09-22 12:38:10 +00:00
Nicholas Marriott 6b37b2d79d Use option print function for info messages as well. 2009-09-21 14:56:03 +00:00
Nicholas Marriott e3c3d746f7 Move common code from show-options and show-window-options into a function. 2009-09-21 14:46:47 +00:00
Nicholas Marriott fc9107a16a Drop tiny union from option struct. 2009-09-21 07:00:09 +00:00
Nicholas Marriott c7a8db5543 Key options were implemented as a number so these struct members are unused. 2009-09-21 06:55:06 +00:00
Nicholas Marriott 14ebcab5b0 run-shell command to run a shell command without opening a window, sending
stdout to output mode.
2009-09-20 19:15:01 +00:00
Nicholas Marriott 9b5f5ed8e8 Move some common and untidy code for window link/unlink into generic functions
instead of duplicating it in move/link window..
2009-09-20 17:27:18 +00:00
Nicholas Marriott 5c60162e3c Rather than constructing an entire termios struct from ttydefaults.h, just let
forkpty do it and then alter the bits that should be changed after fork. A
little neater and more portable.
2009-09-16 12:35:04 +00:00
Nicholas Marriott 8548624676 Nuke unused server_client_index function, pointed out by martynas@. 2009-09-14 11:25:35 +00:00
Nicholas Marriott 8cb8a0da8d Tidy some common code for destroying sessions into a new function. 2009-09-12 13:01:19 +00:00
Nicholas Marriott 372a8cb1d9 Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".
2009-09-10 17:16:24 +00:00
Nicholas Marriott 51c95747d8 Reference count clients and sessions rather than relying on a saved index for
cmd-choose-*.
2009-09-07 21:01:50 +00:00
Nicholas Marriott ccba613e5b Give each paste buffer a size member instead of requiring them to be
zero-terminated.
2009-09-07 18:50:45 +00:00
Nicholas Marriott e97006b102 Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].
2009-09-07 10:49:32 +00:00
Nicholas Marriott 459abafcea That was the wrong fix. MSG_ERROR should set the error and the client should
use the error and exit on MSG_EXIT (it was being handled in the default
case). Undo the last change, move the errstr check into the MSG_EXIT case, and
add a comment.
2009-09-02 20:15:49 +00:00
Nicholas Marriott 7a4bac82d7 Set exittype for error exit as well as the error string. 2009-09-02 20:00:10 +00:00
Nicholas Marriott 74c35c513e Accept -l to make it easier for people who use tmux as a login shell to use
$SHELL. Originally from martynas@, tweaked by me.
2009-09-02 17:34:57 +00:00
Nicholas Marriott c5ac2579ba When incorrect passwords are entered, behave similarly to login(1) and backoff
for a bit. Based on a diff from martynas@.
2009-09-02 16:38:35 +00:00
Nicholas Marriott 61b7dc522d Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.
2009-09-02 06:33:20 +00:00
Nicholas Marriott 7d5e494716 When using tmux as a login shell, there is currently no way to specify a shell
to be used as a login shell inside tmux, so add a default-shell session option.
This sets the shell invoked as a login shell when the default-command option is
empty.

The default option value is whichever of $SHELL, getpwuid(getuid())'s pw_shell
or /bin/sh is valid first.

Based on a diff from martynas@, changed by me to be a session option rather
than a window option.
2009-09-01 13:09:49 +00:00