Ejemplo n.º 1
0
ttinit() {
#ifdef	TCCONIO
	ttresize();			/* set nrow & ncol	*/
	tceeol = 1;
	tcinsl = 1;
	tcdell = 1;

#else
	char *tv_stype;
	char *t, *p, *tgetstr();
# ifndef gettermtype		/* (avoid declaration if #define) */
	char *gettermtype();	/* system dependent function to determin terminal type */
# endif

	if((tv_stype = gettermtype()) == NULL)
		panic("Could not determine terminal type");
	if((tgetent(tcbuf, tv_stype)) != 1) {
		(VOID) strcpy(tcbuf, "Unknown terminal type ");
		(VOID) strcat(tcbuf, tv_stype);
		panic(tcbuf);
	}

	p = tcapbuf;
	t = tgetstr("pc", &p);
	if(t) PC = *t;

	LI = tgetnum("li");
	CD = tgetstr("cd", &p);
	CM = tgetstr("cm", &p);
	CE = tgetstr("ce", &p);
	UP = tgetstr("up", &p);
	BC = tgetstr("bc", &p);
	IM = tgetstr("im", &p);
	IC = tgetstr("ic", &p);
	EI = tgetstr("ei", &p);
	DC = tgetstr("dc", &p);
	AL = tgetstr("al", &p);
	DL = tgetstr("dl", &p);
	pAL= tgetstr("AL", &p);	/* parameterized insert and del. line */
	pDL= tgetstr("DL", &p);
	TI = tgetstr("ti", &p);
	TE = tgetstr("te", &p);
	SO = tgetstr("so", &p);
	SE = tgetstr("se", &p);
	CS = tgetstr("cs", &p); /* set scrolling region */
	SF = tgetstr("sf", &p);
	if(!SF || !*SF) {	/* this is what GNU Emacs does */
		SF = tgetstr("do", &p);
		if(!SF || !*SF) {
		SF = tgetstr("nl", &p);
		if(!SF || !*SF) SF = "\n";
		}
	}
	SR = tgetstr("sr", &p);
	SG = tgetnum("sg");	/* standout glitch	*/
# ifdef	XKEYS
	KS = tgetstr("ks", &p);	/* keypad start, keypad end	*/
	KE = tgetstr("ke", &p);
# endif

	if(CM == NULL || UP == NULL)
		panic("This terminal is to stupid to run MicroGnuEmacs\n");

	ttresize();			/* set nrow & ncol	*/

	/* watch out for empty capabilities (sure to be wrong)	*/
	if (CE && !*CE) CE = NULL;
	if (CS && !*CS) CS = NULL;
	if (SR && !*SR) SR = NULL;
	if (AL && !*AL) AL = NULL;
	if (DL && !*DL) DL = NULL;
	if (pAL && !*pAL) pAL = NULL;
	if (pDL && !*pDL) pDL = NULL;
	if (CD && !*CD) CD = NULL;

	if(!CE) tceeol = ncol;
	else	tceeol = charcost(CE);

	/* Estimate cost of inserting a line */
	if (CS && SR)	tcinsl = charcost(CS)*2 + charcost(SR);
	else if (pAL)	tcinsl = charcost(pAL);
	else if (AL)	tcinsl = charcost(AL);
	else		tcinsl = NROW * NCOL;	/* make this cost high enough */

	/* Estimate cost of deleting a line */
	if (CS)		tcdell = charcost(CS)*2 + charcost(SF);
	else if (pDL)	tcdell = charcost(pDL);
	else if (DL)	tcdell = charcost(DL);
	else		tcdell = NROW * NCOL;	/* make this cost high enough */

	/* Flag to indicate that we can both insert and delete lines */
	insdel = (AL || pAL) && (DL || pDL);

	if (p >= &tcapbuf[TCAPSLEN])
		panic("Terminal description too big!\n");
	if (TI && *TI) putpad(TI, 1);	/* init the term */
#endif	/* TCCONIO */
}
Ejemplo n.º 2
0
void
ttinit (void)
{
  char *t, *p;
  char *tv_stype;
  int cinsl;			/* cost of inserting a line     */
  int cdell;			/* cost of deleting a line      */
  int i;
#ifdef	XKEYS
  char kname[3], lname[3];
#endif

#ifdef	VAXC
  if ((tv_stype = trnlnm ("TERM")) == NULL)
#else
  if ((tv_stype = getenv ("TERM")) == NULL)	/* Don't want VAX C getenv() */
#endif
    panic ("Environment variable TERM not defined!");

  /* If -m flag (mouse reporting) is enabled and we're running
   * on an xterm, enable X10-compatible mouse button press reporting.
   */
  if (mouse && (strncmp (tv_stype, "xterm", 5) == 0))
    {
      xterm_mouse = TRUE;
      ttputs ("\033[?9h", 5);
    }

  if ((tgetent (tcbuf, tv_stype)) != 1)
    {
      strcpy (tcbuf, "Unknown terminal type ");
      strcat (tcbuf, tv_stype);
      panic (tcbuf);
    }

  p = tcapbuf;
  t = tgetstr ("pc", &p);
  if (t)
    PC = *t;

  LI = tgetnum ("li");
  CD = tgetstr ("cd", &p);
  CM = tgetstr ("cm", &p);
  CE = tgetstr ("ce", &p);
  UP = tgetstr ("up", &p);
  BC = tgetstr ("bc", &p);
  IM = tgetstr ("im", &p);
  IC = tgetstr ("ic", &p);
  EI = tgetstr ("ei", &p);
  DC = tgetstr ("dc", &p);
  AL = tgetstr ("al", &p);
  DL = tgetstr ("dl", &p);
  pAL = tgetstr ("AL", &p);	/* parameterized insert and del. line */
  pDL = tgetstr ("DL", &p);
  TI = tgetstr ("ti", &p);
  TE = tgetstr ("te", &p);
  SO = tgetstr ("so", &p);
  SE = tgetstr ("se", &p);
  CS = tgetstr ("cs", &p);	/* set scrolling region */
  SR = tgetstr ("sr", &p);
  SG = tgetnum ("sg");		/* standout glitch      */
#ifdef	XKEYS
  /* get the 10 standard termcap keys */
  strcpy (kname, "kx");
  strcpy (lname, "lx");
  for (i = 0; i < 10; i++)
    {
      kname[1] = i + '1';
      K[i] = tgetstr (kname, &p);
      lname[1] = i + '1';
      L[i] = tgetstr (lname, &p);
    }
  /* Hack to get another bunch */
  strcpy (kname, "Kx");
  strcpy (lname, "Lx");
  for (i = 0; i < 10; i++)
    {
      kname[1] = i + '1';
      K[10 + i] = tgetstr (kname, &p);
      lname[1] = i + '1';
      L[10 + i] = tgetstr (lname, &p);
    }

  /* Get the rest of the sequences */
  KS = tgetstr ("ks", &p);
  KE = tgetstr ("ke", &p);
  KH = tgetstr ("kh", &p);
  KU = tgetstr ("ku", &p);
  KD = tgetstr ("kd", &p);
  KL = tgetstr ("kl", &p);
  KR = tgetstr ("kr", &p);
#endif

  if (CM == NULL || UP == NULL)
    panic ("This terminal is to stupid to run MicroGnuEmacs\n");
  ttresize ();			/* set nrow & ncol      */

  /* watch out for empty capabilities (sure to be wrong)  */
  if (CE && !*CE)
    CE = NULL;
  if (CS && !*CS)
    CS = NULL;
  if (SR && !*SR)
    SR = NULL;
  if (AL && !*AL)
    AL = NULL;
  if (DL && !*DL)
    DL = NULL;
  if (pAL && !*pAL)
    pAL = NULL;
  if (pDL && !*pDL)
    pDL = NULL;
  if (CD && !*CD)
    CD = NULL;

  if (!CE)
    tceeol = ncol;
  else
    tceeol = charcost (CE);

  /* Estimate cost of inserting a line */
  if (CS && SR)
    cinsl = charcost (CS) * 2 + charcost (SR);
  else if (pAL)
    cinsl = charcost (pAL);
  else if (AL)
    cinsl = charcost (AL);
  else
    cinsl = NROW * NCOL;	/* make this cost high enough */


  /* MicroEMACS requires an array of costs, not just a single value.
   * Fill the array with a single value.
   */
  for (i = 0; i <= NROW; i++)
    tcinsl[i] = 20 * cinsl * (i + 1);

  /* Estimate cost of deleting a line */
  if (CS)
    cdell = charcost (CS) * 2 + 1;
  else if (pDL)
    cdell = charcost (pDL);
  else if (DL)
    cdell = charcost (DL);
  else
    cdell = NROW * NCOL;	/* make this cost high enough */

  /* MicroEMACS requires an array of costs, not just a single value.
   * Fill the array with a single value.
   */
  for (i = 0; i <= NROW; i++)
    tcdell[i] = 20 * cdell * (i + 1);

  /* Flag to indicate that we can both insert and delete lines */
  insdel = (AL || pAL) && (DL || pDL);

  if (p >= &tcapbuf[TCAPSLEN])
    panic ("Terminal description too big!\n");
  if (TI && *TI)
    putpad (TI);		/* init the term */
}
Ejemplo n.º 3
0
/*
 * Initialize the terminal when the editor
 * gets started up.
 */
