Screen debugging.

This commit is contained in:
Nicholas Marriott 2007-12-06 10:36:01 +00:00
parent 4f44b09195
commit 8ec9b07c83
3 changed files with 125 additions and 48 deletions

View File

@ -1,4 +1,4 @@
/* $Id: screen-display.c,v 1.11 2007-12-06 10:16:36 nicm Exp $ */ /* $Id: screen-display.c,v 1.12 2007-12-06 10:36:01 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -34,8 +34,10 @@ screen_display_set_cell(
void void
screen_display_make_lines(struct screen *s, u_int py, u_int ny) screen_display_make_lines(struct screen *s, u_int py, u_int ny)
{ {
if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
screen_make_lines(s, screen_y(s, py), ny); screen_make_lines(s, screen_y(s, py), ny);
} }
@ -43,8 +45,10 @@ screen_display_make_lines(struct screen *s, u_int py, u_int ny)
void void
screen_display_free_lines(struct screen *s, u_int py, u_int ny) screen_display_free_lines(struct screen *s, u_int py, u_int ny)
{ {
if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
screen_free_lines(s, screen_y(s, py), ny); screen_free_lines(s, screen_y(s, py), ny);
} }
@ -52,10 +56,14 @@ screen_display_free_lines(struct screen *s, u_int py, u_int ny)
void void
screen_display_move_lines(struct screen *s, u_int dy, u_int py, u_int ny) screen_display_move_lines(struct screen *s, u_int dy, u_int py, u_int ny)
{ {
if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) if (ny == 0 || !screen_in_y(s, py) || !screen_in_y(s, py + ny - 1)) {
SCREEN_DEBUG3(s, dy, py, ny);
return; return;
if (!screen_in_y(s, dy) || !screen_in_y(s, dy + ny - 1) || dy == py) }
if (!screen_in_y(s, dy) || !screen_in_y(s, dy + ny - 1) || dy == py) {
SCREEN_DEBUG3(s, dy, py, ny);
return; return;
}
screen_move_lines(s, screen_y(s, dy), screen_y(s, py), ny); screen_move_lines(s, screen_y(s, dy), screen_y(s, py), ny);
} }
@ -64,12 +72,18 @@ void
screen_display_fill_area(struct screen *s, u_int px, u_int py, screen_display_fill_area(struct screen *s, u_int px, u_int py,
u_int nx, u_int ny, u_char data, u_char attr, u_char colr) u_int nx, u_int ny, u_char data, u_char attr, u_char colr)
{ {
if (nx == 0 || ny == 0) if (nx == 0 || ny == 0) {
SCREEN_DEBUG4(s, px, py, nx, ny);
return; return;
if (!screen_in_x(s, px) || !screen_in_y(s, py)) }
if (!screen_in_x(s, px) || !screen_in_y(s, py)) {
SCREEN_DEBUG4(s, px, py, nx, ny);
return; return;
if (!screen_in_x(s, px + nx - 1) || !screen_in_y(s, py + ny - 1)) }
if (!screen_in_x(s, px + nx - 1) || !screen_in_y(s, py + ny - 1)) {
SCREEN_DEBUG4(s, px, py, nx, ny);
return; return;
}
screen_fill_area( screen_fill_area(
s, screen_x(s, px), screen_y(s, py), nx, ny, data, attr, colr); s, screen_x(s, px), screen_y(s, py), nx, ny, data, attr, colr);
} }
@ -163,15 +177,21 @@ screen_display_scroll_region_down(struct screen *s)
void void
screen_display_insert_lines(struct screen *s, u_int py, u_int ny) screen_display_insert_lines(struct screen *s, u_int py, u_int ny)
{ {
if (!screen_in_y(s, py)) if (!screen_in_y(s, py)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
if (ny == 0) }
if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
if (py + ny > screen_last_y(s)) if (py + ny > screen_last_y(s))
ny = screen_size_y(s) - py; ny = screen_size_y(s) - py;
if (ny == 0) if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
/* /*
* Insert range of ny lines at py: * Insert range of ny lines at py:
@ -200,15 +220,21 @@ screen_display_insert_lines(struct screen *s, u_int py, u_int ny)
void void
screen_display_insert_lines_region(struct screen *s, u_int py, u_int ny) screen_display_insert_lines_region(struct screen *s, u_int py, u_int ny)
{ {
if (!screen_in_region(s, py)) if (!screen_in_region(s, py)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
if (ny == 0) }
if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
if (py + ny > s->rlower) if (py + ny > s->rlower)
ny = (s->rlower + 1) - py; ny = (s->rlower + 1) - py;
if (ny == 0) if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
/* /*
* Insert range of ny lines at py: * Insert range of ny lines at py:
@ -237,15 +263,21 @@ screen_display_insert_lines_region(struct screen *s, u_int py, u_int ny)
void void
screen_display_delete_lines(struct screen *s, u_int py, u_int ny) screen_display_delete_lines(struct screen *s, u_int py, u_int ny)
{ {
if (!screen_in_y(s, py)) if (!screen_in_y(s, py)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
if (ny == 0) }
if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
if (py + ny > screen_last_y(s)) if (py + ny > screen_last_y(s))
ny = screen_size_y(s) - py; ny = screen_size_y(s) - py;
if (ny == 0) if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
/* /*
* Delete range of ny lines at py: * Delete range of ny lines at py:
@ -274,10 +306,14 @@ screen_display_delete_lines(struct screen *s, u_int py, u_int ny)
void void
screen_display_delete_lines_region(struct screen *s, u_int py, u_int ny) screen_display_delete_lines_region(struct screen *s, u_int py, u_int ny)
{ {
if (!screen_in_region(s, py)) if (!screen_in_region(s, py)) {
SCREEN_DEBUG2(s, py, ny);
return; return;
if (ny == 0) }
if (ny == 0) {
SCREEN_DEBUG2(s, py, ny);
return; return;
}
if (py + ny > s->rlower) if (py + ny > s->rlower)
ny = (s->rlower + 1) - py; ny = (s->rlower + 1) - py;
@ -313,8 +349,10 @@ screen_display_insert_characters(struct screen *s, u_int px, u_int py, u_int nx)
{ {
u_int mx; u_int mx;
if (!screen_in_x(s, px) || !screen_in_y(s, py)) if (!screen_in_x(s, px) || !screen_in_y(s, py)) {
SCREEN_DEBUG3(s, px, py, nx);
return; return;
}
if (px + nx > screen_last_x(s)) if (px + nx > screen_last_x(s))
nx = screen_last_x(s) - px; nx = screen_last_x(s) - px;
@ -350,8 +388,10 @@ screen_display_delete_characters(struct screen *s, u_int px, u_int py, u_int nx)
{ {
u_int mx; u_int mx;
if (!screen_in_x(s, px) || !screen_in_y(s, py)) if (!screen_in_x(s, px) || !screen_in_y(s, py)) {
SCREEN_DEBUG3(s, px, py, nx);
return; return;
}
if (px + nx > screen_last_x(s)) if (px + nx > screen_last_x(s))
nx = screen_last_x(s) - px; nx = screen_last_x(s) - px;
@ -389,12 +429,18 @@ screen_display_copy_area(struct screen *dst, struct screen *src,
u_int i, j; u_int i, j;
u_char data, attr, colr; u_char data, attr, colr;
if (nx == 0 || ny == 0) if (nx == 0 || ny == 0) {
SCREEN_DEBUG4(dst, px, py, nx, ny);
return; return;
if (!screen_in_x(dst, px) || !screen_in_y(dst, py)) }
return; if (!screen_in_x(dst, px) || !screen_in_y(dst, py)) {
if (!screen_in_x(dst, px + nx - 1) || !screen_in_y(dst, py + ny - 1)) SCREEN_DEBUG4(dst, px, py, nx, ny);
return;
}
if (!screen_in_x(dst, px + nx - 1) || !screen_in_y(dst, py + ny - 1)) {
SCREEN_DEBUG4(dst, px, py, nx, ny);
return; return;
}
for (i = py; i < py + ny; i++) { for (i = py; i < py + ny; i++) {
for (j = px; j < px + nx; j++) { for (j = px; j < px + nx; j++) {

View File

@ -1,4 +1,4 @@
/* $Id: screen-write.c,v 1.2 2007-12-06 10:16:36 nicm Exp $ */ /* $Id: screen-write.c,v 1.3 2007-12-06 10:36:01 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -22,11 +22,15 @@
#include "tmux.h" #include "tmux.h"
#define screen_write_limit(v, lower, upper) do { \ #define screen_write_limit(s, v, lower, upper) do { \
if (v < lower) \ if (v < lower) { \
v = lower; \ v = lower; \
if (v > upper) \ SCREEN_DEBUG3(s, v, lower, upper); \
v = upper; \ } \
if (v > upper) { \
v = upper; \
SCREEN_DEBUG3(s, v, lower, upper); \
} \
} while (0) } while (0)
/* Initialise writing with a window. */ /* Initialise writing with a window. */
@ -104,8 +108,10 @@ screen_write_put_character(struct screen_write_ctx *ctx, u_char ch)
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CHARACTER, '\r'); ctx->write(ctx->data, TTY_CHARACTER, '\r');
screen_write_cursor_down_scroll(ctx); screen_write_cursor_down_scroll(ctx);
} else if (!screen_in_x(s, s->cx) || !screen_in_y(s, s->cy)) } else if (!screen_in_x(s, s->cx) || !screen_in_y(s, s->cy)) {
SCREEN_DEBUG(s);
return; return;
}
screen_display_set_cell(s, s->cx, s->cy, ch, s->attr, s->colr); screen_display_set_cell(s, s->cx, s->cy, ch, s->attr, s->colr);
s->cx++; s->cx++;
@ -188,10 +194,12 @@ screen_write_set_region(struct screen_write_ctx *ctx, u_int upper, u_int lower)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(upper, 0, screen_last_y(s)); screen_write_limit(s, upper, 0, screen_last_y(s));
screen_write_limit(lower, 0, screen_last_y(s)); screen_write_limit(s, lower, 0, screen_last_y(s));
if (upper > lower) if (upper > lower) {
SCREEN_DEBUG2(s, upper, lower);
return; return;
}
/* Cursor moves to top-left. */ /* Cursor moves to top-left. */
s->cx = 0; s->cx = 0;
@ -240,7 +248,7 @@ screen_write_cursor_up(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_above_y(s, s->cy) - 1); screen_write_limit(s, n, 1, screen_above_y(s, s->cy) - 1);
s->cy -= n; s->cy -= n;
@ -254,7 +262,7 @@ screen_write_cursor_down(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_below_y(s, s->cy) - 1); screen_write_limit(s, n, 1, screen_below_y(s, s->cy) - 1);
s->cy += n; s->cy += n;
@ -268,7 +276,7 @@ screen_write_cursor_left(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_left_x(s, s->cx) - 1); screen_write_limit(s, n, 1, screen_left_x(s, s->cx) - 1);
s->cx -= n; s->cx -= n;
@ -282,7 +290,7 @@ screen_write_cursor_right(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_right_x(s, s->cx) - 1); screen_write_limit(s, n, 1, screen_right_x(s, s->cx) - 1);
s->cx += n; s->cx += n;
@ -296,7 +304,7 @@ screen_write_delete_lines(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_below_y(s, s->cy)); screen_write_limit(s, n, 1, screen_below_y(s, s->cy));
if (s->cy < s->rupper || s->cy > s->rlower) if (s->cy < s->rupper || s->cy > s->rlower)
screen_display_delete_lines(s, s->cy, n); screen_display_delete_lines(s, s->cy, n);
@ -313,7 +321,7 @@ screen_write_delete_characters(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_right_x(s, s->cx)); screen_write_limit(s, n, 1, screen_right_x(s, s->cx));
screen_display_delete_characters(s, s->cx, s->cy, n); screen_display_delete_characters(s, s->cx, s->cy, n);
@ -327,7 +335,7 @@ screen_write_insert_lines(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_below_y(s, s->cy)); screen_write_limit(s, n, 1, screen_below_y(s, s->cy));
if (s->cy < s->rupper || s->cy > s->rlower) if (s->cy < s->rupper || s->cy > s->rlower)
screen_display_insert_lines(s, s->cy, n); screen_display_insert_lines(s, s->cy, n);
@ -344,7 +352,7 @@ screen_write_insert_characters(struct screen_write_ctx *ctx, u_int n)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 1, screen_right_x(s, s->cx)); screen_write_limit(s, n, 1, screen_right_x(s, s->cx));
screen_display_insert_characters(s, s->cx, s->cy, n); screen_display_insert_characters(s, s->cx, s->cy, n);
@ -358,8 +366,8 @@ screen_write_move_cursor(struct screen_write_ctx *ctx, u_int n, u_int m)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
screen_write_limit(n, 0, screen_last_x(s)); screen_write_limit(s, n, 0, screen_last_x(s));
screen_write_limit(m, 0, screen_last_y(s)); screen_write_limit(s, m, 0, screen_last_y(s));
s->cx = n; s->cx = n;
s->cy = m; s->cy = m;
@ -499,8 +507,8 @@ screen_write_copy_area(struct screen_write_ctx *ctx,
struct screen_redraw_ctx rctx; struct screen_redraw_ctx rctx;
int saved_mode; int saved_mode;
screen_write_limit(nx, 1, screen_right_x(s, s->cx)); screen_write_limit(s, nx, 1, screen_right_x(s, s->cx));
screen_write_limit(ny, 1, screen_below_y(s, s->cy)); screen_write_limit(s, ny, 1, screen_below_y(s, s->cy));
screen_display_copy_area(ctx->s, src, s->cx, s->cy, nx, ny, ox, oy); screen_display_copy_area(ctx->s, src, s->cx, s->cy, nx, ny, ox, oy);

25
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.110 2007-12-06 10:04:42 nicm Exp $ */ /* $Id: tmux.h,v 1.111 2007-12-06 10:36:01 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -428,6 +428,29 @@ struct screen_write_ctx {
#define screen_below_y(s, y) \ #define screen_below_y(s, y) \
((y) < screen_size_y(s) ? screen_size_y(s) - (y) : 0) ((y) < screen_size_y(s) ? screen_size_y(s) - (y) : 0)
#define SCREEN_DEBUG(s) do { \
log_warnx("%s: cx=%u,cy=%u sx=%u,sy=%u", __func__, \
s->cx, s->cy, screen_size_x(s), screen_size_y(s)); \
} while (0)
#define SCREEN_DEBUG1(s, n) do { \
log_warnx("%s: cx=%u,cy=%u sx=%u,sy=%u n=%u m=%u", __func__, \
s->cx, s->cy, screen_size_x(s), screen_size_y(s), n); \
} while (0)
#define SCREEN_DEBUG2(s, n, m) do { \
log_warnx("%s: cx=%u,cy=%u sx=%u,sy=%u n=%u m=%u", __func__, \
s->cx, s->cy, screen_size_x(s), screen_size_y(s), n, m); \
} while (0)
#define SCREEN_DEBUG3(s, n, m, o) do { \
log_warnx("%s: cx=%u,cy=%u sx=%u,sy=%u n=%u m=%u o=%u", \
__func__, s->cx, s->cy, screen_size_x(s), screen_size_y(s), \
n, m, o); \
} while (0)
#define SCREEN_DEBUG4(s, n, m, o, p) do { \
log_warnx("%s: cx=%u,cy=%u sx=%u,sy=%u n=%u m=%u o=%u p=%u", \
__func__, s->cx, s->cy, screen_size_x(s), screen_size_y(s), \
n, m, o, p); \
} while (0)
/* Screen default contents. */ /* Screen default contents. */
#define SCREEN_DEFDATA ' ' #define SCREEN_DEFDATA ' '
#define SCREEN_DEFATTR 0 #define SCREEN_DEFATTR 0