aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile4
-rw-r--r--Makefile4
-rw-r--r--cmd-choose-session.c4
-rw-r--r--cmd-choose-window.c4
-rw-r--r--grid.c148
-rw-r--r--screen-write.c5
-rw-r--r--status.c4
7 files changed, 109 insertions, 64 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 833e0674..4548d490 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.56 2009-01-15 19:27:31 nicm Exp $
+# $Id: GNUmakefile,v 1.57 2009-01-17 18:47:36 nicm Exp $
.PHONY: clean
@@ -7,7 +7,7 @@ VERSION= 0.6
DATE= $(shell date +%Y%m%d-%H%M)
-DEBUG= 1
+#DEBUG= 1
META?= \002
diff --git a/Makefile b/Makefile
index fa0204f2..96102b77 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.95 2009-01-17 18:38:12 nicm Exp $
+# $Id: Makefile,v 1.96 2009-01-17 18:47:36 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -11,7 +11,7 @@ REL!= uname -r
DATE!= date +%Y%m%d-%H%M
# This must be empty as OpenBSD includes it in default CFLAGS.
-DEBUG=
+#DEBUG=
META?= \002 # C-b
diff --git a/cmd-choose-session.c b/cmd-choose-session.c
index 8c70aa0b..08057d88 100644
--- a/cmd-choose-session.c
+++ b/cmd-choose-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-session.c,v 1.1 2009-01-15 19:27:31 nicm Exp $ */
+/* $Id: cmd-choose-session.c,v 1.2 2009-01-17 18:47:36 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,7 +63,7 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return;
- idx = 0;
+ cur = idx = 0;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL)
diff --git a/cmd-choose-window.c b/cmd-choose-window.c
index 23bc75c2..280f4ae0 100644
--- a/cmd-choose-window.c
+++ b/cmd-choose-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-choose-window.c,v 1.3 2009-01-15 19:41:12 nicm Exp $ */
+/* $Id: cmd-choose-window.c,v 1.4 2009-01-17 18:47:36 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -64,7 +64,7 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return;
- idx = 0;
+ cur = idx = 0;
RB_FOREACH(wm, winlinks, &s->windows) {
w = wm->window;
diff --git a/grid.c b/grid.c
index 8a4a2576..714721da 100644
--- a/grid.c
+++ b/grid.c
@@ -1,4 +1,4 @@
-/* $Id: grid.c,v 1.6 2009-01-11 02:23:52 nicm Exp $ */
+/* $Id: grid.c,v 1.7 2009-01-17 18:47:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -37,34 +37,51 @@
/* Default grid cell data. */
const struct grid_cell grid_default_cell = { ' ', 0, 0, 8, 8 };
-#ifdef DEBUG
-#define grid_check_x(gd, px) do { \
- if ((px) >= (gd)->sx) \
- log_fatalx("x out of range: %u", px); \
-} while (0)
-#define grid_check_y(gd, py) do { \
- if ((py) >= (gd)->hsize + (gd)->sy) \
- log_fatalx("y out of range: %u", py); \
-} while (0)
-#else
-#define grid_check_x(gd, px) do { \
- if ((px) >= (gd)->sx) { \
- log_debug("x out of range: %u", px); \
- return; \
- } \
-} while (0)
-#define grid_check_y(gd, py) do { \
- if ((py) >= (gd)->hsize + (gd)->sy) { \
- log_debug("y out of range: %u", py); \
- return; \
- } \
-} while (0)
-#endif
-
#define grid_put_cell(gd, px, py, gc) do { \
memcpy(&gd->data[py][px], gc, sizeof gd->data[py][px]); \
} while (0)
+int grid_check_x(struct grid_data *, u_int);
+int grid_check_y(struct grid_data *, u_int);
+
+#ifdef DEBUG
+int
+grid_check_x(struct grid_data *gd, u_int px)
+{
+ if ((px) >= (gd)->sx)
+ log_fatalx("x out of range: %u", px);
+ return (0);
+}
+
+int
+grid_check_y(struct grid_data *gd, u_int py)
+{
+ if ((py) >= (gd)->hsize + (gd)->sy)
+ log_fatalx("y out of range: %u", py);
+ return (0);
+}
+#else
+int
+grid_check_x(struct grid_data *gd, u_int px)
+{
+ if ((px) >= (gd)->sx) {
+ log_debug("x out of range: %u", px);
+ return (-1);
+ }
+ return (0);
+}
+
+int
+grid_check_y(struct grid_data *gd, u_int py)
+{
+ if ((py) >= (gd)->hsize + (gd)->sy) {
+ log_debug("y out of range: %u", py);
+ return (-1);
+ }
+ return (0);
+}
+#endif
+
/* Create a new grid. */
struct grid_data *
grid_create(u_int sx, u_int sy, u_int hlimit)
@@ -160,8 +177,10 @@ grid_expand_line(struct grid_data *gd, u_int py, u_int sx)
const struct grid_cell *
grid_peek_cell(struct grid_data *gd, u_int px, u_int py)
{
- grid_check_x(gd, px);
- grid_check_y(gd, py);
+ if (grid_check_x(gd, px) != 0)
+ return (&grid_default_cell);
+ if (grid_check_y(gd, py) != 0)
+ return (&grid_default_cell);
if (px >= gd->size[py])
return (&grid_default_cell);
@@ -172,8 +191,10 @@ grid_peek_cell(struct grid_data *gd, u_int px, u_int py)
struct grid_cell *
grid_get_cell(struct grid_data *gd, u_int px, u_int py)
{
- grid_check_x(gd, px);
- grid_check_y(gd, py);
+ if (grid_check_x(gd, px) != 0)
+ return (NULL);
+ if (grid_check_y(gd, py) != 0)
+ return (NULL);
grid_expand_line(gd, py, px + 1);
return (&gd->data[py][px]);
@@ -184,8 +205,10 @@ void
grid_set_cell(
struct grid_data *gd, u_int px, u_int py, const struct grid_cell *gc)
{
- grid_check_x(gd, px);
- grid_check_y(gd, py);
+ if (grid_check_x(gd, px) != 0)
+ return;
+ if (grid_check_y(gd, py) != 0)
+ return;
grid_expand_line(gd, py, px + 1);
grid_put_cell(gd, px, py, gc);
@@ -210,10 +233,14 @@ grid_clear(struct grid_data *gd, u_int px, u_int py, u_int nx, u_int ny)
return;
}
- grid_check_x(gd, px);
- grid_check_x(gd, px + nx - 1);
- grid_check_y(gd, py);
- grid_check_y(gd, py + ny - 1);
+ if (grid_check_x(gd, px) != 0)
+ return;
+ if (grid_check_x(gd, px + nx - 1) != 0)
+ return;
+ if (grid_check_y(gd, py) != 0)
+ return;
+ if (grid_check_y(gd, py + ny - 1) != 0)
+ return;
for (yy = py; yy < py + ny; yy++) {
for (xx = px; xx < px + nx; xx++) {
@@ -236,10 +263,14 @@ grid_fill(struct grid_data *gd,
if (nx == 0 || ny == 0)
return;
- grid_check_x(gd, px);
- grid_check_x(gd, px + nx - 1);
- grid_check_y(gd, py);
- grid_check_y(gd, py + ny - 1);
+ if (grid_check_x(gd, px) != 0)
+ return;
+ if (grid_check_x(gd, px + nx - 1) != 0)
+ return;
+ if (grid_check_y(gd, py) != 0)
+ return;
+ if (grid_check_y(gd, py + ny - 1) != 0)
+ return;
for (yy = py; yy < py + ny; yy++) {
for (xx = px; xx < px + nx; xx++) {
@@ -260,8 +291,10 @@ grid_clear_lines(struct grid_data *gd, u_int py, u_int ny)
if (ny == 0)
return;
- grid_check_y(gd, py);
- grid_check_y(gd, py + ny - 1);
+ if (grid_check_y(gd, py) != 0)
+ return;
+ if (grid_check_y(gd, py + ny - 1) != 0)
+ return;
for (yy = py; yy < py + ny; yy++) {
if (gd->data[yy] != NULL) {
@@ -291,10 +324,14 @@ grid_move_lines(struct grid_data *gd, u_int dy, u_int py, u_int ny)
if (ny == 0 || py == dy)
return;
- grid_check_y(gd, py);
- grid_check_y(gd, py + ny - 1);
- grid_check_y(gd, dy);
- grid_check_y(gd, dy + ny - 1);
+ if (grid_check_y(gd, py) != 0)
+ return;
+ if (grid_check_y(gd, py + ny - 1) != 0)
+ return;
+ if (grid_check_y(gd, dy) != 0)
+ return;
+ if (grid_check_y(gd, dy + ny - 1) != 0)
+ return;
/* Free any lines which are being replaced. */
for (yy = dy; yy < dy + ny; yy++) {
@@ -326,9 +363,12 @@ grid_clear_cells(struct grid_data *gd, u_int px, u_int py, u_int nx)
if (nx == 0)
return;
- grid_check_x(gd, px);
- grid_check_x(gd, px + nx - 1);
- grid_check_y(gd, py);
+ if (grid_check_x(gd, px) != 0)
+ return;
+ if (grid_check_x(gd, px + nx - 1) != 0)
+ return;
+ if (grid_check_y(gd, py) != 0)
+ return;
for (xx = px; xx < px + nx; xx++) {
if (xx >= gd->size[py])
@@ -348,10 +388,14 @@ grid_move_cells(struct grid_data *gd, u_int dx, u_int px, u_int py, u_int nx)
if (nx == 0 || px == dx)
return;
- grid_check_x(gd, px);
- grid_check_x(gd, px + nx - 1);
- grid_check_x(gd, dx + nx - 1);
- grid_check_y(gd, py);
+ if (grid_check_x(gd, px) != 0)
+ return;
+ if (grid_check_x(gd, px + nx - 1) != 0)
+ return;
+ if (grid_check_x(gd, dx + nx - 1) != 0)
+ return;
+ if (grid_check_y(gd, py) != 0)
+ return;
grid_expand_line(gd, py, px + nx);
grid_expand_line(gd, py, dx + nx);
diff --git a/screen-write.c b/screen-write.c
index e6d9cb88..037d1b3e 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1,4 +1,4 @@
-/* $Id: screen-write.c,v 1.24 2009-01-11 23:31:46 nicm Exp $ */
+/* $Id: screen-write.c,v 1.25 2009-01-17 18:47:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -589,7 +589,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
*/
for (xx = s->cx + 1; xx < s->cx + width; xx++) {
ic = grid_view_get_cell(gd, xx, s->cy);
- ic->flags |= GRID_FLAG_PADDING;
+ if (ic != NULL)
+ ic->flags |= GRID_FLAG_PADDING;
}
/* Write the actual cell. */
diff --git a/status.c b/status.c
index bdb7e303..9fed1409 100644
--- a/status.c
+++ b/status.c
@@ -1,4 +1,4 @@
-/* $Id: status.c,v 1.63 2009-01-15 23:42:21 nicm Exp $ */
+/* $Id: status.c,v 1.64 2009-01-17 18:47:37 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,7 +44,7 @@ status_redraw(struct client *c)
struct session *s = c->session;
struct winlink *wl;
struct window_pane *wp;
- struct screen *sc;
+ struct screen *sc = NULL;
char *left, *right, *text, *ptr;
size_t llen, rlen, offset, xx, yy, sy;
size_t size, start, width;