Exemplo n.º 1
0
static void CheckMaxSize(int wi)
{
    uint32_t *oldnull = null;
    uint32_t *oldblank = blank;
    Window *p;
    int i;
    struct mline *ml;

    if (wi > MAXWIDTH)
        wi = MAXWIDTH;
    if (wi <= maxwidth)
        return;
    maxwidth = wi + 1;
    blank = xrealloc(blank, maxwidth * 4);
    null = xrealloc(null, maxwidth * 4);
    mline_old.image = xrealloc(mline_old.image, maxwidth * 4);
    mline_old.attr = xrealloc(mline_old.attr, maxwidth * 4);
    mline_old.font = xrealloc(mline_old.font, maxwidth * 4);
    mline_old.fontx = xrealloc(mline_old.fontx, maxwidth * 4);
    mline_old.colorbg = xrealloc(mline_old.colorbg, maxwidth * 4);
    mline_old.colorfg = xrealloc(mline_old.colorfg, maxwidth * 4);
    if (!(blank && null && mline_old.image && mline_old.attr && mline_old.font && mline_old.fontx && mline_old.colorbg && mline_old.colorfg))
        Panic(0, "%s", strnomem);

    MakeBlankLine(blank, maxwidth);
    memset(null, 0, maxwidth * 4);

    mline_blank.image = blank;
    mline_blank.attr = null;
    mline_null.image = null;
    mline_null.attr = null;
    mline_blank.font = null;
    mline_null.font = null;
    mline_blank.fontx = null;
    mline_null.fontx = null;
    mline_blank.colorbg = null;
    mline_null.colorbg = null;
    mline_blank.colorfg = null;
    mline_null.colorfg = null;

#define RESET_AFC(x, bl) do { if (x == old##bl) x = bl; } while (0)

#define RESET_LINES(lines, count) \
  do { \
    ml = lines; \
    for (i = 0; i < count; i++, ml++) \
      { \
	RESET_AFC(ml->image, blank); \
	RESET_AFC(ml->attr, null); \
	RESET_AFC(ml->font, null); \
	RESET_AFC(ml->fontx, null); \
	RESET_AFC(ml->colorbg, null); \
	RESET_AFC(ml->colorfg, null); \
      } \
  } while (0)

    /* We have to run through all windows to substitute
     * the null and blank references.
     */
    for (p = windows; p; p = p->w_next) {
        RESET_LINES(p->w_mlines, p->w_height);

        RESET_LINES(p->w_hlines, p->w_histheight);
        RESET_LINES(p->w_alt.hlines, p->w_alt.histheight);

        RESET_LINES(p->w_alt.mlines, p->w_alt.height);
    }
}
Exemplo n.º 2
0
static void
CheckMaxSize(int wi)
{
  unsigned char *oldnull = null;
  unsigned char *oldblank = blank;
  struct win *p;
  int i;
  struct mline *ml;

  wi = ((wi + 1) + 255) & ~255;
  if (wi <= maxwidth)
    return;
  maxwidth = wi;
  debug1("New maxwidth: %d\n", maxwidth);
  blank = (unsigned char *)xrealloc((char *)blank, maxwidth);
  null = (unsigned char *)xrealloc((char *)null, maxwidth);
  mline_old.image = (unsigned char *)xrealloc((char *)mline_old.image, maxwidth);
  mline_old.attr = (unsigned char *)xrealloc((char *)mline_old.attr, maxwidth);
  mline_old.font = (unsigned char *)xrealloc((char *)mline_old.font, maxwidth);
  mline_old.color = (unsigned char *)xrealloc((char *)mline_old.color, maxwidth);
  mline_old.colorx = (unsigned char *)xrealloc((char *)mline_old.colorx, maxwidth);
  if (!(blank && null && mline_old.image && mline_old.attr && mline_old.font && mline_old.color && mline_old.colorx))
    Panic(0, "%s", strnomem);

  MakeBlankLine(blank, maxwidth);
  memset((char *)null, 0, maxwidth);

  mline_blank.image = blank;
  mline_blank.attr  = null;
  mline_null.image = null;
  mline_null.attr  = null;
  mline_blank.font  = null;
  mline_null.font  = null;
  mline_blank.color = null;
  mline_null.color = null;
  mline_blank.colorx = null;
  mline_null.colorx = null;

#define RESET_AFC(x, bl) { if (x == old##bl) x = bl; }

#define RESET_LINES(lines, count) \
  { \
    ml = lines; \
    for (i = 0; i < count; i++, ml++) \
      { \
	RESET_AFC(ml->image, blank); \
	RESET_AFC(ml->attr, null); \
	RESET_AFC(ml->font, null); \
	RESET_AFC(ml->color, null); \
	RESET_AFC(ml->colorx, null); \
      } \
  }

  /* We have to run through all windows to substitute
   * the null and blank references.
   */
  for (p = windows; p; p = p->w_next)
    {
      RESET_LINES(p->w_mlines, p->w_height);

      RESET_LINES(p->w_hlines, p->w_histheight);
      RESET_LINES(p->w_alt.hlines, p->w_alt.histheight);

      RESET_LINES(p->w_alt.mlines, p->w_alt.height);
    }
}