Commit Graph

277 Commits

Author SHA1 Message Date
nicm
c7374c31c4 Initialize cwd fd to -1 so that we don't close fd 0 if the client is
destroyed before it is changed. Also allow ttyname() to fail. Fixes
problems when running out of file descriptors reported by Bruno Sutic.
2015-07-13 15:49:31 +00:00
nicm
2c53b23d59 In terminfo, sometimes cvvis implies cnorm and sometimes it doesn't, so
don't assume it does. Fixes missing cursor with emacs-in-tmux-in-tmux.
2015-05-19 08:48:37 +00:00
nicm
3f4ee98162 To replace c0-*, add a high watermark to the pty event, and also backoff
when the any of the ttys the pane is going to write to has buffered
enough data.
2015-05-12 22:40:38 +00:00
nicm
33a585c47f Turn cursor off during redraw, pointed out by George Nachman. 2015-05-06 07:52:06 +00:00
nicm
7382ba82c5 If default-terminal is set to "screen" or "screen-*", emulate screen's
historical (incorrect) behaviour for SGR 3 and send smso
(standout). Previously, we would send sitm (italics) if the terminal
outside had it and smso otherwise. This was acceptably until recently
because xterm's terminfo entry lacked sitm, so most users got smso.

People who want italics should set default-terminal to the forthcoming
"tmux" entry (and be prepared to deal with it being missing on older
hosts).

As a side-effect this changes default-terminal to be a server rather
than a session option.

suggested by and ok naddy
2015-04-29 15:59:08 +00:00
nicm
d23af6cca0 Explicitly cancel mouse "button" mode, this happens implicitly with some
one of the other things we send with xterm, but not with urxvt. Reported
by sthen@.
2015-04-25 15:57:48 +00:00
nicm
aeedb464a6 Convert clients list into a TAILQ. 2015-04-24 23:17:11 +00:00
nicm
bf635e7741 Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

    bind -n   MouseDown1Pane select-pane -t=; send-keys -M
    bind -n MouseDown1Status select-window -t=
    bind -n   MouseDrag1Pane copy-mode -M
    bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

    unbind -n MouseDrag1Pane
    unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.
2015-04-19 21:34:21 +00:00
nicm
ee123c2489 Support setting the default window and pane background colours (window
and active pane via window-style and window-active-style options, an
individual pane by a new select-pane -P flag). From J Raynor.
2015-04-19 21:05:27 +00:00
nicm
4a7587931c Fix some issues in bright colour handling. Bold background doesn't exist
so there is no reason for tty_check_bg to mess with the BRIGHT flag at
all, ever. Also use aixterm colours for 256-to-16 translation if the
terminal supports them. And there is no reason for tty_colours_bg to
worry about whether the terminal supports them - tty_check_bg has
already taken care of it.
2015-04-15 22:34:46 +00:00
nicm
eec27f9257 Use tty_term_flag not _has for flags, also fix a typo (position not
permission).
2015-04-15 22:10:13 +00:00
nicm
90bf7026f6 Reset bracket paste mode on detach. 2015-02-05 11:46:57 +00:00
nicm
144025e3e6 Focus off needs to be sent with tty_raw, reported by Geoff Nixon. 2015-01-30 12:33:03 +00:00
nicm
16bdd970dc Support blinking cursor mode, both the xterm CSI ?12 h/l and (the
backwards) screen CSI 34 h/l. From Guanpeng Xu.
2015-01-20 08:18:04 +00:00
nicm
1ac96200a7 Remove support for the continuous reporting "any" mouse mode which never
really worked properly and is rarely used.
2014-08-09 07:33:37 +00:00
jsg
40cb4cb086 specifying ECHOCTL once is enough
ok nicm@
2014-04-25 12:45:16 +00:00
nicm
a5d4b7f3d9 Some more long lines. 2014-04-17 14:45:49 +00:00
nicm
c3b2e5eed3 Wrap some long lines. 2014-04-17 12:57:28 +00:00
nicm
f1828921df Change terminal-overrides to a server option (now that we have them), it
doesn't make much sense as a session option.
2014-02-23 00:53:06 +00:00
nicm
f2e54e1e2f If the terminfo entry has colors#256, assume that setaf and setab work
and use them for the 256 colour set. If the terminfo entry doesn't have
colors#256 and the user gives -2 to the client, use a \033[38;5;Xm
sequence as before. Should allow fbterm to work with it's weird setaf
and setab.
2014-02-14 14:37:08 +00:00
nicm
945339b443 Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

    set -g status-fg yellow
    set -g status-bg red
    set -g status-attr blink

Becomes:

    set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

    set -g status-bg red

Becomes:

    set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.
