示例#1
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
   }
}
示例#2
0
文件: inject_csi.c 项目: koo5/lemon-2
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
    }
}
示例#3
0
文件: vterm_csi.c 项目: posnk/wtkterm
void vterm_interpret_csi(vterm_t *vterm)
{
   static int  csiparam[MAX_CSI_ES_PARAMS];
   int         param_count = 0;
   const char  *p;
   char        verb;

   p=vterm->esbuf+1;
   verb=vterm->esbuf[vterm->esbuf_len-1];

   /* parse numeric parameters */
   while ((*p >= '0' && *p <= '9') || *p == ';' || *p == '?')
   {
      if(*p == '?')
      {
         p++;
         continue;
      }

      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':
      {
         interpret_csi_SGR(vterm,csiparam,param_count);
			break;
      }

      case 'l':
      {
         interpret_dec_RM(vterm,csiparam,param_count);
         break;
      }

      case 'h':
      {
         interpret_dec_SM(vterm,csiparam,param_count);
         break;
      }

      case 'J':
      {
         interpret_csi_ED(vterm,csiparam,param_count);
         break;
      }
      case 'H':
      case 'f':
      {
         interpret_csi_CUP(vterm,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 '`':
      {
         interpret_csi_CUx(vterm,verb,csiparam,param_count);
         break;
      }
      case 'K':
      {
         interpret_csi_EL(vterm,csiparam,param_count);
         break;
      }
      case '@':
      {
         interpret_csi_ICH(vterm,csiparam,param_count);
         break;
      }
      case 'P':
      {
         interpret_csi_DCH(vterm,csiparam,param_count);
         break;
      }
      case 'L':
      {
         interpret_csi_IL(vterm,csiparam,param_count);
         break;
      }
      case 'M':
      {
         interpret_csi_DL(vterm,csiparam,param_count);
         break;
      }
      case 'X':
      {
         interpret_csi_ECH(vterm,csiparam,param_count);
         break;
      }
      case 'r':
      {
         interpret_csi_DECSTBM(vterm,csiparam,param_count);
         break;
      }
      case 's':
      {
         interpret_csi_SAVECUR(vterm,csiparam,param_count);
         break;
      }
      case 'u':
      {
         interpret_csi_RESTORECUR(vterm,csiparam,param_count);
         break;
      }
#ifdef DEBUG
      default:
         //TODO: fprintf(stderr, "Unrecogized CSI: <%s>\n", rt->pd->esbuf); break;
#endif
   }
}