Commit Graph

309 Commits (f8d3d247d884a9dc0b23f2799944c15630cab28f)

Author SHA1 Message Date
nicm 9dc6946ebf We can use ECH to clear sections of lines, so use it for internal panes
(that don't touch an edge). Move all the tty clear code into two common
functions rather than having the same bunch of checks everywhere.
2017-05-10 16:47:03 +00:00
nicm 3b35daacf7 If the current screen was complex enough, it was possible to make redraw
itself hit the "terminal can't keep up" check. To avoid this, record how
much data we send during redraw (we know we will be starting with 0) and
skip the check until it has been flushed. GitHub issue 912.
2017-05-09 13:04:36 +00:00
nicm 54e2205e54 Konsole incorrectly ignores SU (CSI S) if the parameter is bigger than
the scroll region, so clamp it. Reported by Moritz Bunkus.
2017-04-28 17:58:44 +00:00
nicm d520dae6ac Make full width panes try to play more nicely with terminal copy and
paste by avoiding explicit line wraps if we think the terminal will wrap
anyway.
2017-04-25 18:30:29 +00:00
nicm 5172014668 Only use ED for clear screen if at the bottom, same as earlier fix to
clear end of screen.
2017-04-23 18:13:24 +00:00
nicm fa6deb5866 When the data we have buffered to write to a terminal grows beyond a
reasonable amount (currently width * height * 8 bytes), discard all
output to the terminal and start trying to redraw periodically
instead. Continue with this until the amount of data we are trying to
write falls to a low level again.

This helps to prevent tmux sitting on a huge buffer of data when there
are processes with fast output running inside tmux but the outside
terminal is slow.

A new client_discarded format holds the amount of data that has been
discarded due to this mechanism.

The three variables (when to start this, when to stop, and how often to
redraw) are basically "works for me" at the moment, this is going in to
see how it goes and if it causes problems for anyone else.
2017-04-19 06:52:27 +00:00
nicm f731ae4a2d Revert use of DECSLRM on iTerm2, it doesn't help as much as we throught,
and there are some question marks about it's support.
2017-04-18 21:41:42 +00:00
nicm 623e35f594 Detect iTerm2 and use DECSLRM for it as well. 2017-04-18 18:21:37 +00:00
nicm fb3c5efa50 Add a format for number of bytes writtent to client, useful for debugging. 2017-04-18 15:44:17 +00:00
nicm aace1ead1e Do not check for BCE for a background colour that isn't needed, use
colour 8 instead.
2017-04-18 15:27:47 +00:00
nicm 175d1854d4 Don't bother moving the cursor for empty lines. 2017-04-17 08:10:44 +00:00
nicm 7461c165b5 Remove a couple of redraw flags that no longer have any effect. 2017-04-17 06:40:32 +00:00
nicm 54bcaab70e Use EL1 to clear lines when redrawing the leftmost pane, rather than
spaces.
2017-04-16 20:32:14 +00:00
nicm 9b28200578 Give each client a name. This defaults to the tty name as before but
falls back to an alternative if the tty name is not available. This is
clearer than overloading the client ttyname member and allows us to
remove the path stored in the tty struct, it should always be the same
as the client.
2017-04-05 10:49:46 +00:00
nicm b9a4beb6e7 Write raw strings in one go rather than character at a time. 2017-03-24 14:45:00 +00:00
nicm df3ab87964 Add support for the strikethrough attribute (SGR 9), using the new smxx
terminfo capability. This means there are now nine attribute bits, so
anything above 0xff uses an extended cell.
2017-03-22 07:16:54 +00:00
nicm 2a9d697771 Invalidate the cursor when we think we should have wrapped. 2017-03-15 15:22:14 +00:00
nicm 3c3c08b6d9 Try to avoid moving the cursor to the start of the next line when
printing cells if it is already at the very end of the line and the
terminal will wrap it to the next line itself, this means terminals
still see it as a wrapped line for the purposes of their own mouse
selection. Reported by millert@.
2017-03-15 09:21:21 +00:00
nicm 78ca1b0265 Always send smkx to the terminal outside, the keys we get from terminfo
are the keys when it is on.
2017-03-08 14:34:35 +00:00
nicm dc8fefe902 Collect strings correctly when on terminals that don't support UTF-8. 2017-03-06 09:02:59 +00:00
nicm 8a0b279c31 Change pane redraw to collect cells up as well, and simplify it a bit. 2017-02-21 16:25:04 +00:00
nicm 82db1fa9e5 There are buggy terminals out there that do not move the cursor to 0,0
after CSR, so invalidate the cursor position rather than assuming 0,0.
2017-02-16 12:56:01 +00:00
nicm dd25a6cdc2 Do not clear to end of screen unless the pane is at the bottom. 2017-02-15 11:22:13 +00:00
nicm 921880e00b Add not delete the event if more to write. 2017-02-10 15:39:43 +00:00
nicm d22c15107b Don't use a bufferevent for the tty, so we can keep better track of what
is being written and when.

Also a manpage typo fix from jmc@.
2017-02-10 12:59:18 +00:00
nicm 1811dc5271 Another helper function to write to terminal and log. 2017-02-08 23:53:03 +00:00
nicm 2f854969ff Do not adjust region lower by pane offset when scrolling up, it is
already an absolute position.
2017-02-08 22:42:07 +00:00
nicm e100d465da Add support for scroll up escape sequence (CSI S) and use it when
possible instead of sending individual line feeds.
2017-02-08 17:31:09 +00:00
nicm 13a0b6bb3f Collect sequences of printable ASCII characters and process them
together instead of handling them one by one. This is significantly
faster. Sequences are terminated when we reach the end of the line, fill
the internal buffer, or a different character is seen by the input
parser (an escape sequence, or UTF-8).

Rather than writing collected sequences out immediately, hold them until
it is necessary (another screen modification, or we consume all
available data). This means we can discard changes that would have no
effect (for example, lines that would just be scrolled off the screen or
cleared). This reduces the total amount of data we write out to the
terminal - not important for fast terminals, but a big help with slow
(like xterm).
2017-02-08 16:45:18 +00:00
nicm d4b006b9fa Fix clear start of line. 2017-02-08 16:18:20 +00:00
nicm 7475165cd8 Some other tidying bits. 2017-02-08 15:49:29 +00:00
nicm 96b66f8fc3 Remove unnecessary duplicate check. 2017-02-08 15:24:48 +00:00
nicm 713f3b05f3 Improve some of the logging on resize. 2017-02-08 13:53:32 +00:00
nicm cb80901d33 Log size of output buffer as well. 2017-02-08 08:54:45 +00:00
nicm 9cc02d1498 Trying to avoid the occasional newline by saving the last cell on screen
is not actually helping us much and just adds complexity, so don't
bother.
2017-02-08 08:50:10 +00:00
nicm c0a34821c1 Do not clear the scroll region, instead set it to the scroll region we
actually want.
2017-02-07 18:27:46 +00:00
nicm 6ea36afc4b DECSLRM in xterm(1) appears to have a quirk where it can generate an
extra scroll of the entire terminal; issuing DECSTBM first prevents
this. Do that for now.
2017-02-07 17:13:28 +00:00
nicm 9491a5c1cf Unfortunately DECFRA does not handle default colours properly (it does
not reset colours when in SGR 0), so we can't use it without more
trouble than it is worth. Abandon the idea for now.
2017-02-07 14:33:37 +00:00
nicm d60e585d9e Use DECFRA on VT420 compatible terminals (so, xterm) and ED on all
others for clearing panes.
2017-02-06 22:05:11 +00:00
nicm 68e04907de Do not go through the whole attributes setting process if the new cell
is the same as the previous one.
2017-02-06 19:45:23 +00:00
nicm 10e14ae504 Add BCE for clear to start of screen, which was somehow missed. 2017-02-06 19:26:49 +00:00
nicm 3fd34e70e5 Only redraw the modified character when adding combining characters, not
the whole line.
2017-02-06 13:23:00 +00:00
nicm dd0c814779 Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.
2017-02-01 09:55:07 +00:00
nicm 9b6aeacdc0 aixterm colours can be used if -2 is given, as well as if TERM tells us
the terminal has >=16 colours.
2017-01-12 00:30:41 +00:00
nicm 9e786030df Fix setting the palette of aixterm colours (90-97). 2017-01-12 00:19:32 +00:00
nicm 74c40d04ea Be less aggressive about turning margins off. 2017-01-11 23:10:04 +00:00
nicm 3bb14001b9 Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.
2017-01-11 22:36:07 +00:00
nicm bf6a5c056d Add a format for terminal type. 2017-01-11 16:09:57 +00:00
nicm 314e933914 Add support for the OSC 4 and OSC 104 palette setting escape sequences,
from S Gilles.
2017-01-07 15:28:13 +00:00
nicm 5ea143f521 Only skip moving the cursor if it is already in the last position _on
the same line_, fixes redraw bug reported by patrick keshishian.
2016-12-07 09:16:55 +00:00
nicm 1a6156d8fd Fix check for cursor at end of line. 2016-11-30 13:20:02 +00:00
nicm 9fc925ac51 When comparing ocy to orlower in tty_cmd_cell, there is no need to add
yoff (because they are both already relative to the pane). Also fix some
other minor nits.
2016-11-28 17:50:00 +00:00
nicm ddf7ac5ae4 Fix calculation of whether we need a region for drawing a cell (only if
full width and at the edge of the region), otherwise clear the region entirely.
2016-11-16 13:31:22 +00:00
nicm c34a79b152 Turn on margins, with a couple of fixes (only limit to the pane for line
feeds, and do not move cursor to end for full width panes).
2016-11-15 15:17:28 +00:00
nicm d81a5c630f And of course I just find a bug, disable previous for now. 2016-11-15 14:08:27 +00:00
nicm 0ace779cde Initial attempt to make use of left and right margins if the terminal
supports them (that is, if it advertises itself as a VT420 - probably
just xterm). These are the vertical equivalent of the scroll region and
allow much faster scrolling of panes that do not take up the full width
of the terminal.
2016-11-15 14:02:32 +00:00
nicm d413a945ac Don't make assumptions about line wrap on !xenl terminals, means that
using a wrong TERM without xenl is not so broken if used on a sensible
terminal.
2016-10-14 21:48:00 +00:00
nicm 4179b42424 Add support for BCE (background colour erase). This makes various escape
sequences (notable EL and ED but also IL, DL, ICH, DCH) create blank
cells using the current background colour rather than the default
colour.

On modern systems BCE doesn't really have many benefits, but most other
terminals now support it, some (lazy) applications rely on it, and it is
not hard to include now that we have pane background colours anyway.

Mostly written by Sean Haugh.
2016-10-13 20:27:27 +00:00
nicm 4160df4ca4 Redraw selection in tty_draw_line, so it appears when redrawing whole
pane. Reported by Theo Buehler.
2016-10-12 13:24:07 +00:00
nicm e45401846f Add static in window-*.c and move some internal functions out of tmux.h. 2016-10-11 13:21:59 +00:00
nicm c426e485e5 Loads more static, except for cmd-*.c and window-*.c. 2016-10-10 21:29:23 +00:00
nicm 61dfbe702e Remove some redundant checks and make ich/dch consistent. 2016-10-03 19:19:18 +00:00
nicm 0f73af876f Don't update cells in each block of data read from a pane immediately,
instead track them as change (dirty) and update them once at the end,
saves much time if repeatedly writing the same cell. Also fix comparison
of cells being equal in a few places (memcmp is not enough).
2016-07-15 00:49:08 +00:00
nicm 1921fac814 Cache the window styles and do not look up the window-style options
unless they have changed.
2016-05-30 09:50:20 +00:00
nicm 7d105738b6 Send two cub1 instead of using cub for moving the cursor two left. This
is normally better because using cub1 will be ^H^H (so two bytes) but
cub would be ^[[2D (four).
2016-05-30 09:26:49 +00:00
nicm 88bd5b15ff tty_client_ready can not be internal to tty.c again. 2016-04-30 18:59:02 +00:00
nicm bcb41a09b3 RGB colours shouldn't be mixed up with aixterm colours, return before
that happens when working out if they are supported.
2016-03-03 12:58:15 +00:00
nicm 427b820426 Support for RGB colour, using the extended cell mechanism to avoid
wasting unnecessary space. The 'Tc' flag must be set in the external
TERM entry (using terminal-overrides or a custom terminfo entry), if not
tmux will map to the closest of the 256 or 16 colour palettes.

Mostly from Suraj N Kurapati, based on a diff originally by someone else.
2016-01-29 11:13:56 +00:00
nicm 995af0e2b7 I no longer use my SourceForge address so replace it. 2016-01-19 15:59:12 +00:00
nicm 2a1f27eb1a Couple of trivial style nits. 2015-12-28 14:02:52 +00:00
nicm 88bc8f3528 Style nits and line wrapping of function declarations. 2015-12-11 16:37:21 +00:00
nicm 32e510bd70 Remove support for the UTF-8 mouse extension. This was a briefly used,
poor idea that was fairly quickly replaced by SGR mouse input (which is
now widespread). It is impossible to tell the difference between UTF-8
and non-UTF-8 mouse input; since the mouse-utf8 option was removed tmux
has not handled it correctly in any case; and it is ridiculous to have
three different forms of mouse input.
2015-11-23 20:53:09 +00:00
nicm 577c0e3e5a Use __unused rather than rolling our own. 2015-11-18 14:27:44 +00:00
nicm c5689a5a40 Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.
2015-11-13 08:09:28 +00:00
nicm abb4e9e2fa The output log is only useful once and it means creating a file, so open
it once at startup instead of in every call to tty_open.
2015-10-31 13:12:03 +00:00
nicm 44657bf932 Move struct options into options.c. 2015-10-27 15:58:42 +00:00
nicm 26a55ddcf9 Remove some unnecessary checks before free(). 2015-10-23 16:30:15 +00:00
nicm 63a3fd3c0f Use tty_term_flag not _has for XT, and make -2 force direct use of
256-colour escape sequences (so setaf/setab can be bypassed if needed).
2015-10-23 15:52:54 +00:00
nicm 03d7dba5d8 If the terminal has colors=256, only try to use setaf/setab if they
exist, reported by Filipe Brandenburger.
2015-09-25 23:30:12 +00:00
nicm 38e3baab2a A one line helper function is a little silly. 2015-09-02 17:43:25 +00:00
nicm 8121127606 We no longer need the terminal service class, so don't bother asking for it. 2015-09-02 17:37:54 +00:00
nicm e45d624df2 Fix line endings. 2015-07-13 15:51:31 +00:00
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