Beispiel #1
0
void rote_es_interpret_csi(RoteTerm *rt) {
    int param_count = 0;
    const char *p = rt->pd->esbuf + 1;
    char verb = rt->pd->esbuf[rt->pd->esbuf_len - 1];

    if (!strncmp(rt->pd->esbuf, "[?", 2)) /* private-mode CSI, ignore */
    {
        if (!strncmp(rt->pd->esbuf, "[?1002h", 7))
        {
            rt->docellmouse=1;
            printf("doing cellmouse\n");
        }
        else if (!strncmp(rt->pd->esbuf, "[?1002l", 7))
        {
            rt->docellmouse=0;
            printf("not doing cellmouse\n");
        }
        else if (!strncmp(rt->pd->esbuf, "[?1h", 4))
        {
//	P s = 1 → Application Cursor Keys (DECCKM)
        }
        else if (!strncmp(rt->pd->esbuf, "[?25l", 5))
            rt->cursorhidden=1;
        else if (!strncmp(rt->pd->esbuf, "[?25h", 5))
            rt->cursorhidden=0;

        else if (!strncmp(rt->pd->esbuf, "[?1001s", 7))
        {
//    Save DEC Private Mode Values. P s values are the same as for DECSET.
        }
        else if ((!strncmp(rt->pd->esbuf, "[?1049h", 7))||(!strncmp(rt->pd->esbuf, "[?1049l", 7)))
        {
//    Save DEC Private Mode Values. P s values are the same as for DECSET.
        }



        else
            fprintf(stderr, "Ignoring private-mode CSI: <%s>\n", rt->pd->esbuf);
        return;
    }

    /* parse numeric parameters */
    while ((*p >= '0' && *p <= '9') || *p == ';') {
        if (*p == ';') {
            if (param_count >= MAX_CSI_ES_PARAMS) return; /* too long! */
            rt->pd->csiparam[param_count++] = 0;
        }
        else {
            if (param_count == 0) rt->pd->csiparam[param_count++] = 0;
            rt->pd->csiparam[param_count - 1] *= 10;
            rt->pd->csiparam[param_count - 1] += *p - '0';
        }

        p++;
    }

    /* delegate handling depending on command character (verb) */
    switch (verb) {
    case 'm': /* it's a 'set attribute' sequence */
        interpret_csi_SGR(rt, rt->pd->csiparam, param_count);
        break;
    case 'J': /* it's an 'erase display' sequence */
        interpret_csi_ED(rt, rt->pd->csiparam, param_count);
        break;
    case 'H':
    case 'f': /* it's a 'move cursor' sequence */
        interpret_csi_CUP(rt, rt->pd->csiparam, param_count);
        break;
    case 'A':
    case 'B':
    case 'C':
    case 'D':
    case 'E':
    case 'F':
    case 'G':
    case 'e':
    case 'a':
    case 'd':
    case '`':
        /* it is a 'relative move' */
        interpret_csi_C(rt, verb, rt->pd->csiparam, param_count);
        break;
    case 'K': /* erase line */
        interpret_csi_EL(rt, rt->pd->csiparam, param_count);
        break;
    case '@': /* insert characters */
        interpret_csi_ICH(rt, rt->pd->csiparam, param_count);
        break;
    case 'P': /* delete characters */
        interpret_csi_DCH(rt, rt->pd->csiparam, param_count);
        break;
    case 'L': /* insert lines */
        interpret_csi_IL(rt, rt->pd->csiparam, param_count);
        break;
    case 'M': /* delete lines */
        interpret_csi_DL(rt, rt->pd->csiparam, param_count);
        break;
    case 'X': /* erase chars */
        interpret_csi_ECH(rt, rt->pd->csiparam, param_count);
        break;
    case 'r': /* set scrolling region */
        interpret_csi_DECSTBM(rt, rt->pd->csiparam, param_count);
        break;
    case 's': /* save cursor location */
        interpret_csi_SAVECUR(rt);/*, rt->pd->csiparam, param_count);*/ break;
    case 'u': /* restore cursor location */
        interpret_csi_RESTORECUR(rt);/*, rt->pd->csiparam, param_count);*/ break;
//      #ifdef DEBUG
    default:
        fprintf(stderr, "Unrecogized CSI: <%s>\n", rt->pd->esbuf);
        break;
        break;
//      #endif
    }
}
Beispiel #2
0
void rote_es_interpret_csi(RoteTerm *rt) {
   static int csiparam[MAX_CSI_ES_PARAMS];
   int param_count = 0;
   const char *p = rt->pd->esbuf + 1;
   char verb = rt->pd->esbuf[rt->pd->esbuf_len - 1];

   if (!strncmp(rt->pd->esbuf, "[?", 2)) { /* private-mode CSI, ignore */
      #ifdef DEBUG
      fprintf(stderr, "Ignoring private-mode CSI: <%s>\n", rt->pd->esbuf);
      #endif
      return; 
   }

   /* parse numeric parameters */
   while ((*p >= '0' && *p <= '9') || *p == ';') {
      if (*p == ';') {
         if (param_count >= MAX_CSI_ES_PARAMS) return; /* too long! */
         csiparam[param_count++] = 0;
      }
      else {
         if (param_count == 0) csiparam[param_count++] = 0;
         csiparam[param_count - 1] *= 10;
         csiparam[param_count - 1] += *p - '0';
      }

      p++;
   }

   /* delegate handling depending on command character (verb) */
   switch (verb) {
      case 'm': /* it's a 'set attribute' sequence */
         interpret_csi_SGR(rt, csiparam, param_count); break;
      case 'J': /* it's an 'erase display' sequence */
         interpret_csi_ED(rt, csiparam, param_count); break;
      case 'H': case 'f': /* it's a 'move cursor' sequence */
         interpret_csi_CUP(rt, csiparam, param_count); break;
      case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
      case 'e': case 'a': case 'd': case '`':
         /* it is a 'relative move' */
         interpret_csi_C(rt, verb, csiparam, param_count); break;
      case 'K': /* erase line */
         interpret_csi_EL(rt, csiparam, param_count); break;
      case '@': /* insert characters */
         interpret_csi_ICH(rt, csiparam, param_count); break;
      case 'P': /* delete characters */
         interpret_csi_DCH(rt, csiparam, param_count); break;
      case 'L': /* insert lines */
         interpret_csi_IL(rt, csiparam, param_count); break;
      case 'M': /* delete lines */
         interpret_csi_DL(rt, csiparam, param_count); break;
      case 'X': /* erase chars */
         interpret_csi_ECH(rt, csiparam, param_count); break;
      case 'r': /* set scrolling region */
         interpret_csi_DECSTBM(rt, csiparam, param_count); break;
      case 's': /* save cursor location */
         interpret_csi_SAVECUR(rt, csiparam, param_count); break;
      case 'u': /* restore cursor location */
         interpret_csi_RESTORECUR(rt, csiparam, param_count); break;
      #ifdef DEBUG
      default:
         fprintf(stderr, "Unrecogized CSI: <%s>\n", rt->pd->esbuf); break;
      #endif
   }
}