mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Screen debugging.
This commit is contained in:
parent
4f44b09195
commit
8ec9b07c83
@ -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>
|
||||
@ -34,8 +34,10 @@ screen_display_set_cell(
|
||||
void
|
||||
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;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
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
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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,
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
screen_fill_area(
|
||||
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
|
||||
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;
|
||||
if (ny == 0)
|
||||
}
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
if (py + ny > screen_last_y(s))
|
||||
ny = screen_size_y(s) - py;
|
||||
if (ny == 0)
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
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;
|
||||
if (ny == 0)
|
||||
}
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
if (py + ny > s->rlower)
|
||||
ny = (s->rlower + 1) - py;
|
||||
if (ny == 0)
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
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;
|
||||
if (ny == 0)
|
||||
}
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
if (py + ny > screen_last_y(s))
|
||||
ny = screen_size_y(s) - py;
|
||||
if (ny == 0)
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
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;
|
||||
if (ny == 0)
|
||||
}
|
||||
if (ny == 0) {
|
||||
SCREEN_DEBUG2(s, py, ny);
|
||||
return;
|
||||
}
|
||||
|
||||
if (py + ny > s->rlower)
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (px + nx > screen_last_x(s))
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (px + nx > screen_last_x(s))
|
||||
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_char data, attr, colr;
|
||||
|
||||
if (nx == 0 || ny == 0)
|
||||
if (nx == 0 || ny == 0) {
|
||||
SCREEN_DEBUG4(dst, px, py, nx, ny);
|
||||
return;
|
||||
if (!screen_in_x(dst, px) || !screen_in_y(dst, py))
|
||||
return;
|
||||
if (!screen_in_x(dst, px + nx - 1) || !screen_in_y(dst, py + ny - 1))
|
||||
}
|
||||
if (!screen_in_x(dst, px) || !screen_in_y(dst, py)) {
|
||||
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;
|
||||
}
|
||||
|
||||
for (i = py; i < py + ny; i++) {
|
||||
for (j = px; j < px + nx; j++) {
|
||||
|
@ -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>
|
||||
@ -22,11 +22,15 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
#define screen_write_limit(v, lower, upper) do { \
|
||||
if (v < lower) \
|
||||
v = lower; \
|
||||
if (v > upper) \
|
||||
v = upper; \
|
||||
#define screen_write_limit(s, v, lower, upper) do { \
|
||||
if (v < lower) { \
|
||||
v = lower; \
|
||||
SCREEN_DEBUG3(s, v, lower, upper); \
|
||||
} \
|
||||
if (v > upper) { \
|
||||
v = upper; \
|
||||
SCREEN_DEBUG3(s, v, lower, upper); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* 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)
|
||||
ctx->write(ctx->data, TTY_CHARACTER, '\r');
|
||||
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;
|
||||
}
|
||||
|
||||
screen_display_set_cell(s, s->cx, s->cy, ch, s->attr, s->colr);
|
||||
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;
|
||||
|
||||
screen_write_limit(upper, 0, screen_last_y(s));
|
||||
screen_write_limit(lower, 0, screen_last_y(s));
|
||||
if (upper > lower)
|
||||
screen_write_limit(s, upper, 0, screen_last_y(s));
|
||||
screen_write_limit(s, lower, 0, screen_last_y(s));
|
||||
if (upper > lower) {
|
||||
SCREEN_DEBUG2(s, upper, lower);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Cursor moves to top-left. */
|
||||
s->cx = 0;
|
||||
@ -240,7 +248,7 @@ screen_write_cursor_up(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -254,7 +262,7 @@ screen_write_cursor_down(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -268,7 +276,7 @@ screen_write_cursor_left(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -282,7 +290,7 @@ screen_write_cursor_right(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -296,7 +304,7 @@ screen_write_delete_lines(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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)
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
@ -327,7 +335,7 @@ screen_write_insert_lines(struct screen_write_ctx *ctx, u_int n)
|
||||
{
|
||||
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)
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
@ -358,8 +366,8 @@ screen_write_move_cursor(struct screen_write_ctx *ctx, u_int n, u_int m)
|
||||
{
|
||||
struct screen *s = ctx->s;
|
||||
|
||||
screen_write_limit(n, 0, screen_last_x(s));
|
||||
screen_write_limit(m, 0, screen_last_y(s));
|
||||
screen_write_limit(s, n, 0, screen_last_x(s));
|
||||
screen_write_limit(s, m, 0, screen_last_y(s));
|
||||
|
||||
s->cx = n;
|
||||
s->cy = m;
|
||||
@ -499,8 +507,8 @@ screen_write_copy_area(struct screen_write_ctx *ctx,
|
||||
struct screen_redraw_ctx rctx;
|
||||
int saved_mode;
|
||||
|
||||
screen_write_limit(nx, 1, screen_right_x(s, s->cx));
|
||||
screen_write_limit(ny, 1, screen_below_y(s, s->cy));
|
||||
screen_write_limit(s, nx, 1, screen_right_x(s, s->cx));
|
||||
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);
|
||||
|
||||
|
25
tmux.h
25
tmux.h
@ -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>
|
||||
@ -428,6 +428,29 @@ struct screen_write_ctx {
|
||||
#define screen_below_y(s, y) \
|
||||
((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. */
|
||||
#define SCREEN_DEFDATA ' '
|
||||
#define SCREEN_DEFATTR 0
|
||||
|
Loading…
Reference in New Issue
Block a user