2014-01-28 23:07:09 +00:00
nicm
f52eac6225 Don't turn on modifyOtherKeys by default, it is annoying if tmux is
killed and it's left on and we can't turn it on and off like we do for
attributes. It's not hard to enable in .Xresources or .Xdefaults anyway.
2013-10-20 09:37:50 +00:00
Nicholas Marriott
3977dba761 Focus events can cause trouble if left on and they can't be turned off
during idle periods (like the other states are) because we'd miss
events. So add a server option to control them. Defaults to off.
2013-06-23 13:10:46 +00:00
Stuart Henderson
d6debc21c7 revert r1.156 "Add support for focus notifications when tmux pane changes"
beck@ found annoying beeps if a machine was shutdown while tmux is running
and you then focus in/out of an xterm; kettenis tracked it down to 1.156.
2013-06-11 19:18:02 +00:00
Nicholas Marriott
13441e8cb8 The actual terminfo entries we ended up with for cursor changes are Cs,
Ce, Ss and Se (not Cc, Ce, Cs, Csr). So use and document these instead
of the ones we were using earlier.
2013-06-02 07:52:15 +00:00
Nicholas Marriott
cbee283c26 Send an SGR0 after turning on modifyOtherKeys to fix Terminal.app which
treats \033[>4;1m and \033[4;1m (bold+underline). Reported & tested by
otto@.
2013-04-11 07:27:27 +00:00
Nicholas Marriott
982354765b Remove tmux's (already minimal) 88 colour support. Such terminals are
few and unnecessary.
2013-03-27 11:17:12 +00:00
Nicholas Marriott
a60687f9ba Handle focus events from the terminal, from Aaron Jensen. 2013-03-24 09:28:59 +00:00
Nicholas Marriott
79f5fe6f5b Use tty_raw on stop, not tty_puts. 2013-03-22 10:40:22 +00:00
Nicholas Marriott
22a2949bd2 Correctly handle UTF8 mouse option being toggled, from Egmont Koblinger. 2013-03-22 10:34:46 +00:00
Nicholas Marriott
3d24c75d0f Include the \033 in the key tree and adjust key matching for this change. 2013-03-21 18:44:47 +00:00
Nicholas Marriott
3665be7c44 Tidy by splitting default key tables into two. 2013-03-21 16:50:22 +00:00
Nicholas Marriott
fdbfc7e349 Rather than having two grids for each pane, one for ASCII and one for
UTF-8, collapse the two together. Simplifies the code at the expense of
more memory (which can probably be reduced again later).
2013-01-18 02:16:21 +00:00
Nicholas Marriott
44f8e1caff Implement ECH (erase character, CSI X). Reported by Christian Neukirchen. 2013-01-15 23:18:55 +00:00
Nicholas Marriott
260419f48e Put helper function back, will be needed in a bit. 2012-11-22 14:41:11 +00:00
Nicholas Marriott
44dccf7ea2 Do not test client flags against TTY_FREEZE bit, reported by Tom Ryder. 2012-09-29 06:57:56 +00:00
Nicholas Marriott
b433886840 We can't tell what the terminal has done with a DCS string, so reset the
cursor and attributes afterwards.
2012-09-05 09:59:41 +00:00
Nicholas Marriott
6307d63715 Remove xterm CRA support - support is patchy and it will be done better
using margins.
2012-09-03 15:47:40 +00:00
Nicholas Marriott
f61fc576d9 Tidy up tty_write, from Sean Estabrooks. 2012-08-14 08:58:25 +00:00
Nicholas Marriott
df912e3540 xfree is not particularly helpful, remove it. From Thomas Adam. 2012-07-10 11:53:01 +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
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
82b053a811 Use tty_pane_full_width macro in some more places. 2012-05-22 09:37:54 +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
243d12752c Move some common code to repeat spaces into a function. 2012-05-22 09:09:16 +00:00
Nicholas Marriott
96a34a0c0a Tidy up by adding a macro for the pane being the full screen width, from
Ailin Nemui.
2012-05-05 18:45:55 +00:00
Nicholas Marriott
132403b6be Missing ()s in macros. 2012-05-05 18:31:09 +00:00
Nicholas Marriott
3e6454f2d6 Pull CRA out into a separate function and add ERA, from Ailin Nemui. 2012-05-05 18:17:59 +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
889fe42e11 Break out termios initialization into a separate function, from George
Nachman.
2012-03-17 21:27:51 +00:00
Nicholas Marriott
164e85cca7 Do not clear to end of line if the line is full, fixes missing last
character in rightmost pane.
2012-03-17 19:29:46 +00:00
Nicholas Marriott
0b34fefe6e Use the region lower not the pane size to work out where the bottom line
is.
2012-03-17 19:18:37 +00:00
Nicholas Marriott
928f40615c Tweak last fix to actually hit the right end of pane. 2012-03-17 18:51:50 +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
0489213b1b Revert screen-write.c r1.54 and fix the bug properly. After wrapping a
line in a pane, the cursor needs to move to the next line unless it
scrolled.
2012-03-17 17:36:03 +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
005566f915 Fix a warning. Doh. 2012-03-15 09:22:31 +00:00
Nicholas Marriott
698361ccde Add a helper function for enabling an optimization to make some code
clearer.
2012-03-15 09:10:33 +00:00
Nicholas Marriott
575bfa4b4b Erm, use EL in a way that actually works... 2012-03-12 12:43:18 +00:00
Nicholas Marriott
31ddae7735 Use EL to clear to end of line if possible. 2012-03-12 12:38:42 +00:00
Nicholas Marriott
799f437eff Remove some bits leftover from unused backoff code. 2012-03-09 21:42:13 +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
fddbd44c18 Add a wrapper function tty_set_size from George Nachman. 2012-02-15 17:25:02 +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
7f24020cbe Add strings to allow the aixterm bright colours to be used when
configuring colours, requested by Elliott Cable a few months ago.
2012-01-21 08:23:12 +00:00
Nicholas Marriott
299a8fd4a3 Calculate last position correctly for UTF-8 wide characters, reported by
Matthias Lederhofer.
2012-01-15 19:39:42 +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
34e5ec1807 Trim another useless if statement, from Ailin Nemui. 2011-05-26 07:08:48 +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
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
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