Add an option to move the status line to the top of the screen,

requested by many.
This commit is contained in:
Nicholas Marriott
2012-01-29 09:37:02 +00:00
parent 9bbc63ed65
commit 230d0fbc9e
8 changed files with 180 additions and 92 deletions

65
tty.c
View File

@ -513,10 +513,10 @@ tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) {
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 {
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
tty_write(void (*cmdfn)(
struct tty *, const struct tty_ctx *), const struct tty_ctx *ctx)
tty_write(
void (*cmdfn)(struct tty *, const struct tty_ctx *), struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
struct client *c;
struct session *s;
struct options *oo;
u_int i;
/* wp can be NULL if updating the screen but not the terminal. */
@ -607,12 +609,20 @@ tty_write(void (*cmdfn)(
continue;
if (c->flags & CLIENT_SUSPENDED)
continue;
s = c->session;
if (c->session->curw->window == wp->window) {
if (s->curw->window == wp->window) {
if (c->tty.term == NULL)
continue;
if (c->tty.flags & (TTY_FREEZE|TTY_BACKOFF))
continue;
oo = &s->options;
ctx->xoff = wp->xoff;
ctx->yoff = wp->yoff;
if (status_at_line(c) == 0)
ctx->yoff++;
cmdfn(&c->tty, ctx);
}
}
@ -625,8 +635,8 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
struct screen *s = wp->screen;
u_int i;
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx) {
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
return;
}
@ -644,7 +654,7 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_putc(tty, ' ');
tty_putcode(tty, TTYC_RMIR);
} 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
@ -653,10 +663,10 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
struct window_pane *wp = ctx->wp;
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_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;
}
@ -675,7 +685,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
struct window_pane *wp = ctx->wp;
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_IL1)) {
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 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_DL1)) {
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);
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_putcode(tty, TTYC_EL);
} 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);
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_putcode(tty, TTYC_EL);
else {
@ -754,12 +764,11 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
void
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);
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_putcode(tty, TTYC_EL1);
} else {
@ -778,7 +787,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy != ctx->orupper)
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_RI)) {
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)
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_redraw_region(tty, ctx);
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_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_putcode(tty, TTYC_EL);
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_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)) {
for (i = 0; i < ctx->ocy; i++) {
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_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)) {
for (i = 0; i < screen_size_y(s); i++) {
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? */
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
* 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
* 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
@ -1078,9 +1087,7 @@ void
tty_region_pane(
struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower)
{
struct window_pane *wp = ctx->wp;
tty_region(tty, wp->yoff + rupper, wp->yoff + rlower);
tty_region(tty, ctx->yoff + rupper, ctx->yoff + rlower);
}
/* Set region at absolute position. */
@ -1112,9 +1119,7 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower)
void
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, wp->xoff + cx, wp->yoff + cy);
tty_cursor(tty, ctx->xoff + cx, ctx->yoff + cy);
}
/* Move cursor to absolute position. */