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>
|
|
|
|
|
2012-07-10 11:53:01 +00:00
|
|
|
#include <stdlib.h>
|
2009-06-01 22:58:49 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
static void screen_write_initctx(struct screen_write_ctx *,
|
|
|
|
struct tty_ctx *);
|
2017-02-08 16:45:18 +00:00
|
|
|
static void screen_write_collect_clear(struct screen_write_ctx *, u_int,
|
|
|
|
u_int);
|
|
|
|
static void screen_write_collect_scroll(struct screen_write_ctx *);
|
2017-02-09 09:33:15 +00:00
|
|
|
static void screen_write_collect_flush(struct screen_write_ctx *, int);
|
2016-05-27 23:02:17 +00:00
|
|
|
|
2016-05-30 09:32:24 +00:00
|
|
|
static int screen_write_overwrite(struct screen_write_ctx *,
|
|
|
|
struct grid_cell *, u_int);
|
2017-02-06 13:23:00 +00:00
|
|
|
static const struct grid_cell *screen_write_combine(struct screen_write_ctx *,
|
|
|
|
const struct utf8_data *, u_int *);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:06:12 +00:00
|
|
|
static const struct grid_cell screen_write_pad_cell = {
|
2016-07-15 00:49:08 +00:00
|
|
|
GRID_FLAG_PADDING, 0, 8, 8, { { 0 }, 0, 0, 0 }
|
2016-05-27 23:06:12 +00:00
|
|
|
};
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
struct screen_write_collect_item {
|
|
|
|
u_int x;
|
2017-04-25 18:30:29 +00:00
|
|
|
int wrapped;
|
2017-02-08 16:45:18 +00:00
|
|
|
|
|
|
|
u_int used;
|
|
|
|
char data[256];
|
|
|
|
|
|
|
|
struct grid_cell gc;
|
|
|
|
|
2017-05-31 17:56:48 +00:00
|
|
|
TAILQ_ENTRY(screen_write_collect_item) entry;
|
2017-02-08 16:45:18 +00:00
|
|
|
};
|
|
|
|
struct screen_write_collect_line {
|
|
|
|
TAILQ_HEAD(, screen_write_collect_item) items;
|
|
|
|
};
|
2016-07-15 00:49:08 +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
|
|
|
static void
|
|
|
|
screen_write_offset_timer(__unused int fd, __unused short events, void *data)
|
|
|
|
{
|
|
|
|
struct window *w = data;
|
|
|
|
|
|
|
|
tty_update_window_offset(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set cursor position. */
|
|
|
|
static void
|
|
|
|
screen_write_set_cursor(struct screen_write_ctx *ctx, int cx, int cy)
|
|
|
|
{
|
|
|
|
struct window_pane *wp = ctx->wp;
|
|
|
|
struct window *w;
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct timeval tv = { .tv_usec = 10000 };
|
|
|
|
|
|
|
|
if (cx != -1 && (u_int)cx == s->cx && cy != -1 && (u_int)cy == s->cy)
|
|
|
|
return;
|
|
|
|
|
2019-03-12 07:39:27 +00:00
|
|
|
if (cx != -1) {
|
2019-03-12 13:14:14 +00:00
|
|
|
if ((u_int)cx > screen_size_x(s)) /* allow last column */
|
2019-03-12 07:39:27 +00:00
|
|
|
cx = screen_size_x(s) - 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
|
|
|
s->cx = cx;
|
2019-03-12 07:39:27 +00:00
|
|
|
}
|
|
|
|
if (cy != -1) {
|
|
|
|
if ((u_int)cy > screen_size_y(s) - 1)
|
|
|
|
cy = screen_size_y(s) - 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
|
|
|
s->cy = cy;
|
2019-03-12 07:39: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
|
|
|
|
|
|
|
if (wp == NULL)
|
|
|
|
return;
|
|
|
|
w = wp->window;
|
|
|
|
|
|
|
|
if (!event_initialized(&w->offset_timer))
|
|
|
|
evtimer_set(&w->offset_timer, screen_write_offset_timer, w);
|
|
|
|
if (!evtimer_pending(&w->offset_timer, NULL))
|
|
|
|
evtimer_add(&w->offset_timer, &tv);
|
|
|
|
}
|
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
/* Initialize writing with a window. */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2014-10-20 23:57:13 +00:00
|
|
|
screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
|
|
|
|
struct screen *s)
|
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
|
|
|
char tmp[32];
|
2017-02-08 16:45:18 +00:00
|
|
|
u_int y;
|
|
|
|
|
|
|
|
memset(ctx, 0, sizeof *ctx);
|
2016-07-15 00:49:08 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
ctx->wp = wp;
|
|
|
|
if (wp != NULL && s == NULL)
|
|
|
|
ctx->s = wp->screen;
|
|
|
|
else
|
|
|
|
ctx->s = s;
|
2016-07-15 00:49:08 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
ctx->list = xcalloc(screen_size_y(ctx->s), sizeof *ctx->list);
|
|
|
|
for (y = 0; y < screen_size_y(ctx->s); y++)
|
|
|
|
TAILQ_INIT(&ctx->list[y].items);
|
|
|
|
ctx->item = xcalloc(1, sizeof *ctx->item);
|
2016-07-15 00:49:08 +00:00
|
|
|
|
2017-05-12 13:00:56 +00:00
|
|
|
ctx->scrolled = 0;
|
|
|
|
ctx->bg = 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
|
|
|
if (wp != NULL) {
|
|
|
|
snprintf(tmp, sizeof tmp, "pane %%%u (at %u,%u)", wp->id,
|
|
|
|
wp->xoff, wp->yoff);
|
|
|
|
}
|
2016-07-15 00:49:08 +00:00
|
|
|
log_debug("%s: size %ux%u, %s", __func__, screen_size_x(ctx->s),
|
2017-02-08 15:49:29 +00:00
|
|
|
screen_size_y(ctx->s), wp == NULL ? "no pane" : tmp);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish writing. */
|
|
|
|
void
|
2016-07-15 00:49:08 +00:00
|
|
|
screen_write_stop(struct screen_write_ctx *ctx)
|
|
|
|
{
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_end(ctx);
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2016-07-15 00:49:08 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
log_debug("%s: %u cells (%u written, %u skipped)", __func__,
|
|
|
|
ctx->cells, ctx->written, ctx->skipped);
|
2016-07-15 00:49:08 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
free(ctx->item);
|
|
|
|
free(ctx->list); /* flush will have emptied */
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2012-01-21 08:10:21 +00:00
|
|
|
/* Reset screen state. */
|
|
|
|
void
|
|
|
|
screen_write_reset(struct screen_write_ctx *ctx)
|
|
|
|
{
|
2013-03-21 18:47:56 +00:00
|
|
|
struct screen *s = ctx->s;
|
2012-01-21 08:10:21 +00:00
|
|
|
|
2013-03-21 18:47:56 +00:00
|
|
|
screen_reset_tabs(s);
|
|
|
|
screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1);
|
2013-03-22 10:33:50 +00:00
|
|
|
|
2018-10-31 10:05:47 +00:00
|
|
|
s->mode = MODE_CURSOR | MODE_WRAP;
|
2012-01-21 08:10:21 +00:00
|
|
|
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearscreen(ctx, 8);
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, 0, 0);
|
2012-01-21 08:10:21 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Write character. */
|
|
|
|
void
|
2016-04-29 13:21:33 +00:00
|
|
|
screen_write_putc(struct screen_write_ctx *ctx, const struct grid_cell *gcp,
|
2014-04-17 14:45:49 +00:00
|
|
|
u_char ch)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2016-04-29 13:21:33 +00:00
|
|
|
struct grid_cell gc;
|
|
|
|
|
|
|
|
memcpy(&gc, gcp, sizeof gc);
|
|
|
|
|
|
|
|
utf8_set(&gc.data, ch);
|
|
|
|
screen_write_cell(ctx, &gc);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 16:05:46 +00:00
|
|
|
/* Calculate string length. */
|
2014-10-20 23:57:13 +00:00
|
|
|
size_t
|
2015-11-12 11:09:11 +00:00
|
|
|
screen_write_strlen(const char *fmt, ...)
|
2009-06-03 16:05:46 +00:00
|
|
|
{
|
2009-10-20 19:18:28 +00:00
|
|
|
va_list ap;
|
|
|
|
char *msg;
|
2015-11-12 22:04:37 +00:00
|
|
|
struct utf8_data ud;
|
2009-10-20 19:18:28 +00:00
|
|
|
u_char *ptr;
|
|
|
|
size_t left, size = 0;
|
2015-11-14 11:45:43 +00:00
|
|
|
enum utf8_state more;
|
2009-06-03 16:05:46 +00:00
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
xvasprintf(&msg, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
ptr = msg;
|
|
|
|
while (*ptr != '\0') {
|
2015-11-14 11:45:43 +00:00
|
|
|
if (*ptr > 0x7f && utf8_open(&ud, *ptr) == UTF8_MORE) {
|
2009-10-20 19:18:28 +00:00
|
|
|
ptr++;
|
2009-06-03 16:05:46 +00:00
|
|
|
|
|
|
|
left = strlen(ptr);
|
2015-11-13 08:09:28 +00:00
|
|
|
if (left < (size_t)ud.size - 1)
|
2009-10-20 19:18:28 +00:00
|
|
|
break;
|
2015-11-14 11:45:43 +00:00
|
|
|
while ((more = utf8_append(&ud, *ptr)) == UTF8_MORE)
|
2009-06-03 16:05:46 +00:00
|
|
|
ptr++;
|
2009-10-20 19:18:28 +00:00
|
|
|
ptr++;
|
|
|
|
|
2015-11-14 11:45:43 +00:00
|
|
|
if (more == UTF8_DONE)
|
2015-11-14 10:56:31 +00:00
|
|
|
size += ud.width;
|
2009-06-03 16:05:46 +00:00
|
|
|
} else {
|
2015-11-12 11:09:11 +00:00
|
|
|
if (*ptr > 0x1f && *ptr < 0x7f)
|
|
|
|
size++;
|
2009-06-03 16:05:46 +00:00
|
|
|
ptr++;
|
|
|
|
}
|
2009-06-05 03:13:16 +00:00
|
|
|
}
|
2009-06-03 16:05:46 +00:00
|
|
|
|
2012-07-10 11:53:01 +00:00
|
|
|
free(msg);
|
2009-06-03 16:05:46 +00:00
|
|
|
return (size);
|
|
|
|
}
|
|
|
|
|
2009-06-03 16:54:26 +00:00
|
|
|
/* Write simple string (no UTF-8 or maximum length). */
|
2014-10-20 23:57:13 +00:00
|
|
|
void
|
2016-04-29 13:21:33 +00:00
|
|
|
screen_write_puts(struct screen_write_ctx *ctx, const struct grid_cell *gcp,
|
2014-10-20 23:57:13 +00:00
|
|
|
const char *fmt, ...)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2016-04-29 13:21:33 +00:00
|
|
|
screen_write_vnputs(ctx, -1, gcp, fmt, ap);
|
2009-06-01 22:58:49 +00:00
|
|
|
va_end(ap);
|
2009-06-03 16:05:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write string with length limit (-1 for unlimited). */
|
2014-10-20 23:57:13 +00:00
|
|
|
void
|
|
|
|
screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
2016-04-29 13:21:33 +00:00
|
|
|
const struct grid_cell *gcp, const char *fmt, ...)
|
2009-06-03 16:05:46 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2016-04-29 13:21:33 +00:00
|
|
|
screen_write_vnputs(ctx, maxlen, gcp, fmt, ap);
|
2009-06-03 16:05:46 +00:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-03 16:54:26 +00:00
|
|
|
screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
2016-04-29 13:21:33 +00:00
|
|
|
const struct grid_cell *gcp, const char *fmt, va_list ap)
|
2009-06-03 16:05:46 +00:00
|
|
|
{
|
2016-04-29 13:21:33 +00:00
|
|
|
struct grid_cell gc;
|
|
|
|
struct utf8_data *ud = &gc.data;
|
2009-10-20 19:18:28 +00:00
|
|
|
char *msg;
|
|
|
|
u_char *ptr;
|
|
|
|
size_t left, size = 0;
|
2015-11-14 11:45:43 +00:00
|
|
|
enum utf8_state more;
|
2009-06-03 16:05:46 +00:00
|
|
|
|
2016-04-29 13:21:33 +00:00
|
|
|
memcpy(&gc, gcp, sizeof gc);
|
2009-06-03 16:05:46 +00:00
|
|
|
xvasprintf(&msg, fmt, ap);
|
|
|
|
|
|
|
|
ptr = msg;
|
|
|
|
while (*ptr != '\0') {
|
2016-04-29 13:21:33 +00:00
|
|
|
if (*ptr > 0x7f && utf8_open(ud, *ptr) == UTF8_MORE) {
|
2009-10-20 19:18:28 +00:00
|
|
|
ptr++;
|
2009-06-03 16:05:46 +00:00
|
|
|
|
|
|
|
left = strlen(ptr);
|
2016-04-29 13:21:33 +00:00
|
|
|
if (left < (size_t)ud->size - 1)
|
2009-10-20 19:18:28 +00:00
|
|
|
break;
|
2016-04-29 13:21:33 +00:00
|
|
|
while ((more = utf8_append(ud, *ptr)) == UTF8_MORE)
|
2009-06-03 16:05:46 +00:00
|
|
|
ptr++;
|
2009-10-20 19:18:28 +00:00
|
|
|
ptr++;
|
2009-06-05 03:13:16 +00:00
|
|
|
|
2016-04-29 13:21:33 +00:00
|
|
|
if (more != UTF8_DONE)
|
|
|
|
continue;
|
|
|
|
if (maxlen > 0 && size + ud->width > (size_t)maxlen) {
|
|
|
|
while (size < (size_t)maxlen) {
|
|
|
|
screen_write_putc(ctx, &gc, ' ');
|
|
|
|
size++;
|
2009-06-03 16:05:46 +00:00
|
|
|
}
|
2016-04-29 13:21:33 +00:00
|
|
|
break;
|
2015-11-14 10:56:31 +00:00
|
|
|
}
|
2016-04-29 13:21:33 +00:00
|
|
|
size += ud->width;
|
|
|
|
screen_write_cell(ctx, &gc);
|
2009-06-03 16:05:46 +00:00
|
|
|
} else {
|
2016-04-29 13:21:33 +00:00
|
|
|
if (maxlen > 0 && size + 1 > (size_t)maxlen)
|
2009-06-03 16:05:46 +00:00
|
|
|
break;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2012-09-24 12:53:55 +00:00
|
|
|
if (*ptr == '\001')
|
2016-04-29 13:21:33 +00:00
|
|
|
gc.attr ^= GRID_ATTR_CHARSET;
|
2015-11-12 11:09:11 +00:00
|
|
|
else if (*ptr > 0x1f && *ptr < 0x7f) {
|
2012-09-24 12:53:55 +00:00
|
|
|
size++;
|
2016-04-29 13:21:33 +00:00
|
|
|
screen_write_putc(ctx, &gc, *ptr);
|
2012-09-24 12:53:55 +00:00
|
|
|
}
|
2009-06-03 16:05:46 +00:00
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2012-07-10 11:53:01 +00:00
|
|
|
free(msg);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 21:29:17 +00:00
|
|
|
/* Copy from another screen. Assumes target region is big enough. */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2016-10-05 12:36:36 +00:00
|
|
|
screen_write_copy(struct screen_write_ctx *ctx, struct screen *src, u_int px,
|
2017-11-02 21:29:17 +00:00
|
|
|
u_int py, u_int nx, u_int ny, bitstr_t *mbs, const struct grid_cell *mgc)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = src->grid;
|
2015-11-13 08:09:28 +00:00
|
|
|
struct grid_cell gc;
|
2017-01-05 09:07:15 +00:00
|
|
|
u_int xx, yy, cx, cy, b;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
if (nx == 0 || ny == 0)
|
|
|
|
return;
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
2016-10-05 22:00:29 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
for (yy = py; yy < py + ny; yy++) {
|
2016-10-05 22:00:29 +00:00
|
|
|
for (xx = px; xx < px + nx; xx++) {
|
|
|
|
grid_get_cell(gd, xx, yy, &gc);
|
2017-11-02 21:29:17 +00:00
|
|
|
if (mbs != NULL) {
|
2017-01-05 09:07:15 +00:00
|
|
|
b = (yy * screen_size_x(src)) + xx;
|
2017-11-02 21:29:17 +00:00
|
|
|
if (bit_test(mbs, b)) {
|
|
|
|
gc.attr = mgc->attr;
|
|
|
|
gc.fg = mgc->fg;
|
|
|
|
gc.bg = mgc->bg;
|
2017-01-05 09:07:15 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-15 19:21:24 +00:00
|
|
|
if (xx + gc.data.width <= px + nx)
|
|
|
|
screen_write_cell(ctx, &gc);
|
2016-10-05 22:00:29 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
cy++;
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-02 21:29:17 +00:00
|
|
|
/*
|
|
|
|
* Copy from another screen but without the selection stuff. Also assumes the
|
2019-04-03 06:43:04 +00:00
|
|
|
* target region is already big enough.
|
2017-11-02 21:29:17 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
|
|
|
|
u_int px, u_int py, u_int nx, u_int ny)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = src->grid;
|
|
|
|
struct grid_cell gc;
|
|
|
|
u_int xx, yy, cx, cy;
|
|
|
|
|
|
|
|
if (nx == 0 || ny == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cy = s->cy;
|
|
|
|
for (yy = py; yy < py + ny; yy++) {
|
2017-11-03 17:02:33 +00:00
|
|
|
if (yy >= gd->hsize + gd->sy)
|
|
|
|
break;
|
2017-11-02 21:29:17 +00:00
|
|
|
cx = s->cx;
|
|
|
|
for (xx = px; xx < px + nx; xx++) {
|
2018-07-04 09:44:07 +00:00
|
|
|
if (xx >= grid_get_line(gd, yy)->cellsize)
|
2017-11-02 21:29:17 +00:00
|
|
|
break;
|
|
|
|
grid_get_cell(gd, xx, yy, &gc);
|
2017-11-15 19:21:24 +00:00
|
|
|
if (xx + gc.data.width > px + nx)
|
|
|
|
break;
|
2019-04-03 06:43:04 +00:00
|
|
|
grid_view_set_cell(ctx->s->grid, cx, cy, &gc);
|
2017-11-02 21:29:17 +00:00
|
|
|
cx++;
|
|
|
|
}
|
|
|
|
cy++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-30 22:24:08 +00:00
|
|
|
/* Draw a horizontal line on screen. */
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
void
|
2017-06-30 22:24:08 +00:00
|
|
|
screen_write_hline(struct screen_write_ctx *ctx, u_int nx, int left, int right)
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_cell gc;
|
|
|
|
u_int cx, cy, i;
|
|
|
|
|
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
|
|
|
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
|
|
gc.attr |= GRID_ATTR_CHARSET;
|
|
|
|
|
|
|
|
screen_write_putc(ctx, &gc, left ? 't' : 'q');
|
|
|
|
for (i = 1; i < nx - 1; i++)
|
|
|
|
screen_write_putc(ctx, &gc, 'q');
|
|
|
|
screen_write_putc(ctx, &gc, right ? 'u' : 'q');
|
|
|
|
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
2017-06-30 22:24:08 +00:00
|
|
|
/* Draw a horizontal line on screen. */
|
|
|
|
void
|
2017-08-09 11:43:45 +00:00
|
|
|
screen_write_vline(struct screen_write_ctx *ctx, u_int ny, int top, int bottom)
|
2017-06-30 22:24:08 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_cell gc;
|
|
|
|
u_int cx, cy, i;
|
|
|
|
|
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
|
|
|
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
|
|
gc.attr |= GRID_ATTR_CHARSET;
|
|
|
|
|
|
|
|
screen_write_putc(ctx, &gc, top ? 'w' : 'x');
|
|
|
|
for (i = 1; i < ny - 1; i++) {
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy + i);
|
2017-06-30 22:24:08 +00:00
|
|
|
screen_write_putc(ctx, &gc, 'x');
|
|
|
|
}
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy + ny - 1);
|
2017-06-30 22:24:08 +00:00
|
|
|
screen_write_putc(ctx, &gc, bottom ? 'v' : 'x');
|
|
|
|
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2017-06-30 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
/* Draw a box on screen. */
|
|
|
|
void
|
|
|
|
screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_cell gc;
|
|
|
|
u_int cx, cy, i;
|
|
|
|
|
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
|
|
|
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
|
|
|
gc.attr |= GRID_ATTR_CHARSET;
|
|
|
|
|
|
|
|
screen_write_putc(ctx, &gc, 'l');
|
|
|
|
for (i = 1; i < nx - 1; i++)
|
|
|
|
screen_write_putc(ctx, &gc, 'q');
|
|
|
|
screen_write_putc(ctx, &gc, 'k');
|
|
|
|
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy + ny - 1);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_putc(ctx, &gc, 'm');
|
|
|
|
for (i = 1; i < nx - 1; i++)
|
|
|
|
screen_write_putc(ctx, &gc, 'q');
|
|
|
|
screen_write_putc(ctx, &gc, 'j');
|
|
|
|
|
|
|
|
for (i = 1; i < ny - 1; i++) {
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy + i);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_putc(ctx, &gc, 'x');
|
|
|
|
}
|
|
|
|
for (i = 1; i < ny - 1; i++) {
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx + nx - 1, cy + i);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
screen_write_putc(ctx, &gc, 'x');
|
|
|
|
}
|
|
|
|
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 21:29:17 +00:00
|
|
|
/*
|
|
|
|
* Write a preview version of a window. Assumes target area is big enough and
|
|
|
|
* already cleared.
|
|
|
|
*/
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
void
|
|
|
|
screen_write_preview(struct screen_write_ctx *ctx, struct screen *src, u_int nx,
|
|
|
|
u_int ny)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_cell gc;
|
|
|
|
u_int cx, cy, px, py;
|
|
|
|
|
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the cursor is on, pick the area around the cursor, otherwise use
|
|
|
|
* the top left.
|
|
|
|
*/
|
|
|
|
if (src->mode & MODE_CURSOR) {
|
|
|
|
px = src->cx;
|
|
|
|
if (px < nx / 3)
|
|
|
|
px = 0;
|
|
|
|
else
|
|
|
|
px = px - nx / 3;
|
|
|
|
if (px + nx > screen_size_x(src)) {
|
|
|
|
if (nx > screen_size_x(src))
|
|
|
|
px = 0;
|
|
|
|
else
|
|
|
|
px = screen_size_x(src) - nx;
|
|
|
|
}
|
|
|
|
py = src->cy;
|
|
|
|
if (py < ny / 3)
|
|
|
|
py = 0;
|
|
|
|
else
|
|
|
|
py = py - ny / 3;
|
|
|
|
if (py + ny > screen_size_y(src)) {
|
|
|
|
if (ny > screen_size_y(src))
|
|
|
|
py = 0;
|
|
|
|
else
|
|
|
|
py = screen_size_y(src) - ny;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
px = 0;
|
|
|
|
py = 0;
|
|
|
|
}
|
|
|
|
|
2017-11-02 21:29:17 +00:00
|
|
|
screen_write_fast_copy(ctx, src, px, src->grid->hsize + py, nx, ny);
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
|
|
|
|
if (src->mode & MODE_CURSOR) {
|
|
|
|
grid_view_get_cell(src->grid, src->cx, src->cy, &gc);
|
|
|
|
gc.attr |= GRID_ATTR_REVERSE;
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, cx + (src->cx - px),
|
Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.
Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.
Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:
- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;
- items may be sorted in different ways ('O' key);
- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);
- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');
- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');
- the custom format (-F) for the display is no longer available;
- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.
Now that the code is simpler, other improvements will come later.
Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).
Parts written by Thomas Adam.
2017-05-30 21:44:59 +00:00
|
|
|
cy + (src->cy - py));
|
|
|
|
screen_write_cell(ctx, &gc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-22 20:53:38 +00:00
|
|
|
/* Set up context for TTY command. */
|
2016-05-27 23:02:17 +00:00
|
|
|
static void
|
|
|
|
screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2016-05-27 23:02:17 +00:00
|
|
|
struct screen *s = ctx->s;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-05-12 13:29:05 +00:00
|
|
|
memset(ttyctx, 0, sizeof *ttyctx);
|
|
|
|
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx->wp = ctx->wp;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx->ocx = s->cx;
|
|
|
|
ttyctx->ocy = s->cy;
|
|
|
|
|
|
|
|
ttyctx->orlower = s->rlower;
|
|
|
|
ttyctx->orupper = s->rupper;
|
2016-05-27 23:02:17 +00:00
|
|
|
}
|
2009-10-17 08:24:46 +00:00
|
|
|
|
2013-03-21 18:47:56 +00:00
|
|
|
/* Set a mode. */
|
|
|
|
void
|
|
|
|
screen_write_mode_set(struct screen_write_ctx *ctx, int mode)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
|
|
|
|
s->mode |= mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear a mode. */
|
|
|
|
void
|
|
|
|
screen_write_mode_clear(struct screen_write_ctx *ctx, int mode)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
|
|
|
|
s->mode &= ~mode;
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Cursor up by ny. */
|
|
|
|
void
|
|
|
|
screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->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
|
|
|
u_int cx = s->cx, cy = s->cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (ny == 0)
|
|
|
|
ny = 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
|
|
|
if (cy < s->rupper) {
|
2009-07-09 17:57:11 +00:00
|
|
|
/* Above region. */
|
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 (ny > cy)
|
|
|
|
ny = cy;
|
2009-07-09 17:57:11 +00:00
|
|
|
} else {
|
|
|
|
/* Below region. */
|
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 (ny > cy - s->rupper)
|
|
|
|
ny = cy - s->rupper;
|
2009-07-09 17:57:11 +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 (cx == screen_size_x(s))
|
|
|
|
cx--;
|
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
|
|
|
cy -= ny;
|
|
|
|
|
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cursor down by ny. */
|
|
|
|
void
|
|
|
|
screen_write_cursordown(struct screen_write_ctx *ctx, u_int ny)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->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
|
|
|
u_int cx = s->cx, cy = s->cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (ny == 0)
|
|
|
|
ny = 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
|
|
|
if (cy > s->rlower) {
|
2009-07-09 17:57:11 +00:00
|
|
|
/* Below region. */
|
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 (ny > screen_size_y(s) - 1 - cy)
|
|
|
|
ny = screen_size_y(s) - 1 - cy;
|
2009-07-09 17:57:11 +00:00
|
|
|
} else {
|
|
|
|
/* Above region. */
|
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 (ny > s->rlower - cy)
|
|
|
|
ny = s->rlower - cy;
|
2009-07-09 17:57:11 +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 (cx == screen_size_x(s))
|
|
|
|
cx--;
|
|
|
|
else if (ny == 0)
|
2009-06-01 22:58:49 +00:00
|
|
|
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
|
|
|
cy += ny;
|
|
|
|
|
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 21:39:27 +00:00
|
|
|
/* Cursor right by nx. */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
|
|
|
screen_write_cursorright(struct screen_write_ctx *ctx, u_int nx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->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
|
|
|
u_int cx = s->cx, cy = s->cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (nx == 0)
|
|
|
|
nx = 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
|
|
|
if (nx > screen_size_x(s) - 1 - cx)
|
|
|
|
nx = screen_size_x(s) - 1 - cx;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (nx == 0)
|
|
|
|
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
|
|
|
cx += nx;
|
|
|
|
|
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cursor left by nx. */
|
|
|
|
void
|
|
|
|
screen_write_cursorleft(struct screen_write_ctx *ctx, u_int nx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->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
|
|
|
u_int cx = s->cx, cy = s->cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (nx == 0)
|
|
|
|
nx = 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
|
|
|
if (nx > cx)
|
|
|
|
nx = cx;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (nx == 0)
|
|
|
|
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
|
|
|
cx -= nx;
|
|
|
|
|
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 16:59:55 +00:00
|
|
|
/* Backspace; cursor left unless at start of wrapped line when can move up. */
|
|
|
|
void
|
|
|
|
screen_write_backspace(struct screen_write_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_line *gl;
|
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 = s->cx, cy = s->cy;
|
2009-10-12 16:59:55 +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 (cx == 0) {
|
|
|
|
if (cy == 0)
|
2009-10-12 16:59:55 +00:00
|
|
|
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
|
|
|
gl = grid_get_line(s->grid, s->grid->hsize + cy - 1);
|
2009-10-12 16:59:55 +00:00
|
|
|
if (gl->flags & GRID_LINE_WRAPPED) {
|
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
|
|
|
cy--;
|
|
|
|
cx = screen_size_x(s) - 1;
|
2009-10-12 16:59:55 +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
|
|
|
cx--;
|
|
|
|
|
|
|
|
screen_write_set_cursor(ctx, cx, cy);
|
2009-10-12 16:59:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 23:30:40 +00:00
|
|
|
/* VT100 alignment test. */
|
|
|
|
void
|
|
|
|
screen_write_alignmenttest(struct screen_write_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-03 23:30:40 +00:00
|
|
|
struct grid_cell gc;
|
|
|
|
u_int xx, yy;
|
|
|
|
|
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
2015-11-13 08:09:28 +00:00
|
|
|
utf8_set(&gc.data, 'E');
|
2009-06-05 03:13:16 +00:00
|
|
|
|
2009-06-03 23:30:40 +00:00
|
|
|
for (yy = 0; yy < screen_size_y(s); yy++) {
|
|
|
|
for (xx = 0; xx < screen_size_x(s); xx++)
|
|
|
|
grid_view_set_cell(s->grid, xx, yy, &gc);
|
|
|
|
}
|
2009-06-05 03:13: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
|
|
|
screen_write_set_cursor(ctx, 0, 0);
|
2009-06-03 23:30:40 +00:00
|
|
|
|
|
|
|
s->rupper = 0;
|
|
|
|
s->rlower = screen_size_y(s) - 1;
|
|
|
|
|
2018-11-13 11:36:37 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, 0, screen_size_y(s) - 1);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_alignmenttest, &ttyctx);
|
2009-06-03 23:30:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Insert nx characters. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (nx == 0)
|
|
|
|
nx = 1;
|
|
|
|
|
2009-06-29 21:30:50 +00:00
|
|
|
if (nx > screen_size_x(s) - s->cx)
|
|
|
|
nx = screen_size_x(s) - s->cx;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (nx == 0)
|
|
|
|
return;
|
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
if (s->cx > screen_size_x(s) - 1)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = nx;
|
|
|
|
tty_write(tty_cmd_insertcharacter, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete nx characters. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (nx == 0)
|
|
|
|
nx = 1;
|
|
|
|
|
2009-06-29 21:30:50 +00:00
|
|
|
if (nx > screen_size_x(s) - s->cx)
|
|
|
|
nx = screen_size_x(s) - s->cx;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (nx == 0)
|
|
|
|
return;
|
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
if (s->cx > screen_size_x(s) - 1)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = nx;
|
|
|
|
tty_write(tty_cmd_deletecharacter, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 23:18:55 +00:00
|
|
|
/* Clear nx characters. */
|
|
|
|
void
|
2017-05-12 10:50:11 +00:00
|
|
|
screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
|
2013-01-15 23:18:55 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct tty_ctx ttyctx;
|
|
|
|
|
|
|
|
if (nx == 0)
|
|
|
|
nx = 1;
|
|
|
|
|
|
|
|
if (nx > screen_size_x(s) - s->cx)
|
|
|
|
nx = screen_size_x(s) - s->cx;
|
|
|
|
if (nx == 0)
|
|
|
|
return;
|
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
if (s->cx > screen_size_x(s) - 1)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-05-12 10:50:11 +00:00
|
|
|
ttyctx.bg = bg;
|
2013-01-15 23:18:55 +00:00
|
|
|
|
2017-05-12 14:56:56 +00:00
|
|
|
grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg);
|
2013-01-15 23:18:55 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2013-01-15 23:18:55 +00:00
|
|
|
ttyctx.num = nx;
|
|
|
|
tty_write(tty_cmd_clearcharacter, &ttyctx);
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Insert ny lines. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2017-02-08 15:49:29 +00:00
|
|
|
struct grid *gd = s->grid;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (ny == 0)
|
|
|
|
ny = 1;
|
|
|
|
|
2009-07-09 07:58:14 +00:00
|
|
|
if (s->cy < s->rupper || s->cy > s->rlower) {
|
|
|
|
if (ny > screen_size_y(s) - s->cy)
|
|
|
|
ny = screen_size_y(s) - s->cy;
|
|
|
|
if (ny == 0)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-07-09 07:58:14 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_insert_lines(gd, s->cy, ny, bg);
|
2009-07-09 07:58:14 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = ny;
|
|
|
|
tty_write(tty_cmd_insertline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2009-07-09 07:58:14 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2009-07-09 07:58:14 +00:00
|
|
|
if (ny > s->rlower + 1 - s->cy)
|
|
|
|
ny = s->rlower + 1 - s->cy;
|
|
|
|
if (ny == 0)
|
|
|
|
return;
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (s->cy < s->rupper || s->cy > s->rlower)
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_insert_lines(gd, s->cy, ny, bg);
|
|
|
|
else
|
|
|
|
grid_view_insert_lines_region(gd, s->rlower, s->cy, ny, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = ny;
|
|
|
|
tty_write(tty_cmd_insertline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete ny lines. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2017-02-08 15:49:29 +00:00
|
|
|
struct grid *gd = s->grid;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (ny == 0)
|
|
|
|
ny = 1;
|
|
|
|
|
2009-07-09 07:58:14 +00:00
|
|
|
if (s->cy < s->rupper || s->cy > s->rlower) {
|
|
|
|
if (ny > screen_size_y(s) - s->cy)
|
|
|
|
ny = screen_size_y(s) - s->cy;
|
|
|
|
if (ny == 0)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-07-09 07:58:14 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_delete_lines(gd, s->cy, ny, bg);
|
2009-07-09 07:58:14 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = ny;
|
|
|
|
tty_write(tty_cmd_deleteline, &ttyctx);
|
2009-07-09 07:58:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2009-07-09 07:58:14 +00:00
|
|
|
if (ny > s->rlower + 1 - s->cy)
|
|
|
|
ny = s->rlower + 1 - s->cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
if (ny == 0)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-08 15:49:29 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
if (s->cy < s->rupper || s->cy > s->rlower)
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_delete_lines(gd, s->cy, ny, bg);
|
|
|
|
else
|
|
|
|
grid_view_delete_lines_region(gd, s->rlower, s->cy, ny, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = ny;
|
|
|
|
tty_write(tty_cmd_deleteline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear line at cursor. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearline(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2016-07-15 00:49:08 +00:00
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_line *gl;
|
|
|
|
struct tty_ctx ttyctx;
|
|
|
|
u_int sx = screen_size_x(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2018-07-04 09:44:07 +00:00
|
|
|
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
2018-10-25 15:13:38 +00:00
|
|
|
if (gl->cellsize == 0 && COLOUR_DEFAULT(bg))
|
2016-07-15 00:49:08 +00:00
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
ttyctx.bg = bg;
|
|
|
|
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, s->cy, 1);
|
2017-02-21 10:30:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_clearline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear to end of line from cursor. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2016-07-15 00:49:08 +00:00
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid_line *gl;
|
|
|
|
struct tty_ctx ttyctx;
|
|
|
|
u_int sx = screen_size_x(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2018-07-04 09:44:07 +00:00
|
|
|
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
2018-10-25 15:13:38 +00:00
|
|
|
if (s->cx > sx - 1 || (s->cx >= gl->cellsize && COLOUR_DEFAULT(bg)))
|
2016-07-15 00:49:08 +00:00
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
ttyctx.bg = bg;
|
|
|
|
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1, bg);
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx == 0)
|
|
|
|
screen_write_collect_clear(ctx, s->cy, 1);
|
2017-02-21 10:30:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-12-03 22:50:09 +00:00
|
|
|
tty_write(tty_cmd_clearendofline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear to start of line from cursor. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearstartofline(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2016-07-15 00:49:08 +00:00
|
|
|
u_int sx = screen_size_x(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2016-10-13 20:27:27 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx > sx - 1)
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
else
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx > sx - 1)
|
|
|
|
screen_write_collect_clear(ctx, s->cy, 1);
|
2017-02-21 10:30:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_clearstartofline, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 21:39:27 +00:00
|
|
|
/* Move cursor to px,py. */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2019-03-12 20:02:47 +00:00
|
|
|
screen_write_cursormove(struct screen_write_ctx *ctx, int px, int py,
|
|
|
|
int origin)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
|
2019-03-12 20:02:47 +00:00
|
|
|
if (origin && py != -1 && (s->mode & MODE_ORIGIN)) {
|
2019-03-12 18:30:08 +00:00
|
|
|
if ((u_int)py > s->rlower - s->rupper)
|
2019-03-12 07:39:27 +00:00
|
|
|
py = s->rlower;
|
|
|
|
else
|
|
|
|
py += s->rupper;
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2019-03-12 18:30:08 +00:00
|
|
|
if (px != -1 && (u_int)px > screen_size_x(s) - 1)
|
2019-03-12 13:14:14 +00:00
|
|
|
px = screen_size_x(s) - 1;
|
2019-03-12 18:30:08 +00:00
|
|
|
if (py != -1 && (u_int)py > screen_size_y(s) - 1)
|
2019-03-12 13:14:14 +00:00
|
|
|
py = screen_size_y(s) - 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
|
|
|
screen_write_set_cursor(ctx, px, py);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 21:39:27 +00:00
|
|
|
/* Reverse index (up with scroll). */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-05-12 13:00:56 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cy == s->rupper)
|
2017-05-12 13:00:56 +00:00
|
|
|
grid_view_scroll_region_down(s->grid, s->rupper, s->rlower, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
else if (s->cy > 0)
|
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
|
|
|
screen_write_set_cursor(ctx, -1, s->cy - 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_reverseindex, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set scroll region. */
|
|
|
|
void
|
2015-12-11 16:37:21 +00:00
|
|
|
screen_write_scrollregion(struct screen_write_ctx *ctx, u_int rupper,
|
|
|
|
u_int rlower)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
|
|
|
|
if (rupper > screen_size_y(s) - 1)
|
|
|
|
rupper = screen_size_y(s) - 1;
|
|
|
|
if (rlower > screen_size_y(s) - 1)
|
|
|
|
rlower = screen_size_y(s) - 1;
|
2009-07-14 14:47:32 +00:00
|
|
|
if (rupper >= rlower) /* cannot be one line */
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2017-02-08 17:31:09 +00:00
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Cursor moves to top-left. */
|
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
|
|
|
screen_write_set_cursor(ctx, 0, 0);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
s->rupper = rupper;
|
|
|
|
s->rlower = rlower;
|
|
|
|
}
|
|
|
|
|
2009-10-20 16:32:23 +00:00
|
|
|
/* Line feed. */
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2009-08-08 15:57:49 +00:00
|
|
|
struct screen *s = ctx->s;
|
2017-02-08 16:45:18 +00:00
|
|
|
struct grid *gd = s->grid;
|
2009-08-08 15:57:49 +00:00
|
|
|
struct grid_line *gl;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2018-07-04 09:44:07 +00:00
|
|
|
gl = grid_get_line(gd, gd->hsize + s->cy);
|
2009-08-08 15:57:49 +00:00
|
|
|
if (wrapped)
|
|
|
|
gl->flags |= GRID_LINE_WRAPPED;
|
2015-07-13 13:28:50 +00:00
|
|
|
else
|
|
|
|
gl->flags &= ~GRID_LINE_WRAPPED;
|
2009-08-08 15:57:49 +00:00
|
|
|
|
2017-02-21 10:30:15 +00:00
|
|
|
log_debug("%s: at %u,%u (region %u-%u)", __func__, s->cx, s->cy,
|
|
|
|
s->rupper, s->rlower);
|
|
|
|
|
2017-05-12 13:00:56 +00:00
|
|
|
if (bg != ctx->bg) {
|
|
|
|
screen_write_collect_flush(ctx, 1);
|
|
|
|
ctx->bg = bg;
|
|
|
|
}
|
|
|
|
|
2016-07-15 00:49:08 +00:00
|
|
|
if (s->cy == s->rlower) {
|
2017-05-12 13:00:56 +00:00
|
|
|
grid_view_scroll_region_up(gd, s->rupper, s->rlower, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_scroll(ctx);
|
2017-02-08 17:31:09 +00:00
|
|
|
ctx->scrolled++;
|
2017-02-08 16:45:18 +00:00
|
|
|
} else if (s->cy < screen_size_y(s) - 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
|
|
|
screen_write_set_cursor(ctx, -1, s->cy + 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 17:31:09 +00:00
|
|
|
/* Scroll up. */
|
|
|
|
void
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg)
|
2017-02-08 17:31:09 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = s->grid;
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
if (lines == 0)
|
|
|
|
lines = 1;
|
|
|
|
else if (lines > s->rlower - s->rupper + 1)
|
|
|
|
lines = s->rlower - s->rupper + 1;
|
|
|
|
|
2017-05-12 13:00:56 +00:00
|
|
|
if (bg != ctx->bg) {
|
|
|
|
screen_write_collect_flush(ctx, 1);
|
|
|
|
ctx->bg = bg;
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:31:09 +00:00
|
|
|
for (i = 0; i < lines; i++) {
|
2017-05-12 13:00:56 +00:00
|
|
|
grid_view_scroll_region_up(gd, s->rupper, s->rlower, bg);
|
2017-02-08 17:31:09 +00:00
|
|
|
screen_write_collect_scroll(ctx);
|
|
|
|
}
|
|
|
|
ctx->scrolled += lines;
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Carriage return (cursor to start of line). */
|
|
|
|
void
|
|
|
|
screen_write_carriagereturn(struct screen_write_ctx *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
|
|
|
screen_write_set_cursor(ctx, 0, -1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear to end of screen from cursor. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2017-02-08 15:49:29 +00:00
|
|
|
struct grid *gd = s->grid;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2016-07-15 00:49:08 +00:00
|
|
|
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2016-10-13 20:27:27 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2011-01-25 23:40:26 +00:00
|
|
|
/* Scroll into history if it is enabled and clearing entire screen. */
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx == 0 && s->cy == 0 && (gd->flags & GRID_HISTORY))
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_clear_history(gd, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
else {
|
|
|
|
if (s->cx <= sx - 1)
|
2017-02-08 15:49:29 +00:00
|
|
|
grid_view_clear(gd, s->cx, s->cy, sx - s->cx, 1, bg);
|
|
|
|
grid_view_clear(gd, 0, s->cy + 1, sx, sy - (s->cy + 1), bg);
|
2011-01-25 23:40:26 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, s->cy + 1, sy - (s->cy + 1));
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_clearendofscreen, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear to start of screen. */
|
|
|
|
void
|
2017-02-06 19:26:49 +00:00
|
|
|
screen_write_clearstartofscreen(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2016-07-15 00:49:08 +00:00
|
|
|
u_int sx = screen_size_x(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-06 19:26:49 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cy > 0)
|
2017-02-06 19:26:49 +00:00
|
|
|
grid_view_clear(s->grid, 0, 0, sx, s->cy, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx > sx - 1)
|
2017-05-11 11:39:30 +00:00
|
|
|
grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
|
2017-02-08 16:45:18 +00:00
|
|
|
else
|
2017-05-11 11:39:30 +00:00
|
|
|
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, 0, s->cy);
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_clearstartofscreen, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear entire screen. */
|
|
|
|
void
|
2016-10-13 20:27:27 +00:00
|
|
|
screen_write_clearscreen(struct screen_write_ctx *ctx, u_int bg)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
2009-07-22 20:53:38 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2016-07-15 00:49:08 +00:00
|
|
|
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2016-10-13 20:27:27 +00:00
|
|
|
ttyctx.bg = bg;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2011-01-25 23:40:26 +00:00
|
|
|
/* Scroll into history if it is enabled. */
|
|
|
|
if (s->grid->flags & GRID_HISTORY)
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear_history(s->grid, bg);
|
2015-12-11 16:37:21 +00:00
|
|
|
else
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_view_clear(s->grid, 0, 0, sx, sy, bg);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, 0, sy);
|
2009-07-22 20:53:38 +00:00
|
|
|
tty_write(tty_cmd_clearscreen, &ttyctx);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 10:16:14 +00:00
|
|
|
/* Clear entire history. */
|
|
|
|
void
|
|
|
|
screen_write_clearhistory(struct screen_write_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = s->grid;
|
|
|
|
|
2016-10-13 20:27:27 +00:00
|
|
|
grid_move_lines(gd, 0, gd->hsize, gd->sy, 8);
|
2016-09-02 20:57:20 +00:00
|
|
|
gd->hscrolled = gd->hsize = 0;
|
2011-10-23 10:16:14 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
/* Clear a collected line. */
|
|
|
|
static void
|
|
|
|
screen_write_collect_clear(struct screen_write_ctx *ctx, u_int y, u_int n)
|
|
|
|
{
|
|
|
|
struct screen_write_collect_item *ci, *tmp;
|
|
|
|
u_int i;
|
|
|
|
size_t size;
|
|
|
|
|
2019-04-18 11:07:28 +00:00
|
|
|
for (i = y; i < y + n; i++) {
|
2017-02-08 16:45:18 +00:00
|
|
|
if (TAILQ_EMPTY(&ctx->list[i].items))
|
|
|
|
continue;
|
|
|
|
size = 0;
|
|
|
|
TAILQ_FOREACH_SAFE(ci, &ctx->list[i].items, entry, tmp) {
|
|
|
|
size += ci->used;
|
|
|
|
TAILQ_REMOVE(&ctx->list[i].items, ci, entry);
|
|
|
|
free(ci);
|
|
|
|
}
|
|
|
|
ctx->skipped += size;
|
2017-02-21 10:30:15 +00:00
|
|
|
log_debug("%s: dropped %zu bytes (line %u)", __func__, size, i);
|
2017-02-08 16:45:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scroll collected lines up. */
|
|
|
|
static void
|
|
|
|
screen_write_collect_scroll(struct screen_write_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct screen_write_collect_line *cl;
|
|
|
|
u_int y;
|
|
|
|
|
2017-02-21 10:30:15 +00:00
|
|
|
log_debug("%s: at %u,%u (region %u-%u)", __func__, s->cx, s->cy,
|
|
|
|
s->rupper, s->rlower);
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_collect_clear(ctx, s->rupper, 1);
|
|
|
|
for (y = s->rupper; y < s->rlower; y++) {
|
|
|
|
cl = &ctx->list[y + 1];
|
|
|
|
TAILQ_CONCAT(&ctx->list[y].items, &cl->items, entry);
|
|
|
|
TAILQ_INIT(&cl->items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flush collected lines. */
|
|
|
|
static void
|
2017-02-09 09:33:15 +00:00
|
|
|
screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only)
|
2017-02-08 16:45:18 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct screen_write_collect_item *ci, *tmp;
|
2017-03-07 13:48:28 +00:00
|
|
|
u_int y, cx, cy, items = 0;
|
2017-02-08 16:45:18 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2017-03-07 13:48:28 +00:00
|
|
|
size_t written = 0;
|
2017-02-08 16:45:18 +00:00
|
|
|
|
2017-02-08 17:31:09 +00:00
|
|
|
if (ctx->scrolled != 0) {
|
|
|
|
log_debug("%s: scrolled %u (region %u-%u)", __func__,
|
|
|
|
ctx->scrolled, s->rupper, s->rlower);
|
|
|
|
if (ctx->scrolled > s->rlower - s->rupper + 1)
|
|
|
|
ctx->scrolled = s->rlower - s->rupper + 1;
|
|
|
|
|
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
ttyctx.num = ctx->scrolled;
|
2017-05-12 13:00:56 +00:00
|
|
|
ttyctx.bg = ctx->bg;
|
2017-02-08 17:31:09 +00:00
|
|
|
tty_write(tty_cmd_scrollup, &ttyctx);
|
|
|
|
}
|
|
|
|
ctx->scrolled = 0;
|
2017-05-12 13:00:56 +00:00
|
|
|
ctx->bg = 8;
|
|
|
|
|
2017-02-09 09:33:15 +00:00
|
|
|
if (scroll_only)
|
|
|
|
return;
|
2017-02-08 17:31:09 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
cx = s->cx; cy = s->cy;
|
|
|
|
for (y = 0; y < screen_size_y(s); y++) {
|
|
|
|
TAILQ_FOREACH_SAFE(ci, &ctx->list[y].items, entry, tmp) {
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, ci->x, y);
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
ttyctx.cell = &ci->gc;
|
2017-04-25 18:30:29 +00:00
|
|
|
ttyctx.wrapped = ci->wrapped;
|
2017-02-08 16:45:18 +00:00
|
|
|
ttyctx.ptr = ci->data;
|
|
|
|
ttyctx.num = ci->used;
|
|
|
|
tty_write(tty_cmd_cells, &ttyctx);
|
2017-03-07 13:48:28 +00:00
|
|
|
|
|
|
|
items++;
|
|
|
|
written += ci->used;
|
2017-02-08 16:45:18 +00:00
|
|
|
|
|
|
|
TAILQ_REMOVE(&ctx->list[y].items, ci, entry);
|
|
|
|
free(ci);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->cx = cx; s->cy = cy;
|
2017-03-07 13:48:28 +00:00
|
|
|
|
|
|
|
log_debug("%s: flushed %u items (%zu bytes)", __func__, items, written);
|
|
|
|
ctx->written += written;
|
2017-02-08 16:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish and store collected cells. */
|
|
|
|
void
|
|
|
|
screen_write_collect_end(struct screen_write_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct screen_write_collect_item *ci = ctx->item;
|
|
|
|
struct grid_cell gc;
|
2017-10-05 08:12:24 +00:00
|
|
|
u_int xx;
|
2017-02-08 16:45:18 +00:00
|
|
|
|
|
|
|
if (ci->used == 0)
|
|
|
|
return;
|
|
|
|
ci->data[ci->used] = '\0';
|
|
|
|
|
|
|
|
ci->x = s->cx;
|
|
|
|
TAILQ_INSERT_TAIL(&ctx->list[s->cy].items, ci, entry);
|
|
|
|
ctx->item = xcalloc(1, sizeof *ctx->item);
|
|
|
|
|
|
|
|
log_debug("%s: %u %s (at %u,%u)", __func__, ci->used, ci->data, s->cx,
|
|
|
|
s->cy);
|
|
|
|
|
2017-10-05 08:12:24 +00:00
|
|
|
if (s->cx != 0) {
|
|
|
|
for (xx = s->cx; xx > 0; xx--) {
|
|
|
|
grid_view_get_cell(s->grid, xx, s->cy, &gc);
|
|
|
|
if (~gc.flags & GRID_FLAG_PADDING)
|
|
|
|
break;
|
2018-01-12 16:43:47 +00:00
|
|
|
grid_view_set_cell(s->grid, xx, s->cy,
|
|
|
|
&grid_default_cell);
|
2017-10-05 08:12:24 +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 (gc.data.width > 1) {
|
2018-01-12 16:43:47 +00:00
|
|
|
grid_view_set_cell(s->grid, xx, s->cy,
|
|
|
|
&grid_default_cell);
|
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
|
|
|
}
|
2017-10-05 08:12:24 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
memcpy(&gc, &ci->gc, sizeof gc);
|
|
|
|
grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used);
|
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
|
|
|
screen_write_set_cursor(ctx, s->cx + ci->used, -1);
|
2017-10-05 08:12:24 +00:00
|
|
|
|
|
|
|
for (xx = s->cx; xx < screen_size_x(s); xx++) {
|
|
|
|
grid_view_get_cell(s->grid, xx, s->cy, &gc);
|
|
|
|
if (~gc.flags & GRID_FLAG_PADDING)
|
|
|
|
break;
|
|
|
|
grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell);
|
|
|
|
}
|
2017-02-08 16:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write cell data, collecting if necessary. */
|
|
|
|
void
|
|
|
|
screen_write_collect_add(struct screen_write_ctx *ctx,
|
|
|
|
const struct grid_cell *gc)
|
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct screen_write_collect_item *ci;
|
|
|
|
u_int sx = screen_size_x(s);
|
|
|
|
int collect;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't need to check that the attributes and whatnot are still the
|
2017-03-07 13:48:28 +00:00
|
|
|
* same - input_parse will end the collection when anything that isn't
|
|
|
|
* a plain character is encountered. Also nothing should make it here
|
|
|
|
* that isn't a single ASCII character.
|
2017-02-08 16:45:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
collect = 1;
|
2018-01-12 16:43:47 +00:00
|
|
|
if (gc->data.width != 1 || gc->data.size != 1 || *gc->data.data >= 0x7f)
|
2017-02-08 16:45:18 +00:00
|
|
|
collect = 0;
|
|
|
|
else if (gc->attr & GRID_ATTR_CHARSET)
|
|
|
|
collect = 0;
|
|
|
|
else if (~s->mode & MODE_WRAP)
|
|
|
|
collect = 0;
|
|
|
|
else if (s->mode & MODE_INSERT)
|
|
|
|
collect = 0;
|
2018-07-31 11:49:26 +00:00
|
|
|
else if (s->sel != NULL)
|
2017-02-08 16:45:18 +00:00
|
|
|
collect = 0;
|
|
|
|
if (!collect) {
|
|
|
|
screen_write_collect_end(ctx);
|
2017-03-07 13:48:28 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2017-02-08 16:45:18 +00:00
|
|
|
screen_write_cell(ctx, gc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->cells++;
|
|
|
|
|
|
|
|
if (s->cx > sx - 1 || ctx->item->used > sx - 1 - s->cx)
|
|
|
|
screen_write_collect_end(ctx);
|
2017-04-25 18:30:29 +00:00
|
|
|
ci = ctx->item; /* may have changed */
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->cx > sx - 1) {
|
2017-02-21 10:30:15 +00:00
|
|
|
log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy);
|
2017-04-25 18:30:29 +00:00
|
|
|
ci->wrapped = 1;
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_linefeed(ctx, 1, 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
|
|
|
screen_write_set_cursor(ctx, 0, -1);
|
2017-02-08 16:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ci->used == 0)
|
|
|
|
memcpy(&ci->gc, gc, sizeof ci->gc);
|
|
|
|
ci->data[ci->used++] = gc->data.data[0];
|
|
|
|
if (ci->used == (sizeof ci->data) - 1)
|
|
|
|
screen_write_collect_end(ctx);
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Write cell data. */
|
|
|
|
void
|
2013-01-18 02:16:21 +00:00
|
|
|
screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = s->grid;
|
2016-07-15 00:49:08 +00:00
|
|
|
struct grid_line *gl;
|
|
|
|
struct grid_cell_entry *gce;
|
2017-02-08 16:45:18 +00:00
|
|
|
struct grid_cell tmp_gc, now_gc;
|
|
|
|
struct tty_ctx ttyctx;
|
|
|
|
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
2017-03-06 09:02:36 +00:00
|
|
|
u_int width = gc->data.width, xx, last, cx, cy;
|
2017-02-08 16:45:18 +00:00
|
|
|
int selected, skip = 1;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
/* Ignore padding cells. */
|
2009-06-01 22:58:49 +00:00
|
|
|
if (gc->flags & GRID_FLAG_PADDING)
|
|
|
|
return;
|
2017-02-08 16:45:18 +00:00
|
|
|
ctx->cells++;
|
2009-10-17 08:32:18 +00:00
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
/* If the width is zero, combine onto the previous character. */
|
2009-06-01 22:58:49 +00:00
|
|
|
if (width == 0) {
|
2017-02-09 10:09:14 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2017-02-06 13:23:00 +00:00
|
|
|
if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) {
|
2017-03-06 09:02:36 +00:00
|
|
|
cx = s->cx; cy = s->cy;
|
2019-03-12 07:39:27 +00:00
|
|
|
screen_write_set_cursor(ctx, xx, s->cy);
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2017-02-06 13:23:00 +00:00
|
|
|
ttyctx.cell = gc;
|
|
|
|
tty_write(tty_cmd_cell, &ttyctx);
|
2017-03-06 09:02:36 +00:00
|
|
|
s->cx = cx; s->cy = cy;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-09 10:09:14 +00:00
|
|
|
/* Flush any existing scrolling. */
|
|
|
|
screen_write_collect_flush(ctx, 1);
|
|
|
|
|
2017-02-08 16:45:18 +00:00
|
|
|
/* If this character doesn't fit, ignore it. */
|
|
|
|
if ((~s->mode & MODE_WRAP) &&
|
|
|
|
width > 1 &&
|
|
|
|
(width > sx || (s->cx != sx && s->cx > sx - width)))
|
|
|
|
return;
|
|
|
|
|
2009-06-03 23:37:30 +00:00
|
|
|
/* If in insert mode, make space for the cells. */
|
2016-10-12 15:43:51 +00:00
|
|
|
if (s->mode & MODE_INSERT) {
|
2017-02-08 16:45:18 +00:00
|
|
|
grid_view_insert_cells(s->grid, s->cx, s->cy, width, 8);
|
|
|
|
skip = 0;
|
|
|
|
}
|
2009-06-03 23:37:30 +00:00
|
|
|
|
2009-08-08 15:57:49 +00:00
|
|
|
/* Check this will fit on the current line and wrap if not. */
|
2016-07-15 00:49:08 +00:00
|
|
|
if ((s->mode & MODE_WRAP) && s->cx > sx - width) {
|
2017-06-12 10:57:35 +00:00
|
|
|
log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy);
|
2017-05-12 13:00:56 +00:00
|
|
|
screen_write_linefeed(ctx, 1, 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
|
|
|
screen_write_set_cursor(ctx, 0, -1);
|
2017-06-12 10:57:35 +00:00
|
|
|
screen_write_collect_flush(ctx, 1);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 10:36:53 +00:00
|
|
|
/* Sanity check cursor position. */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (s->cx > sx - width || s->cy > sy - 1)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2017-02-08 08:50:10 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/* Handle overwriting of UTF-8 characters. */
|
2018-07-04 09:44:07 +00:00
|
|
|
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
2016-07-15 00:49:08 +00:00
|
|
|
if (gl->flags & GRID_LINE_EXTENDED) {
|
|
|
|
grid_view_get_cell(gd, s->cx, s->cy, &now_gc);
|
|
|
|
if (screen_write_overwrite(ctx, &now_gc, width))
|
|
|
|
skip = 0;
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the new character is UTF-8 wide, fill in padding cells. Have
|
|
|
|
* already ensured there is enough room.
|
|
|
|
*/
|
2016-05-30 09:32:24 +00:00
|
|
|
for (xx = s->cx + 1; xx < s->cx + width; xx++) {
|
2017-10-05 08:12:24 +00:00
|
|
|
log_debug("%s: new padding at %u,%u", __func__, xx, s->cy);
|
2016-05-27 23:06:12 +00:00
|
|
|
grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
|
2016-05-30 09:32:24 +00:00
|
|
|
skip = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If no change, do not draw. */
|
2016-07-15 00:49:08 +00:00
|
|
|
if (skip) {
|
|
|
|
if (s->cx >= gl->cellsize)
|
|
|
|
skip = grid_cells_equal(gc, &grid_default_cell);
|
|
|
|
else {
|
|
|
|
gce = &gl->celldata[s->cx];
|
|
|
|
if (gce->flags & GRID_FLAG_EXTENDED)
|
|
|
|
skip = 0;
|
2016-10-05 12:36:36 +00:00
|
|
|
else if (gc->flags != gce->flags)
|
2016-07-15 00:49:08 +00:00
|
|
|
skip = 0;
|
|
|
|
else if (gc->attr != gce->data.attr)
|
|
|
|
skip = 0;
|
|
|
|
else if (gc->fg != gce->data.fg)
|
|
|
|
skip = 0;
|
|
|
|
else if (gc->bg != gce->data.bg)
|
|
|
|
skip = 0;
|
2016-10-05 12:36:36 +00:00
|
|
|
else if (gc->data.width != 1)
|
|
|
|
skip = 0;
|
2017-02-08 16:45:18 +00:00
|
|
|
else if (gc->data.size != 1)
|
|
|
|
skip = 0;
|
2016-10-05 12:36:36 +00:00
|
|
|
else if (gce->data.data != gc->data.data[0])
|
2016-07-15 00:49:08 +00:00
|
|
|
skip = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-06-04 08:02:20 +00:00
|
|
|
/* Update the selected flag and set the cell. */
|
2016-06-06 07:28:52 +00:00
|
|
|
selected = screen_check_selection(s, s->cx, s->cy);
|
2017-02-08 16:45:18 +00:00
|
|
|
if (selected && (~gc->flags & GRID_FLAG_SELECTED)) {
|
2016-06-06 07:28:52 +00:00
|
|
|
memcpy(&tmp_gc, gc, sizeof tmp_gc);
|
|
|
|
tmp_gc.flags |= GRID_FLAG_SELECTED;
|
|
|
|
grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
|
2017-02-08 16:45:18 +00:00
|
|
|
} else if (!selected && (gc->flags & GRID_FLAG_SELECTED)) {
|
2016-06-06 07:28:52 +00:00
|
|
|
memcpy(&tmp_gc, gc, sizeof tmp_gc);
|
|
|
|
tmp_gc.flags &= ~GRID_FLAG_SELECTED;
|
|
|
|
grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
|
|
|
|
} else if (!skip)
|
2016-05-30 09:32:24 +00:00
|
|
|
grid_view_set_cell(gd, s->cx, s->cy, gc);
|
2017-02-08 16:45:18 +00:00
|
|
|
if (selected)
|
|
|
|
skip = 0;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2013-03-22 10:36:53 +00:00
|
|
|
/*
|
|
|
|
* Move the cursor. If not wrapping, stick at the last character and
|
|
|
|
* replace it.
|
|
|
|
*/
|
2013-03-22 10:41:01 +00:00
|
|
|
last = !(s->mode & MODE_WRAP);
|
2016-07-15 00:49:08 +00:00
|
|
|
if (s->cx <= sx - last - width)
|
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
|
|
|
screen_write_set_cursor(ctx, s->cx + width, -1);
|
2013-03-22 10:36:53 +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
|
|
|
screen_write_set_cursor(ctx, sx - last, -1);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-30 09:32:24 +00:00
|
|
|
/* Create space for character in insert mode. */
|
2017-02-08 16:45:18 +00:00
|
|
|
if (s->mode & MODE_INSERT) {
|
2017-02-16 12:43:08 +00:00
|
|
|
screen_write_collect_flush(ctx, 0);
|
2009-07-22 20:53:38 +00:00
|
|
|
ttyctx.num = width;
|
|
|
|
tty_write(tty_cmd_insertcharacter, &ttyctx);
|
|
|
|
}
|
2016-05-30 09:32:24 +00:00
|
|
|
|
|
|
|
/* Write to the screen. */
|
2017-02-08 16:45:18 +00:00
|
|
|
if (!skip) {
|
|
|
|
if (selected) {
|
|
|
|
screen_select_cell(s, &tmp_gc, gc);
|
|
|
|
ttyctx.cell = &tmp_gc;
|
|
|
|
} else
|
|
|
|
ttyctx.cell = gc;
|
2009-07-22 18:02:23 +00:00
|
|
|
tty_write(tty_cmd_cell, &ttyctx);
|
2016-07-15 00:49:08 +00:00
|
|
|
ctx->written++;
|
|
|
|
} else
|
|
|
|
ctx->skipped++;
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 17:33:33 +00:00
|
|
|
/* Combine a UTF-8 zero-width character onto the previous. */
|
2017-02-06 13:23:00 +00:00
|
|
|
static const struct grid_cell *
|
|
|
|
screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud,
|
|
|
|
u_int *xx)
|
2009-10-20 17:33:33 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = s->grid;
|
2017-02-06 13:23:00 +00:00
|
|
|
static struct grid_cell gc;
|
|
|
|
u_int n;
|
2009-10-20 17:33:33 +00:00
|
|
|
|
|
|
|
/* Can't combine if at 0. */
|
|
|
|
if (s->cx == 0)
|
2017-02-06 13:23:00 +00:00
|
|
|
return (NULL);
|
2009-10-20 17:33:33 +00:00
|
|
|
|
2013-01-18 02:16:21 +00:00
|
|
|
/* Empty data is out. */
|
|
|
|
if (ud->size == 0)
|
2009-11-11 18:53:21 +00:00
|
|
|
fatalx("UTF-8 data empty");
|
|
|
|
|
2013-01-18 02:16:21 +00:00
|
|
|
/* Retrieve the previous cell. */
|
2017-04-29 21:27:46 +00:00
|
|
|
for (n = 1; n <= s->cx; n++) {
|
2017-02-06 13:23:00 +00:00
|
|
|
grid_view_get_cell(gd, s->cx - n, s->cy, &gc);
|
|
|
|
if (~gc.flags & GRID_FLAG_PADDING)
|
|
|
|
break;
|
|
|
|
}
|
2017-04-29 21:27:46 +00:00
|
|
|
if (n > s->cx)
|
2017-02-06 13:23:00 +00:00
|
|
|
return (NULL);
|
|
|
|
*xx = s->cx - n;
|
2009-10-20 17:33:33 +00:00
|
|
|
|
2013-01-18 02:16:21 +00:00
|
|
|
/* Check there is enough space. */
|
2015-11-13 08:09:28 +00:00
|
|
|
if (gc.data.size + ud->size > sizeof gc.data.data)
|
2017-02-06 13:23:00 +00:00
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
log_debug("%s: %.*s onto %.*s at %u,%u", __func__, (int)ud->size,
|
|
|
|
ud->data, (int)gc.data.size, gc.data.data, *xx, s->cy);
|
2009-10-20 17:33:33 +00:00
|
|
|
|
2015-11-13 08:09:28 +00:00
|
|
|
/* Append the data. */
|
|
|
|
memcpy(gc.data.data + gc.data.size, ud->data, ud->size);
|
|
|
|
gc.data.size += ud->size;
|
|
|
|
|
|
|
|
/* Set the new cell. */
|
2017-02-06 13:23:00 +00:00
|
|
|
grid_view_set_cell(gd, *xx, s->cy, &gc);
|
2009-10-20 17:33:33 +00:00
|
|
|
|
2017-02-06 13:23:00 +00:00
|
|
|
return (&gc);
|
2009-10-20 17:33:33 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
/*
|
|
|
|
* UTF-8 wide characters are a bit of an annoyance. They take up more than one
|
|
|
|
* cell on the screen, so following cells must not be drawn by marking them as
|
|
|
|
* padding.
|
|
|
|
*
|
|
|
|
* So far, so good. The problem is, when overwriting a padding cell, or a UTF-8
|
|
|
|
* character, it is necessary to also overwrite any other cells which covered
|
|
|
|
* by the same character.
|
|
|
|
*/
|
2016-05-30 09:32:24 +00:00
|
|
|
static int
|
|
|
|
screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
|
|
|
|
u_int width)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct screen *s = ctx->s;
|
|
|
|
struct grid *gd = s->grid;
|
2016-05-30 09:32:24 +00:00
|
|
|
struct grid_cell tmp_gc;
|
2009-06-01 22:58:49 +00:00
|
|
|
u_int xx;
|
2016-05-30 09:32:24 +00:00
|
|
|
int done = 0;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2016-05-30 09:32:24 +00:00
|
|
|
if (gc->flags & GRID_FLAG_PADDING) {
|
2009-06-01 22:58:49 +00:00
|
|
|
/*
|
|
|
|
* A padding cell, so clear any following and leading padding
|
|
|
|
* cells back to the character. Don't overwrite the current
|
|
|
|
* cell as that happens later anyway.
|
|
|
|
*/
|
|
|
|
xx = s->cx + 1;
|
|
|
|
while (--xx > 0) {
|
2016-05-30 09:32:24 +00:00
|
|
|
grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
|
|
|
|
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
2009-06-01 22:58:49 +00:00
|
|
|
break;
|
2017-10-05 08:12:24 +00:00
|
|
|
log_debug("%s: padding at %u,%u", __func__, xx, s->cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overwrite the character at the start of this padding. */
|
2017-10-05 08:12:24 +00:00
|
|
|
log_debug("%s: character at %u,%u", __func__, xx, s->cy);
|
2009-06-01 22:58:49 +00:00
|
|
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
2016-05-30 09:32:24 +00:00
|
|
|
done = 1;
|
2010-06-21 00:11:12 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2010-06-21 00:11:12 +00:00
|
|
|
/*
|
2016-10-05 12:36:36 +00:00
|
|
|
* Overwrite any padding cells that belong to any UTF-8 characters
|
|
|
|
* we'll be overwriting with the current character.
|
2010-06-21 00:11:12 +00:00
|
|
|
*/
|
2016-10-05 12:36:36 +00:00
|
|
|
if (width != 1 ||
|
|
|
|
gc->data.width != 1 ||
|
|
|
|
gc->flags & GRID_FLAG_PADDING) {
|
2016-05-30 09:32:24 +00:00
|
|
|
xx = s->cx + width - 1;
|
|
|
|
while (++xx < screen_size_x(s)) {
|
|
|
|
grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
|
|
|
|
if (~tmp_gc.flags & GRID_FLAG_PADDING)
|
|
|
|
break;
|
2017-10-05 08:12:24 +00:00
|
|
|
log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy);
|
2016-05-30 09:32:24 +00:00
|
|
|
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
|
|
|
done = 1;
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2016-05-30 09:32:24 +00:00
|
|
|
|
|
|
|
return (done);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2011-03-07 23:46:27 +00:00
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
/* Set external clipboard. */
|
2011-05-18 20:24:29 +00:00
|
|
|
void
|
|
|
|
screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len)
|
|
|
|
{
|
|
|
|
struct tty_ctx ttyctx;
|
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2011-05-18 20:24:29 +00:00
|
|
|
ttyctx.ptr = str;
|
|
|
|
ttyctx.num = len;
|
|
|
|
|
|
|
|
tty_write(tty_cmd_setselection, &ttyctx);
|
|
|
|
}
|
|
|
|
|
2017-02-08 15:49:29 +00:00
|
|
|
/* Write unmodified string. */
|
2011-03-07 23:46:27 +00:00
|
|
|
void
|
|
|
|
screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len)
|
|
|
|
{
|
2016-05-27 23:02:17 +00:00
|
|
|
struct tty_ctx ttyctx;
|
2011-03-07 23:46:27 +00:00
|
|
|
|
2016-05-27 23:02:17 +00:00
|
|
|
screen_write_initctx(ctx, &ttyctx);
|
2011-03-07 23:46:27 +00:00
|
|
|
ttyctx.ptr = str;
|
|
|
|
ttyctx.num = len;
|
|
|
|
|
|
|
|
tty_write(tty_cmd_rawstring, &ttyctx);
|
|
|
|
}
|