Ejemplo n.º 1
0
static void
wprint_escaped(FILE *f, const wchar_t *s, int len)
{ const wchar_t *e = &s[len];

  while ( s < e )
  { wint_t x = *s++;

    if (x >= ' ')
    { if (x == '\\')			/* \ --> \\ */
	wputc(x, f);
      wputc(x, f);
    } else if (x == '\t')
    { wputc(x, f);			/* \t */
    } else if (x == '\n')
    { fprintf(f, "\\n");		/* \n */
    } else
      { fprintf(f, "\\%03o", (unsigned int)x);
    }
  }
}
Ejemplo n.º 2
0
static int
print_data(dtd_parser * p, data_type type, int len, const wchar_t *data)
{ char c;

  switch (type)
  { case EC_CDATA:
      c = '-';
      break;
    case EC_NDATA:
      c = 'N';
      break;
    case EC_SDATA:
      c = 'S';
      break;
    default:
      assert(0);
  }
  wputc(c, stdout);
  wprint_escaped(stdout, data, len);
  wputc('\n', stdout);
  return TRUE;
}
Ejemplo n.º 3
0
static void
print_word(dtd_parser * p, char c,     /* preceding character */
	   ichar const *s,	       /* where to start */
	   ichar const *e)	       /* where to end (at NUL if e is NULL) */
{ FILE *f = stdout;
  ichar x;

  wputc(c, f);
  if (p->dtd->case_sensitive)
  { if (e != 0)
      while (s != e)
	wputc(*s++, f);
    else
      while ((x = *s++) != (ichar) 0)
	wputc(x, f);
  } else
  { if (e != 0)
      while (s != e)
	wputc(towupper((wint_t)*s++), f);
    else
      while ((x = *s++) != (ichar) 0)
	wputc(towupper(x), f);
  }
}
Ejemplo n.º 4
0
VOID TScreen::BufferByte (UCHAR byte)
{
   short x, y;
   USHORT i;

   if (byte == '[' && Prec == ESC) {
      Ansi = TRUE;
      Count = 0;
      Params[Count] = 0;
   }
   else {
      if (Ansi == TRUE) {
         if (isalpha (byte)) {
            if (byte == 'm') {
               for (i = 0; i <= Count; i++) {
                  if (Params[i] >= 30 && Params[i] <= 39)
                     Attr &= 0xF8;
                  else if (Params[i] >= 40 && Params[i] <= 49)
                     Attr &= 0x8F;

                  switch (Params[i]) {
                     case 0:
                        Attr = 7;
                        break;
                     case 1:
                        Attr |= 0x08;
                        break;
                     case 5:
                        Attr |= BLINK;
                        break;
                     case 30:
                        Attr |= BLACK;
                        break;
                     case 34:
                        Attr |= BLUE;
                        break;
                     case 32:
                        Attr |= GREEN;
                        break;
                     case 36:
                        Attr |= CYAN;
                        break;
                     case 31:
                        Attr |= RED;
                        break;
                     case 35:
                        Attr |= MAGENTA;
                        break;
                     case 39:
                        Attr |= BROWN;
                        break;
                     case 37:
                        Attr |= LGREY;
                        break;
                     case 33:
                        Attr |= YELLOW;
                        break;
                     case 40:
                        Attr |= _BLACK;
                        break;
                     case 44:
                        Attr |= _BLUE;
                        break;
                     case 42:
                        Attr |= _GREEN;
                        break;
                     case 46:
                        Attr |= _CYAN;
                        break;
                     case 41:
                        Attr |= _RED;
                        break;
                     case 45:
                        Attr |= _MAGENTA;
                        break;
                     case 49:
                        Attr |= _BROWN;
                        break;
                     case 47:
                        Attr |= _LGREY;
                        break;
                  }
               }
               wtextattr (Attr);
            }
            else if (byte == 'A') {
               wreadcur (&y, &x);
               if (Params[0] == 0)
                  Params[0] = 1;
               wgotoxy ((SHORT)(y - Params[0]), x);
            }
            else if (byte == 'B') {
               wreadcur (&y, &x);
               if (Params[0] == 0)
                  Params[0] = 1;
               wgotoxy ((SHORT)(y + Params[0]), x);
            }
            else if (byte == 'C') {
               wreadcur (&y, &x);
               if (Params[0] == 0)
                  Params[0] = 1;
               wgotoxy (y, (SHORT)(x + Params[0]));
            }
            else if (byte == 'D') {
               wreadcur (&y, &x);
               if (Params[0] == 0)
                  Params[0] = 1;
               wgotoxy (y, (SHORT)(x - Params[0]));
            }
            else if (byte == 'n') {
               if (Params[0] == 6) {
                  memcpy (RxBuffer, "\x1B[0;0h", 6);
                  RxBytes = 6;
                  RxPosition = 0;
               }
            }
            else if (byte == 'f' || byte == 'H')
               wgotoxy ((SHORT)(Params[0] - 1), (SHORT)(Params[1] - 1));
            else if (byte == 'J' && Params[0] == 2)
               wclear ();
            else if (byte == 'K')
               wclreol ();
            Ansi = FALSE;
         }
         else if (byte == ';') {
            Count++;
            Params[Count] = 0;
         }
         else if (isdigit (byte)) {
            Params[Count] *= 10;
            Params[Count] += (USHORT)(byte - '0');
         }
         else
            Ansi = FALSE;
      }
      else if (byte == CTRLL) {
         wclear ();
         videoupdate ();
      }
      else if (byte != ESC)
         wputc (byte);
   }

   Prec = byte;

   if ((++Counter % 64) == 0) {
      videoupdate ();
      Counter = 0;
   }
}
Ejemplo n.º 5
0
static int
on_pi(dtd_parser *p, ichar const *pi)
{ wputc('?', stdout);
  wprint_escaped(stdout, pi, wcslen(pi));
  return TRUE;
}
Ejemplo n.º 6
0
static void
print_cdata(char c, sgml_attribute *a)
{ wputc(c, stdout);
  wprint_escaped(stdout, a->value.textW, a->value.number);
  wputc('\n', stdout);
}