+
+static void
+redraw_cells (m_state *state, Bool active)
+{
+ int x, y;
+ int count = 0;
+
+ for (y = 0; y < state->grid_height; y++)
+ for (x = 0; x < state->grid_width; x++)
+ {
+ m_cell *cell = &state->cells[state->grid_width * y + x];
+
+ if (cell->glyph)
+ count++;
+
+ if (state->mode == TRACE2 && active)
+ {
+ int xx = x % strlen(state->tracing);
+ Bool dead_p = state->tracing[xx] > 0;
+
+ if (y == 0 && x == xx)
+ cell->glyph = (dead_p
+ ? state->glyph_map[state->tracing[xx]-'0'] + 1
+ : 0);
+ else if (y == 0)
+ cell->glyph = 0;
+ else
+ cell->glyph = (dead_p ? 0 :
+ (state->glyph_map[(random()%state->nglyphs)]
+ + 1));
+
+ cell->changed = 1;
+ }
+
+ if (!cell->changed)
+ continue;
+
+ if (cell->glyph == 0 && cell != state->cursor)
+ XFillRectangle (state->dpy, state->window, state->erase_gc,
+ x * state->char_width,
+ y * state->char_height,
+ state->char_width,
+ state->char_height);
+ else
+ {
+ int g = (cell == state->cursor ? CURSOR_GLYPH : cell->glyph);
+ int cx = (g - 1) % CHAR_COLS;
+ int cy = (g - 1) / CHAR_COLS;
+ int map = ((cell->glow > 0 || cell->spinner) ? GLOW_MAP :
+ (cell->glow < 0) ? FADE_MAP :
+ PLAIN_MAP);
+
+ XCopyArea (state->dpy, state->images[map],
+ state->window, state->draw_gc,
+ cx * state->char_width,
+ cy * state->char_height,
+ state->char_width,
+ state->char_height,
+ x * state->char_width,
+ y * state->char_height);
+ }
+
+ cell->changed = 0;
+
+ if (cell->glow > 0)
+ {
+ cell->glow--;
+ cell->changed = 1;
+ }
+ else if (cell->glow < 0)
+ {
+ cell->glow++;
+ if (cell->glow == 0)
+ cell->glyph = 0;
+ cell->changed = 1;
+ }
+
+ if (cell->spinner && active)
+ {
+ cell->glyph = (state->glyph_map[(random()%state->nglyphs)] + 1);
+ cell->changed = 1;
+ }
+ }
+
+ if (state->cursor)
+ {
+ state->cursor->changed = 1;
+ }
+}
+
+