Commit Graph

154 Commits (a41cd8d75b55da5a1e75e187b30b33917c18c1b2)

Author SHA1 Message Date
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 71e8e26ccc Set the terminal blocking again earlier, before sending the reset
sequences.
2011-03-27 20:36:19 +00:00
Nicholas Marriott d74e5bffba Fix to properly wrap wide characters, from Micah Cowan. 2011-03-26 19:07:33 +00:00
Nicholas Marriott 54456d5602 Fix an incorrect test which was always true (oupper is always < olower),
from Yusuke ENDOH.
2011-03-08 19:23:49 +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 9fc2c34a3b Accept tcgetattr/tcsetattr failure, fixes problems with fatal() if the
terminal disappears while locked.
2011-01-29 08:39:43 +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 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 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 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 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 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
Nicholas Marriott ea4487c6da Ugh. Pass the right type into tty_term_has. Teaches me to make last
minute changes :-/.
2010-09-11 16:20:58 +00:00
Nicholas Marriott cb564bb427 Use UTF-8 line drawing characters on UTF-8 terminals. Fixes some stupid
terminals (I'm looking at you, putty) which disable the vt100 ACS mode
switching sequences in UTF-8 mode.

Also on terminals without ACS at all, use ASCII equivalents where
obvious.
2010-09-11 16:19:22 +00:00
Nicholas Marriott 8363e31953 Change the way backoff works. Instead of stopping reading from the pty
when the client tty backs up too much, just stop updating the tty and
only update the internal screen. Then when the tty recovers, force a
redraw.

This prevents a dodgy client from causing other clients to go into
backoff while still allowing tmux to be responsive (locally) when seeing
lots of output.
2010-08-11 07:34:43 +00:00
Nicholas Marriott 510ec3fb9e Fix problems with window sizing seen by Raghavendra D Prabhu when
starting tmux from .xinitrc.

One of the very few things the server relies on the client for now is to
pass through a message on SIGWINCH, but there is a condition where
potentially a SIGWINCH may be lost during the transition from unattached
(main.c) to attached (client.c). So trigger a size change immediately
after the client installs its SIGWINCH handler.

Also, when the terminal is resized, reset the scroll region and cursor
position. Previously, we were clearing our saved idea of these, but in
fact some terminals do not reset them on resize, so this caused problems
during redraw.

While here make a resize to the same size not cause a redraw and rename
the tmux.out output log file to include the tmux PID.
2010-06-05 16:47:11 +00:00
Nicholas Marriott 0440d325d9 Shut up gcc4 warnings. 2010-06-05 16:32:22 +00:00
Nicholas Marriott 43fa9a9ba6 When the mode-mouse option is on, support dragging to make a selection
in copy mode.

Also support the scroll wheel, although xterm strangely does not ignore
it in application mouse mode, causing redraw artifacts when scrolling up
(other terminals appear to be better behaved).
2010-05-31 19:51:29 +00:00
Nicholas Marriott c7046b9a0c Check for colour and attribute modifications early so the translated
values can be stored in the cached terminal attributes rather than the
requested (untranslated) values. Prevents tmux clearing and setting the
attributes for every character when using aixterm colours.
2010-03-01 22:44:31 +00:00
Nicholas Marriott f1dd95650b Don't set the terminal to nonblocking on detach until we have finished with it
entirely.
2010-02-24 19:08:39 +00:00
Nicholas Marriott 9ffe549ab1 If redrawing line 0 of the screen onto the tty, there can't be a wrap flag on
the previous line, so move the cursor. Fixes status line redraw issues when
resizing in choose mode and hopefully at other times as well.
2010-02-01 23:06:24 +00:00
Nicholas Marriott 9ee979167a Use tcflush(3) instead of TIOCFLUSH, from Ed Schouten. 2010-01-01 14:29:18 +00:00
Nicholas Marriott a775107f5f Fix the logic so that transition from a 256 colour to default works properly. 2009-12-26 11:02:32 +00:00
Nicholas Marriott cd9b1b1fd3 Nuke some stray debugging. 2009-12-26 10:39:02 +00:00
Nicholas Marriott 0dda866679 Pass through the aixterm bright colours if the terminal supports them (>= 16
colours).
2009-12-14 21:33:38 +00:00
Nicholas Marriott 796eb522ac vte is buggy and doesn't home the cursor after changing the scroll
region. Several people are hitting this, so add a workaround.
2009-12-04 11:01:29 +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
Nicholas Marriott 6bbc92a6f5 Reflect the keypad mode of the application so that numlock works. 2009-12-02 22:13:15 +00:00
Nicholas Marriott 2182e1badc Add a couple of comments. 2009-11-27 09:41:03 +00:00
Nicholas Marriott e7f4319ac6 Fix type - attributes should be u_char not int. 2009-11-26 22:47:14 +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 d31d4c05cf Emulate il1, dl1, ich1 to run (albeit slowly) with vt100 feature set. 2009-11-26 14:46:08 +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 5ae542e7ee Emulate the ri (reverse index) capability: this allows tmux to at least start
on Sun consoles (TERM=sun or sun-color), even if there appear to still be
problems on some boxes (my Blade 100 is fine but edd's Blade 1000 shows odd
screen corruption).
2009-11-12 08:05:23 +00:00
Nicholas Marriott 6609093625 Just ignore tty fd errors rather than dying, stops the server dying if the
session is disconnected abrubtly (eg ssh ~.).
2009-11-09 22:50:29 +00:00
Nicholas Marriott bed8153ba0 Clear to the end of the screen from the right starting point when drawing
line-by-line (in panes or if ed not supported). Fixes problem spotted by Frank
Terbeck.
2009-11-05 22:35:28 +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 7342615c7d Switch tty fds over to a bufferevent. 2009-11-04 21:47:42 +00:00
Nicholas Marriott 10f58cb1bc Ignore the colour on space, /not/ the attributes. 2009-11-04 15:59:27 +00:00
Nicholas Marriott a94535f318 Fix the reverse emulation when a terminal doesn't have setab to use the correct
fg/bg (adjusted if spaces) and happen before attribute setting.
2009-11-04 13:34:26 +00:00
Nicholas Marriott 1eaefbf169 Add a minor optimisatin: if the character being printed is space, don't worry
about setting the background colour or attributes (except reverse).
2009-10-28 08:52:36 +00:00
Nicholas Marriott 5730cbf3e3 Twaek this slightly to avoid confusing use of flags variable. 2009-10-28 08:33:20 +00:00
Nicholas Marriott eb5f4460d1 Setting SGR0 when setting the fg and bg has problems if only one of the two is
meant to be default, so rewrite the code to move this outside, move setting
colours before attributes and generally clean up.

Tested by sthen@, fixes problems he was seeing with mutt and should fix some
existing problems with (rarely) lost attributes.
2009-10-28 08:27:33 +00:00
Theo Deraadt ed62d1263c tabs are better; ok nicm 2009-10-26 21:42:04 +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 59e667906f Unused variable. 2009-10-21 19:27:09 +00:00
Nicholas Marriott dd46f634fe Now we are correctly not redrawing the whole pane on linefeed, redo the
last-cursor-position code to move to the right position when panes reach EOL.
2009-10-21 16:52:30 +00:00
Nicholas Marriott 9b5da97e6f Don't redraw the scroll region on linefeed/reverse index unless it is necessary
(the cursor is at the bottom/top). Should fix slow cursor movement when using
vi in a pane spotted by pirofti@.
2009-10-21 13:42:44 +00:00
Nicholas Marriott 683ddbc466 Some terminals don't correctly clear their let's-wrap flag after changing the
scroll region (which moves the cursor to 0,0). This means that if the cursor
was at the edge of the screen, any further output after scroll region change
incorrectly causes a line wrap. Add a workaround to move the cursor to position
0 if it is at the screen edge before changing scroll region.
2009-10-21 09:36:53 +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 387f4d42cc Move the check for whether to force a line wrapper lower down into the tty code
where it has access to the tty width, which is what should have been checked.
2009-10-20 16:32:23 +00:00
Nicholas Marriott daa26079ee Always move the cursor position on !xenl terminals, since there is no invisible
last cursor position.

Also nuke an unused variable.
2009-10-17 08:35:38 +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 70355021d8 When checking whether the region will scroll and the cursor position is thus
unsuitable for using CUD/CUU, check the current cursor position not the target
position.
2009-10-16 19:09:40 +00:00
Nicholas Marriott 5d78371628 Don't try to use \n across scroll region when doing \r\n either. 2009-10-13 08:37:15 +00:00
Nicholas Marriott 4dcb5040a0 Instead of using something sort of similar for both newline checks, use
something the same. Doesn't fix the bug I'm looking for though :-/.
2009-10-13 00:44:16 +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 693b3d03e6 Don't run through the column unchanged case if the row was unchanged but there
were no suitable optimisations, instead make it an else to fall through to
absolute addressing.
2009-10-12 16:41:02 +00:00
Nicholas Marriott eb9826f65d If the vertical cursor movement crosses the scroll region, CUU and CUD
shouldn't be used even if VPA isn't present - in that case CUP should be used.
2009-10-12 16:37:43 +00:00
Nicholas Marriott 0aab5811ca Use absolute movement if right at the end of the line as it isn't a reliable
place to move from relatively.
2009-10-12 14:54:19 +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 0a2a354499 Like linefeed, don't set the scroll region for reverse index unless it will be
needed.

While here, also tidy up a couple of long lines and remove an extraneous blank.
2009-10-11 22:35:10 +00:00
Nicholas Marriott 3a20a05a49 There is no point setting the scroll region up for line feeds unless scrolling
is actually going to happen, so don't.
2009-10-10 10:36:46 +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 d528184836 Be less aggressive about turning the cursor off, only explicitly turn it off
when tmux is redrawing, otherwise leave in the state set by the application.
2009-10-09 07:23:28 +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 631a618238 Don't die if the client is detaching (the tty has been closed) after waking up
from locking.
2009-09-23 07:25:31 +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 0a9005678d Be more careful about what flags are cleared when opening the terminal,
otherwise the opened/started flags are cleared and the terminal never released.
2009-09-22 19:11:52 +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 04319964b9 Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.
2009-08-31 20:46:19 +00:00
Nicholas Marriott 926b52b600 Emulate dch/dch1 if missing by redrawing the entire line. 2009-08-21 12:29:59 +00:00
Nicholas Marriott 5cf994856f Send SGR0 when initialising the screen. Fixes problems on terminals with BCE
(like putty) if the background colours is non-default when tmux starts. May
also fix problems when resuming a suspended tmux.
2009-08-14 08:53:52 +00:00
Nicholas Marriott bc497dbb92 A tty context must not be modified as it may be reused to update multiple
clients, so make it const.

Also fix an actual modification which caused a hang when a session was
connected to multiple terminals at least one of which was missing ich/ich1.
2009-08-12 09:41:59 +00:00
Nicholas Marriott e0a19abb99 Initialise log_fd to -1, prevents spurious disconnection of the client when it
ends up as fd 0 (likely if the server is started with "tmux start").

Also add some extra debugging messages to server.c.
2009-08-11 22:34:17 +00:00
Nicholas Marriott 4310282a4c Have the client pass its stdin fd to the server when identifying itself and
have the server use that rather than reopening the tty. If the fd isn't given,
use the old behaviour (so no need for a version change).

This allows tmux to be used as the shell, so also change so that when working
out the command to execute if default-command is empty (the default), tmux will
try not execute itself.
2009-08-11 21:28:11 +00:00
Nicholas Marriott 4ec8ade11c Add a TTY_OPENED flag and tidy a little. 2009-08-11 20:29:04 +00:00
Nicholas Marriott ff65e37545 Drop the no_stop argument to tty_close and tty_free in favour of a flag in the
tty struct.
2009-08-11 19:32:25 +00:00
Nicholas Marriott 5e01b6d663 Change the way the grid is stored, previously it was:
- a two-dimensional array of cells;
- a two-dimensional array of utf8 data;
- an array of line lengths.

Now it is a single array of a new struct grid_line each of which represents a
line and containts the length and an array of cells and an array of utf8 data.

This will make it easier to add additional per-line members, such as flags.
2009-08-08 13:29:27 +00:00
Nicholas Marriott bcddddf98d If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.
2009-08-05 16:26:38 +00:00
Nicholas Marriott 1673735f02 Add a terminal-overrides session option allowing individual terminfo(5) entries
to be overridden. The 88col/256col checks are now moved into the default
setting and out of the code.

Also remove a couple of old workarounds for xterm and rxvt which are no longer
necessary (tmux can emulate them if missing).
2009-08-03 14:10:54 +00:00
Nicholas Marriott fc65da1eed Draw UTF-8 characters under the selection correctly. 2009-07-27 11:33:21 +00:00
Nicholas Marriott dd4a3b24fc tty_write is relatively short and the only function left in tty-write.c so move
it into tty.c.
2009-07-22 20:56:58 +00:00
Nicholas Marriott ddad0be5f7 More tty code tidying: move the saved cursor/region position (from before the
screen was updated) out of struct screen and into struct tty_ctx.
2009-07-22 20:53:38 +00:00
Nicholas Marriott 2ec2837daa enum tty_cmd is only used as an index into the array of command function
pointers, so remove it and use the function pointers directly to represent
themselves.
2009-07-22 18:02:23 +00:00
Nicholas Marriott 6a309c53a8 There are relatively few arguments to tty_cmd_* functions now, so tidy them up
by using a struct rather than hiding everything with varargs.
2009-07-22 16:45:31 +00:00
Nicholas Marriott 5bd72ec629 tty_cmd_raw is only used once, for raw UTF-8 output, so rename it to
tty_cmd_utf8character and eliminate the size argument.
2009-07-22 15:55:32 +00:00
Nicholas Marriott 4a6d62e401 Don't send initialisation strings is1/2/3 (barely anything else does) and move
smcup to the first and rmcup to the last sequences output to the terminal. This
allows tmux to use the alternate screen (smcup/rmcup) when available.
2009-07-10 07:11:59 +00:00
Nicholas Marriott 474fdebb7a Handle empty or unset TERM correctly; also fix a fatal() message while here. 2009-07-07 17:24:32 +00:00
Nicholas Marriott 2660692fb1 Copy the 256-colour flag into the tty saved cell as well as the actual colour,
otherwise colour 8 isn't reset properly.
2009-06-27 12:57:14 +00:00
Nicholas Marriott 1675ddb4d1 Miscellaneous unused functions, including one which was basically a
duplicate. Found by lint.
2009-06-25 06:15:04 +00:00
Nicholas Marriott 83078bdcbc Unused variables. Found by lint, no binary change. 2009-06-25 05:56:44 +00:00
Nicholas Marriott 2de599ac0e Trying to predict the cursor position for UTF-8 output in the same way as for
normal eight-bit output is wrong, separate it into a different function. Fixes
spacing when mixing UTF-8 with some escape sequences, notably the way w3m does
it.
2009-06-24 16:01:02 +00:00