mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add an option to move the status line to the top of the screen,
requested by many.
This commit is contained in:
parent
9bbc63ed65
commit
230d0fbc9e
4
layout.c
4
layout.c
@ -502,14 +502,14 @@ layout_resize_pane_mouse(struct client *c, struct mouse_event *mouse)
|
|||||||
wp->yoff <= 1 + c->last_mouse.y &&
|
wp->yoff <= 1 + c->last_mouse.y &&
|
||||||
wp->yoff + wp->sy >= c->last_mouse.y) {
|
wp->yoff + wp->sy >= c->last_mouse.y) {
|
||||||
layout_resize_pane(wp, LAYOUT_LEFTRIGHT,
|
layout_resize_pane(wp, LAYOUT_LEFTRIGHT,
|
||||||
mouse->x - c->last_mouse.x);
|
mouse->x - c->last_mouse.x);
|
||||||
pane_border = 1;
|
pane_border = 1;
|
||||||
}
|
}
|
||||||
if (wp->yoff + wp->sy == c->last_mouse.y &&
|
if (wp->yoff + wp->sy == c->last_mouse.y &&
|
||||||
wp->xoff <= 1 + c->last_mouse.x &&
|
wp->xoff <= 1 + c->last_mouse.x &&
|
||||||
wp->xoff + wp->sx >= c->last_mouse.x) {
|
wp->xoff + wp->sx >= c->last_mouse.x) {
|
||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM,
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM,
|
||||||
mouse->y - c->last_mouse.y);
|
mouse->y - c->last_mouse.y);
|
||||||
pane_border = 1;
|
pane_border = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@ const char *options_table_status_keys_list[] = {
|
|||||||
const char *options_table_status_justify_list[] = {
|
const char *options_table_status_justify_list[] = {
|
||||||
"left", "centre", "right", NULL
|
"left", "centre", "right", NULL
|
||||||
};
|
};
|
||||||
|
const char *options_table_status_position_list[] = {
|
||||||
|
"top", "bottom", NULL
|
||||||
|
};
|
||||||
const char *options_table_bell_action_list[] = {
|
const char *options_table_bell_action_list[] = {
|
||||||
"none", "any", "current", NULL
|
"none", "any", "current", NULL
|
||||||
};
|
};
|
||||||
@ -359,6 +362,12 @@ const struct options_table_entry session_options_table[] = {
|
|||||||
.default_num = 10
|
.default_num = 10
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ .name = "status-position",
|
||||||
|
.type = OPTIONS_TABLE_CHOICE,
|
||||||
|
.choices = options_table_status_position_list,
|
||||||
|
.default_num = 1
|
||||||
|
},
|
||||||
|
|
||||||
{ .name = "status-right",
|
{ .name = "status-right",
|
||||||
.type = OPTIONS_TABLE_STRING,
|
.type = OPTIONS_TABLE_STRING,
|
||||||
.default_str = "\"#22T\" %H:%M %d-%b-%y"
|
.default_str = "\"#22T\" %H:%M %d-%b-%y"
|
||||||
|
@ -170,25 +170,33 @@ void
|
|||||||
screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
||||||
{
|
{
|
||||||
struct window *w = c->session->curw->window;
|
struct window *w = c->session->curw->window;
|
||||||
|
struct options *oo = &c->session->options;
|
||||||
struct tty *tty = &c->tty;
|
struct tty *tty = &c->tty;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct grid_cell active_gc, other_gc;
|
struct grid_cell active_gc, other_gc;
|
||||||
u_int i, j, type;
|
u_int i, j, type, top;
|
||||||
int status, fg, bg;
|
int status, spos, fg, bg;
|
||||||
|
|
||||||
/* Suspended clients should not be updated. */
|
/* Suspended clients should not be updated. */
|
||||||
if (c->flags & CLIENT_SUSPENDED)
|
if (c->flags & CLIENT_SUSPENDED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get status line, er, status. */
|
/* Get status line, er, status. */
|
||||||
|
spos = options_get_number(oo, "status-position");
|
||||||
if (c->message_string != NULL || c->prompt_string != NULL)
|
if (c->message_string != NULL || c->prompt_string != NULL)
|
||||||
status = 1;
|
status = 1;
|
||||||
else
|
else
|
||||||
status = options_get_number(&c->session->options, "status");
|
status = options_get_number(oo, "status");
|
||||||
|
top = 0;
|
||||||
|
if (status && spos == 0)
|
||||||
|
top = 1;
|
||||||
|
|
||||||
/* If only drawing status and it is present, don't need the rest. */
|
/* If only drawing status and it is present, don't need the rest. */
|
||||||
if (status_only && status) {
|
if (status_only && status) {
|
||||||
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
if (top)
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, 0);
|
||||||
|
else
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -198,19 +206,23 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
|||||||
memcpy(&active_gc, &grid_default_cell, sizeof active_gc);
|
memcpy(&active_gc, &grid_default_cell, sizeof active_gc);
|
||||||
active_gc.data = other_gc.data = 'x'; /* not space */
|
active_gc.data = other_gc.data = 'x'; /* not space */
|
||||||
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
|
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
|
||||||
fg = options_get_number(&c->session->options, "pane-border-fg");
|
fg = options_get_number(oo, "pane-border-fg");
|
||||||
colour_set_fg(&other_gc, fg);
|
colour_set_fg(&other_gc, fg);
|
||||||
bg = options_get_number(&c->session->options, "pane-border-bg");
|
bg = options_get_number(oo, "pane-border-bg");
|
||||||
colour_set_bg(&other_gc, bg);
|
colour_set_bg(&other_gc, bg);
|
||||||
fg = options_get_number(&c->session->options, "pane-active-border-fg");
|
fg = options_get_number(oo, "pane-active-border-fg");
|
||||||
colour_set_fg(&active_gc, fg);
|
colour_set_fg(&active_gc, fg);
|
||||||
bg = options_get_number(&c->session->options, "pane-active-border-bg");
|
bg = options_get_number(oo, "pane-active-border-bg");
|
||||||
colour_set_bg(&active_gc, bg);
|
colour_set_bg(&active_gc, bg);
|
||||||
|
|
||||||
/* Draw background and borders. */
|
/* Draw background and borders. */
|
||||||
for (j = 0; j < tty->sy - status; j++) {
|
for (j = 0; j < tty->sy - status; j++) {
|
||||||
if (status_only && j != tty->sy - 1)
|
if (status_only) {
|
||||||
continue;
|
if (spos == 1 && j != tty->sy - 1)
|
||||||
|
continue;
|
||||||
|
else if (spos == 0 && j != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (i = 0; i < tty->sx; i++) {
|
for (i = 0; i < tty->sx; i++) {
|
||||||
type = screen_redraw_check_cell(c, i, j);
|
type = screen_redraw_check_cell(c, i, j);
|
||||||
if (type == CELL_INSIDE)
|
if (type == CELL_INSIDE)
|
||||||
@ -219,7 +231,7 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
|||||||
tty_attributes(tty, &active_gc);
|
tty_attributes(tty, &active_gc);
|
||||||
else
|
else
|
||||||
tty_attributes(tty, &other_gc);
|
tty_attributes(tty, &other_gc);
|
||||||
tty_cursor(tty, i, j);
|
tty_cursor(tty, i, top + j);
|
||||||
tty_putc(tty, CELL_BORDERS[type]);
|
tty_putc(tty, CELL_BORDERS[type]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,17 +245,26 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
|||||||
if (!window_pane_visible(wp))
|
if (!window_pane_visible(wp))
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < wp->sy; i++) {
|
for (i = 0; i < wp->sy; i++) {
|
||||||
if (status_only && wp->yoff + i != tty->sy - 1)
|
if (status_only) {
|
||||||
continue;
|
if (spos == 1 && wp->yoff + i != tty->sy - 1)
|
||||||
tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff);
|
continue;
|
||||||
|
else if (spos == 0 && wp->yoff + i != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tty_draw_line(
|
||||||
|
tty, wp->screen, i, wp->xoff, top + wp->yoff);
|
||||||
}
|
}
|
||||||
if (c->flags & CLIENT_IDENTIFY)
|
if (c->flags & CLIENT_IDENTIFY)
|
||||||
screen_redraw_draw_number(c, wp);
|
screen_redraw_draw_number(c, wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the status line. */
|
/* Draw the status line. */
|
||||||
if (status)
|
if (status) {
|
||||||
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
if (top)
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, 0);
|
||||||
|
else
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
||||||
|
}
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,10 +272,14 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
|||||||
void
|
void
|
||||||
screen_redraw_pane(struct client *c, struct window_pane *wp)
|
screen_redraw_pane(struct client *c, struct window_pane *wp)
|
||||||
{
|
{
|
||||||
u_int i;
|
u_int i, yoff;
|
||||||
|
|
||||||
|
yoff = wp->yoff;
|
||||||
|
if (status_at_line(c) == 0)
|
||||||
|
yoff++;
|
||||||
|
|
||||||
for (i = 0; i < wp->sy; i++)
|
for (i = 0; i < wp->sy; i++)
|
||||||
tty_draw_line(&c->tty, wp->screen, i, wp->xoff, wp->yoff);
|
tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff);
|
||||||
tty_reset(&c->tty);
|
tty_reset(&c->tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
107
server-client.c
107
server-client.c
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
|
void server_client_check_mouse(struct client *c,
|
||||||
|
struct window_pane *wp, struct mouse_event *mouse);
|
||||||
void server_client_handle_key(int, struct mouse_event *, void *);
|
void server_client_handle_key(int, struct mouse_event *, void *);
|
||||||
void server_client_repeat_timer(int, short, void *);
|
void server_client_repeat_timer(int, short, void *);
|
||||||
void server_client_check_exit(struct client *);
|
void server_client_check_exit(struct client *);
|
||||||
@ -262,6 +264,65 @@ server_client_status_timer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for mouse keys. */
|
||||||
|
void
|
||||||
|
server_client_check_mouse(
|
||||||
|
struct client *c, struct window_pane *wp, struct mouse_event *mouse)
|
||||||
|
{
|
||||||
|
struct session *s = c->session;
|
||||||
|
struct options *oo = &s->options;
|
||||||
|
int statusat;
|
||||||
|
|
||||||
|
statusat = status_at_line(c);
|
||||||
|
|
||||||
|
/* Is this a window selection click on the status line? */
|
||||||
|
if (statusat != -1 && mouse->y == (u_int)statusat &&
|
||||||
|
options_get_number(oo, "mouse-select-window")) {
|
||||||
|
if (mouse->b == MOUSE_UP && c->last_mouse.b != MOUSE_UP) {
|
||||||
|
status_set_window_at(c, mouse->x);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mouse->b & MOUSE_45) {
|
||||||
|
if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
|
||||||
|
session_previous(c->session, 0);
|
||||||
|
server_redraw_session(s);
|
||||||
|
}
|
||||||
|
if ((mouse->b & MOUSE_BUTTON) == MOUSE_2) {
|
||||||
|
session_next(c->session, 0);
|
||||||
|
server_redraw_session(s);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Not on status line - adjust mouse position if status line is at the
|
||||||
|
* top and limit if at the bottom. From here on a struct mouse
|
||||||
|
* represents the offset onto the window itself.
|
||||||
|
*/
|
||||||
|
if (statusat == 0 &&mouse->y > 0)
|
||||||
|
mouse->y--;
|
||||||
|
else if (statusat > 0 && mouse->y >= (u_int)statusat)
|
||||||
|
mouse->y = statusat - 1;
|
||||||
|
|
||||||
|
/* Is this a pane selection? Allow down only in copy mode. */
|
||||||
|
if (options_get_number(oo, "mouse-select-pane") &&
|
||||||
|
((!(mouse->b & MOUSE_DRAG) && mouse->b != MOUSE_UP) ||
|
||||||
|
wp->mode != &window_copy_mode)) {
|
||||||
|
window_set_active_at(wp->window, mouse->x, mouse->y);
|
||||||
|
server_redraw_window_borders(wp->window);
|
||||||
|
wp = wp->window->active; /* may have changed */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if trying to resize pane. */
|
||||||
|
if (options_get_number(oo, "mouse-resize-pane"))
|
||||||
|
layout_resize_pane_mouse(c, mouse);
|
||||||
|
|
||||||
|
/* Update last and pass through to client. */
|
||||||
|
memcpy(&c->last_mouse, mouse, sizeof c->last_mouse);
|
||||||
|
window_pane_mouse(wp, c->session, mouse);
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle data key input from client. */
|
/* Handle data key input from client. */
|
||||||
void
|
void
|
||||||
server_client_handle_key(int key, struct mouse_event *mouse, void *data)
|
server_client_handle_key(int key, struct mouse_event *mouse, void *data)
|
||||||
@ -317,43 +378,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
|
|||||||
if (key == KEYC_MOUSE) {
|
if (key == KEYC_MOUSE) {
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
return;
|
||||||
if (options_get_number(oo, "mouse-select-pane") &&
|
server_client_check_mouse(c, wp, mouse);
|
||||||
(!(options_get_number(oo, "status") &&
|
|
||||||
mouse->y + 1 == c->tty.sy)) &&
|
|
||||||
((!(mouse->b & MOUSE_DRAG) && mouse->b != MOUSE_UP) ||
|
|
||||||
wp->mode != &window_copy_mode)) {
|
|
||||||
/*
|
|
||||||
* Allow pane switching in copy mode only by mouse down
|
|
||||||
* (click).
|
|
||||||
*/
|
|
||||||
window_set_active_at(w, mouse->x, mouse->y);
|
|
||||||
server_redraw_window_borders(w);
|
|
||||||
wp = w->active;
|
|
||||||
}
|
|
||||||
if (mouse->y + 1 == c->tty.sy &&
|
|
||||||
options_get_number(oo, "mouse-select-window") &&
|
|
||||||
options_get_number(oo, "status")) {
|
|
||||||
if (mouse->b == MOUSE_UP &&
|
|
||||||
c->last_mouse.b != MOUSE_UP) {
|
|
||||||
status_set_window_at(c, mouse->x);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mouse->b & MOUSE_45) {
|
|
||||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
|
|
||||||
session_previous(c->session, 0);
|
|
||||||
server_redraw_session(s);
|
|
||||||
}
|
|
||||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_2) {
|
|
||||||
session_next(c->session, 0);
|
|
||||||
server_redraw_session(s);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (options_get_number(oo, "mouse-resize-pane"))
|
|
||||||
layout_resize_pane_mouse(c, mouse);
|
|
||||||
memcpy(&c->last_mouse, mouse, sizeof c->last_mouse);
|
|
||||||
window_pane_mouse(wp, c->session, mouse);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +497,7 @@ server_client_reset_state(struct client *c)
|
|||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
struct options *oo = &c->session->options;
|
struct options *oo = &c->session->options;
|
||||||
struct options *wo = &w->options;
|
struct options *wo = &w->options;
|
||||||
int status, mode;
|
int status, mode, o;
|
||||||
|
|
||||||
if (c->flags & CLIENT_SUSPENDED)
|
if (c->flags & CLIENT_SUSPENDED)
|
||||||
return;
|
return;
|
||||||
@ -482,8 +507,10 @@ server_client_reset_state(struct client *c)
|
|||||||
status = options_get_number(oo, "status");
|
status = options_get_number(oo, "status");
|
||||||
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
|
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
|
||||||
tty_cursor(&c->tty, 0, 0);
|
tty_cursor(&c->tty, 0, 0);
|
||||||
else
|
else {
|
||||||
tty_cursor(&c->tty, wp->xoff + s->cx, wp->yoff + s->cy);
|
o = status && options_get_number (oo, "status-position") == 0;
|
||||||
|
tty_cursor(&c->tty, wp->xoff + s->cx, o + wp->yoff + s->cy);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Resizing panes with the mouse requires at least button mode to give
|
* Resizing panes with the mouse requires at least button mode to give
|
||||||
|
14
status.c
14
status.c
@ -60,6 +60,20 @@ status_out_cmp(struct status_out *so1, struct status_out *so2)
|
|||||||
return (strcmp(so1->cmd, so2->cmd));
|
return (strcmp(so1->cmd, so2->cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get screen line of status line. -1 means off. */
|
||||||
|
int
|
||||||
|
status_at_line(struct client *c)
|
||||||
|
{
|
||||||
|
struct session *s = c->session;
|
||||||
|
|
||||||
|
if (!options_get_number(&s->options, "status"))
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (options_get_number(&s->options, "status-position") == 0)
|
||||||
|
return (0);
|
||||||
|
return (c->tty.sy - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Retrieve options for left string. */
|
/* Retrieve options for left string. */
|
||||||
char *
|
char *
|
||||||
status_redraw_get_left(struct client *c,
|
status_redraw_get_left(struct client *c,
|
||||||
|
4
tmux.1
4
tmux.1
@ -2199,6 +2199,10 @@ Set the maximum
|
|||||||
.Ar length
|
.Ar length
|
||||||
of the left component of the status bar.
|
of the left component of the status bar.
|
||||||
The default is 10.
|
The default is 10.
|
||||||
|
.It Xo Ic status-position
|
||||||
|
.Op Ic top | bottom
|
||||||
|
.Xc
|
||||||
|
Set the position of the status line.
|
||||||
.It Ic status-right Ar string
|
.It Ic status-right Ar string
|
||||||
Display
|
Display
|
||||||
.Ar string
|
.Ar string
|
||||||
|
8
tmux.h
8
tmux.h
@ -1078,6 +1078,9 @@ struct tty_ctx {
|
|||||||
u_int orupper;
|
u_int orupper;
|
||||||
u_int orlower;
|
u_int orlower;
|
||||||
|
|
||||||
|
u_int xoff;
|
||||||
|
u_int yoff;
|
||||||
|
|
||||||
/* Saved last cell on line. */
|
/* Saved last cell on line. */
|
||||||
struct grid_cell last_cell;
|
struct grid_cell last_cell;
|
||||||
struct grid_utf8 last_utf8;
|
struct grid_utf8 last_utf8;
|
||||||
@ -1463,8 +1466,8 @@ void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
|
|||||||
int tty_open(struct tty *, const char *, char **);
|
int tty_open(struct tty *, const char *, char **);
|
||||||
void tty_close(struct tty *);
|
void tty_close(struct tty *);
|
||||||
void tty_free(struct tty *);
|
void tty_free(struct tty *);
|
||||||
void tty_write(void (*)(
|
void tty_write(
|
||||||
struct tty *, const struct tty_ctx *), const struct tty_ctx *);
|
void (*)(struct tty *, const struct tty_ctx *), struct tty_ctx *);
|
||||||
void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
|
void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
|
||||||
void tty_cmd_cell(struct tty *, const struct tty_ctx *);
|
void tty_cmd_cell(struct tty *, const struct tty_ctx *);
|
||||||
void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
|
void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
|
||||||
@ -1722,6 +1725,7 @@ void server_update_event(struct client *);
|
|||||||
/* status.c */
|
/* status.c */
|
||||||
int status_out_cmp(struct status_out *, struct status_out *);
|
int status_out_cmp(struct status_out *, struct status_out *);
|
||||||
RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
|
RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
|
||||||
|
int status_at_line(struct client *);
|
||||||
void status_free_jobs(struct status_out_tree *);
|
void status_free_jobs(struct status_out_tree *);
|
||||||
void status_update_jobs(struct client *);
|
void status_update_jobs(struct client *);
|
||||||
void status_set_window_at(struct client *, u_int);
|
void status_set_window_at(struct client *, u_int);
|
||||||
|
65
tty.c
65
tty.c
@ -513,10 +513,10 @@ tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) {
|
if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) {
|
||||||
for (i = ctx->ocy; i < screen_size_y(s); i++)
|
for (i = ctx->ocy; i < screen_size_y(s); i++)
|
||||||
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
|
tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff);
|
||||||
} else {
|
} else {
|
||||||
for (i = ctx->orupper; i <= ctx->orlower; i++)
|
for (i = ctx->orupper; i <= ctx->orlower; i++)
|
||||||
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
|
tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,11 +585,13 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_write(void (*cmdfn)(
|
tty_write(
|
||||||
struct tty *, const struct tty_ctx *), const struct tty_ctx *ctx)
|
void (*cmdfn)(struct tty *, const struct tty_ctx *), struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = ctx->wp;
|
struct window_pane *wp = ctx->wp;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct options *oo;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
/* wp can be NULL if updating the screen but not the terminal. */
|
/* wp can be NULL if updating the screen but not the terminal. */
|
||||||
@ -607,12 +609,20 @@ tty_write(void (*cmdfn)(
|
|||||||
continue;
|
continue;
|
||||||
if (c->flags & CLIENT_SUSPENDED)
|
if (c->flags & CLIENT_SUSPENDED)
|
||||||
continue;
|
continue;
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
if (c->session->curw->window == wp->window) {
|
if (s->curw->window == wp->window) {
|
||||||
if (c->tty.term == NULL)
|
if (c->tty.term == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (c->tty.flags & (TTY_FREEZE|TTY_BACKOFF))
|
if (c->tty.flags & (TTY_FREEZE|TTY_BACKOFF))
|
||||||
continue;
|
continue;
|
||||||
|
oo = &s->options;
|
||||||
|
|
||||||
|
ctx->xoff = wp->xoff;
|
||||||
|
ctx->yoff = wp->yoff;
|
||||||
|
if (status_at_line(c) == 0)
|
||||||
|
ctx->yoff++;
|
||||||
|
|
||||||
cmdfn(&c->tty, ctx);
|
cmdfn(&c->tty, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,8 +635,8 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx) {
|
||||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +654,7 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
tty_putc(tty, ' ');
|
tty_putc(tty, ' ');
|
||||||
tty_putcode(tty, TTYC_RMIR);
|
tty_putcode(tty, TTYC_RMIR);
|
||||||
} else
|
} else
|
||||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -653,10 +663,10 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
struct window_pane *wp = ctx->wp;
|
struct window_pane *wp = ctx->wp;
|
||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
(!tty_term_has(tty->term, TTYC_DCH) &&
|
(!tty_term_has(tty->term, TTYC_DCH) &&
|
||||||
!tty_term_has(tty->term, TTYC_DCH1))) {
|
!tty_term_has(tty->term, TTYC_DCH1))) {
|
||||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +685,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
struct window_pane *wp = ctx->wp;
|
struct window_pane *wp = ctx->wp;
|
||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR) ||
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
||||||
!tty_term_has(tty->term, TTYC_IL1)) {
|
!tty_term_has(tty->term, TTYC_IL1)) {
|
||||||
tty_redraw_region(tty, ctx);
|
tty_redraw_region(tty, ctx);
|
||||||
@ -696,7 +706,7 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
struct window_pane *wp = ctx->wp;
|
struct window_pane *wp = ctx->wp;
|
||||||
struct screen *s = wp->screen;
|
struct screen *s = wp->screen;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR) ||
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
||||||
!tty_term_has(tty->term, TTYC_DL1)) {
|
!tty_term_has(tty->term, TTYC_DL1)) {
|
||||||
tty_redraw_region(tty, ctx);
|
tty_redraw_region(tty, ctx);
|
||||||
@ -722,7 +732,7 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
|
|
||||||
tty_cursor_pane(tty, ctx, 0, ctx->ocy);
|
tty_cursor_pane(tty, ctx, 0, ctx->ocy);
|
||||||
|
|
||||||
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
if (ctx->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
||||||
tty_term_has(tty->term, TTYC_EL)) {
|
tty_term_has(tty->term, TTYC_EL)) {
|
||||||
tty_putcode(tty, TTYC_EL);
|
tty_putcode(tty, TTYC_EL);
|
||||||
} else {
|
} else {
|
||||||
@ -742,7 +752,7 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
|
|
||||||
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
||||||
|
|
||||||
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
if (ctx->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
||||||
tty_term_has(tty->term, TTYC_EL))
|
tty_term_has(tty->term, TTYC_EL))
|
||||||
tty_putcode(tty, TTYC_EL);
|
tty_putcode(tty, TTYC_EL);
|
||||||
else {
|
else {
|
||||||
@ -754,12 +764,11 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
void
|
void
|
||||||
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
|
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = ctx->wp;
|
u_int i;
|
||||||
u_int i;
|
|
||||||
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
|
|
||||||
if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
|
if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
|
||||||
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
||||||
tty_putcode(tty, TTYC_EL1);
|
tty_putcode(tty, TTYC_EL1);
|
||||||
} else {
|
} else {
|
||||||
@ -778,7 +787,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
if (ctx->ocy != ctx->orupper)
|
if (ctx->ocy != ctx->orupper)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR) ||
|
!tty_term_has(tty->term, TTYC_CSR) ||
|
||||||
!tty_term_has(tty->term, TTYC_RI)) {
|
!tty_term_has(tty->term, TTYC_RI)) {
|
||||||
tty_redraw_region(tty, ctx);
|
tty_redraw_region(tty, ctx);
|
||||||
@ -802,7 +811,7 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
if (ctx->ocy != ctx->orlower)
|
if (ctx->ocy != ctx->orlower)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
|
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx ||
|
||||||
!tty_term_has(tty->term, TTYC_CSR)) {
|
!tty_term_has(tty->term, TTYC_CSR)) {
|
||||||
tty_redraw_region(tty, ctx);
|
tty_redraw_region(tty, ctx);
|
||||||
return;
|
return;
|
||||||
@ -836,7 +845,7 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
||||||
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
|
||||||
|
|
||||||
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
if (ctx->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
||||||
tty_term_has(tty->term, TTYC_EL)) {
|
tty_term_has(tty->term, TTYC_EL)) {
|
||||||
tty_putcode(tty, TTYC_EL);
|
tty_putcode(tty, TTYC_EL);
|
||||||
if (ctx->ocy != screen_size_y(s) - 1) {
|
if (ctx->ocy != screen_size_y(s) - 1) {
|
||||||
@ -872,7 +881,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
||||||
tty_cursor_pane(tty, ctx, 0, 0);
|
tty_cursor_pane(tty, ctx, 0, 0);
|
||||||
|
|
||||||
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
if (ctx->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
||||||
tty_term_has(tty->term, TTYC_EL)) {
|
tty_term_has(tty->term, TTYC_EL)) {
|
||||||
for (i = 0; i < ctx->ocy; i++) {
|
for (i = 0; i < ctx->ocy; i++) {
|
||||||
tty_putcode(tty, TTYC_EL);
|
tty_putcode(tty, TTYC_EL);
|
||||||
@ -902,7 +911,7 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
|
||||||
tty_cursor_pane(tty, ctx, 0, 0);
|
tty_cursor_pane(tty, ctx, 0, 0);
|
||||||
|
|
||||||
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
if (ctx->xoff == 0 && screen_size_x(s) >= tty->sx &&
|
||||||
tty_term_has(tty->term, TTYC_EL)) {
|
tty_term_has(tty->term, TTYC_EL)) {
|
||||||
for (i = 0; i < screen_size_y(s); i++) {
|
for (i = 0; i < screen_size_y(s); i++) {
|
||||||
tty_putcode(tty, TTYC_EL);
|
tty_putcode(tty, TTYC_EL);
|
||||||
@ -957,7 +966,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
|
|
||||||
/* Is the cursor in the very last position? */
|
/* Is the cursor in the very last position? */
|
||||||
if (ctx->ocx > wp->sx - width) {
|
if (ctx->ocx > wp->sx - width) {
|
||||||
if (wp->xoff != 0 || wp->sx != tty->sx) {
|
if (ctx->xoff != 0 || wp->sx != tty->sx) {
|
||||||
/*
|
/*
|
||||||
* The pane doesn't fill the entire line, the linefeed
|
* The pane doesn't fill the entire line, the linefeed
|
||||||
* will already have happened, so just move the cursor.
|
* will already have happened, so just move the cursor.
|
||||||
@ -991,7 +1000,7 @@ tty_cmd_utf8character(struct tty *tty, const struct tty_ctx *ctx)
|
|||||||
* Cannot rely on not being a partial character, so just redraw the
|
* Cannot rely on not being a partial character, so just redraw the
|
||||||
* whole line.
|
* whole line.
|
||||||
*/
|
*/
|
||||||
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
|
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1078,9 +1087,7 @@ void
|
|||||||
tty_region_pane(
|
tty_region_pane(
|
||||||
struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower)
|
struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = ctx->wp;
|
tty_region(tty, ctx->yoff + rupper, ctx->yoff + rlower);
|
||||||
|
|
||||||
tty_region(tty, wp->yoff + rupper, wp->yoff + rlower);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set region at absolute position. */
|
/* Set region at absolute position. */
|
||||||
@ -1112,9 +1119,7 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower)
|
|||||||
void
|
void
|
||||||
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy)
|
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = ctx->wp;
|
tty_cursor(tty, ctx->xoff + cx, ctx->yoff + cy);
|
||||||
|
|
||||||
tty_cursor(tty, wp->xoff + cx, wp->yoff + cy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move cursor to absolute position. */
|
/* Move cursor to absolute position. */
|
||||||
|
Loading…
Reference in New Issue
Block a user