2009-06-01 22:58:49 +00:00
|
|
|
/* $OpenBSD$ */
|
|
|
|
|
|
|
|
/*
|
2016-01-19 15:59:12 +00:00
|
|
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
2009-06-01 22:58:49 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2011-05-18 20:24:29 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
#include <curses.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
2011-05-18 20:24:29 +00:00
|
|
|
#include <resolv.h>
|
2009-10-12 13:01:18 +00:00
|
|
|
#include <stdlib.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static int tty_log_fd = -1;
|
2015-10-31 13:12:03 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
static int tty_client_ready(struct client *);
|
2016-04-30 18:59:02 +00:00
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void tty_set_italics(struct tty *);
|
|
|
|
static int tty_try_colour(struct tty *, int, const char *);
|
2021-11-01 09:34:49 +00:00
|
|
|
static void tty_force_cursor_colour(struct tty *, int);
|
2016-10-11 13:21:59 +00:00
|
|
|
static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int,
|
|
|
|
u_int);
|
2017-03-15 09:21:21 +00:00
|
|
|
static void tty_cursor_pane_unless_wrap(struct tty *,
|
|
|
|
const struct tty_ctx *, u_int, u_int);
|
2017-02-08 23:53:03 +00:00
|
|
|
static void tty_invalidate(struct tty *);
|
2016-10-10 21:29:23 +00:00
|
|
|
static void tty_colours(struct tty *, const struct grid_cell *);
|
2021-08-11 20:49:55 +00:00
|
|
|
static void tty_check_fg(struct tty *, struct colour_palette *,
|
|
|
|
struct grid_cell *);
|
|
|
|
static void tty_check_bg(struct tty *, struct colour_palette *,
|
|
|
|
struct grid_cell *);
|
|
|
|
static void tty_check_us(struct tty *, struct colour_palette *,
|
|
|
|
struct grid_cell *);
|
2016-10-10 21:29:23 +00:00
|
|
|
static void tty_colours_fg(struct tty *, const struct grid_cell *);
|
|
|
|
static void tty_colours_bg(struct tty *, const struct grid_cell *);
|
2019-06-27 15:17:41 +00:00
|
|
|
static void tty_colours_us(struct tty *, const struct grid_cell *);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-10-11 13:21:59 +00:00
|
|
|
static void tty_region_pane(struct tty *, const struct tty_ctx *, u_int,
|
|
|
|
u_int);
|
2016-11-15 15:17:28 +00:00
|
|
|
static void tty_region(struct tty *, u_int, u_int);
|
2016-11-15 14:02:32 +00:00
|
|
|
static void tty_margin_pane(struct tty *, const struct tty_ctx *);
|
2016-11-15 15:17:28 +00:00
|
|
|
static void tty_margin(struct tty *, u_int, u_int);
|
2016-10-10 21:29:23 +00:00
|
|
|
static int tty_large_region(struct tty *, const struct tty_ctx *);
|
2020-05-16 15:34:08 +00:00
|
|
|
static int tty_fake_bce(const struct tty *, const struct grid_cell *,
|
|
|
|
u_int);
|
2016-10-10 21:29:23 +00:00
|
|
|
static void tty_redraw_region(struct tty *, const struct tty_ctx *);
|
|
|
|
static void tty_emulate_repeat(struct tty *, enum tty_code_code,
|
|
|
|
enum tty_code_code, u_int);
|
|
|
|
static void tty_repeat_space(struct tty *, u_int);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int);
|
2020-05-16 15:34:08 +00:00
|
|
|
static void tty_default_attributes(struct tty *, const struct grid_cell *,
|
2021-08-11 20:49:55 +00:00
|
|
|
struct colour_palette *, u_int);
|
2021-08-05 09:43:51 +00:00
|
|
|
static int tty_check_overlay(struct tty *, u_int, u_int);
|
2021-10-11 13:27:50 +00:00
|
|
|
static void tty_check_overlay_range(struct tty *, u_int, u_int, u_int,
|
|
|
|
struct overlay_ranges *);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
#define tty_use_margin(tty) \
|
2020-04-20 13:25:36 +00:00
|
|
|
(tty->term->flags & TERM_DECSLRM)
|
2020-05-16 15:27:08 +00:00
|
|
|
#define tty_full_width(tty, ctx) \
|
|
|
|
((ctx)->xoff == 0 && (ctx)->sx >= (tty)->sx)
|
2012-05-05 18:45:55 +00:00
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
#define TTY_BLOCK_INTERVAL (100000 /* 100 milliseconds */)
|
|
|
|
#define TTY_BLOCK_START(tty) (1 + ((tty)->sx * (tty)->sy) * 8)
|
|
|
|
#define TTY_BLOCK_STOP(tty) (1 + ((tty)->sx * (tty)->sy) / 8)
|
|
|
|
|
2022-02-15 13:03:02 +00:00
|
|
|
#define TTY_QUERY_TIMEOUT 5
|
|
|
|
|
2015-10-31 13:12:03 +00:00
|
|
|
void
|
|
|
|
tty_create_log(void)
|
|
|
|
{
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
xsnprintf(name, sizeof name, "tmux-out-%ld.log", (long)getpid());
|
|
|
|
|
|
|
|
tty_log_fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
|
|
|
if (tty_log_fd != -1 && fcntl(tty_log_fd, F_SETFD, FD_CLOEXEC) == -1)
|
|
|
|
fatal("fcntl failed");
|
|
|
|
}
|
|
|
|
|
2015-07-13 15:51:31 +00:00
|
|
|
int
|
2020-05-24 09:13:06 +00:00
|
|
|
tty_init(struct tty *tty, struct client *c)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-24 09:13:06 +00:00
|
|
|
if (!isatty(c->fd))
|
2015-07-13 15:51:31 +00:00
|
|
|
return (-1);
|
|
|
|
|
2009-09-23 06:05:02 +00:00
|
|
|
memset(tty, 0, sizeof *tty);
|
2012-05-22 14:32:28 +00:00
|
|
|
tty->client = c;
|
2009-09-23 06:05:02 +00:00
|
|
|
|
2021-06-10 07:36:47 +00:00
|
|
|
tty->cstyle = SCREEN_CURSOR_DEFAULT;
|
2021-11-01 09:34:49 +00:00
|
|
|
tty->ccolour = -1;
|
2009-09-23 06:05:02 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
if (tcgetattr(c->fd, &tty->tio) != 0)
|
|
|
|
return (-1);
|
2015-07-13 15:51:31 +00:00
|
|
|
return (0);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 10:29:15 +00:00
|
|
|
void
|
2009-09-23 06:12:58 +00:00
|
|
|
tty_resize(struct tty *tty)
|
|
|
|
{
|
2017-04-05 10:49:46 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
struct winsize ws;
|
2019-11-28 09:05:34 +00:00
|
|
|
u_int sx, sy, xpixel, ypixel;
|
2009-09-23 06:12:58 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
if (ioctl(c->fd, TIOCGWINSZ, &ws) != -1) {
|
2010-06-05 16:47:11 +00:00
|
|
|
sx = ws.ws_col;
|
2019-11-28 09:05:34 +00:00
|
|
|
if (sx == 0) {
|
2010-06-05 16:47:11 +00:00
|
|
|
sx = 80;
|
2019-11-28 09:05:34 +00:00
|
|
|
xpixel = 0;
|
|
|
|
} else
|
|
|
|
xpixel = ws.ws_xpixel / sx;
|
2010-06-05 16:47:11 +00:00
|
|
|
sy = ws.ws_row;
|
2019-11-28 09:05:34 +00:00
|
|
|
if (sy == 0) {
|
2010-06-05 16:47:11 +00:00
|
|
|
sy = 24;
|
2019-11-28 09:05:34 +00:00
|
|
|
ypixel = 0;
|
|
|
|
} else
|
|
|
|
ypixel = ws.ws_ypixel / sy;
|
2010-06-05 16:47:11 +00:00
|
|
|
} else {
|
|
|
|
sx = 80;
|
|
|
|
sy = 24;
|
2019-11-28 09:05:34 +00:00
|
|
|
xpixel = 0;
|
|
|
|
ypixel = 0;
|
2009-09-23 06:12:58 +00:00
|
|
|
}
|
2019-11-28 09:05:34 +00:00
|
|
|
log_debug("%s: %s now %ux%u (%ux%u)", __func__, c->name, sx, sy,
|
|
|
|
xpixel, ypixel);
|
|
|
|
tty_set_size(tty, sx, sy, xpixel, ypixel);
|
2017-02-08 23:53:03 +00:00
|
|
|
tty_invalidate(tty);
|
2009-09-23 06:12:58 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 10:29:15 +00:00
|
|
|
void
|
2019-11-28 09:05:34 +00:00
|
|
|
tty_set_size(struct tty *tty, u_int sx, u_int sy, u_int xpixel, u_int ypixel)
|
2016-11-15 14:02:32 +00:00
|
|
|
{
|
2012-02-15 17:25:02 +00:00
|
|
|
tty->sx = sx;
|
|
|
|
tty->sy = sy;
|
2019-11-28 09:05:34 +00:00
|
|
|
tty->xpixel = xpixel;
|
|
|
|
tty->ypixel = ypixel;
|
2012-02-15 17:25:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2017-02-10 12:59:18 +00:00
|
|
|
tty_read_callback(__unused int fd, __unused short events, void *data)
|
2009-11-05 08:45:08 +00:00
|
|
|
{
|
|
|
|
struct tty *tty = data;
|
2017-04-05 10:49:46 +00:00
|
|
|
struct client *c = tty->client;
|
2020-05-16 16:07:55 +00:00
|
|
|
const char *name = c->name;
|
2017-02-10 12:59:18 +00:00
|
|
|
size_t size = EVBUFFER_LENGTH(tty->in);
|
|
|
|
int nread;
|
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
nread = evbuffer_read(tty->in, c->fd, -1);
|
2017-08-24 08:48:37 +00:00
|
|
|
if (nread == 0 || nread == -1) {
|
2020-05-16 16:07:55 +00:00
|
|
|
if (nread == 0)
|
|
|
|
log_debug("%s: read closed", name);
|
|
|
|
else
|
|
|
|
log_debug("%s: read error: %s", name, strerror(errno));
|
2017-06-06 14:53:28 +00:00
|
|
|
event_del(&tty->event_in);
|
2017-08-24 08:48:37 +00:00
|
|
|
server_client_lost(tty->client);
|
2017-02-10 12:59:18 +00:00
|
|
|
return;
|
2017-06-06 14:53:28 +00:00
|
|
|
}
|
2020-05-16 16:07:55 +00:00
|
|
|
log_debug("%s: read %d bytes (already %zu)", name, nread, size);
|
2009-11-05 08:45:08 +00:00
|
|
|
|
|
|
|
while (tty_keys_next(tty))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
static void
|
|
|
|
tty_timer_callback(__unused int fd, __unused short events, void *data)
|
|
|
|
{
|
|
|
|
struct tty *tty = data;
|
|
|
|
struct client *c = tty->client;
|
|
|
|
struct timeval tv = { .tv_usec = TTY_BLOCK_INTERVAL };
|
|
|
|
|
|
|
|
log_debug("%s: %zu discarded", c->name, tty->discarded);
|
|
|
|
|
2018-08-19 16:45:03 +00:00
|
|
|
c->flags |= CLIENT_ALLREDRAWFLAGS;
|
2017-04-19 06:52:27 +00:00
|
|
|
c->discarded += tty->discarded;
|
|
|
|
|
|
|
|
if (tty->discarded < TTY_BLOCK_STOP(tty)) {
|
|
|
|
tty->flags &= ~TTY_BLOCK;
|
|
|
|
tty_invalidate(tty);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tty->discarded = 0;
|
|
|
|
evtimer_add(&tty->timer, &tv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tty_block_maybe(struct tty *tty)
|
|
|
|
{
|
|
|
|
struct client *c = tty->client;
|
|
|
|
size_t size = EVBUFFER_LENGTH(tty->out);
|
|
|
|
struct timeval tv = { .tv_usec = TTY_BLOCK_INTERVAL };
|
|
|
|
|
2021-12-10 12:42:37 +00:00
|
|
|
if (size == 0)
|
|
|
|
tty->flags &= ~TTY_NOBLOCK;
|
|
|
|
else if (tty->flags & TTY_NOBLOCK)
|
|
|
|
return (0);
|
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
if (size < TTY_BLOCK_START(tty))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (tty->flags & TTY_BLOCK)
|
|
|
|
return (1);
|
|
|
|
tty->flags |= TTY_BLOCK;
|
|
|
|
|
|
|
|
log_debug("%s: can't keep up, %zu discarded", c->name, size);
|
|
|
|
|
|
|
|
evbuffer_drain(tty->out, size);
|
|
|
|
c->discarded += size;
|
|
|
|
|
|
|
|
tty->discarded = 0;
|
|
|
|
evtimer_add(&tty->timer, &tv);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2017-02-10 12:59:18 +00:00
|
|
|
tty_write_callback(__unused int fd, __unused short events, void *data)
|
2009-11-04 21:47:42 +00:00
|
|
|
{
|
2017-02-10 12:59:18 +00:00
|
|
|
struct tty *tty = data;
|
2017-04-05 10:49:46 +00:00
|
|
|
struct client *c = tty->client;
|
2017-02-10 12:59:18 +00:00
|
|
|
size_t size = EVBUFFER_LENGTH(tty->out);
|
|
|
|
int nwrite;
|
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
nwrite = evbuffer_write(tty->out, c->fd);
|
2017-02-10 12:59:18 +00:00
|
|
|
if (nwrite == -1)
|
|
|
|
return;
|
2017-04-05 10:49:46 +00:00
|
|
|
log_debug("%s: wrote %d bytes (of %zu)", c->name, nwrite, size);
|
2017-02-10 12:59:18 +00:00
|
|
|
|
2017-05-09 13:04:36 +00:00
|
|
|
if (c->redraw > 0) {
|
|
|
|
if ((size_t)nwrite >= c->redraw)
|
|
|
|
c->redraw = 0;
|
|
|
|
else
|
|
|
|
c->redraw -= nwrite;
|
|
|
|
log_debug("%s: waiting for redraw, %zu bytes left", c->name,
|
|
|
|
c->redraw);
|
|
|
|
} else if (tty_block_maybe(tty))
|
2017-04-19 06:52:27 +00:00
|
|
|
return;
|
|
|
|
|
2017-02-10 15:39:43 +00:00
|
|
|
if (EVBUFFER_LENGTH(tty->out) != 0)
|
|
|
|
event_add(&tty->event_out, NULL);
|
2009-11-04 21:47:42 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 12:59:18 +00:00
|
|
|
int
|
|
|
|
tty_open(struct tty *tty, char **cause)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-04-20 13:25:36 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2021-02-17 07:18:36 +00:00
|
|
|
tty->term = tty_term_create(tty, c->term_name, c->term_caps,
|
|
|
|
c->term_ncaps, &c->term_features, cause);
|
2017-02-10 12:59:18 +00:00
|
|
|
if (tty->term == NULL) {
|
|
|
|
tty_close(tty);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
tty->flags |= TTY_OPENED;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
tty->flags &= ~(TTY_NOCURSOR|TTY_FREEZE|TTY_BLOCK|TTY_TIMER);
|
2009-09-23 07:25:31 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
event_set(&tty->event_in, c->fd, EV_PERSIST|EV_READ,
|
2017-02-10 12:59:18 +00:00
|
|
|
tty_read_callback, tty);
|
|
|
|
tty->in = evbuffer_new();
|
2018-11-19 13:35:40 +00:00
|
|
|
if (tty->in == NULL)
|
|
|
|
fatal("out of memory");
|
2009-09-23 12:03:30 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
event_set(&tty->event_out, c->fd, EV_WRITE, tty_write_callback, tty);
|
2017-02-10 12:59:18 +00:00
|
|
|
tty->out = evbuffer_new();
|
2018-11-19 13:35:40 +00:00
|
|
|
if (tty->out == NULL)
|
|
|
|
fatal("out of memory");
|
2009-11-04 21:47:42 +00:00
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
evtimer_set(&tty->timer, tty_timer_callback, tty);
|
|
|
|
|
2017-02-10 12:59:18 +00:00
|
|
|
tty_start_tty(tty);
|
|
|
|
|
|
|
|
tty_keys_build(tty);
|
|
|
|
|
|
|
|
return (0);
|
2012-03-17 21:27:51 +00:00
|
|
|
}
|
|
|
|
|
2020-01-13 11:59:21 +00:00
|
|
|
static void
|
|
|
|
tty_start_timer_callback(__unused int fd, __unused short events, void *data)
|
|
|
|
{
|
|
|
|
struct tty *tty = data;
|
|
|
|
struct client *c = tty->client;
|
|
|
|
|
|
|
|
log_debug("%s: start timer fired", c->name);
|
2020-05-16 16:44:54 +00:00
|
|
|
if ((tty->flags & (TTY_HAVEDA|TTY_HAVEXDA)) == 0)
|
|
|
|
tty_update_features(tty);
|
2020-05-16 14:16:25 +00:00
|
|
|
tty->flags |= (TTY_HAVEDA|TTY_HAVEXDA);
|
2020-01-13 11:59:21 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 21:27:51 +00:00
|
|
|
void
|
|
|
|
tty_start_tty(struct tty *tty)
|
|
|
|
{
|
2017-05-15 16:44:04 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
struct termios tio;
|
2022-02-15 13:03:02 +00:00
|
|
|
struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT };
|
2017-02-10 12:59:18 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
setblocking(c->fd, 0);
|
|
|
|
event_add(&tty->event_in, NULL);
|
|
|
|
|
|
|
|
memcpy(&tio, &tty->tio, sizeof tio);
|
|
|
|
tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP);
|
|
|
|
tio.c_iflag |= IGNBRK;
|
|
|
|
tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET);
|
|
|
|
tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL|ECHOPRT|
|
|
|
|
ECHOKE|ISIG);
|
|
|
|
tio.c_cc[VMIN] = 1;
|
|
|
|
tio.c_cc[VTIME] = 0;
|
|
|
|
if (tcsetattr(c->fd, TCSANOW, &tio) == 0)
|
2021-10-05 12:46:02 +00:00
|
|
|
tcflush(c->fd, TCOFLUSH);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
tty_putcode(tty, TTYC_SMCUP);
|
2009-07-10 07:11:59 +00:00
|
|
|
|
2017-03-08 14:34:35 +00:00
|
|
|
tty_putcode(tty, TTYC_SMKX);
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_putcode(tty, TTYC_CLEAR);
|
|
|
|
|
2017-05-15 16:44:04 +00:00
|
|
|
if (tty_acs_needed(tty)) {
|
|
|
|
log_debug("%s: using capabilities for ACS", c->name);
|
|
|
|
tty_putcode(tty, TTYC_ENACS);
|
|
|
|
} else
|
|
|
|
log_debug("%s: using UTF-8 for ACS", c->name);
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_putcode(tty, TTYC_CNORM);
|
2020-03-16 09:18:47 +00:00
|
|
|
if (tty_term_has(tty->term, TTYC_KMOUS)) {
|
|
|
|
tty_puts(tty, "\033[?1000l\033[?1002l\033[?1003l");
|
|
|
|
tty_puts(tty, "\033[?1006l\033[?1005l");
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-01-13 11:59:21 +00:00
|
|
|
evtimer_set(&tty->start_timer, tty_start_timer_callback, tty);
|
|
|
|
evtimer_add(&tty->start_timer, &tv);
|
|
|
|
|
2009-08-11 19:32:25 +00:00
|
|
|
tty->flags |= TTY_STARTED;
|
2017-02-08 23:53:03 +00:00
|
|
|
tty_invalidate(tty);
|
2011-05-20 19:03:58 +00:00
|
|
|
|
2021-11-01 09:34:49 +00:00
|
|
|
if (tty->ccolour != -1)
|
|
|
|
tty_force_cursor_colour(tty, -1);
|
2015-04-19 21:34:21 +00:00
|
|
|
|
|
|
|
tty->mouse_drag_flag = 0;
|
|
|
|
tty->mouse_drag_update = NULL;
|
|
|
|
tty->mouse_drag_release = NULL;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 12:16:16 +00:00
|
|
|
void
|
|
|
|
tty_send_requests(struct tty *tty)
|
|
|
|
{
|
|
|
|
if (~tty->flags & TTY_STARTED)
|
|
|
|
return;
|
|
|
|
|
2020-05-16 14:53:23 +00:00
|
|
|
if (tty->term->flags & TERM_VT100LIKE) {
|
2020-04-09 12:16:16 +00:00
|
|
|
if (~tty->flags & TTY_HAVEDA)
|
2020-04-16 15:14:25 +00:00
|
|
|
tty_puts(tty, "\033[>c");
|
2020-05-16 14:16:25 +00:00
|
|
|
if (~tty->flags & TTY_HAVEXDA)
|
|
|
|
tty_puts(tty, "\033[>q");
|
2020-04-09 12:16:16 +00:00
|
|
|
} else
|
2020-05-16 14:16:25 +00:00
|
|
|
tty->flags |= (TTY_HAVEDA|TTY_HAVEXDA);
|
2020-04-09 12:16:16 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
tty_stop_tty(struct tty *tty)
|
|
|
|
{
|
2020-05-24 09:13:06 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
struct winsize ws;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-08-11 19:32:25 +00:00
|
|
|
if (!(tty->flags & TTY_STARTED))
|
|
|
|
return;
|
|
|
|
tty->flags &= ~TTY_STARTED;
|
|
|
|
|
2020-01-13 11:59:21 +00:00
|
|
|
evtimer_del(&tty->start_timer);
|
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
event_del(&tty->timer);
|
|
|
|
tty->flags &= ~TTY_BLOCK;
|
|
|
|
|
2017-02-10 12:59:18 +00:00
|
|
|
event_del(&tty->event_in);
|
|
|
|
event_del(&tty->event_out);
|
2009-11-04 21:47:42 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/*
|
|
|
|
* Be flexible about error handling and try not kill the server just
|
|
|
|
* because the fd is invalid. Things like ssh -t can easily leave us
|
|
|
|
* with a dead tty.
|
|
|
|
*/
|
2020-05-24 09:13:06 +00:00
|
|
|
if (ioctl(c->fd, TIOCGWINSZ, &ws) == -1)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2020-05-24 09:13:06 +00:00
|
|
|
if (tcsetattr(c->fd, TCSANOW, &tty->tio) == -1)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
|
2017-05-15 16:44:04 +00:00
|
|
|
if (tty_acs_needed(tty))
|
2010-09-11 16:19:22 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
|
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX));
|
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR));
|
2021-06-10 07:36:47 +00:00
|
|
|
if (tty->cstyle != SCREEN_CURSOR_DEFAULT) {
|
2013-06-02 07:52:15 +00:00
|
|
|
if (tty_term_has(tty->term, TTYC_SE))
|
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_SE));
|
2021-06-10 07:36:47 +00:00
|
|
|
else if (tty_term_has(tty->term, TTYC_SS))
|
2013-06-02 07:52:15 +00:00
|
|
|
tty_raw(tty, tty_term_string1(tty->term, TTYC_SS, 0));
|
2011-05-20 19:17:39 +00:00
|
|
|
}
|
2015-02-05 11:46:57 +00:00
|
|
|
if (tty->mode & MODE_BRACKETPASTE)
|
2020-05-16 14:53:23 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_DSBP));
|
2021-11-01 09:34:49 +00:00
|
|
|
if (tty->ccolour != -1)
|
2019-12-11 12:13:37 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_CR));
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
|
2020-03-16 09:18:47 +00:00
|
|
|
if (tty_term_has(tty->term, TTYC_KMOUS)) {
|
|
|
|
tty_raw(tty, "\033[?1000l\033[?1002l\033[?1003l");
|
|
|
|
tty_raw(tty, "\033[?1006l\033[?1005l");
|
|
|
|
}
|
2013-03-22 10:34:46 +00:00
|
|
|
|
2020-05-16 14:53:23 +00:00
|
|
|
if (tty->term->flags & TERM_VT100LIKE)
|
|
|
|
tty_raw(tty, "\033[?7727l");
|
2020-05-16 16:44:54 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS));
|
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_DSEKS));
|
2009-07-10 07:11:59 +00:00
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
if (tty_use_margin(tty))
|
2020-05-16 14:22:51 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_DSMG));
|
2009-07-10 07:11:59 +00:00
|
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
|
2013-03-22 10:34:46 +00:00
|
|
|
|
2020-05-24 09:13:06 +00:00
|
|
|
setblocking(c->fd, 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-11 19:32:25 +00:00
|
|
|
tty_close(struct tty *tty)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2012-03-17 18:24:07 +00:00
|
|
|
if (event_initialized(&tty->key_timer))
|
|
|
|
evtimer_del(&tty->key_timer);
|
2009-08-11 19:32:25 +00:00
|
|
|
tty_stop_tty(tty);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-08-11 20:29:04 +00:00
|
|
|
if (tty->flags & TTY_OPENED) {
|
2017-02-10 12:59:18 +00:00
|
|
|
evbuffer_free(tty->in);
|
|
|
|
event_del(&tty->event_in);
|
|
|
|
evbuffer_free(tty->out);
|
|
|
|
event_del(&tty->event_out);
|
2009-11-04 21:47:42 +00:00
|
|
|
|
2009-08-11 20:29:04 +00:00
|
|
|
tty_term_free(tty->term);
|
|
|
|
tty_keys_free(tty);
|
|
|
|
|
|
|
|
tty->flags &= ~TTY_OPENED;
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-11 19:32:25 +00:00
|
|
|
tty_free(struct tty *tty)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-08-11 19:32:25 +00:00
|
|
|
tty_close(tty);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
void
|
2020-04-20 13:25:36 +00:00
|
|
|
tty_update_features(struct tty *tty)
|
2016-11-15 14:02:32 +00:00
|
|
|
{
|
2020-04-20 13:25:36 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2020-04-20 15:37:32 +00:00
|
|
|
if (tty_apply_features(tty->term, c->term_features))
|
|
|
|
tty_term_apply_overrides(tty->term);
|
2016-11-15 14:02:32 +00:00
|
|
|
|
|
|
|
if (tty_use_margin(tty))
|
2020-05-16 14:22:51 +00:00
|
|
|
tty_putcode(tty, TTYC_ENMG);
|
2020-05-16 16:44:54 +00:00
|
|
|
if (options_get_number(global_options, "extended-keys"))
|
|
|
|
tty_puts(tty, tty_term_string(tty->term, TTYC_ENEKS));
|
|
|
|
if (options_get_number(global_options, "focus-events"))
|
2020-05-22 15:08:38 +00:00
|
|
|
tty_puts(tty, tty_term_string(tty->term, TTYC_ENFCS));
|
2020-05-16 16:44:54 +00:00
|
|
|
if (tty->term->flags & TERM_VT100LIKE)
|
|
|
|
tty_puts(tty, "\033[?7727h");
|
2016-11-15 14:02:32 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
tty_raw(struct tty *tty, const char *s)
|
|
|
|
{
|
2020-05-24 09:13:06 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
ssize_t n, slen;
|
|
|
|
u_int i;
|
2013-03-22 10:34:46 +00:00
|
|
|
|
|
|
|
slen = strlen(s);
|
|
|
|
for (i = 0; i < 5; i++) {
|
2020-05-24 09:13:06 +00:00
|
|
|
n = write(c->fd, s, slen);
|
2013-03-22 10:34:46 +00:00
|
|
|
if (n >= 0) {
|
|
|
|
s += n;
|
|
|
|
slen -= n;
|
|
|
|
if (slen == 0)
|
|
|
|
break;
|
|
|
|
} else if (n == -1 && errno != EAGAIN)
|
|
|
|
break;
|
|
|
|
usleep(100);
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_putcode(struct tty *tty, enum tty_code_code code)
|
|
|
|
{
|
|
|
|
tty_puts(tty, tty_term_string(tty->term, code));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_putcode1(struct tty *tty, enum tty_code_code code, int a)
|
|
|
|
{
|
|
|
|
if (a < 0)
|
|
|
|
return;
|
|
|
|
tty_puts(tty, tty_term_string1(tty->term, code, a));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_putcode2(struct tty *tty, enum tty_code_code code, int a, int b)
|
|
|
|
{
|
|
|
|
if (a < 0 || b < 0)
|
|
|
|
return;
|
|
|
|
tty_puts(tty, tty_term_string2(tty->term, code, a, b));
|
|
|
|
}
|
|
|
|
|
2017-05-31 08:43:44 +00:00
|
|
|
void
|
|
|
|
tty_putcode3(struct tty *tty, enum tty_code_code code, int a, int b, int c)
|
|
|
|
{
|
|
|
|
if (a < 0 || b < 0 || c < 0)
|
|
|
|
return;
|
|
|
|
tty_puts(tty, tty_term_string3(tty->term, code, a, b, c));
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:03:58 +00:00
|
|
|
void
|
|
|
|
tty_putcode_ptr1(struct tty *tty, enum tty_code_code code, const void *a)
|
|
|
|
{
|
|
|
|
if (a != NULL)
|
|
|
|
tty_puts(tty, tty_term_ptr1(tty->term, code, a));
|
|
|
|
}
|
|
|
|
|
2011-05-18 20:24:29 +00:00
|
|
|
void
|
2014-04-17 12:57:28 +00:00
|
|
|
tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a,
|
|
|
|
const void *b)
|
2011-05-18 20:24:29 +00:00
|
|
|
{
|
|
|
|
if (a != NULL && b != NULL)
|
|
|
|
tty_puts(tty, tty_term_ptr2(tty->term, code, a, b));
|
|
|
|
}
|
|
|
|
|
2017-02-08 23:53:03 +00:00
|
|
|
static void
|
|
|
|
tty_add(struct tty *tty, const char *buf, size_t len)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2017-04-05 10:49:46 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2017-04-19 06:52:27 +00:00
|
|
|
if (tty->flags & TTY_BLOCK) {
|
|
|
|
tty->discarded += len;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-10 12:59:18 +00:00
|
|
|
evbuffer_add(tty->out, buf, len);
|
2017-05-09 13:04:36 +00:00
|
|
|
log_debug("%s: %.*s", c->name, (int)len, buf);
|
2017-04-19 06:52:27 +00:00
|
|
|
c->written += len;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2015-10-31 13:12:03 +00:00
|
|
|
if (tty_log_fd != -1)
|
2017-02-08 23:53:03 +00:00
|
|
|
write(tty_log_fd, buf, len);
|
2017-02-10 12:59:18 +00:00
|
|
|
if (tty->flags & TTY_STARTED)
|
|
|
|
event_add(&tty->event_out, NULL);
|
2017-02-08 23:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_puts(struct tty *tty, const char *s)
|
|
|
|
{
|
|
|
|
if (*s != '\0')
|
|
|
|
tty_add(tty, s, strlen(s));
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_putc(struct tty *tty, u_char ch)
|
|
|
|
{
|
2010-09-11 16:19:22 +00:00
|
|
|
const char *acs;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-06-05 09:32:15 +00:00
|
|
|
if ((tty->term->flags & TERM_NOAM) &&
|
2019-05-30 07:42:41 +00:00
|
|
|
ch >= 0x20 && ch != 0x7f &&
|
|
|
|
tty->cy == tty->sy - 1 &&
|
|
|
|
tty->cx + 1 >= tty->sx)
|
|
|
|
return;
|
|
|
|
|
2010-09-11 16:19:22 +00:00
|
|
|
if (tty->cell.attr & GRID_ATTR_CHARSET) {
|
|
|
|
acs = tty_acs_get(tty, ch);
|
2017-02-08 23:53:03 +00:00
|
|
|
if (acs != NULL)
|
|
|
|
tty_add(tty, acs, strlen(acs));
|
|
|
|
else
|
|
|
|
tty_add(tty, &ch, 1);
|
|
|
|
} else
|
|
|
|
tty_add(tty, &ch, 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (ch >= 0x20 && ch != 0x7f) {
|
2016-10-14 21:48:00 +00:00
|
|
|
if (tty->cx >= tty->sx) {
|
2009-10-12 17:19:47 +00:00
|
|
|
tty->cx = 1;
|
|
|
|
if (tty->cy != tty->rlower)
|
|
|
|
tty->cy++;
|
2016-10-14 21:48:00 +00:00
|
|
|
|
|
|
|
/*
|
2020-06-05 09:32:15 +00:00
|
|
|
* On !am terminals, force the cursor position to where
|
|
|
|
* we think it should be after a line wrap - this means
|
|
|
|
* it works on sensible terminals as well.
|
2016-10-14 21:48:00 +00:00
|
|
|
*/
|
2020-06-05 09:32:15 +00:00
|
|
|
if (tty->term->flags & TERM_NOAM)
|
2016-10-14 21:48:00 +00:00
|
|
|
tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);
|
2009-06-01 22:58:49 +00:00
|
|
|
} else
|
|
|
|
tty->cx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-24 16:01:02 +00:00
|
|
|
void
|
2013-01-18 02:16:21 +00:00
|
|
|
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
|
2009-06-24 16:01:02 +00:00
|
|
|
{
|
2020-06-05 09:32:15 +00:00
|
|
|
if ((tty->term->flags & TERM_NOAM) &&
|
2019-05-30 07:42:41 +00:00
|
|
|
tty->cy == tty->sy - 1 &&
|
|
|
|
tty->cx + len >= tty->sx)
|
|
|
|
len = tty->sx - tty->cx - 1;
|
|
|
|
|
2017-02-08 23:53:03 +00:00
|
|
|
tty_add(tty, buf, len);
|
2017-04-25 18:30:29 +00:00
|
|
|
if (tty->cx + width > tty->sx) {
|
|
|
|
tty->cx = (tty->cx + width) - tty->sx;
|
|
|
|
if (tty->cx <= tty->sx)
|
|
|
|
tty->cy++;
|
|
|
|
else
|
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
|
|
|
} else
|
2017-03-15 15:22:14 +00:00
|
|
|
tty->cx += width;
|
2009-06-24 16:01:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2015-04-29 15:59:08 +00:00
|
|
|
tty_set_italics(struct tty *tty)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
if (tty_term_has(tty->term, TTYC_SITM)) {
|
2015-10-27 15:58:42 +00:00
|
|
|
s = options_get_string(global_options, "default-terminal");
|
2015-04-29 15:59:08 +00:00
|
|
|
if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) {
|
|
|
|
tty_putcode(tty, TTYC_SITM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tty_putcode(tty, TTYC_SMSO);
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
tty_set_title(struct tty *tty, const char *title)
|
|
|
|
{
|
2011-05-08 19:53:06 +00:00
|
|
|
if (!tty_term_has(tty->term, TTYC_TSL) ||
|
|
|
|
!tty_term_has(tty->term, TTYC_FSL))
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
|
2011-05-08 19:53:06 +00:00
|
|
|
tty_putcode(tty, TTYC_TSL);
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_puts(tty, title);
|
2011-05-08 19:53:06 +00:00
|
|
|
tty_putcode(tty, TTYC_FSL);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 13:21:59 +00:00
|
|
|
static void
|
2021-11-01 09:34:49 +00:00
|
|
|
tty_force_cursor_colour(struct tty *tty, int c)
|
2011-05-20 19:03:58 +00:00
|
|
|
{
|
2021-11-01 09:34:49 +00:00
|
|
|
u_char r, g, b;
|
|
|
|
char s[13] = "";
|
|
|
|
|
|
|
|
if (c != -1)
|
|
|
|
c = colour_force_rgb(c);
|
|
|
|
if (c == tty->ccolour)
|
|
|
|
return;
|
|
|
|
if (c == -1)
|
2011-05-20 19:03:58 +00:00
|
|
|
tty_putcode(tty, TTYC_CR);
|
2021-11-01 09:34:49 +00:00
|
|
|
else {
|
|
|
|
colour_split_rgb(c, &r, &g, &b);
|
|
|
|
xsnprintf(s, sizeof s, "rgb:%02hhx/%02hhx/%02hhx", r, g, b);
|
|
|
|
tty_putcode_ptr1(tty, TTYC_CS, s);
|
|
|
|
}
|
|
|
|
tty->ccolour = c;
|
2011-05-20 19:03:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 13:37:17 +00:00
|
|
|
static int
|
|
|
|
tty_update_cursor(struct tty *tty, int mode, struct screen *s)
|
2021-10-05 12:46:02 +00:00
|
|
|
{
|
2021-11-01 09:34:49 +00:00
|
|
|
enum screen_cursor_style cstyle;
|
2021-11-03 13:37:17 +00:00
|
|
|
int ccolour, changed, cmode = mode;
|
2021-10-05 12:46:02 +00:00
|
|
|
|
|
|
|
/* Set cursor colour if changed. */
|
2021-11-01 09:34:49 +00:00
|
|
|
if (s != NULL) {
|
|
|
|
ccolour = s->ccolour;
|
|
|
|
if (s->ccolour == -1)
|
|
|
|
ccolour = s->default_ccolour;
|
|
|
|
tty_force_cursor_colour(tty, ccolour);
|
|
|
|
}
|
2021-10-05 12:46:02 +00:00
|
|
|
|
|
|
|
/* If cursor is off, set as invisible. */
|
2021-11-03 13:37:17 +00:00
|
|
|
if (~cmode & MODE_CURSOR) {
|
|
|
|
if (tty->mode & MODE_CURSOR)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode(tty, TTYC_CIVIS);
|
2021-11-03 13:37:17 +00:00
|
|
|
return (cmode);
|
2021-10-05 12:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if blinking or very visible flag changed or style changed. */
|
|
|
|
if (s == NULL)
|
|
|
|
cstyle = tty->cstyle;
|
2021-11-03 13:37:17 +00:00
|
|
|
else {
|
2021-10-05 12:46:02 +00:00
|
|
|
cstyle = s->cstyle;
|
2021-11-03 13:37:17 +00:00
|
|
|
if (cstyle == SCREEN_CURSOR_DEFAULT) {
|
|
|
|
if (~cmode & MODE_CURSOR_BLINKING_SET) {
|
|
|
|
if (s->default_mode & MODE_CURSOR_BLINKING)
|
|
|
|
cmode |= MODE_CURSOR_BLINKING;
|
|
|
|
else
|
|
|
|
cmode &= ~MODE_CURSOR_BLINKING;
|
|
|
|
}
|
|
|
|
cstyle = s->default_cstyle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If nothing changed, do nothing. */
|
|
|
|
changed = cmode ^ tty->mode;
|
2021-10-05 12:46:02 +00:00
|
|
|
if ((changed & CURSOR_MODES) == 0 && cstyle == tty->cstyle)
|
2021-11-03 13:37:17 +00:00
|
|
|
return (cmode);
|
2021-10-05 12:46:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set cursor style. If an explicit style has been set with DECSCUSR,
|
|
|
|
* set it if supported, otherwise send cvvis for blinking styles.
|
|
|
|
*
|
|
|
|
* If no style, has been set (SCREEN_CURSOR_DEFAULT), then send cvvis
|
|
|
|
* if either the blinking or very visible flags are set.
|
|
|
|
*/
|
|
|
|
tty_putcode(tty, TTYC_CNORM);
|
|
|
|
switch (cstyle) {
|
|
|
|
case SCREEN_CURSOR_DEFAULT:
|
2021-10-06 10:33:12 +00:00
|
|
|
if (tty->cstyle != SCREEN_CURSOR_DEFAULT) {
|
|
|
|
if (tty_term_has(tty->term, TTYC_SE))
|
|
|
|
tty_putcode(tty, TTYC_SE);
|
|
|
|
else
|
|
|
|
tty_putcode1(tty, TTYC_SS, 0);
|
|
|
|
}
|
2021-11-03 13:37:17 +00:00
|
|
|
if (cmode & (MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE))
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode(tty, TTYC_CVVIS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CURSOR_BLOCK:
|
|
|
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
2021-11-03 13:37:17 +00:00
|
|
|
if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode1(tty, TTYC_SS, 1);
|
|
|
|
else
|
|
|
|
tty_putcode1(tty, TTYC_SS, 2);
|
2021-11-03 13:37:17 +00:00
|
|
|
} else if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode(tty, TTYC_CVVIS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CURSOR_UNDERLINE:
|
|
|
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
2021-11-03 13:37:17 +00:00
|
|
|
if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode1(tty, TTYC_SS, 3);
|
|
|
|
else
|
|
|
|
tty_putcode1(tty, TTYC_SS, 4);
|
2021-11-03 13:37:17 +00:00
|
|
|
} else if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode(tty, TTYC_CVVIS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CURSOR_BAR:
|
|
|
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
2021-11-03 13:37:17 +00:00
|
|
|
if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode1(tty, TTYC_SS, 5);
|
|
|
|
else
|
|
|
|
tty_putcode1(tty, TTYC_SS, 6);
|
2021-11-03 13:37:17 +00:00
|
|
|
} else if (cmode & MODE_CURSOR_BLINKING)
|
2021-10-05 12:46:02 +00:00
|
|
|
tty_putcode(tty, TTYC_CVVIS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tty->cstyle = cstyle;
|
2021-11-03 13:37:17 +00:00
|
|
|
return (cmode);
|
2021-10-05 12:46:02 +00:00
|
|
|
}
|
|
|
|
|
2011-05-20 19:03:58 +00:00
|
|
|
void
|
|
|
|
tty_update_mode(struct tty *tty, int mode, struct screen *s)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-11-03 13:37:17 +00:00
|
|
|
struct tty_term *term = tty->term;
|
2021-10-05 12:46:02 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
int changed;
|
2011-05-20 19:03:58 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
if (tty->flags & TTY_NOCURSOR)
|
|
|
|
mode &= ~MODE_CURSOR;
|
|
|
|
|
2021-11-03 13:37:17 +00:00
|
|
|
if (tty_update_cursor(tty, mode, s) & MODE_CURSOR_BLINKING)
|
|
|
|
mode |= MODE_CURSOR_BLINKING;
|
|
|
|
else
|
|
|
|
mode &= ~MODE_CURSOR_BLINKING;
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
changed = mode ^ tty->mode;
|
2021-06-10 07:43:44 +00:00
|
|
|
if (log_get_level() != 0 && changed != 0) {
|
|
|
|
log_debug("%s: current mode %s", c->name,
|
|
|
|
screen_mode_to_string(tty->mode));
|
|
|
|
log_debug("%s: setting mode %s", c->name,
|
|
|
|
screen_mode_to_string(mode));
|
|
|
|
}
|
2020-03-16 10:49:06 +00:00
|
|
|
|
2021-11-03 13:37:17 +00:00
|
|
|
if ((changed & ALL_MOUSE_MODES) && tty_term_has(term, TTYC_KMOUS)) {
|
2020-11-09 10:54:28 +00:00
|
|
|
/*
|
2021-12-31 11:35:49 +00:00
|
|
|
* If the mouse modes have changed, clear then all and apply
|
|
|
|
* again. There are differences in how terminals track the
|
|
|
|
* various bits.
|
2020-11-09 10:54:28 +00:00
|
|
|
*/
|
2021-12-31 11:35:49 +00:00
|
|
|
tty_puts(tty, "\033[?1006l\033[?1000l\033[?1002l\033[?1003l");
|
2020-03-16 10:49:06 +00:00
|
|
|
if (mode & ALL_MOUSE_MODES)
|
|
|
|
tty_puts(tty, "\033[?1006h");
|
2020-11-09 10:54:28 +00:00
|
|
|
if (mode & MODE_MOUSE_ALL)
|
2021-12-31 11:35:49 +00:00
|
|
|
tty_puts(tty, "\033[?1000h\033[?1002h\033[?1003h");
|
|
|
|
if (mode & MODE_MOUSE_BUTTON)
|
|
|
|
tty_puts(tty, "\033[?1000h\033[?1002h");
|
|
|
|
else if (mode & MODE_MOUSE_STANDARD)
|
|
|
|
tty_puts(tty, "\033[?1000h");
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2012-03-03 09:43:22 +00:00
|
|
|
if (changed & MODE_BRACKETPASTE) {
|
|
|
|
if (mode & MODE_BRACKETPASTE)
|
2020-05-16 14:53:23 +00:00
|
|
|
tty_putcode(tty, TTYC_ENBP);
|
2012-03-03 09:43:22 +00:00
|
|
|
else
|
2020-05-16 14:53:23 +00:00
|
|
|
tty_putcode(tty, TTYC_DSBP);
|
2012-03-03 09:43:22 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
tty->mode = mode;
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2014-04-17 14:45:49 +00:00
|
|
|
tty_emulate_repeat(struct tty *tty, enum tty_code_code code,
|
|
|
|
enum tty_code_code code1, u_int n)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
if (tty_term_has(tty->term, code))
|
|
|
|
tty_putcode1(tty, code, n);
|
|
|
|
else {
|
|
|
|
while (n-- > 0)
|
|
|
|
tty_putcode(tty, code1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2012-05-22 09:09:16 +00:00
|
|
|
tty_repeat_space(struct tty *tty, u_int n)
|
|
|
|
{
|
2017-04-05 10:49:46 +00:00
|
|
|
static char s[500];
|
|
|
|
|
|
|
|
if (*s != ' ')
|
|
|
|
memset(s, ' ', sizeof s);
|
|
|
|
|
|
|
|
while (n > sizeof s) {
|
|
|
|
tty_putn(tty, s, sizeof s, sizeof s);
|
|
|
|
n -= sizeof s;
|
|
|
|
}
|
|
|
|
if (n != 0)
|
|
|
|
tty_putn(tty, s, n, n);
|
2012-05-22 09:09:16 +00:00
|
|
|
}
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Is this window bigger than the terminal? */
|
|
|
|
int
|
|
|
|
tty_window_bigger(struct tty *tty)
|
2018-08-18 16:14:03 +00:00
|
|
|
{
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
struct window *w = c->session->curw->window;
|
2018-08-18 16:14:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return (tty->sx < w->sx || tty->sy - status_line_size(c) < w->sy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* What offset should this window be drawn at? */
|
|
|
|
int
|
|
|
|
tty_window_offset(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
|
|
|
|
{
|
|
|
|
*ox = tty->oox;
|
|
|
|
*oy = tty->ooy;
|
|
|
|
*sx = tty->osx;
|
|
|
|
*sy = tty->osy;
|
|
|
|
|
|
|
|
return (tty->oflag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* What offset should this window be drawn at? */
|
|
|
|
static int
|
|
|
|
tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
|
|
|
|
{
|
|
|
|
struct client *c = tty->client;
|
|
|
|
struct window *w = c->session->curw->window;
|
2020-05-16 16:20:59 +00:00
|
|
|
struct window_pane *wp = server_client_get_pane(c);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
u_int cx, cy, lines;
|
|
|
|
|
|
|
|
lines = status_line_size(c);
|
|
|
|
|
|
|
|
if (tty->sx >= w->sx && tty->sy - lines >= w->sy) {
|
|
|
|
*ox = 0;
|
|
|
|
*oy = 0;
|
|
|
|
*sx = w->sx;
|
|
|
|
*sy = w->sy;
|
|
|
|
|
|
|
|
c->pan_window = NULL;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
*sx = tty->sx;
|
|
|
|
*sy = tty->sy - lines;
|
|
|
|
|
|
|
|
if (c->pan_window == w) {
|
|
|
|
if (*sx >= w->sx)
|
|
|
|
c->pan_ox = 0;
|
|
|
|
else if (c->pan_ox + *sx > w->sx)
|
|
|
|
c->pan_ox = w->sx - *sx;
|
|
|
|
*ox = c->pan_ox;
|
|
|
|
if (*sy >= w->sy)
|
|
|
|
c->pan_oy = 0;
|
|
|
|
else if (c->pan_oy + *sy > w->sy)
|
|
|
|
c->pan_oy = w->sy - *sy;
|
|
|
|
*oy = c->pan_oy;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (~wp->screen->mode & MODE_CURSOR) {
|
|
|
|
*ox = 0;
|
|
|
|
*oy = 0;
|
|
|
|
} else {
|
|
|
|
cx = wp->xoff + wp->screen->cx;
|
|
|
|
cy = wp->yoff + wp->screen->cy;
|
|
|
|
|
|
|
|
if (cx < *sx)
|
|
|
|
*ox = 0;
|
|
|
|
else if (cx > w->sx - *sx)
|
|
|
|
*ox = w->sx - *sx;
|
|
|
|
else
|
|
|
|
*ox = cx - *sx / 2;
|
|
|
|
|
|
|
|
if (cy < *sy)
|
|
|
|
*oy = 0;
|
|
|
|
else if (cy > w->sy - *sy)
|
|
|
|
*oy = w->sy - *sy;
|
|
|
|
else
|
|
|
|
*oy = cy - *sy / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->pan_window = NULL;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update stored offsets for a window and redraw if necessary. */
|
|
|
|
void
|
|
|
|
tty_update_window_offset(struct window *w)
|
|
|
|
{
|
|
|
|
struct client *c;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
2021-12-06 10:08:42 +00:00
|
|
|
if (c->session != NULL &&
|
|
|
|
c->session->curw != NULL &&
|
|
|
|
c->session->curw->window == w)
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_update_client_offset(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update stored offsets for a client and redraw if necessary. */
|
|
|
|
void
|
|
|
|
tty_update_client_offset(struct client *c)
|
|
|
|
{
|
|
|
|
u_int ox, oy, sx, sy;
|
|
|
|
|
2019-03-04 09:29:40 +00:00
|
|
|
if (~c->flags & CLIENT_TERMINAL)
|
|
|
|
return;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
c->tty.oflag = tty_window_offset1(&c->tty, &ox, &oy, &sx, &sy);
|
|
|
|
if (ox == c->tty.oox &&
|
|
|
|
oy == c->tty.ooy &&
|
|
|
|
sx == c->tty.osx &&
|
|
|
|
sy == c->tty.osy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
log_debug ("%s: %s offset has changed (%u,%u %ux%u -> %u,%u %ux%u)",
|
|
|
|
__func__, c->name, c->tty.oox, c->tty.ooy, c->tty.osx, c->tty.osy,
|
|
|
|
ox, oy, sx, sy);
|
|
|
|
|
|
|
|
c->tty.oox = ox;
|
|
|
|
c->tty.ooy = oy;
|
|
|
|
c->tty.osx = sx;
|
|
|
|
c->tty.osy = sy;
|
|
|
|
|
|
|
|
c->flags |= (CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS);
|
2018-08-18 16:14:03 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:10:33 +00:00
|
|
|
/*
|
|
|
|
* Is the region large enough to be worth redrawing once later rather than
|
|
|
|
* probably several times now? Currently yes if it is more than 50% of the
|
|
|
|
* pane.
|
|
|
|
*/
|
2016-10-10 21:29:23 +00:00
|
|
|
static int
|
2015-11-18 14:27:44 +00:00
|
|
|
tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
|
2012-03-15 09:10:33 +00:00
|
|
|
{
|
2020-05-16 15:27:08 +00:00
|
|
|
return (ctx->orlower - ctx->orupper >= ctx->sy / 2);
|
2012-03-15 09:10:33 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 21:05:27 +00:00
|
|
|
/*
|
|
|
|
* Return if BCE is needed but the terminal doesn't have it - it'll need to be
|
|
|
|
* emulated.
|
|
|
|
*/
|
2016-10-10 21:29:23 +00:00
|
|
|
static int
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(const struct tty *tty, const struct grid_cell *gc, u_int bg)
|
2015-04-19 21:05:27 +00:00
|
|
|
{
|
2016-10-13 20:27:27 +00:00
|
|
|
if (tty_term_flag(tty->term, TTYC_BCE))
|
|
|
|
return (0);
|
2020-05-16 15:34:08 +00:00
|
|
|
if (!COLOUR_DEFAULT(bg) || !COLOUR_DEFAULT(gc->bg))
|
2016-10-13 20:27:27 +00:00
|
|
|
return (1);
|
|
|
|
return (0);
|
2015-04-19 21:05:27 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/*
|
|
|
|
* Redraw scroll region using data from screen (already updated). Used when
|
|
|
|
* CSR not supported, or window is a pane that doesn't take up the full
|
|
|
|
* width of the terminal.
|
|
|
|
*/
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-04-18 07:32:53 +00:00
|
|
|
struct client *c = tty->client;
|
2016-07-15 00:49:08 +00:00
|
|
|
u_int i;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
/*
|
2020-05-16 15:34:08 +00:00
|
|
|
* If region is large, schedule a redraw. In most cases this is likely
|
|
|
|
* to be followed by some more scrolling.
|
2009-06-01 22:58:49 +00:00
|
|
|
*/
|
2012-03-15 09:10:33 +00:00
|
|
|
if (tty_large_region(tty, ctx)) {
|
2020-05-16 15:34:08 +00:00
|
|
|
log_debug("%s: %s large redraw", __func__, c->name);
|
|
|
|
ctx->redraw_cb(ctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-10 07:59:31 +00:00
|
|
|
for (i = ctx->orupper; i <= ctx->orlower; i++)
|
|
|
|
tty_draw_pane(tty, ctx, i);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Is this position visible in the pane? */
|
|
|
|
static int
|
2020-05-16 15:36:57 +00:00
|
|
|
tty_is_visible(__unused struct tty *tty, const struct tty_ctx *ctx, u_int px,
|
|
|
|
u_int py, u_int nx, u_int ny)
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
{
|
2020-05-16 15:36:57 +00:00
|
|
|
u_int xoff = ctx->rxoff + px, yoff = ctx->ryoff + py;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
if (!ctx->bigger)
|
|
|
|
return (1);
|
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
if (xoff + nx <= ctx->wox || xoff >= ctx->wox + ctx->wsx ||
|
2020-05-16 15:36:57 +00:00
|
|
|
yoff + ny <= ctx->woy || yoff >= ctx->woy + ctx->wsy)
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return (0);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clamp line position to visible part of pane. */
|
|
|
|
static int
|
|
|
|
tty_clamp_line(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
|
|
|
|
u_int nx, u_int *i, u_int *x, u_int *rx, u_int *ry)
|
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int xoff = ctx->rxoff + px;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
if (!tty_is_visible(tty, ctx, px, py, nx, 1))
|
|
|
|
return (0);
|
2020-05-16 15:27:08 +00:00
|
|
|
*ry = ctx->yoff + py - ctx->woy;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
if (xoff >= ctx->wox && xoff + nx <= ctx->wox + ctx->wsx) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* All visible. */
|
|
|
|
*i = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*x = ctx->xoff + px - ctx->wox;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*rx = nx;
|
2020-05-16 15:27:08 +00:00
|
|
|
} else if (xoff < ctx->wox && xoff + nx > ctx->wox + ctx->wsx) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Both left and right not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*i = ctx->wox;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*x = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*rx = ctx->wsx;
|
|
|
|
} else if (xoff < ctx->wox) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Left not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*i = ctx->wox - (ctx->xoff + px);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*x = 0;
|
|
|
|
*rx = nx - *i;
|
|
|
|
} else {
|
|
|
|
/* Right not visible. */
|
|
|
|
*i = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*x = (ctx->xoff + px) - ctx->wox;
|
|
|
|
*rx = ctx->wsx - *x;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
}
|
|
|
|
if (*rx > nx)
|
|
|
|
fatalx("%s: x too big, %u > %u", __func__, *rx, nx);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear a line. */
|
2017-05-10 16:47:03 +00:00
|
|
|
static void
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_line(struct tty *tty, const struct grid_cell *defaults, u_int py,
|
|
|
|
u_int px, u_int nx, u_int bg)
|
2017-05-10 16:47:03 +00:00
|
|
|
{
|
2021-10-11 13:27:50 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
struct overlay_ranges r;
|
|
|
|
u_int i;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
log_debug("%s: %s, %u at %u,%u", __func__, c->name, nx, px, py);
|
2017-05-10 16:47:03 +00:00
|
|
|
|
|
|
|
/* Nothing to clear. */
|
|
|
|
if (nx == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If genuine BCE is available, can try escape sequences. */
|
2021-08-05 09:43:51 +00:00
|
|
|
if (c->overlay_check == NULL && !tty_fake_bce(tty, defaults, bg)) {
|
2017-05-10 16:47:03 +00:00
|
|
|
/* Off the end of the line, use EL if available. */
|
|
|
|
if (px + nx >= tty->sx && tty_term_has(tty->term, TTYC_EL)) {
|
|
|
|
tty_cursor(tty, px, py);
|
|
|
|
tty_putcode(tty, TTYC_EL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At the start of the line. Use EL1. */
|
|
|
|
if (px == 0 && tty_term_has(tty->term, TTYC_EL1)) {
|
|
|
|
tty_cursor(tty, px + nx - 1, py);
|
|
|
|
tty_putcode(tty, TTYC_EL1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Section of line. Use ECH if possible. */
|
|
|
|
if (tty_term_has(tty->term, TTYC_ECH)) {
|
|
|
|
tty_cursor(tty, px, py);
|
|
|
|
tty_putcode1(tty, TTYC_ECH, nx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 09:43:51 +00:00
|
|
|
/*
|
|
|
|
* Couldn't use an escape sequence, use spaces. Clear only the visible
|
|
|
|
* bit if there is an overlay.
|
|
|
|
*/
|
2021-10-11 13:27:50 +00:00
|
|
|
tty_check_overlay_range(tty, px, py, nx, &r);
|
|
|
|
for (i = 0; i < OVERLAY_MAX_RANGES; i++) {
|
|
|
|
if (r.nx[i] == 0)
|
|
|
|
continue;
|
|
|
|
tty_cursor(tty, r.px[i], py);
|
|
|
|
tty_repeat_space(tty, r.nx[i]);
|
2021-08-05 09:43:51 +00:00
|
|
|
}
|
2017-05-10 16:47:03 +00:00
|
|
|
}
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Clear a line, adjusting to visible part of pane. */
|
|
|
|
static void
|
|
|
|
tty_clear_pane_line(struct tty *tty, const struct tty_ctx *ctx, u_int py,
|
|
|
|
u_int px, u_int nx, u_int bg)
|
|
|
|
{
|
|
|
|
struct client *c = tty->client;
|
|
|
|
u_int i, x, rx, ry;
|
|
|
|
|
|
|
|
log_debug("%s: %s, %u at %u,%u", __func__, c->name, nx, px, py);
|
|
|
|
|
|
|
|
if (tty_clamp_line(tty, ctx, px, py, nx, &i, &x, &rx, &ry))
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_line(tty, &ctx->defaults, ry, x, rx, bg);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clamp area position to visible part of pane. */
|
|
|
|
static int
|
|
|
|
tty_clamp_area(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
|
|
|
|
u_int nx, u_int ny, u_int *i, u_int *j, u_int *x, u_int *y, u_int *rx,
|
|
|
|
u_int *ry)
|
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int xoff = ctx->rxoff + px, yoff = ctx->ryoff + py;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
if (!tty_is_visible(tty, ctx, px, py, nx, ny))
|
|
|
|
return (0);
|
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
if (xoff >= ctx->wox && xoff + nx <= ctx->wox + ctx->wsx) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* All visible. */
|
|
|
|
*i = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*x = ctx->xoff + px - ctx->wox;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*rx = nx;
|
2020-05-16 15:27:08 +00:00
|
|
|
} else if (xoff < ctx->wox && xoff + nx > ctx->wox + ctx->wsx) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Both left and right not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*i = ctx->wox;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*x = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*rx = ctx->wsx;
|
|
|
|
} else if (xoff < ctx->wox) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Left not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*i = ctx->wox - (ctx->xoff + px);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*x = 0;
|
|
|
|
*rx = nx - *i;
|
|
|
|
} else {
|
|
|
|
/* Right not visible. */
|
|
|
|
*i = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*x = (ctx->xoff + px) - ctx->wox;
|
|
|
|
*rx = ctx->wsx - *x;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
}
|
|
|
|
if (*rx > nx)
|
|
|
|
fatalx("%s: x too big, %u > %u", __func__, *rx, nx);
|
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
if (yoff >= ctx->woy && yoff + ny <= ctx->woy + ctx->wsy) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* All visible. */
|
|
|
|
*j = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*y = ctx->yoff + py - ctx->woy;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*ry = ny;
|
2020-05-16 15:27:08 +00:00
|
|
|
} else if (yoff < ctx->woy && yoff + ny > ctx->woy + ctx->wsy) {
|
2019-06-26 13:05:06 +00:00
|
|
|
/* Both top and bottom not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*j = ctx->woy;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*y = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*ry = ctx->wsy;
|
|
|
|
} else if (yoff < ctx->woy) {
|
2019-06-26 13:05:06 +00:00
|
|
|
/* Top not visible. */
|
2020-05-16 15:27:08 +00:00
|
|
|
*j = ctx->woy - (ctx->yoff + py);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*y = 0;
|
|
|
|
*ry = ny - *j;
|
|
|
|
} else {
|
2019-06-26 13:05:06 +00:00
|
|
|
/* Bottom not visible. */
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
*j = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
*y = (ctx->yoff + py) - ctx->woy;
|
|
|
|
*ry = ctx->wsy - *y;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
}
|
|
|
|
if (*ry > ny)
|
|
|
|
fatalx("%s: y too big, %u > %u", __func__, *ry, ny);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear an area, adjusting to visible part of pane. */
|
2017-05-10 16:47:03 +00:00
|
|
|
static void
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_area(struct tty *tty, const struct grid_cell *defaults, u_int py,
|
|
|
|
u_int ny, u_int px, u_int nx, u_int bg)
|
2017-05-10 16:47:03 +00:00
|
|
|
{
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
u_int yy;
|
|
|
|
char tmp[64];
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
log_debug("%s: %s, %u,%u at %u,%u", __func__, c->name, nx, ny, px, py);
|
2017-05-10 16:47:03 +00:00
|
|
|
|
|
|
|
/* Nothing to clear. */
|
|
|
|
if (nx == 0 || ny == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If genuine BCE is available, can try escape sequences. */
|
2021-08-05 09:43:51 +00:00
|
|
|
if (c->overlay_check == NULL && !tty_fake_bce(tty, defaults, bg)) {
|
2017-05-12 11:13:43 +00:00
|
|
|
/* Use ED if clearing off the bottom of the terminal. */
|
2017-05-10 16:47:03 +00:00
|
|
|
if (px == 0 &&
|
|
|
|
px + nx >= tty->sx &&
|
|
|
|
py + ny >= tty->sy &&
|
|
|
|
tty_term_has(tty->term, TTYC_ED)) {
|
|
|
|
tty_cursor(tty, 0, py);
|
|
|
|
tty_putcode(tty, TTYC_ED);
|
|
|
|
return;
|
|
|
|
}
|
2017-05-12 10:50:11 +00:00
|
|
|
|
|
|
|
/*
|
2017-05-12 11:13:43 +00:00
|
|
|
* On VT420 compatible terminals we can use DECFRA if the
|
|
|
|
* background colour isn't default (because it doesn't work
|
|
|
|
* after SGR 0).
|
2017-05-12 10:50:11 +00:00
|
|
|
*/
|
2020-04-20 13:25:36 +00:00
|
|
|
if ((tty->term->flags & TERM_DECFRA) && !COLOUR_DEFAULT(bg)) {
|
2017-05-12 10:50:11 +00:00
|
|
|
xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",
|
|
|
|
py + 1, px + 1, py + ny, px + nx);
|
|
|
|
tty_puts(tty, tmp);
|
|
|
|
return;
|
|
|
|
}
|
2017-05-12 11:13:43 +00:00
|
|
|
|
2017-05-12 23:06:43 +00:00
|
|
|
/* Full lines can be scrolled away to clear them. */
|
|
|
|
if (px == 0 &&
|
2017-05-12 23:10:19 +00:00
|
|
|
px + nx >= tty->sx &&
|
2017-05-12 23:06:43 +00:00
|
|
|
ny > 2 &&
|
|
|
|
tty_term_has(tty->term, TTYC_CSR) &&
|
|
|
|
tty_term_has(tty->term, TTYC_INDN)) {
|
|
|
|
tty_region(tty, py, py + ny - 1);
|
|
|
|
tty_margin_off(tty);
|
2017-05-15 07:54:44 +00:00
|
|
|
tty_putcode1(tty, TTYC_INDN, ny);
|
2017-05-12 23:06:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-12 11:13:43 +00:00
|
|
|
/*
|
|
|
|
* If margins are supported, can just scroll the area off to
|
|
|
|
* clear it.
|
|
|
|
*/
|
2017-05-12 11:19:24 +00:00
|
|
|
if (nx > 2 &&
|
|
|
|
ny > 2 &&
|
2017-05-12 23:06:43 +00:00
|
|
|
tty_term_has(tty->term, TTYC_CSR) &&
|
2017-05-12 11:19:24 +00:00
|
|
|
tty_use_margin(tty) &&
|
|
|
|
tty_term_has(tty->term, TTYC_INDN)) {
|
2017-05-12 11:13:43 +00:00
|
|
|
tty_region(tty, py, py + ny - 1);
|
|
|
|
tty_margin(tty, px, px + nx - 1);
|
2017-05-15 07:54:44 +00:00
|
|
|
tty_putcode1(tty, TTYC_INDN, ny);
|
2017-05-12 11:13:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-10 16:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Couldn't use an escape sequence, loop over the lines. */
|
|
|
|
for (yy = py; yy < py + ny; yy++)
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_line(tty, defaults, yy, px, nx, bg);
|
2017-05-10 16:47:03 +00:00
|
|
|
}
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
/* Clear an area in a pane. */
|
|
|
|
static void
|
|
|
|
tty_clear_pane_area(struct tty *tty, const struct tty_ctx *ctx, u_int py,
|
|
|
|
u_int ny, u_int px, u_int nx, u_int bg)
|
2015-04-19 21:05:27 +00:00
|
|
|
{
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
u_int i, j, x, y, rx, ry;
|
|
|
|
|
|
|
|
if (tty_clamp_area(tty, ctx, px, py, nx, ny, &i, &j, &x, &y, &rx, &ry))
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_area(tty, &ctx->defaults, y, ry, x, rx, bg);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tty_draw_pane(struct tty *tty, const struct tty_ctx *ctx, u_int py)
|
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
struct screen *s = ctx->s;
|
|
|
|
u_int nx = ctx->sx, i, x, rx, ry;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
log_debug("%s: %s %u %d", __func__, tty->client->name, py, ctx->bigger);
|
|
|
|
|
|
|
|
if (!ctx->bigger) {
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_draw_line(tty, s, 0, py, nx, ctx->xoff, ctx->yoff + py,
|
|
|
|
&ctx->defaults, ctx->palette);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-16 15:34:08 +00:00
|
|
|
if (tty_clamp_line(tty, ctx, 0, py, nx, &i, &x, &rx, &ry)) {
|
|
|
|
tty_draw_line(tty, s, i, py, rx, x, ry, &ctx->defaults,
|
|
|
|
ctx->palette);
|
|
|
|
}
|
2015-04-19 21:05:27 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 16:41:00 +00:00
|
|
|
static const struct grid_cell *
|
|
|
|
tty_check_codeset(struct tty *tty, const struct grid_cell *gc)
|
|
|
|
{
|
|
|
|
static struct grid_cell new;
|
2020-05-16 16:26:34 +00:00
|
|
|
int c;
|
2018-01-12 16:41:00 +00:00
|
|
|
|
|
|
|
/* Characters less than 0x7f are always fine, no matter what. */
|
|
|
|
if (gc->data.size == 1 && *gc->data.data < 0x7f)
|
|
|
|
return (gc);
|
|
|
|
|
|
|
|
/* UTF-8 terminal and a UTF-8 character - fine. */
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->client->flags & CLIENT_UTF8)
|
2018-01-12 16:41:00 +00:00
|
|
|
return (gc);
|
2020-05-16 16:26:34 +00:00
|
|
|
memcpy(&new, gc, sizeof new);
|
|
|
|
|
|
|
|
/* See if this can be mapped to an ACS character. */
|
|
|
|
c = tty_acs_reverse_get(tty, gc->data.data, gc->data.size);
|
|
|
|
if (c != -1) {
|
|
|
|
utf8_set(&new.data, c);
|
|
|
|
new.attr |= GRID_ATTR_CHARSET;
|
|
|
|
return (&new);
|
|
|
|
}
|
2018-01-12 16:41:00 +00:00
|
|
|
|
|
|
|
/* Replace by the right number of underscores. */
|
2020-05-16 16:26:34 +00:00
|
|
|
new.data.size = gc->data.width;
|
|
|
|
if (new.data.size > UTF8_SIZE)
|
|
|
|
new.data.size = UTF8_SIZE;
|
|
|
|
memset(new.data.data, '_', new.data.size);
|
2018-01-12 16:41:00 +00:00
|
|
|
return (&new);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:27:50 +00:00
|
|
|
/*
|
|
|
|
* Check if a single character is obstructed by the overlay and return a
|
|
|
|
* boolean.
|
|
|
|
*/
|
2020-03-24 08:09:43 +00:00
|
|
|
static int
|
|
|
|
tty_check_overlay(struct tty *tty, u_int px, u_int py)
|
2021-10-11 13:27:50 +00:00
|
|
|
{
|
|
|
|
struct overlay_ranges r;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A unit width range will always return nx[2] == 0 from a check, even
|
|
|
|
* with multiple overlays, so it's sufficient to check just the first
|
|
|
|
* two entries.
|
|
|
|
*/
|
|
|
|
tty_check_overlay_range(tty, px, py, 1, &r);
|
|
|
|
if (r.nx[0] + r.nx[1] == 0)
|
|
|
|
return (0);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return parts of the input range which are visible. */
|
|
|
|
static void
|
|
|
|
tty_check_overlay_range(struct tty *tty, u_int px, u_int py, u_int nx,
|
|
|
|
struct overlay_ranges *r)
|
2020-03-24 08:09:43 +00:00
|
|
|
{
|
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2021-10-11 13:27:50 +00:00
|
|
|
if (c->overlay_check == NULL) {
|
|
|
|
r->px[0] = px;
|
|
|
|
r->nx[0] = nx;
|
|
|
|
r->px[1] = 0;
|
|
|
|
r->nx[1] = 0;
|
|
|
|
r->px[2] = 0;
|
|
|
|
r->nx[2] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->overlay_check(c, c->overlay_data, px, py, nx, r);
|
2020-03-24 08:09:43 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 21:05:27 +00:00
|
|
|
void
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
2021-08-11 20:49:55 +00:00
|
|
|
u_int atx, u_int aty, const struct grid_cell *defaults,
|
|
|
|
struct colour_palette *palette)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2017-11-15 19:18:57 +00:00
|
|
|
struct grid *gd = s->grid;
|
2017-02-21 16:25:04 +00:00
|
|
|
struct grid_cell gc, last;
|
2018-01-12 16:41:00 +00:00
|
|
|
const struct grid_cell *gcp;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
struct grid_line *gl;
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
2021-10-11 13:27:50 +00:00
|
|
|
struct overlay_ranges r;
|
|
|
|
u_int i, j, ux, sx, width, hidden, eux, nxx;
|
|
|
|
u_int cellsize;
|
2021-08-06 03:29:15 +00:00
|
|
|
int flags, cleared = 0, wrapped = 0;
|
2017-02-21 16:25:04 +00:00
|
|
|
char buf[512];
|
2019-03-12 23:21:45 +00:00
|
|
|
size_t len;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__,
|
|
|
|
px, py, nx, atx, aty);
|
2021-08-11 20:49:55 +00:00
|
|
|
log_debug("%s: defaults: fg=%d, bg=%d", __func__, defaults->fg,
|
|
|
|
defaults->bg);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* py is the line in the screen to draw.
|
|
|
|
* px is the start x and nx is the width to draw.
|
|
|
|
* atx,aty is the line on the terminal to draw it.
|
|
|
|
*/
|
|
|
|
|
2017-04-16 20:32:14 +00:00
|
|
|
flags = (tty->flags & TTY_NOCURSOR);
|
2015-05-06 07:52:06 +00:00
|
|
|
tty->flags |= TTY_NOCURSOR;
|
|
|
|
tty_update_mode(tty, tty->mode, s);
|
2009-10-09 07:23:28 +00:00
|
|
|
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_region_off(tty);
|
|
|
|
tty_margin_off(tty);
|
|
|
|
|
2017-05-11 11:38:49 +00:00
|
|
|
/*
|
|
|
|
* Clamp the width to cellsize - note this is not cellused, because
|
|
|
|
* there may be empty background cells after it (from BCE).
|
|
|
|
*/
|
2009-06-01 22:58:49 +00:00
|
|
|
sx = screen_size_x(s);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (nx > sx)
|
|
|
|
nx = sx;
|
2018-07-04 09:44:07 +00:00
|
|
|
cellsize = grid_get_line(gd, gd->hsize + py)->cellsize;
|
|
|
|
if (sx > cellsize)
|
|
|
|
sx = cellsize;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (sx > tty->sx)
|
|
|
|
sx = tty->sx;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (sx > nx)
|
|
|
|
sx = nx;
|
2017-07-21 22:55:45 +00:00
|
|
|
ux = 0;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (py == 0)
|
|
|
|
gl = NULL;
|
|
|
|
else
|
|
|
|
gl = grid_get_line(gd, gd->hsize + py - 1);
|
2020-05-16 15:34:08 +00:00
|
|
|
if (gl == NULL ||
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
(~gl->flags & GRID_LINE_WRAPPED) ||
|
|
|
|
atx != 0 ||
|
2017-04-25 18:30:29 +00:00
|
|
|
tty->cx < tty->sx ||
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
nx < tty->sx) {
|
|
|
|
if (nx < tty->sx &&
|
|
|
|
atx == 0 &&
|
|
|
|
px + sx != nx &&
|
2017-04-25 18:30:29 +00:00
|
|
|
tty_term_has(tty->term, TTYC_EL1) &&
|
2021-08-05 09:43:51 +00:00
|
|
|
!tty_fake_bce(tty, defaults, 8) &&
|
|
|
|
c->overlay_check == NULL) {
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, defaults, palette, 8);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_cursor(tty, nx - 1, aty);
|
2017-04-25 18:30:29 +00:00
|
|
|
tty_putcode(tty, TTYC_EL1);
|
|
|
|
cleared = 1;
|
|
|
|
}
|
2019-07-16 14:11:52 +00:00
|
|
|
} else {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
log_debug("%s: wrapped line %u", __func__, aty);
|
2019-07-16 14:11:52 +00:00
|
|
|
wrapped = 1;
|
|
|
|
}
|
2017-02-21 16:25:04 +00:00
|
|
|
|
|
|
|
memcpy(&last, &grid_default_cell, sizeof last);
|
|
|
|
len = 0;
|
|
|
|
width = 0;
|
2009-10-12 17:19:47 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
for (i = 0; i < sx; i++) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
grid_view_get_cell(gd, px + i, py, &gc);
|
2018-01-12 16:41:00 +00:00
|
|
|
gcp = tty_check_codeset(tty, &gc);
|
2017-02-21 16:25:04 +00:00
|
|
|
if (len != 0 &&
|
2020-03-24 08:09:43 +00:00
|
|
|
(!tty_check_overlay(tty, atx + ux + width, aty) ||
|
|
|
|
(gcp->attr & GRID_ATTR_CHARSET) ||
|
2018-01-12 16:41:00 +00:00
|
|
|
gcp->flags != last.flags ||
|
|
|
|
gcp->attr != last.attr ||
|
|
|
|
gcp->fg != last.fg ||
|
|
|
|
gcp->bg != last.bg ||
|
2019-06-27 15:17:41 +00:00
|
|
|
gcp->us != last.us ||
|
2019-03-12 23:21:45 +00:00
|
|
|
ux + width + gcp->data.width > nx ||
|
2018-01-12 16:41:00 +00:00
|
|
|
(sizeof buf) - len < gcp->data.size)) {
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, &last, defaults, palette);
|
2019-03-12 23:21:45 +00:00
|
|
|
if (last.flags & GRID_FLAG_CLEARED) {
|
|
|
|
log_debug("%s: %zu cleared", __func__, len);
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_line(tty, defaults, aty, atx + ux,
|
|
|
|
width, last.bg);
|
2019-03-12 23:21:45 +00:00
|
|
|
} else {
|
2019-07-16 14:11:52 +00:00
|
|
|
if (!wrapped || atx != 0 || ux != 0)
|
|
|
|
tty_cursor(tty, atx + ux, aty);
|
2019-03-12 23:21:45 +00:00
|
|
|
tty_putn(tty, buf, len, width);
|
|
|
|
}
|
2017-07-21 22:55:45 +00:00
|
|
|
ux += width;
|
2017-02-21 16:25:04 +00:00
|
|
|
|
|
|
|
len = 0;
|
|
|
|
width = 0;
|
2019-07-16 14:11:52 +00:00
|
|
|
wrapped = 0;
|
2017-02-21 16:25:04 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 16:41:00 +00:00
|
|
|
if (gcp->flags & GRID_FLAG_SELECTED)
|
2018-01-16 17:03:18 +00:00
|
|
|
screen_select_cell(s, &last, gcp);
|
2017-02-21 16:25:04 +00:00
|
|
|
else
|
2018-01-16 17:03:18 +00:00
|
|
|
memcpy(&last, gcp, sizeof last);
|
2021-08-06 03:13:05 +00:00
|
|
|
|
2021-10-11 13:27:50 +00:00
|
|
|
tty_check_overlay_range(tty, atx + ux, aty, gcp->data.width,
|
|
|
|
&r);
|
2021-08-06 03:13:05 +00:00
|
|
|
hidden = 0;
|
2021-10-11 13:27:50 +00:00
|
|
|
for (j = 0; j < OVERLAY_MAX_RANGES; j++)
|
|
|
|
hidden += r.nx[j];
|
|
|
|
hidden = gcp->data.width - hidden;
|
2021-08-06 03:29:15 +00:00
|
|
|
if (hidden != 0 && hidden == gcp->data.width) {
|
|
|
|
if (~gcp->flags & GRID_FLAG_PADDING)
|
|
|
|
ux += gcp->data.width;
|
|
|
|
} else if (hidden != 0 || ux + gcp->data.width > nx) {
|
2021-08-06 03:13:05 +00:00
|
|
|
if (~gcp->flags & GRID_FLAG_PADDING) {
|
|
|
|
tty_attributes(tty, &last, defaults, palette);
|
2021-10-11 13:27:50 +00:00
|
|
|
for (j = 0; j < OVERLAY_MAX_RANGES; j++) {
|
|
|
|
if (r.nx[j] == 0)
|
|
|
|
continue;
|
|
|
|
/* Effective width drawn so far. */
|
|
|
|
eux = r.px[j] - atx;
|
|
|
|
if (eux < nx) {
|
|
|
|
tty_cursor(tty, r.px[j], aty);
|
|
|
|
nxx = nx - eux;
|
|
|
|
if (r.nx[j] > nxx)
|
|
|
|
r.nx[j] = nxx;
|
|
|
|
tty_repeat_space(tty, r.nx[j]);
|
|
|
|
ux = eux + r.nx[j];
|
2021-08-06 07:32:21 +00:00
|
|
|
}
|
2021-08-06 03:13:05 +00:00
|
|
|
}
|
2017-11-15 19:18:57 +00:00
|
|
|
}
|
2018-01-16 17:03:18 +00:00
|
|
|
} else if (gcp->attr & GRID_ATTR_CHARSET) {
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, &last, defaults, palette);
|
2019-03-12 23:21:45 +00:00
|
|
|
tty_cursor(tty, atx + ux, aty);
|
2018-01-16 17:03:18 +00:00
|
|
|
for (j = 0; j < gcp->data.size; j++)
|
|
|
|
tty_putc(tty, gcp->data.data[j]);
|
2020-03-24 08:09:43 +00:00
|
|
|
ux += gcp->data.width;
|
2020-06-02 20:51:46 +00:00
|
|
|
} else if (~gcp->flags & GRID_FLAG_PADDING) {
|
2018-01-12 16:41:00 +00:00
|
|
|
memcpy(buf + len, gcp->data.data, gcp->data.size);
|
|
|
|
len += gcp->data.size;
|
|
|
|
width += gcp->data.width;
|
2017-02-21 16:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-12 23:21:45 +00:00
|
|
|
if (len != 0 && ((~last.flags & GRID_FLAG_CLEARED) || last.bg != 8)) {
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, &last, defaults, palette);
|
2019-03-12 23:21:45 +00:00
|
|
|
if (last.flags & GRID_FLAG_CLEARED) {
|
|
|
|
log_debug("%s: %zu cleared (end)", __func__, len);
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_clear_line(tty, defaults, aty, atx + ux, width,
|
|
|
|
last.bg);
|
2019-03-12 23:21:45 +00:00
|
|
|
} else {
|
2019-07-16 14:11:52 +00:00
|
|
|
if (!wrapped || atx != 0 || ux != 0)
|
|
|
|
tty_cursor(tty, atx + ux, aty);
|
2017-07-21 14:25:29 +00:00
|
|
|
tty_putn(tty, buf, len, width);
|
|
|
|
}
|
2019-03-12 23:21:45 +00:00
|
|
|
ux += width;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (!cleared && ux < nx) {
|
2019-03-12 23:21:45 +00:00
|
|
|
log_debug("%s: %u to end of line (%zu cleared)", __func__,
|
|
|
|
nx - ux, len);
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, defaults, palette, 8);
|
|
|
|
tty_clear_line(tty, defaults, aty, atx + ux, nx - ux, 8);
|
2009-10-09 07:23:28 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2015-05-06 07:52:06 +00:00
|
|
|
tty->flags = (tty->flags & ~TTY_NOCURSOR) | flags;
|
2011-05-20 19:03:58 +00:00
|
|
|
tty_update_mode(tty, tty->mode, s);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 13:35:24 +00:00
|
|
|
void
|
|
|
|
tty_sync_start(struct tty *tty)
|
|
|
|
{
|
2020-04-20 14:59:31 +00:00
|
|
|
if (tty->flags & TTY_BLOCK)
|
|
|
|
return;
|
|
|
|
if (tty->flags & TTY_SYNCING)
|
|
|
|
return;
|
|
|
|
tty->flags |= TTY_SYNCING;
|
|
|
|
|
|
|
|
if (tty_term_has(tty->term, TTYC_SYNC)) {
|
|
|
|
log_debug("%s sync start", tty->client->name);
|
2020-04-20 13:38:48 +00:00
|
|
|
tty_putcode1(tty, TTYC_SYNC, 1);
|
2020-04-18 06:20:50 +00:00
|
|
|
}
|
2020-04-16 13:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_sync_end(struct tty *tty)
|
|
|
|
{
|
2020-04-20 14:59:31 +00:00
|
|
|
if (tty->flags & TTY_BLOCK)
|
|
|
|
return;
|
|
|
|
if (~tty->flags & TTY_SYNCING)
|
|
|
|
return;
|
|
|
|
tty->flags &= ~TTY_SYNCING;
|
|
|
|
|
|
|
|
if (tty_term_has(tty->term, TTYC_SYNC)) {
|
|
|
|
log_debug("%s sync end", tty->client->name);
|
2020-04-20 13:38:48 +00:00
|
|
|
tty_putcode1(tty, TTYC_SYNC, 2);
|
2020-04-18 06:20:50 +00:00
|
|
|
}
|
2020-04-16 13:35:24 +00:00
|
|
|
}
|
|
|
|
|
2016-04-30 18:59:02 +00:00
|
|
|
static int
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_client_ready(struct client *c)
|
2015-05-12 22:40:38 +00:00
|
|
|
{
|
|
|
|
if (c->session == NULL || c->tty.term == NULL)
|
|
|
|
return (0);
|
2018-08-19 16:45:03 +00:00
|
|
|
if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_SUSPENDED))
|
2015-05-12 22:40:38 +00:00
|
|
|
return (0);
|
|
|
|
if (c->tty.flags & TTY_FREEZE)
|
|
|
|
return (0);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2009-07-22 20:56:58 +00:00
|
|
|
void
|
2015-05-12 22:40:38 +00:00
|
|
|
tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
|
|
|
|
struct tty_ctx *ctx)
|
2009-07-22 20:56:58 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
struct client *c;
|
|
|
|
int state;
|
2009-07-22 20:56:58 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
if (ctx->set_client_cb == NULL)
|
2009-07-22 20:56:58 +00:00
|
|
|
return;
|
2015-04-24 23:17:11 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
2020-05-16 15:34:08 +00:00
|
|
|
if (!tty_client_ready(c))
|
2009-07-22 20:56:58 +00:00
|
|
|
continue;
|
2020-05-16 15:34:08 +00:00
|
|
|
state = ctx->set_client_cb(ctx, c);
|
|
|
|
if (state == -1)
|
2020-04-18 07:32:53 +00:00
|
|
|
break;
|
2020-05-16 15:34:08 +00:00
|
|
|
if (state == 0)
|
|
|
|
continue;
|
2012-08-14 08:58:25 +00:00
|
|
|
cmdfn(&c->tty, ctx);
|
2009-07-22 20:56:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, ctx->bg) ||
|
2016-10-13 20:27:27 +00:00
|
|
|
(!tty_term_has(tty->term, TTYC_ICH) &&
|
2021-08-05 09:43:51 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_ICH1)) ||
|
|
|
|
c->overlay_check != NULL) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_draw_pane(tty, ctx, ctx->ocy);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-10-12 09:29:58 +00:00
|
|
|
|
2016-10-03 19:19:18 +00:00
|
|
|
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, ctx->bg) ||
|
2009-08-21 12:29:59 +00:00
|
|
|
(!tty_term_has(tty->term, TTYC_DCH) &&
|
2021-08-05 09:43:51 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_DCH1)) ||
|
|
|
|
c->overlay_check != NULL) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_draw_pane(tty, ctx, ctx->ocy);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-10-12 09:29:58 +00:00
|
|
|
|
2016-10-03 19:19:18 +00:00
|
|
|
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 23:18:55 +00:00
|
|
|
void
|
|
|
|
tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2013-01-15 23:18:55 +00:00
|
|
|
|
2021-01-18 10:27:54 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, ctx->ocy, ctx->ocx, ctx->num, ctx->bg);
|
2013-01-15 23:18:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, ctx->bg) ||
|
2009-12-03 22:50:09 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
2018-09-25 14:27:20 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_IL1) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-07-22 16:45:31 +00:00
|
|
|
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
|
2017-05-12 14:13:54 +00:00
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, ctx->bg) ||
|
2009-11-26 14:46:08 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
2018-09-25 14:27:20 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_DL1) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-07-22 16:45:31 +00:00
|
|
|
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
|
2017-05-12 14:13:54 +00:00
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, ctx->ocy, 0, ctx->sx, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int nx = ctx->sx - ctx->ocx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, ctx->ocy, ctx->ocx, nx, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2016-10-13 20:27:27 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, ctx->ocy, 0, ctx->ocx + 1, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2009-10-21 13:42:44 +00:00
|
|
|
if (ctx->ocy != ctx->orupper)
|
|
|
|
return;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
(!tty_full_width(tty, ctx) && !tty_use_margin(tty)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, 8) ||
|
2009-11-12 08:05:23 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
2019-08-05 06:42:02 +00:00
|
|
|
(!tty_term_has(tty->term, TTYC_RI) &&
|
|
|
|
!tty_term_has(tty->term, TTYC_RIN)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2009-10-21 13:42:44 +00:00
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
2019-08-05 06:42:02 +00:00
|
|
|
tty_margin_pane(tty, ctx);
|
2009-10-21 13:42:44 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2019-08-05 06:42:02 +00:00
|
|
|
if (tty_term_has(tty->term, TTYC_RI))
|
|
|
|
tty_putcode(tty, TTYC_RI);
|
|
|
|
else
|
|
|
|
tty_putcode1(tty, TTYC_RIN, 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
2009-10-21 13:42:44 +00:00
|
|
|
if (ctx->ocy != ctx->orlower)
|
|
|
|
return;
|
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
(!tty_full_width(tty, ctx) && !tty_use_margin(tty)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, 8) ||
|
2018-09-25 14:27:20 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2017-02-08 15:24:48 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2009-10-21 13:42:44 +00:00
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
2016-11-15 14:02:32 +00:00
|
|
|
tty_margin_pane(tty, ctx);
|
|
|
|
|
|
|
|
/*
|
2018-04-23 07:41:30 +00:00
|
|
|
* If we want to wrap a pane while using margins, the cursor needs to
|
|
|
|
* be exactly on the right of the region. If the cursor is entirely off
|
|
|
|
* the edge - move it back to the right. Some terminals are funny about
|
|
|
|
* this and insert extra spaces, so only use the right if margins are
|
|
|
|
* enabled.
|
2016-11-15 14:02:32 +00:00
|
|
|
*/
|
2018-04-23 07:41:30 +00:00
|
|
|
if (ctx->xoff + ctx->ocx > tty->rright) {
|
|
|
|
if (!tty_use_margin(tty))
|
|
|
|
tty_cursor(tty, 0, ctx->yoff + ctx->ocy);
|
|
|
|
else
|
|
|
|
tty_cursor(tty, tty->rright, ctx->yoff + ctx->ocy);
|
|
|
|
} else
|
2016-11-15 14:02:32 +00:00
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2009-10-21 13:42:44 +00:00
|
|
|
tty_putc(tty, '\n');
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 17:31:09 +00:00
|
|
|
void
|
|
|
|
tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
u_int i;
|
2017-02-08 17:31:09 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
(!tty_full_width(tty, ctx) && !tty_use_margin(tty)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, 8) ||
|
2018-09-25 14:27:20 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2017-02-08 17:31:09 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2017-02-08 17:31:09 +00:00
|
|
|
|
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
|
|
|
tty_margin_pane(tty, ctx);
|
|
|
|
|
2017-05-15 07:54:44 +00:00
|
|
|
if (ctx->num == 1 || !tty_term_has(tty->term, TTYC_INDN)) {
|
2018-04-23 07:41:30 +00:00
|
|
|
if (!tty_use_margin(tty))
|
|
|
|
tty_cursor(tty, 0, tty->rlower);
|
|
|
|
else
|
|
|
|
tty_cursor(tty, tty->rright, tty->rlower);
|
2017-05-15 07:54:44 +00:00
|
|
|
for (i = 0; i < ctx->num; i++)
|
2017-02-08 17:31:09 +00:00
|
|
|
tty_putc(tty, '\n');
|
2018-04-23 07:41:30 +00:00
|
|
|
} else {
|
2020-04-17 21:33:18 +00:00
|
|
|
if (tty->cy == UINT_MAX)
|
|
|
|
tty_cursor(tty, 0, 0);
|
|
|
|
else
|
|
|
|
tty_cursor(tty, 0, tty->cy);
|
2017-05-15 07:54:44 +00:00
|
|
|
tty_putcode1(tty, TTYC_INDN, ctx->num);
|
2018-04-23 07:41:30 +00:00
|
|
|
}
|
2017-02-08 17:31:09 +00:00
|
|
|
}
|
|
|
|
|
2019-08-05 06:42:02 +00:00
|
|
|
void
|
|
|
|
tty_cmd_scrolldown(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
u_int i;
|
|
|
|
struct client *c = tty->client;
|
2019-08-05 06:42:02 +00:00
|
|
|
|
|
|
|
if (ctx->bigger ||
|
2020-05-16 15:27:08 +00:00
|
|
|
(!tty_full_width(tty, ctx) && !tty_use_margin(tty)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_fake_bce(tty, &ctx->defaults, 8) ||
|
2019-08-05 06:42:02 +00:00
|
|
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
|
|
|
(!tty_term_has(tty->term, TTYC_RI) &&
|
|
|
|
!tty_term_has(tty->term, TTYC_RIN)) ||
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->sx == 1 ||
|
2021-08-05 09:43:51 +00:00
|
|
|
ctx->sy == 1 ||
|
|
|
|
c->overlay_check != NULL) {
|
2019-08-05 06:42:02 +00:00
|
|
|
tty_redraw_region(tty, ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2019-08-05 06:42:02 +00:00
|
|
|
|
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
|
|
|
tty_margin_pane(tty, ctx);
|
|
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
|
|
|
|
|
|
|
|
if (tty_term_has(tty->term, TTYC_RIN))
|
|
|
|
tty_putcode1(tty, TTYC_RIN, ctx->num);
|
|
|
|
else {
|
|
|
|
for (i = 0; i < ctx->num; i++)
|
|
|
|
tty_putcode(tty, TTYC_RI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int px, py, nx, ny;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_region_pane(tty, ctx, 0, ctx->sy - 1);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-10-12 09:09:35 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
px = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
nx = ctx->sx;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
py = ctx->ocy + 1;
|
2020-05-16 15:27:08 +00:00
|
|
|
ny = ctx->sy - ctx->ocy - 1;
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_area(tty, ctx, py, ny, px, nx, ctx->bg);
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
px = ctx->ocx;
|
2020-05-16 15:27:08 +00:00
|
|
|
nx = ctx->sx - ctx->ocx;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
py = ctx->ocy;
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, py, px, nx, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int px, py, nx, ny;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_region_pane(tty, ctx, 0, ctx->sy - 1);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-10-12 09:09:35 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
px = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
nx = ctx->sx;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
py = 0;
|
2019-03-14 17:58:52 +00:00
|
|
|
ny = ctx->ocy;
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_area(tty, ctx, py, ny, px, nx, ctx->bg);
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
px = 0;
|
2017-05-10 16:47:03 +00:00
|
|
|
nx = ctx->ocx + 1;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
py = ctx->ocy;
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_line(tty, ctx, py, px, nx, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int px, py, nx, ny;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_region_pane(tty, ctx, 0, ctx->sy - 1);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-10-12 09:09:35 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
px = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
nx = ctx->sx;
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
py = 0;
|
2020-05-16 15:27:08 +00:00
|
|
|
ny = ctx->sy;
|
2017-05-10 16:47:03 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
tty_clear_pane_area(tty, ctx, py, ny, px, nx, ctx->bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 23:30:40 +00:00
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_alignmenttest(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-03 23:30:40 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
u_int i, j;
|
2009-06-03 23:30:40 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (ctx->bigger) {
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->redraw_cb(ctx);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, &grid_default_cell, &ctx->defaults, ctx->palette);
|
2009-06-03 23:30:40 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_region_pane(tty, ctx, 0, ctx->sy - 1);
|
2016-11-15 15:17:28 +00:00
|
|
|
tty_margin_off(tty);
|
2009-06-03 23:30:40 +00:00
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
for (j = 0; j < ctx->sy; j++) {
|
2009-10-12 09:29:58 +00:00
|
|
|
tty_cursor_pane(tty, ctx, 0, j);
|
2020-05-16 15:27:08 +00:00
|
|
|
for (i = 0; i < ctx->sx; i++)
|
2009-06-03 23:30:40 +00:00
|
|
|
tty_putc(tty, 'E');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2009-08-12 09:41:59 +00:00
|
|
|
tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2021-08-05 09:43:51 +00:00
|
|
|
const struct grid_cell *gcp = ctx->cell;
|
|
|
|
struct screen *s = ctx->s;
|
2021-10-11 13:27:50 +00:00
|
|
|
struct overlay_ranges r;
|
|
|
|
u_int px, py, i, vis = 0;
|
2021-08-05 09:43:51 +00:00
|
|
|
|
|
|
|
px = ctx->xoff + ctx->ocx - ctx->wox;
|
|
|
|
py = ctx->yoff + ctx->ocy - ctx->woy;
|
|
|
|
if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, 1, 1) ||
|
|
|
|
(gcp->data.width == 1 && !tty_check_overlay(tty, px, py)))
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return;
|
|
|
|
|
2021-08-05 09:43:51 +00:00
|
|
|
/* Handle partially obstructed wide characters. */
|
|
|
|
if (gcp->data.width > 1) {
|
2021-10-11 13:27:50 +00:00
|
|
|
tty_check_overlay_range(tty, px, py, gcp->data.width, &r);
|
|
|
|
for (i = 0; i < OVERLAY_MAX_RANGES; i++)
|
|
|
|
vis += r.nx[i];
|
|
|
|
if (vis < gcp->data.width) {
|
2021-10-25 09:22:17 +00:00
|
|
|
tty_draw_line(tty, s, s->cx, s->cy, gcp->data.width,
|
|
|
|
px, py, &ctx->defaults, ctx->palette);
|
|
|
|
return;
|
2021-08-05 09:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:27:08 +00:00
|
|
|
if (ctx->xoff + ctx->ocx - ctx->wox > tty->sx - 1 &&
|
2018-09-11 17:31:01 +00:00
|
|
|
ctx->ocy == ctx->orlower &&
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_full_width(tty, ctx))
|
2018-09-11 17:31:01 +00:00
|
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
|
2009-10-12 17:19:47 +00:00
|
|
|
|
2018-09-11 17:31:01 +00:00
|
|
|
tty_margin_off(tty);
|
2017-03-15 09:21:21 +00:00
|
|
|
tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_cell(tty, ctx->cell, &ctx->defaults, ctx->palette);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
void
|
|
|
|
tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2021-10-14 09:54:51 +00:00
|
|
|
struct overlay_ranges r;
|
|
|
|
u_int i, px, py, cx;
|
|
|
|
char *cp = ctx->ptr;
|
2021-08-05 09:43:51 +00:00
|
|
|
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, ctx->num, 1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ctx->bigger &&
|
2020-05-16 15:27:08 +00:00
|
|
|
(ctx->xoff + ctx->ocx < ctx->wox ||
|
|
|
|
ctx->xoff + ctx->ocx + ctx->num > ctx->wox + ctx->wsx)) {
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
if (!ctx->wrapped ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-06-05 09:32:15 +00:00
|
|
|
(tty->term->flags & TERM_NOAM) ||
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
ctx->xoff + ctx->ocx != 0 ||
|
|
|
|
ctx->yoff + ctx->ocy != tty->cy + 1 ||
|
|
|
|
tty->cx < tty->sx ||
|
|
|
|
tty->cy == tty->rlower)
|
|
|
|
tty_draw_pane(tty, ctx, ctx->ocy);
|
|
|
|
else
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->redraw_cb(ctx);
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:31:01 +00:00
|
|
|
tty_margin_off(tty);
|
2017-03-15 09:21:21 +00:00
|
|
|
tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy);
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, ctx->cell, &ctx->defaults, ctx->palette);
|
2021-10-14 09:54:51 +00:00
|
|
|
|
|
|
|
/* Get tty position from pane position for overlay check. */
|
|
|
|
px = ctx->xoff + ctx->ocx - ctx->wox;
|
|
|
|
py = ctx->yoff + ctx->ocy - ctx->woy;
|
|
|
|
|
|
|
|
tty_check_overlay_range(tty, px, py, ctx->num, &r);
|
2021-10-11 13:27:50 +00:00
|
|
|
for (i = 0; i < OVERLAY_MAX_RANGES; i++) {
|
|
|
|
if (r.nx[i] == 0)
|
|
|
|
continue;
|
2021-10-14 09:54:51 +00:00
|
|
|
/* Convert back to pane position for printing. */
|
|
|
|
cx = r.px[i] - ctx->xoff + ctx->wox;
|
|
|
|
tty_cursor_pane_unless_wrap(tty, ctx, cx, ctx->ocy);
|
|
|
|
tty_putn(tty, cp + r.px[i] - px, r.nx[i], r.nx[i]);
|
2021-08-05 09:43:51 +00:00
|
|
|
}
|
2017-02-08 16:45:18 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 20:24:29 +00:00
|
|
|
void
|
|
|
|
tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2020-09-02 13:46:35 +00:00
|
|
|
tty_set_selection(tty, ctx->ptr, ctx->num);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_set_selection(struct tty *tty, const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
char *encoded;
|
|
|
|
size_t size;
|
2011-05-18 20:24:29 +00:00
|
|
|
|
2020-09-02 13:46:35 +00:00
|
|
|
if (~tty->flags & TTY_STARTED)
|
|
|
|
return;
|
2020-09-02 17:19:58 +00:00
|
|
|
if (!tty_term_has(tty->term, TTYC_MS))
|
|
|
|
return;
|
2011-05-18 20:24:29 +00:00
|
|
|
|
2020-09-02 13:46:35 +00:00
|
|
|
size = 4 * ((len + 2) / 3) + 1; /* storage for base64 */
|
|
|
|
encoded = xmalloc(size);
|
2011-05-18 20:24:29 +00:00
|
|
|
|
2020-09-02 13:46:35 +00:00
|
|
|
b64_ntop(buf, len, encoded, size);
|
2021-12-10 12:42:37 +00:00
|
|
|
tty->flags |= TTY_NOBLOCK;
|
2020-09-02 13:46:35 +00:00
|
|
|
tty_putcode_ptr2(tty, TTYC_MS, "", encoded);
|
2011-05-18 20:24:29 +00:00
|
|
|
|
2020-09-02 13:46:35 +00:00
|
|
|
free(encoded);
|
2011-05-18 20:24:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-07 23:46:27 +00:00
|
|
|
void
|
|
|
|
tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2021-12-10 12:42:37 +00:00
|
|
|
tty->flags |= TTY_NOBLOCK;
|
2017-03-24 14:45:00 +00:00
|
|
|
tty_add(tty, ctx->ptr, ctx->num);
|
2017-02-08 23:53:03 +00:00
|
|
|
tty_invalidate(tty);
|
2011-03-07 23:46:27 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 13:35:24 +00:00
|
|
|
void
|
2021-08-17 08:44:52 +00:00
|
|
|
tty_cmd_syncstart(struct tty *tty, const struct tty_ctx *ctx)
|
2020-04-16 13:35:24 +00:00
|
|
|
{
|
2021-08-17 08:44:52 +00:00
|
|
|
if (ctx->num == 0x11) {
|
|
|
|
/*
|
2021-08-17 11:20:13 +00:00
|
|
|
* This is an overlay and a command that moves the cursor so
|
2021-08-17 08:44:52 +00:00
|
|
|
* start synchronized updates.
|
|
|
|
*/
|
|
|
|
tty_sync_start(tty);
|
|
|
|
} else if (~ctx->num & 0x10) {
|
|
|
|
/*
|
|
|
|
* This is a pane. If there is an overlay, always start;
|
|
|
|
* otherwise, only if requested.
|
|
|
|
*/
|
|
|
|
if (ctx->num || tty->client->overlay_draw != NULL)
|
|
|
|
tty_sync_start(tty);
|
|
|
|
}
|
2020-04-16 13:35:24 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 16:26:34 +00:00
|
|
|
void
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_cell(struct tty *tty, const struct grid_cell *gc,
|
2021-08-11 20:49:55 +00:00
|
|
|
const struct grid_cell *defaults, struct colour_palette *palette)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2018-01-12 16:41:00 +00:00
|
|
|
const struct grid_cell *gcp;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
/* Skip last character if terminal is stupid. */
|
2020-06-05 09:32:15 +00:00
|
|
|
if ((tty->term->flags & TERM_NOAM) &&
|
2016-10-14 21:48:00 +00:00
|
|
|
tty->cy == tty->sy - 1 &&
|
|
|
|
tty->cx == tty->sx - 1)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If this is a padding character, do nothing. */
|
|
|
|
if (gc->flags & GRID_FLAG_PADDING)
|
|
|
|
return;
|
|
|
|
|
2020-05-16 16:26:34 +00:00
|
|
|
/* Check the output codeset and apply attributes. */
|
2018-01-12 16:41:00 +00:00
|
|
|
gcp = tty_check_codeset(tty, gc);
|
2020-05-16 16:26:34 +00:00
|
|
|
tty_attributes(tty, gcp, defaults, palette);
|
|
|
|
|
|
|
|
/* If it is a single character, write with putc to handle ACS. */
|
2018-01-12 16:41:00 +00:00
|
|
|
if (gcp->data.size == 1) {
|
2020-05-16 16:26:34 +00:00
|
|
|
tty_attributes(tty, gcp, defaults, palette);
|
2018-01-12 16:41:00 +00:00
|
|
|
if (*gcp->data.data < 0x20 || *gcp->data.data == 0x7f)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2018-01-12 16:41:00 +00:00
|
|
|
tty_putc(tty, *gcp->data.data);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-18 02:16:21 +00:00
|
|
|
/* Write the data. */
|
2018-01-12 16:41:00 +00:00
|
|
|
tty_putn(tty, gcp->data.data, gcp->data.size, gcp->data.width);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_reset(struct tty *tty)
|
|
|
|
{
|
|
|
|
struct grid_cell *gc = &tty->cell;
|
|
|
|
|
2017-02-06 19:45:23 +00:00
|
|
|
if (!grid_cells_equal(gc, &grid_default_cell)) {
|
2017-05-15 16:44:04 +00:00
|
|
|
if ((gc->attr & GRID_ATTR_CHARSET) && tty_acs_needed(tty))
|
2017-02-06 19:45:23 +00:00
|
|
|
tty_putcode(tty, TTYC_RMACS);
|
|
|
|
tty_putcode(tty, TTYC_SGR0);
|
|
|
|
memcpy(gc, &grid_default_cell, sizeof *gc);
|
|
|
|
}
|
|
|
|
memcpy(&tty->last_cell, &grid_default_cell, sizeof tty->last_cell);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 23:53:03 +00:00
|
|
|
static void
|
|
|
|
tty_invalidate(struct tty *tty)
|
|
|
|
{
|
|
|
|
memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell);
|
|
|
|
memcpy(&tty->last_cell, &grid_default_cell, sizeof tty->last_cell);
|
|
|
|
|
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
|
|
|
tty->rupper = tty->rleft = UINT_MAX;
|
|
|
|
tty->rlower = tty->rright = UINT_MAX;
|
|
|
|
|
|
|
|
if (tty->flags & TTY_STARTED) {
|
2019-08-01 11:45:34 +00:00
|
|
|
if (tty_use_margin(tty))
|
2020-05-16 14:22:51 +00:00
|
|
|
tty_putcode(tty, TTYC_ENMG);
|
2017-02-08 23:53:03 +00:00
|
|
|
tty_putcode(tty, TTYC_SGR0);
|
|
|
|
|
|
|
|
tty->mode = ALL_MODES;
|
|
|
|
tty_update_mode(tty, MODE_CURSOR, NULL);
|
|
|
|
|
|
|
|
tty_cursor(tty, 0, 0);
|
|
|
|
tty_region_off(tty);
|
|
|
|
tty_margin_off(tty);
|
|
|
|
} else
|
|
|
|
tty->mode = MODE_CURSOR;
|
|
|
|
}
|
|
|
|
|
2016-11-15 15:17:28 +00:00
|
|
|
/* Turn off margin. */
|
|
|
|
void
|
|
|
|
tty_region_off(struct tty *tty)
|
|
|
|
{
|
|
|
|
tty_region(tty, 0, tty->sy - 1);
|
|
|
|
}
|
|
|
|
|
2009-10-12 09:16:59 +00:00
|
|
|
/* Set region inside pane. */
|
2016-10-11 13:21:59 +00:00
|
|
|
static void
|
2015-12-11 16:37:21 +00:00
|
|
|
tty_region_pane(struct tty *tty, const struct tty_ctx *ctx, u_int rupper,
|
|
|
|
u_int rlower)
|
2009-10-12 09:09:35 +00:00
|
|
|
{
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_region(tty, ctx->yoff + rupper - ctx->woy,
|
|
|
|
ctx->yoff + rlower - ctx->woy);
|
2009-10-12 09:09:35 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 09:16:59 +00:00
|
|
|
/* Set region at absolute position. */
|
2016-11-15 15:17:28 +00:00
|
|
|
static void
|
2009-10-12 09:16:59 +00:00
|
|
|
tty_region(struct tty *tty, u_int rupper, u_int rlower)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-12 09:09:35 +00:00
|
|
|
if (tty->rlower == rlower && tty->rupper == rupper)
|
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (!tty_term_has(tty->term, TTYC_CSR))
|
|
|
|
return;
|
2009-10-12 09:09:35 +00:00
|
|
|
|
|
|
|
tty->rupper = rupper;
|
|
|
|
tty->rlower = rlower;
|
2009-10-12 13:01:18 +00:00
|
|
|
|
2009-10-21 09:36:53 +00:00
|
|
|
/*
|
|
|
|
* Some terminals (such as PuTTY) do not correctly reset the cursor to
|
|
|
|
* 0,0 if it is beyond the last column (they do not reset their wrap
|
|
|
|
* flag so further output causes a line feed). As a workaround, do an
|
|
|
|
* explicit move to 0 first.
|
|
|
|
*/
|
2020-04-17 21:33:18 +00:00
|
|
|
if (tty->cx >= tty->sx) {
|
|
|
|
if (tty->cy == UINT_MAX)
|
|
|
|
tty_cursor(tty, 0, 0);
|
|
|
|
else
|
|
|
|
tty_cursor(tty, 0, tty->cy);
|
|
|
|
}
|
2009-10-21 09:36:53 +00:00
|
|
|
|
2009-10-12 09:09:35 +00:00
|
|
|
tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower);
|
2017-02-16 12:56:01 +00:00
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-11-15 15:17:28 +00:00
|
|
|
/* Turn off margin. */
|
|
|
|
void
|
|
|
|
tty_margin_off(struct tty *tty)
|
|
|
|
{
|
|
|
|
tty_margin(tty, 0, tty->sx - 1);
|
|
|
|
}
|
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
/* Set margin inside pane. */
|
|
|
|
static void
|
|
|
|
tty_margin_pane(struct tty *tty, const struct tty_ctx *ctx)
|
|
|
|
{
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_margin(tty, ctx->xoff - ctx->wox,
|
2020-05-16 15:34:08 +00:00
|
|
|
ctx->xoff + ctx->sx - 1 - ctx->wox);
|
2016-11-15 14:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set margin at absolute position. */
|
2016-11-15 15:17:28 +00:00
|
|
|
static void
|
2016-11-15 14:02:32 +00:00
|
|
|
tty_margin(struct tty *tty, u_int rleft, u_int rright)
|
|
|
|
{
|
|
|
|
if (!tty_use_margin(tty))
|
|
|
|
return;
|
|
|
|
if (tty->rleft == rleft && tty->rright == rright)
|
|
|
|
return;
|
|
|
|
|
2017-02-07 18:27:46 +00:00
|
|
|
tty_putcode2(tty, TTYC_CSR, tty->rupper, tty->rlower);
|
2017-02-07 17:13:28 +00:00
|
|
|
|
2016-11-15 14:02:32 +00:00
|
|
|
tty->rleft = rleft;
|
|
|
|
tty->rright = rright;
|
|
|
|
|
2017-02-07 18:27:46 +00:00
|
|
|
if (rleft == 0 && rright == tty->sx - 1)
|
2020-05-16 14:22:51 +00:00
|
|
|
tty_putcode(tty, TTYC_CLMG);
|
2017-02-07 18:27:46 +00:00
|
|
|
else
|
2020-05-16 14:22:51 +00:00
|
|
|
tty_putcode2(tty, TTYC_CMG, rleft, rright);
|
2017-02-16 12:56:01 +00:00
|
|
|
tty->cx = tty->cy = UINT_MAX;
|
2016-11-15 14:02:32 +00:00
|
|
|
}
|
|
|
|
|
2017-03-15 09:21:21 +00:00
|
|
|
/*
|
|
|
|
* Move the cursor, unless it would wrap itself when the next character is
|
|
|
|
* printed.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx,
|
|
|
|
u_int cx, u_int cy)
|
|
|
|
{
|
2017-04-25 18:30:29 +00:00
|
|
|
if (!ctx->wrapped ||
|
2020-05-16 15:27:08 +00:00
|
|
|
!tty_full_width(tty, ctx) ||
|
2020-06-05 09:32:15 +00:00
|
|
|
(tty->term->flags & TERM_NOAM) ||
|
2017-03-15 09:21:21 +00:00
|
|
|
ctx->xoff + cx != 0 ||
|
|
|
|
ctx->yoff + cy != tty->cy + 1 ||
|
2017-03-15 15:22:14 +00:00
|
|
|
tty->cx < tty->sx ||
|
|
|
|
tty->cy == tty->rlower)
|
2017-03-15 09:21:21 +00:00
|
|
|
tty_cursor_pane(tty, ctx, cx, cy);
|
|
|
|
else
|
|
|
|
log_debug("%s: will wrap at %u,%u", __func__, tty->cx, tty->cy);
|
|
|
|
}
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
/* Move cursor inside pane. */
|
2016-10-11 13:21:59 +00:00
|
|
|
static void
|
2009-10-12 09:29:58 +00:00
|
|
|
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy)
|
|
|
|
{
|
2020-05-16 15:27:08 +00:00
|
|
|
tty_cursor(tty, ctx->xoff + cx - ctx->wox, ctx->yoff + cy - ctx->woy);
|
2009-10-12 09:29:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
/* Move cursor to absolute position. */
|
2009-10-12 09:29:58 +00:00
|
|
|
void
|
|
|
|
tty_cursor(struct tty *tty, u_int cx, u_int cy)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-12 13:01:18 +00:00
|
|
|
struct tty_term *term = tty->term;
|
|
|
|
u_int thisx, thisy;
|
|
|
|
int change;
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2020-04-17 22:16:28 +00:00
|
|
|
if (tty->flags & TTY_BLOCK)
|
|
|
|
return;
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
thisx = tty->cx;
|
|
|
|
thisy = tty->cy;
|
|
|
|
|
2021-10-28 18:57:06 +00:00
|
|
|
/*
|
|
|
|
* If in the automargin space, and want to be there, do not move.
|
|
|
|
* Otherwise, force the cursor to be in range (and complain).
|
|
|
|
*/
|
|
|
|
if (cx == thisx && cy == thisy && cx == tty->sx)
|
|
|
|
return;
|
|
|
|
if (cx > tty->sx - 1) {
|
|
|
|
log_debug("%s: x too big %u > %u", __func__, cx, tty->sx - 1);
|
|
|
|
cx = tty->sx - 1;
|
|
|
|
}
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
/* No change. */
|
|
|
|
if (cx == thisx && cy == thisy)
|
|
|
|
return;
|
|
|
|
|
2021-10-28 18:57:06 +00:00
|
|
|
/* Currently at the very end of the line - use absolute movement. */
|
2009-10-12 14:54:19 +00:00
|
|
|
if (thisx > tty->sx - 1)
|
|
|
|
goto absolute;
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
/* Move to home position (0, 0). */
|
|
|
|
if (cx == 0 && cy == 0 && tty_term_has(term, TTYC_HOME)) {
|
|
|
|
tty_putcode(tty, TTYC_HOME);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Zero on the next line. */
|
2017-08-21 21:01:21 +00:00
|
|
|
if (cx == 0 && cy == thisy + 1 && thisy != tty->rlower &&
|
|
|
|
(!tty_use_margin(tty) || tty->rleft == 0)) {
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_putc(tty, '\r');
|
2009-10-12 13:01:18 +00:00
|
|
|
tty_putc(tty, '\n');
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2009-10-12 16:41:02 +00:00
|
|
|
/* Moving column or row. */
|
2009-10-12 13:01:18 +00:00
|
|
|
if (cy == thisy) {
|
2009-10-12 16:41:02 +00:00
|
|
|
/*
|
|
|
|
* Moving column only, row staying the same.
|
|
|
|
*/
|
|
|
|
|
2009-10-12 13:01:18 +00:00
|
|
|
/* To left edge. */
|
2017-08-21 21:02:58 +00:00
|
|
|
if (cx == 0 && (!tty_use_margin(tty) || tty->rleft == 0)) {
|
2009-10-12 13:01:18 +00:00
|
|
|
tty_putc(tty, '\r');
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* One to the left. */
|
|
|
|
if (cx == thisx - 1 && tty_term_has(term, TTYC_CUB1)) {
|
|
|
|
tty_putcode(tty, TTYC_CUB1);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* One to the right. */
|
|
|
|
if (cx == thisx + 1 && tty_term_has(term, TTYC_CUF1)) {
|
|
|
|
tty_putcode(tty, TTYC_CUF1);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate difference. */
|
|
|
|
change = thisx - cx; /* +ve left, -ve right */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use HPA if change is larger than absolute, otherwise move
|
|
|
|
* the cursor with CUB/CUF.
|
|
|
|
*/
|
2010-06-05 16:32:22 +00:00
|
|
|
if ((u_int) abs(change) > cx && tty_term_has(term, TTYC_HPA)) {
|
2009-10-12 13:01:18 +00:00
|
|
|
tty_putcode1(tty, TTYC_HPA, cx);
|
|
|
|
goto out;
|
2019-11-14 07:56:32 +00:00
|
|
|
} else if (change > 0 &&
|
|
|
|
tty_term_has(term, TTYC_CUB) &&
|
|
|
|
!tty_use_margin(tty)) {
|
2016-05-30 09:26:49 +00:00
|
|
|
if (change == 2 && tty_term_has(term, TTYC_CUB1)) {
|
|
|
|
tty_putcode(tty, TTYC_CUB1);
|
|
|
|
tty_putcode(tty, TTYC_CUB1);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-12 13:01:18 +00:00
|
|
|
tty_putcode1(tty, TTYC_CUB, change);
|
|
|
|
goto out;
|
2019-11-14 07:56:32 +00:00
|
|
|
} else if (change < 0 &&
|
|
|
|
tty_term_has(term, TTYC_CUF) &&
|
|
|
|
!tty_use_margin(tty)) {
|
2009-10-12 13:01:18 +00:00
|
|
|
tty_putcode1(tty, TTYC_CUF, -change);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-12 16:41:02 +00:00
|
|
|
} else if (cx == thisx) {
|
|
|
|
/*
|
|
|
|
* Moving row only, column staying the same.
|
|
|
|
*/
|
2009-10-12 13:01:18 +00:00
|
|
|
|
|
|
|
/* One above. */
|
2009-12-03 22:50:09 +00:00
|
|
|
if (thisy != tty->rupper &&
|
2009-10-12 13:01:18 +00:00
|
|
|
cy == thisy - 1 && tty_term_has(term, TTYC_CUU1)) {
|
|
|
|
tty_putcode(tty, TTYC_CUU1);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* One below. */
|
2009-10-16 19:09:40 +00:00
|
|
|
if (thisy != tty->rlower &&
|
2009-10-12 13:01:18 +00:00
|
|
|
cy == thisy + 1 && tty_term_has(term, TTYC_CUD1)) {
|
|
|
|
tty_putcode(tty, TTYC_CUD1);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate difference. */
|
|
|
|
change = thisy - cy; /* +ve up, -ve down */
|
|
|
|
|
|
|
|
/*
|
2009-12-03 22:50:09 +00:00
|
|
|
* Try to use VPA if change is larger than absolute or if this
|
|
|
|
* change would cross the scroll region, otherwise use CUU/CUD.
|
2009-10-12 13:01:18 +00:00
|
|
|
*/
|
2010-06-05 16:32:22 +00:00
|
|
|
if ((u_int) abs(change) > cy ||
|
2009-10-12 13:01:18 +00:00
|
|
|
(change < 0 && cy - change > tty->rlower) ||
|
2009-10-12 16:37:43 +00:00
|
|
|
(change > 0 && cy - change < tty->rupper)) {
|
|
|
|
if (tty_term_has(term, TTYC_VPA)) {
|
|
|
|
tty_putcode1(tty, TTYC_VPA, cy);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-12 13:01:18 +00:00
|
|
|
} else if (change > 0 && tty_term_has(term, TTYC_CUU)) {
|
|
|
|
tty_putcode1(tty, TTYC_CUU, change);
|
|
|
|
goto out;
|
|
|
|
} else if (change < 0 && tty_term_has(term, TTYC_CUD)) {
|
|
|
|
tty_putcode1(tty, TTYC_CUD, -change);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2009-10-12 13:01:18 +00:00
|
|
|
|
2009-10-12 14:54:19 +00:00
|
|
|
absolute:
|
2009-10-12 13:01:18 +00:00
|
|
|
/* Absolute movement. */
|
|
|
|
tty_putcode2(tty, TTYC_CUP, cy, cx);
|
|
|
|
|
|
|
|
out:
|
|
|
|
tty->cx = cx;
|
|
|
|
tty->cy = cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-04-19 21:05:27 +00:00
|
|
|
tty_attributes(struct tty *tty, const struct grid_cell *gc,
|
2021-08-11 20:49:55 +00:00
|
|
|
const struct grid_cell *defaults, struct colour_palette *palette)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-28 08:52:36 +00:00
|
|
|
struct grid_cell *tc = &tty->cell, gc2;
|
2017-03-22 07:16:54 +00:00
|
|
|
int changed;
|
2009-10-28 08:27:33 +00:00
|
|
|
|
2017-02-06 19:45:23 +00:00
|
|
|
/* Copy cell and update default colours. */
|
2010-03-01 22:44:31 +00:00
|
|
|
memcpy(&gc2, gc, sizeof gc2);
|
2021-08-11 20:49:55 +00:00
|
|
|
if (~gc->flags & GRID_FLAG_NOPALETTE) {
|
|
|
|
if (gc2.fg == 8)
|
|
|
|
gc2.fg = defaults->fg;
|
|
|
|
if (gc2.bg == 8)
|
|
|
|
gc2.bg = defaults->bg;
|
|
|
|
}
|
2020-05-16 15:34:08 +00:00
|
|
|
|
|
|
|
/* Ignore cell if it is the same as the last one. */
|
|
|
|
if (gc2.attr == tty->last_cell.attr &&
|
|
|
|
gc2.fg == tty->last_cell.fg &&
|
|
|
|
gc2.bg == tty->last_cell.bg &&
|
|
|
|
gc2.us == tty->last_cell.us)
|
|
|
|
return;
|
2009-10-28 08:52:36 +00:00
|
|
|
|
2009-08-05 16:26:38 +00:00
|
|
|
/*
|
|
|
|
* If no setab, try to use the reverse attribute as a best-effort for a
|
|
|
|
* non-default background. This is a bit of a hack but it doesn't do
|
|
|
|
* any serious harm and makes a couple of applications happier.
|
|
|
|
*/
|
|
|
|
if (!tty_term_has(tty->term, TTYC_SETAB)) {
|
2010-03-01 22:44:31 +00:00
|
|
|
if (gc2.attr & GRID_ATTR_REVERSE) {
|
2018-10-25 15:13:38 +00:00
|
|
|
if (gc2.fg != 7 && !COLOUR_DEFAULT(gc2.fg))
|
2009-11-04 13:34:26 +00:00
|
|
|
gc2.attr &= ~GRID_ATTR_REVERSE;
|
2009-08-05 16:26:38 +00:00
|
|
|
} else {
|
2018-10-25 15:13:38 +00:00
|
|
|
if (gc2.bg != 0 && !COLOUR_DEFAULT(gc2.bg))
|
2009-11-04 13:34:26 +00:00
|
|
|
gc2.attr |= GRID_ATTR_REVERSE;
|
2009-08-05 16:26:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2010-03-01 22:44:31 +00:00
|
|
|
/* Fix up the colours if necessary. */
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_check_fg(tty, palette, &gc2);
|
|
|
|
tty_check_bg(tty, palette, &gc2);
|
|
|
|
tty_check_us(tty, palette, &gc2);
|
2010-03-01 22:44:31 +00:00
|
|
|
|
2019-06-27 15:17:41 +00:00
|
|
|
/*
|
|
|
|
* If any bits are being cleared or the underline colour is now default,
|
|
|
|
* reset everything.
|
|
|
|
*/
|
|
|
|
if ((tc->attr & ~gc2.attr) || (tc->us != gc2.us && gc2.us == 0))
|
2009-11-04 13:34:26 +00:00
|
|
|
tty_reset(tty);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the colours. This may call tty_reset() (so it comes next) and
|
2019-06-27 15:17:41 +00:00
|
|
|
* may add to (NOT remove) the desired attributes.
|
2009-11-04 13:34:26 +00:00
|
|
|
*/
|
2010-03-01 22:44:31 +00:00
|
|
|
tty_colours(tty, &gc2);
|
2009-11-04 13:34:26 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Filter out attribute bits already set. */
|
2010-03-01 22:44:31 +00:00
|
|
|
changed = gc2.attr & ~tc->attr;
|
|
|
|
tc->attr = gc2.attr;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
/* Set the attributes. */
|
|
|
|
if (changed & GRID_ATTR_BRIGHT)
|
|
|
|
tty_putcode(tty, TTYC_BOLD);
|
|
|
|
if (changed & GRID_ATTR_DIM)
|
|
|
|
tty_putcode(tty, TTYC_DIM);
|
2015-04-29 15:59:08 +00:00
|
|
|
if (changed & GRID_ATTR_ITALICS)
|
|
|
|
tty_set_italics(tty);
|
2018-10-18 07:57:57 +00:00
|
|
|
if (changed & GRID_ATTR_ALL_UNDERSCORE) {
|
|
|
|
if ((changed & GRID_ATTR_UNDERSCORE) ||
|
|
|
|
!tty_term_has(tty->term, TTYC_SMULX))
|
|
|
|
tty_putcode(tty, TTYC_SMUL);
|
|
|
|
else if (changed & GRID_ATTR_UNDERSCORE_2)
|
|
|
|
tty_putcode1(tty, TTYC_SMULX, 2);
|
|
|
|
else if (changed & GRID_ATTR_UNDERSCORE_3)
|
|
|
|
tty_putcode1(tty, TTYC_SMULX, 3);
|
|
|
|
else if (changed & GRID_ATTR_UNDERSCORE_4)
|
|
|
|
tty_putcode1(tty, TTYC_SMULX, 4);
|
|
|
|
else if (changed & GRID_ATTR_UNDERSCORE_5)
|
|
|
|
tty_putcode1(tty, TTYC_SMULX, 5);
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
if (changed & GRID_ATTR_BLINK)
|
|
|
|
tty_putcode(tty, TTYC_BLINK);
|
|
|
|
if (changed & GRID_ATTR_REVERSE) {
|
|
|
|
if (tty_term_has(tty->term, TTYC_REV))
|
|
|
|
tty_putcode(tty, TTYC_REV);
|
|
|
|
else if (tty_term_has(tty->term, TTYC_SMSO))
|
|
|
|
tty_putcode(tty, TTYC_SMSO);
|
|
|
|
}
|
|
|
|
if (changed & GRID_ATTR_HIDDEN)
|
|
|
|
tty_putcode(tty, TTYC_INVIS);
|
2017-03-22 07:16:54 +00:00
|
|
|
if (changed & GRID_ATTR_STRIKETHROUGH)
|
|
|
|
tty_putcode(tty, TTYC_SMXX);
|
2019-05-13 20:10:23 +00:00
|
|
|
if (changed & GRID_ATTR_OVERLINE)
|
|
|
|
tty_putcode(tty, TTYC_SMOL);
|
2017-05-15 16:44:04 +00:00
|
|
|
if ((changed & GRID_ATTR_CHARSET) && tty_acs_needed(tty))
|
2009-06-01 22:58:49 +00:00
|
|
|
tty_putcode(tty, TTYC_SMACS);
|
2020-05-16 15:34:08 +00:00
|
|
|
|
|
|
|
memcpy(&tty->last_cell, &gc2, sizeof tty->last_cell);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2010-03-01 22:44:31 +00:00
|
|
|
tty_colours(struct tty *tty, const struct grid_cell *gc)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-28 08:27:33 +00:00
|
|
|
struct grid_cell *tc = &tty->cell;
|
2016-07-15 00:49:08 +00:00
|
|
|
int have_ax;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/* No changes? Nothing is necessary. */
|
2019-06-27 15:17:41 +00:00
|
|
|
if (gc->fg == tc->fg && gc->bg == tc->bg && gc->us == tc->us)
|
2009-10-28 08:52:36 +00:00
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/*
|
|
|
|
* Is either the default colour? This is handled specially because the
|
|
|
|
* best solution might be to reset both colours to default, in which
|
|
|
|
* case if only one is default need to fall onward to set the other
|
|
|
|
* colour.
|
|
|
|
*/
|
2018-10-25 15:13:38 +00:00
|
|
|
if (COLOUR_DEFAULT(gc->fg) || COLOUR_DEFAULT(gc->bg)) {
|
2009-10-28 08:27:33 +00:00
|
|
|
/*
|
|
|
|
* If don't have AX but do have op, send sgr0 (op can't
|
|
|
|
* actually be used because it is sometimes the same as sgr0
|
|
|
|
* and sometimes isn't). This resets both colours to default.
|
|
|
|
*
|
|
|
|
* Otherwise, try to set the default colour only as needed.
|
|
|
|
*/
|
2015-04-15 22:10:13 +00:00
|
|
|
have_ax = tty_term_flag(tty->term, TTYC_AX);
|
2009-10-28 08:27:33 +00:00
|
|
|
if (!have_ax && tty_term_has(tty->term, TTYC_OP))
|
|
|
|
tty_reset(tty);
|
|
|
|
else {
|
2018-10-25 15:13:38 +00:00
|
|
|
if (COLOUR_DEFAULT(gc->fg) && !COLOUR_DEFAULT(tc->fg)) {
|
2009-10-28 08:27:33 +00:00
|
|
|
if (have_ax)
|
|
|
|
tty_puts(tty, "\033[39m");
|
2016-07-15 00:49:08 +00:00
|
|
|
else if (tc->fg != 7)
|
2009-10-28 08:27:33 +00:00
|
|
|
tty_putcode1(tty, TTYC_SETAF, 7);
|
2018-10-25 15:13:38 +00:00
|
|
|
tc->fg = gc->fg;
|
2009-10-28 08:27:33 +00:00
|
|
|
}
|
2018-10-25 15:13:38 +00:00
|
|
|
if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) {
|
2009-12-03 22:50:09 +00:00
|
|
|
if (have_ax)
|
2009-10-28 08:27:33 +00:00
|
|
|
tty_puts(tty, "\033[49m");
|
2016-07-15 00:49:08 +00:00
|
|
|
else if (tc->bg != 0)
|
2009-10-28 08:27:33 +00:00
|
|
|
tty_putcode1(tty, TTYC_SETAB, 0);
|
2019-01-15 12:08:53 +00:00
|
|
|
tc->bg = gc->bg;
|
2009-10-28 08:27:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/* Set the foreground colour. */
|
2018-10-25 15:13:38 +00:00
|
|
|
if (!COLOUR_DEFAULT(gc->fg) && gc->fg != tc->fg)
|
2010-03-01 22:44:31 +00:00
|
|
|
tty_colours_fg(tty, gc);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/*
|
|
|
|
* Set the background colour. This must come after the foreground as
|
|
|
|
* tty_colour_fg() can call tty_reset().
|
|
|
|
*/
|
2018-10-25 15:13:38 +00:00
|
|
|
if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg)
|
2009-11-26 21:37:13 +00:00
|
|
|
tty_colours_bg(tty, gc);
|
2019-06-27 15:17:41 +00:00
|
|
|
|
2021-08-11 20:49:55 +00:00
|
|
|
/* Set the underscore colour. */
|
2019-06-27 15:17:41 +00:00
|
|
|
if (gc->us != tc->us)
|
|
|
|
tty_colours_us(tty, gc);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-01-07 15:28:13 +00:00
|
|
|
static void
|
2021-08-11 20:49:55 +00:00
|
|
|
tty_check_fg(struct tty *tty, struct colour_palette *palette,
|
|
|
|
struct grid_cell *gc)
|
2010-03-01 22:44:31 +00:00
|
|
|
{
|
2016-07-15 00:49:08 +00:00
|
|
|
u_char r, g, b;
|
|
|
|
u_int colours;
|
2017-01-12 00:19:32 +00:00
|
|
|
int c;
|
2010-03-01 22:44:31 +00:00
|
|
|
|
2017-06-03 07:15:23 +00:00
|
|
|
/*
|
|
|
|
* Perform substitution if this pane has a palette. If the bright
|
|
|
|
* attribute is set, use the bright entry in the palette by changing to
|
|
|
|
* the aixterm colour.
|
|
|
|
*/
|
|
|
|
if (~gc->flags & GRID_FLAG_NOPALETTE) {
|
|
|
|
c = gc->fg;
|
2017-06-04 08:02:20 +00:00
|
|
|
if (c < 8 && gc->attr & GRID_ATTR_BRIGHT)
|
2017-06-03 07:15:23 +00:00
|
|
|
c += 90;
|
2021-08-11 20:49:55 +00:00
|
|
|
if ((c = colour_palette_get(palette, c)) != -1)
|
2017-06-03 07:15:23 +00:00
|
|
|
gc->fg = c;
|
|
|
|
}
|
2017-01-07 15:28:13 +00:00
|
|
|
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Is this a 24-bit colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->fg & COLOUR_FLAG_RGB) {
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Not a 24-bit terminal? Translate to 256-colour palette. */
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_RGBCOLOURS)
|
2016-03-03 12:58:15 +00:00
|
|
|
return;
|
2020-01-28 11:39:51 +00:00
|
|
|
colour_split_rgb(gc->fg, &r, &g, &b);
|
|
|
|
gc->fg = colour_find_rgb(r, g, b);
|
2016-01-29 11:13:56 +00:00
|
|
|
}
|
2017-01-12 00:30:41 +00:00
|
|
|
|
|
|
|
/* How many colours does this terminal have? */
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_256COLOURS)
|
2017-01-12 00:30:41 +00:00
|
|
|
colours = 256;
|
|
|
|
else
|
|
|
|
colours = tty_term_number(tty->term, TTYC_COLORS);
|
2015-04-15 22:34:46 +00:00
|
|
|
|
2010-03-01 22:44:31 +00:00
|
|
|
/* Is this a 256-colour colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->fg & COLOUR_FLAG_256) {
|
2010-03-01 22:44:31 +00:00
|
|
|
/* And not a 256 colour mode? */
|
2020-12-03 07:12:11 +00:00
|
|
|
if (colours < 256) {
|
2010-03-01 22:44:31 +00:00
|
|
|
gc->fg = colour_256to16(gc->fg);
|
|
|
|
if (gc->fg & 8) {
|
|
|
|
gc->fg &= 7;
|
2015-04-15 22:34:46 +00:00
|
|
|
if (colours >= 16)
|
|
|
|
gc->fg += 90;
|
2019-09-19 08:56:37 +00:00
|
|
|
}
|
2010-03-01 22:44:31 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is this an aixterm colour? */
|
|
|
|
if (gc->fg >= 90 && gc->fg <= 97 && colours < 16) {
|
|
|
|
gc->fg -= 90;
|
|
|
|
gc->attr |= GRID_ATTR_BRIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-07 15:28:13 +00:00
|
|
|
static void
|
2021-08-11 20:49:55 +00:00
|
|
|
tty_check_bg(struct tty *tty, struct colour_palette *palette,
|
|
|
|
struct grid_cell *gc)
|
2010-03-01 22:44:31 +00:00
|
|
|
{
|
2016-07-15 00:49:08 +00:00
|
|
|
u_char r, g, b;
|
|
|
|
u_int colours;
|
2017-01-12 00:19:32 +00:00
|
|
|
int c;
|
2010-03-01 22:44:31 +00:00
|
|
|
|
2017-06-03 07:15:23 +00:00
|
|
|
/* Perform substitution if this pane has a palette. */
|
|
|
|
if (~gc->flags & GRID_FLAG_NOPALETTE) {
|
2021-08-11 20:49:55 +00:00
|
|
|
if ((c = colour_palette_get(palette, gc->bg)) != -1)
|
2017-06-03 07:15:23 +00:00
|
|
|
gc->bg = c;
|
|
|
|
}
|
2017-01-07 15:28:13 +00:00
|
|
|
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Is this a 24-bit colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->bg & COLOUR_FLAG_RGB) {
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Not a 24-bit terminal? Translate to 256-colour palette. */
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_RGBCOLOURS)
|
2016-03-03 12:58:15 +00:00
|
|
|
return;
|
2020-01-28 11:39:51 +00:00
|
|
|
colour_split_rgb(gc->bg, &r, &g, &b);
|
|
|
|
gc->bg = colour_find_rgb(r, g, b);
|
2016-01-29 11:13:56 +00:00
|
|
|
}
|
2017-01-12 00:30:41 +00:00
|
|
|
|
|
|
|
/* How many colours does this terminal have? */
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_256COLOURS)
|
2017-01-12 00:30:41 +00:00
|
|
|
colours = 256;
|
|
|
|
else
|
|
|
|
colours = tty_term_number(tty->term, TTYC_COLORS);
|
2015-04-15 22:34:46 +00:00
|
|
|
|
2010-03-01 22:44:31 +00:00
|
|
|
/* Is this a 256-colour colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->bg & COLOUR_FLAG_256) {
|
2010-03-01 22:44:31 +00:00
|
|
|
/*
|
|
|
|
* And not a 256 colour mode? Translate to 16-colour
|
|
|
|
* palette. Bold background doesn't exist portably, so just
|
|
|
|
* discard the bold bit if set.
|
|
|
|
*/
|
2020-12-03 07:12:11 +00:00
|
|
|
if (colours < 256) {
|
2010-03-01 22:44:31 +00:00
|
|
|
gc->bg = colour_256to16(gc->bg);
|
2015-04-15 22:34:46 +00:00
|
|
|
if (gc->bg & 8) {
|
2010-03-01 22:44:31 +00:00
|
|
|
gc->bg &= 7;
|
2015-04-15 22:34:46 +00:00
|
|
|
if (colours >= 16)
|
2019-04-24 20:32:31 +00:00
|
|
|
gc->bg += 90;
|
2015-04-15 22:34:46 +00:00
|
|
|
}
|
2010-03-01 22:44:31 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is this an aixterm colour? */
|
2015-04-15 22:34:46 +00:00
|
|
|
if (gc->bg >= 90 && gc->bg <= 97 && colours < 16)
|
2010-03-01 22:44:31 +00:00
|
|
|
gc->bg -= 90;
|
|
|
|
}
|
|
|
|
|
2019-06-27 15:17:41 +00:00
|
|
|
static void
|
2021-08-11 20:49:55 +00:00
|
|
|
tty_check_us(__unused struct tty *tty, struct colour_palette *palette,
|
|
|
|
struct grid_cell *gc)
|
2019-06-27 15:17:41 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
/* Perform substitution if this pane has a palette. */
|
|
|
|
if (~gc->flags & GRID_FLAG_NOPALETTE) {
|
2021-08-11 20:49:55 +00:00
|
|
|
if ((c = colour_palette_get(palette, gc->us)) != -1)
|
2019-06-27 15:17:41 +00:00
|
|
|
gc->us = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Underscore colour is set as RGB so convert a 256 colour to RGB. */
|
|
|
|
if (gc->us & COLOUR_FLAG_256)
|
|
|
|
gc->us = colour_256toRGB (gc->us);
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2010-03-01 22:44:31 +00:00
|
|
|
tty_colours_fg(struct tty *tty, const struct grid_cell *gc)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-28 08:27:33 +00:00
|
|
|
struct grid_cell *tc = &tty->cell;
|
2009-12-14 21:33:38 +00:00
|
|
|
char s[32];
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
/* Is this a 24-bit or 256-colour colour? */
|
2018-05-07 13:39:09 +00:00
|
|
|
if (gc->fg & COLOUR_FLAG_RGB || gc->fg & COLOUR_FLAG_256) {
|
2016-07-15 00:49:08 +00:00
|
|
|
if (tty_try_colour(tty, gc->fg, "38") == 0)
|
2020-10-05 09:53:01 +00:00
|
|
|
goto save;
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Should not get here, already converted in tty_check_fg. */
|
2010-03-01 22:44:31 +00:00
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-12-14 21:33:38 +00:00
|
|
|
/* Is this an aixterm bright colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->fg >= 90 && gc->fg <= 97) {
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_256COLOURS) {
|
2019-04-25 19:03:43 +00:00
|
|
|
xsnprintf(s, sizeof s, "\033[%dm", gc->fg);
|
|
|
|
tty_puts(tty, s);
|
|
|
|
} else
|
|
|
|
tty_putcode1(tty, TTYC_SETAF, gc->fg - 90 + 8);
|
2020-10-05 09:53:01 +00:00
|
|
|
goto save;
|
2009-12-14 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/* Otherwise set the foreground colour. */
|
2016-07-15 00:49:08 +00:00
|
|
|
tty_putcode1(tty, TTYC_SETAF, gc->fg);
|
2009-10-28 08:27:33 +00:00
|
|
|
|
2020-10-05 09:53:01 +00:00
|
|
|
save:
|
2009-10-28 08:27:33 +00:00
|
|
|
/* Save the new values in the terminal current cell. */
|
2016-07-15 00:49:08 +00:00
|
|
|
tc->fg = gc->fg;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static void
|
2009-11-26 21:37:13 +00:00
|
|
|
tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-10-28 08:27:33 +00:00
|
|
|
struct grid_cell *tc = &tty->cell;
|
2009-12-14 21:33:38 +00:00
|
|
|
char s[32];
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
/* Is this a 24-bit or 256-colour colour? */
|
2018-05-07 13:39:09 +00:00
|
|
|
if (gc->bg & COLOUR_FLAG_RGB || gc->bg & COLOUR_FLAG_256) {
|
2016-07-15 00:49:08 +00:00
|
|
|
if (tty_try_colour(tty, gc->bg, "48") == 0)
|
2020-10-05 09:53:01 +00:00
|
|
|
goto save;
|
2016-01-29 11:13:56 +00:00
|
|
|
/* Should not get here, already converted in tty_check_bg. */
|
2010-03-01 22:44:31 +00:00
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-12-14 21:33:38 +00:00
|
|
|
/* Is this an aixterm bright colour? */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->bg >= 90 && gc->bg <= 97) {
|
2020-04-20 13:25:36 +00:00
|
|
|
if (tty->term->flags & TERM_256COLOURS) {
|
2019-04-25 19:03:43 +00:00
|
|
|
xsnprintf(s, sizeof s, "\033[%dm", gc->bg + 10);
|
|
|
|
tty_puts(tty, s);
|
|
|
|
} else
|
|
|
|
tty_putcode1(tty, TTYC_SETAB, gc->bg - 90 + 8);
|
2020-10-05 09:53:01 +00:00
|
|
|
goto save;
|
2009-12-14 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 08:27:33 +00:00
|
|
|
/* Otherwise set the background colour. */
|
2016-07-15 00:49:08 +00:00
|
|
|
tty_putcode1(tty, TTYC_SETAB, gc->bg);
|
2009-10-28 08:27:33 +00:00
|
|
|
|
2020-10-05 09:53:01 +00:00
|
|
|
save:
|
2009-10-28 08:27:33 +00:00
|
|
|
/* Save the new values in the terminal current cell. */
|
2016-07-15 00:49:08 +00:00
|
|
|
tc->bg = gc->bg;
|
2009-10-28 08:27:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-27 15:17:41 +00:00
|
|
|
static void
|
|
|
|
tty_colours_us(struct tty *tty, const struct grid_cell *gc)
|
|
|
|
{
|
|
|
|
struct grid_cell *tc = &tty->cell;
|
|
|
|
u_int c;
|
|
|
|
u_char r, g, b;
|
|
|
|
|
2020-10-05 09:53:01 +00:00
|
|
|
/* Clear underline colour. */
|
|
|
|
if (gc->us == 0) {
|
|
|
|
tty_putcode(tty, TTYC_OL);
|
|
|
|
goto save;
|
|
|
|
}
|
|
|
|
|
2019-06-27 15:17:41 +00:00
|
|
|
/* Must be an RGB colour - this should never happen. */
|
|
|
|
if (~gc->us & COLOUR_FLAG_RGB)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
2020-10-05 09:53:01 +00:00
|
|
|
* Setulc and setal follows the ncurses(3) one argument "direct colour"
|
2019-06-27 15:17:41 +00:00
|
|
|
* capability format. Calculate the colour value.
|
|
|
|
*/
|
|
|
|
colour_split_rgb(gc->us, &r, &g, &b);
|
|
|
|
c = (65536 * r) + (256 * g) + b;
|
|
|
|
|
2020-10-05 09:53:01 +00:00
|
|
|
/*
|
|
|
|
* Write the colour. Only use setal if the RGB flag is set because the
|
|
|
|
* non-RGB version may be wrong.
|
|
|
|
*/
|
|
|
|
if (tty_term_has(tty->term, TTYC_SETULC))
|
|
|
|
tty_putcode1(tty, TTYC_SETULC, c);
|
|
|
|
else if (tty_term_has(tty->term, TTYC_SETAL) &&
|
|
|
|
tty_term_has(tty->term, TTYC_RGB))
|
|
|
|
tty_putcode1(tty, TTYC_SETAL, c);
|
2019-06-27 15:17:41 +00:00
|
|
|
|
2020-10-05 09:53:01 +00:00
|
|
|
save:
|
2019-06-27 15:17:41 +00:00
|
|
|
/* Save the new values in the terminal current cell. */
|
|
|
|
tc->us = gc->us;
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:29:23 +00:00
|
|
|
static int
|
2016-07-15 00:49:08 +00:00
|
|
|
tty_try_colour(struct tty *tty, int colour, const char *type)
|
2009-10-28 08:27:33 +00:00
|
|
|
{
|
2016-07-15 00:49:08 +00:00
|
|
|
u_char r, g, b;
|
2009-10-28 08:27:33 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
if (colour & COLOUR_FLAG_256) {
|
2020-04-20 13:25:36 +00:00
|
|
|
if (*type == '3' && tty_term_has(tty->term, TTYC_SETAF))
|
|
|
|
tty_putcode1(tty, TTYC_SETAF, colour & 0xff);
|
|
|
|
else if (tty_term_has(tty->term, TTYC_SETAB))
|
|
|
|
tty_putcode1(tty, TTYC_SETAB, colour & 0xff);
|
|
|
|
return (0);
|
2014-02-14 14:37:08 +00:00
|
|
|
}
|
2009-10-28 08:27:33 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
if (colour & COLOUR_FLAG_RGB) {
|
2020-01-28 11:39:51 +00:00
|
|
|
colour_split_rgb(colour & 0xffffff, &r, &g, &b);
|
2020-04-20 13:25:36 +00:00
|
|
|
if (*type == '3' && tty_term_has(tty->term, TTYC_SETRGBF))
|
2017-05-31 08:43:44 +00:00
|
|
|
tty_putcode3(tty, TTYC_SETRGBF, r, g, b);
|
2020-04-20 13:25:36 +00:00
|
|
|
else if (tty_term_has(tty->term, TTYC_SETRGBB))
|
2017-05-31 08:43:44 +00:00
|
|
|
tty_putcode3(tty, TTYC_SETRGBB, r, g, b);
|
2016-07-15 00:49:08 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2016-01-29 11:13:56 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
return (-1);
|
2016-01-29 11:13:56 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 15:01:30 +00:00
|
|
|
static void
|
|
|
|
tty_window_default_style(struct grid_cell *gc, struct window_pane *wp)
|
|
|
|
{
|
|
|
|
memcpy(gc, &grid_default_cell, sizeof *gc);
|
2021-08-11 20:49:55 +00:00
|
|
|
gc->fg = wp->palette.fg;
|
|
|
|
gc->bg = wp->palette.bg;
|
2020-05-16 15:01:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 15:34:08 +00:00
|
|
|
void
|
2019-03-14 09:53:52 +00:00
|
|
|
tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
|
2015-04-19 21:05:27 +00:00
|
|
|
{
|
2021-08-12 19:47:05 +00:00
|
|
|
struct options *oo = wp->options;
|
|
|
|
struct format_tree *ft;
|
2020-05-16 15:34:08 +00:00
|
|
|
|
|
|
|
memcpy(gc, &grid_default_cell, sizeof *gc);
|
2019-06-20 11:59:59 +00:00
|
|
|
|
|
|
|
if (wp->flags & PANE_STYLECHANGED) {
|
2021-08-12 19:47:05 +00:00
|
|
|
log_debug("%%%u: style changed", wp->id);
|
2019-06-20 11:59:59 +00:00
|
|
|
wp->flags &= ~PANE_STYLECHANGED;
|
2020-05-16 15:01:30 +00:00
|
|
|
|
2021-08-12 19:47:05 +00:00
|
|
|
ft = format_create(NULL, NULL, FORMAT_PANE|wp->id,
|
|
|
|
FORMAT_NOJOBS);
|
|
|
|
format_defaults(ft, NULL, NULL, NULL, wp);
|
2020-05-16 15:01:30 +00:00
|
|
|
tty_window_default_style(&wp->cached_active_gc, wp);
|
2021-08-12 19:47:05 +00:00
|
|
|
style_add(&wp->cached_active_gc, oo, "window-active-style", ft);
|
2020-05-16 15:01:30 +00:00
|
|
|
tty_window_default_style(&wp->cached_gc, wp);
|
2021-08-12 19:47:05 +00:00
|
|
|
style_add(&wp->cached_gc, oo, "window-style", ft);
|
|
|
|
format_free(ft);
|
2016-05-30 09:50:20 +00:00
|
|
|
}
|
2015-04-19 21:05:27 +00:00
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->fg == 8) {
|
2020-05-16 14:53:23 +00:00
|
|
|
if (wp == wp->window->active && wp->cached_active_gc.fg != 8)
|
|
|
|
gc->fg = wp->cached_active_gc.fg;
|
2016-07-15 00:49:08 +00:00
|
|
|
else
|
2020-05-16 14:53:23 +00:00
|
|
|
gc->fg = wp->cached_gc.fg;
|
2015-04-19 21:05:27 +00:00
|
|
|
}
|
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gc->bg == 8) {
|
2020-05-16 14:53:23 +00:00
|
|
|
if (wp == wp->window->active && wp->cached_active_gc.bg != 8)
|
|
|
|
gc->bg = wp->cached_active_gc.bg;
|
2016-07-15 00:49:08 +00:00
|
|
|
else
|
2020-05-16 14:53:23 +00:00
|
|
|
gc->bg = wp->cached_gc.bg;
|
2015-04-19 21:05:27 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-13 20:27:27 +00:00
|
|
|
|
|
|
|
static void
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_default_attributes(struct tty *tty, const struct grid_cell *defaults,
|
2021-08-11 20:49:55 +00:00
|
|
|
struct colour_palette *palette, u_int bg)
|
2016-10-13 20:27:27 +00:00
|
|
|
{
|
2020-05-16 15:34:08 +00:00
|
|
|
struct grid_cell gc;
|
2016-10-13 20:27:27 +00:00
|
|
|
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
|
|
gc.bg = bg;
|
2020-05-16 15:34:08 +00:00
|
|
|
tty_attributes(tty, &gc, defaults, palette);
|
2016-10-13 20:27:27 +00:00
|
|
|
}
|
2022-02-15 13:03:02 +00:00
|
|
|
|
|
|
|
static void
|
2022-03-08 12:01:19 +00:00
|
|
|
tty_clipboard_query_callback(__unused int fd, __unused short events, void *data)
|
2022-02-15 13:03:02 +00:00
|
|
|
{
|
|
|
|
struct tty *tty = data;
|
2022-03-08 12:01:19 +00:00
|
|
|
struct client *c = tty->client;
|
|
|
|
|
|
|
|
c->flags &= ~CLIENT_CLIPBOARDBUFFER;
|
|
|
|
free(c->clipboard_panes);
|
|
|
|
c->clipboard_panes = NULL;
|
|
|
|
c->clipboard_npanes = 0;
|
2022-02-15 13:03:02 +00:00
|
|
|
|
|
|
|
tty->flags &= ~TTY_OSC52QUERY;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-08 12:01:19 +00:00
|
|
|
tty_clipboard_query(struct tty *tty)
|
2022-02-15 13:03:02 +00:00
|
|
|
{
|
|
|
|
struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT };
|
|
|
|
|
|
|
|
if ((~tty->flags & TTY_STARTED) || (tty->flags & TTY_OSC52QUERY))
|
|
|
|
return;
|
|
|
|
tty_putcode_ptr2(tty, TTYC_MS, "", "?");
|
|
|
|
|
2022-03-08 12:01:19 +00:00
|
|
|
tty->flags |= TTY_OSC52QUERY;
|
|
|
|
evtimer_set(&tty->clipboard_timer, tty_clipboard_query_callback, tty);
|
|
|
|
evtimer_add(&tty->clipboard_timer, &tv);
|
2022-02-15 13:03:02 +00:00
|
|
|
}
|