void
ttinit(void)
{
	int errret;

	if (setupterm(NULL, 1, &errret))
		panic("Terminal setup failed");

	signal(SIGWINCH, winchhandler);
	signal(SIGCONT, winchhandler);
	siginterrupt(SIGWINCH, 1);

	scroll_fwd = scroll_forward;
	if (scroll_fwd == NULL || *scroll_fwd == '\0') {
		/* this is what GNU Emacs does */
		scroll_fwd = parm_down_cursor;
		if (scroll_fwd == NULL || *scroll_fwd == '\0')
			scroll_fwd = "\n";
	}

	if (cursor_address == NULL || cursor_up == NULL)
		panic("This terminal is too stupid to run mg");

	/* set nrow & ncol */
	ttresize();

	if (!clr_eol)
		tceeol = ncol;
	else
		tceeol = charcost(clr_eol);

	/* Estimate cost of inserting a line */
	if (change_scroll_region && scroll_reverse)
		tcinsl = charcost(change_scroll_region) * 2 +
		    charcost(scroll_reverse);
	else if (parm_insert_line)
		tcinsl = charcost(parm_insert_line);
	else if (insert_line)
		tcinsl = charcost(insert_line);
	else
		/* make this cost high enough */
		tcinsl = nrow * ncol;

	/* Estimate cost of deleting a line */
	if (change_scroll_region)
		tcdell = charcost(change_scroll_region) * 2 +
		    charcost(scroll_fwd);
	else if (parm_delete_line)
		tcdell = charcost(parm_delete_line);
	else if (delete_line)
		tcdell = charcost(delete_line);
	else
		/* make this cost high enough */
		tcdell = nrow * ncol;

	/* Flag to indicate that we can both insert and delete lines */
	insdel = (insert_line || parm_insert_line) &&
	    (delete_line || parm_delete_line);

	if (enter_ca_mode)
		/* enter application mode */
		putpad(enter_ca_mode, 1);

	ttresize();
}